void Start() { levelcreator = GameObject.FindGameObjectWithTag("levelSettings"); levelSettings = levelcreator.GetComponent <Copy_LevelCreator>(); needsSelection = true; pathfinder = this.GetComponent <Pathfinder>(); }
void Update() { if (Network.isServer && nodeGridInitialised) { if (findPath) { if (Mathf.RoundToInt(this.transform.position.x) < nodeGrid.GetLength(0) && Mathf.RoundToInt(this.transform.position.y) < nodeGrid.GetLength(0) && Mathf.RoundToInt(this.transform.position.z) < nodeGrid.GetLength(0)) { if (reset) { startNode = nodeGrid[Mathf.RoundToInt(this.transform.position.x), Mathf.RoundToInt(this.transform.position.y), Mathf.RoundToInt(this.transform.position.z)]; if (openList != null && closedList != null) { for (int i = 0; i < openList.Count; i++) { openList[i].parentNode = null; } for (int i = 0; i < closedList.Count; i++) { closedList[i].parentNode = null; } startNode = path[1]; } path = new List <Node>(); openList = new List <Node>(); closedList = new List <Node>(); checkingNode = startNode; CalculateAllHeuristics(); levelcreator = GameObject.FindGameObjectWithTag("levelSettings"); level = levelcreator.GetComponent <Copy_LevelCreator>(); grid = level.getGrid(); reset = false; } int j = 0; while (j < (1.7 / Time.deltaTime)) { if (foundTarget == false) { FindPath(); } if (foundTarget == true) { if (tracedBack == false) { TraceBackPath(); reset = true; } } j++; } } } } }
void OnDestroy() { if (!quitting && Network.isServer && !playerController.dontDestroy) { robot.SendMessage("setNeedsSelection", true); Pathfinder pathfinder = robot.GetComponent <Pathfinder>(); pathfinder.foundTarget = false; RobotMovement robotmovement = robot.GetComponent <RobotMovement>(); robotmovement.destroyTarget = false; GameObject levelcreator = GameObject.FindGameObjectWithTag("levelSettings"); Copy_LevelCreator levelSettings = levelcreator.GetComponent <Copy_LevelCreator>(); levelSettings.setGrid(Mathf.RoundToInt(this.transform.position.x), Mathf.RoundToInt(this.transform.position.y), Mathf.RoundToInt(this.transform.position.z), 0); } }
void Start() { playerController.dontDestroy = false; hasspawned = false; level = GameObject.FindGameObjectWithTag("levelSettings").GetComponent <Copy_LevelCreator>(); }