mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2026-07-31 22:59:03 +02:00
PathMap Class
+Made the PathMap into a standalone class
This commit is contained in:
45
Assets/Scripts/NPC/NPCController.cs
Normal file
45
Assets/Scripts/NPC/NPCController.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NPCController : MonoBehaviour
|
||||
{
|
||||
|
||||
PathMap Map;
|
||||
private GameObject[,] ball;
|
||||
public List<PathNode> path;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
ball = new GameObject[30, 30];
|
||||
Map = new PathMap(new Vector3(0, 0, 0), 30, 30, 30);
|
||||
for (int r = 0; r < 30; r++)
|
||||
{
|
||||
for (int c = 0; c < 30; c++)
|
||||
{
|
||||
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
sphere.transform.position = Map.map[r, c].Position;
|
||||
ball[r, c] = sphere;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
path = Map.QueryNodes(new Vector3(0,0, 0), new Vector3(100, 0,100));
|
||||
//Debug.Log("yeet");
|
||||
Debug.Log(path.Count);
|
||||
Debug.Log((int)path[0].index.x + " "+ (int)path[0].index.y);
|
||||
for (int i = 0; i < path.Count - 1; i++) {
|
||||
int x = path[i].index.x;
|
||||
int y = path[i].index.y;
|
||||
Destroy(ball[x, y]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user