質問編集履歴

1

エラーの部分のソースコードを記載

2016/11/30 04:15

投稿

TKM_waiwai
TKM_waiwai

スコア16

test CHANGED
File without changes
test CHANGED
@@ -7,3 +7,213 @@
7
7
 
8
8
 
9
9
  このエラーの改善方法について教えて頂けると嬉しいです。
10
+
11
+
12
+
13
+ ```C#
14
+
15
+ using UnityEngine;
16
+
17
+ using System.Collections;
18
+
19
+ using System.Collections.Generic;
20
+
21
+
22
+
23
+ public abstract class EnemyBase : GameActor {
24
+
25
+
26
+
27
+ [SerializeField]
28
+
29
+ private PlayerMover player;
30
+
31
+ [SerializeField]
32
+
33
+ protected float tweenTime = 0.05f;
34
+
35
+ [SerializeField]
36
+
37
+ public enum EnemyStatas
38
+
39
+ {
40
+
41
+ Enemy,
42
+
43
+ Enemy1,
44
+
45
+ }
46
+
47
+ public EnemyStatas type;
48
+
49
+
50
+
51
+
52
+
53
+ public enum State
54
+
55
+ {
56
+
57
+ Moving,
58
+
59
+ MoveEnd,
60
+
61
+ }
62
+
63
+
64
+
65
+ public State state = State.Moving;
66
+
67
+ public State GetState { get { return state; } }
68
+
69
+
70
+
71
+ protected ANode node = null;
72
+
73
+
74
+
75
+ protected Vector3 nextPosition = Vector3.one;
76
+
77
+ protected Vector3 currentPosition = Vector3.one;
78
+
79
+
80
+
81
+
82
+
83
+ public abstract void Init();
84
+
85
+ public abstract void Proc();
86
+
87
+ public abstract void Finish();
88
+
89
+ public abstract void Dead();
90
+
91
+
92
+
93
+
94
+
95
+ public void AIMoveDirAStar()
96
+
97
+ {
98
+
99
+ FieldManager.Instance.GetGroundLayer.SetParam(X, Z, (int)ObjectType.None);
100
+
101
+ var path = FieldManager.Instance.FindPath(X, Z, player.X, player.Z);
102
+
103
+
104
+
105
+ if(path == null) { return; }
106
+
107
+
108
+
109
+ nextPosition = new Vector3(path[1].x, 1, path[1].z);
110
+
111
+ }
112
+
113
+
114
+
115
+ public List<Point2D> FindPath(int xStart, int zStart, int xGoal, int zGoal)
116
+
117
+ {
118
+
119
+ var pList = new List<Point2D>();
120
+
121
+ var astar = new ANodeManager(FieldManager.Instance.GetGroundLayer, xGoal, zGoal);
122
+
123
+ var node = astar.OpenNode(xStart, zStart, 0, null);
124
+
125
+ if (node == null)
126
+
127
+ {
128
+
129
+ Debug.LogError("スタート地点が不正です");
130
+
131
+ return null;
132
+
133
+ }
134
+
135
+
136
+
137
+ astar.AddOpenList(node);
138
+
139
+
140
+
141
+ int cnt = 0;
142
+
143
+ while (cnt < 1000)
144
+
145
+ {
146
+
147
+ astar.RemoveOpenList(node);
148
+
149
+ astar.OpenAround(node);
150
+
151
+
152
+
153
+ node = astar.SerchMinScoreNodeFromOpenList();
154
+
155
+ if (node == null)
156
+
157
+ {
158
+
159
+ Debug.LogError("袋小路なので終了");
160
+
161
+ return null;
162
+
163
+ }
164
+
165
+ if (node.X == xGoal && node.Z == zGoal)
166
+
167
+ {
168
+
169
+ astar.RemoveOpenList(node);
170
+
171
+ node.GetPath(pList);
172
+
173
+ pList.Reverse();
174
+
175
+ return pList;
176
+
177
+ }
178
+
179
+ }
180
+
181
+ Debug.LogError("なんもねえ");
182
+
183
+ return null;
184
+
185
+ }
186
+
187
+ public virtual void Move()
188
+
189
+ {
190
+
191
+
192
+
193
+ }
194
+
195
+ public virtual void AnimationEnd()
196
+
197
+ {
198
+
199
+
200
+
201
+ }
202
+
203
+ public virtual void Attack(PlayerMover pl)
204
+
205
+ {
206
+
207
+
208
+
209
+ }
210
+
211
+ }
212
+
213
+ ```
214
+
215
+ AIMoveDirAStar()の中の
216
+
217
+ nextPosition = new Vector3(path[1].x, 1, path[1].z);
218
+
219
+ でエラーを吐いているみたいです。