質問するログイン新規登録

質問編集履歴

1

今のところのコードを追記

2018/03/23 05:00

投稿

mymsmpb_love
mymsmpb_love

スコア13

title CHANGED
File without changes
body CHANGED
@@ -7,4 +7,40 @@
7
7
 
8
8
  アルゴリズムでも何でもいいので知識をくれたらいいなと思っています。
9
9
  こんな変な質問で申し訳ありません。
10
- ご回答お待ちしております。
10
+ ご回答お待ちしております。
11
+
12
+ ```C#
13
+ using System.Collections;
14
+ using System.Collections.Generic;
15
+ using UnityEngine;
16
+
17
+ public class AStar : MonoBehaviour
18
+ {
19
+
20
+ bool roadPass;
21
+ public int[,] charaPos;
22
+
23
+ void Start()
24
+ {
25
+ charaPos = new int[GameController.Instance.maxHeight, GameController.Instance.maxWidth]; //マップ探索用の二次元配列
26
+
27
+ for (int i = 0; i< GameController.Instance.mapTilesBox.GetLength(0); i++)
28
+ {
29
+ for (int j = 0; j< GameController.Instance.mapTilesBox.GetLength(1); j++)
30
+ {
31
+ if (GameController.Instance.LayerName(i, j) == "Obstacle") //移動不可能な場所は‐1
32
+ {
33
+ charaPos[i, j] = -1;
34
+ }
35
+ else  //0で初期化
36
+ {
37
+ charaPos[i, j] = 0;
38
+ }
39
+ }
40
+ }
41
+
42
+ charaPos[GameController.Instance.enemyPosition.x, GameController.Instance.enemyPosition.y] = 1; //敵のスタート地点を1とする
43
+
44
+ }
45
+ }
46
+ ```