質問編集履歴
1
今のところのコードを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -17,3 +17,75 @@
|
|
17
17
|
こんな変な質問で申し訳ありません。
|
18
18
|
|
19
19
|
ご回答お待ちしております。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```C#
|
24
|
+
|
25
|
+
using System.Collections;
|
26
|
+
|
27
|
+
using System.Collections.Generic;
|
28
|
+
|
29
|
+
using UnityEngine;
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
public class AStar : MonoBehaviour
|
34
|
+
|
35
|
+
{
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
bool roadPass;
|
40
|
+
|
41
|
+
public int[,] charaPos;
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
void Start()
|
46
|
+
|
47
|
+
{
|
48
|
+
|
49
|
+
charaPos = new int[GameController.Instance.maxHeight, GameController.Instance.maxWidth]; //マップ探索用の二次元配列
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
for (int i = 0; i< GameController.Instance.mapTilesBox.GetLength(0); i++)
|
54
|
+
|
55
|
+
{
|
56
|
+
|
57
|
+
for (int j = 0; j< GameController.Instance.mapTilesBox.GetLength(1); j++)
|
58
|
+
|
59
|
+
{
|
60
|
+
|
61
|
+
if (GameController.Instance.LayerName(i, j) == "Obstacle") //移動不可能な場所は‐1
|
62
|
+
|
63
|
+
{
|
64
|
+
|
65
|
+
charaPos[i, j] = -1;
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
else //0で初期化
|
70
|
+
|
71
|
+
{
|
72
|
+
|
73
|
+
charaPos[i, j] = 0;
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
charaPos[GameController.Instance.enemyPosition.x, GameController.Instance.enemyPosition.y] = 1; //敵のスタート地点を1とする
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
```
|