// Start is called before the first frame update void Start() { CurrentState = States.Idle; rb = GetComponent <Rigidbody>(); SearchPoint = new Vector3(0, 0, 0); Pathfinding = GameObject.FindGameObjectWithTag("Manager").GetComponent <AStarNav>(); SearchPath = new List <Node>(); Player = GameObject.Find("Player"); DetectRange = 10f; FOV = 20; PlayerFoundAction += OnPlayerFound; NotifiedAction += OnNotified; }
public void Initializer() { thisExe = System.Reflection.Assembly.GetExecutingAssembly(); using (Stream stream = thisExe.GetManifestResourceStream(resource)) using (StreamReader reader = new StreamReader(stream)) { string line; while ((line = reader.ReadLine()) != null) { width = line.Length; height++; } currentBoard = new char[width, height]; } using (Stream stream = thisExe.GetManifestResourceStream(resource)) using (StreamReader reader = new StreamReader(stream)) { string line; int currHeight = 0; int currWidth = 0; while ((line = reader.ReadLine()) != null) { foreach (char c in line) { currentBoard[currWidth, currHeight] = c; if (c == 'E' || c == 'G') { players.Add(new Player(c, defaultHP, new Point(currWidth, currHeight), this)); } currWidth++; } currWidth = 0; currHeight++; } } nav = new AStarNav(currentBoard, new char[] { '.' }, new Point(0, 0), new Point(0, 0)); foreach (Player p in players) { p.Nav = nav; } this.Delay = players.Count(); }