NPC Speed Fix
This commit is contained in:
commit
0149b8a19f
@ -15,9 +15,10 @@ public class NodeMap : MonoBehaviour
|
|||||||
public bool hasEverRun = false;
|
public bool hasEverRun = false;
|
||||||
public Tilemap tilemap;
|
public Tilemap tilemap;
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void LateUpdate()
|
|
||||||
|
|
||||||
|
void Start()
|
||||||
{
|
{
|
||||||
if (!hasEverRun){
|
|
||||||
DataFromTiles = new Dictionary<TileBase, TileData>();
|
DataFromTiles = new Dictionary<TileBase, TileData>();
|
||||||
foreach (var tileData in TileDatas)
|
foreach (var tileData in TileDatas)
|
||||||
{
|
{
|
||||||
@ -26,12 +27,24 @@ public class NodeMap : MonoBehaviour
|
|||||||
DataFromTiles.Add(tile, tileData);
|
DataFromTiles.Add(tile, tileData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasEverRun = true;
|
hasEverRun = true;
|
||||||
CreateNodes();
|
CreateNodes();
|
||||||
TileCheck();
|
TileCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Generate()
|
||||||
|
{
|
||||||
|
DataFromTiles = new Dictionary<TileBase, TileData>();
|
||||||
|
foreach (var tileData in TileDatas)
|
||||||
|
{
|
||||||
|
foreach (var tile in tileData.Tiles)
|
||||||
|
{
|
||||||
|
DataFromTiles.Add(tile, tileData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hasEverRun = true;
|
||||||
|
CreateNodes();
|
||||||
|
TileCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,15 +16,26 @@ public class TileMapGenerator : MonoBehaviour
|
|||||||
public Tile ground1, wall1, corner_left_up, corner_left_down, corner_right_down, corner_right_up, left, right, up, down;
|
public Tile ground1, wall1, corner_left_up, corner_left_down, corner_right_down, corner_right_up, left, right, up, down;
|
||||||
public Graph graph;
|
public Graph graph;
|
||||||
public List<Vector3> availablePos;
|
public List<Vector3> availablePos;
|
||||||
|
public bool generated=false;
|
||||||
|
public bool nodeMapGenerated = false;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
while (!Generate())
|
while (!(generated=Generate()))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (generated && !nodeMapGenerated)
|
||||||
|
{
|
||||||
|
GameObject.FindObjectOfType<NodeMap>().Generate();
|
||||||
|
nodeMapGenerated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Generate()
|
bool Generate()
|
||||||
{
|
{
|
||||||
@ -134,9 +145,4 @@ public class TileMapGenerator : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user