void FixedUpdate() { if (!hasInitiated) { hasInitiated = true; agent.enabled = true; agent.SetDestination(currentDestination.goalPosition); onNewDestination(); } if (agent.pathPending) { return; } if (hasInitiated) { if (agent.remainingDistance < agent.stoppingDistance) { Destination dest = destMgr.nextDestination(); if (dest == null) { Instantiate(explosionPrefab, this.transform.position, Quaternion.identity); arrowMgr.HideArrow(); pathShower.hidePath(); GameObject.Destroy(this.gameObject); } else { IconManager.SetIcon(startDestination.gameObject, IconManager.LabelIcon.Purple); IconManager.SetIcon(currentDestination.gameObject, IconManager.LabelIcon.Purple); SpawnGhost(); startDestination = currentDestination; currentDestination = dest; agent.SetDestination(dest.goalPosition); onNewDestination(); } } if (Time.time - lastTime > 1.0f) { lastTime = Time.time; Waypoint point = new Waypoint(); point.goalPosition = transform.position; waypoints.Add(point); } pathShower.displayPath(agent.path); } }
void FixedUpdate() { if (!hasInitialized) { hasInitialized = true; agent.enabled = true; onNewDestination(); } if (agent.pathPending || !hasInitialized) { return; } if (agent.remainingDistance < agent.stoppingDistance) { Destination dest = destMgr.nextDestination(); if (dest == null) { sceneReloader.DoShowWinMenu(startTime); Explode(); } else { currentDestination.hasReached = true; IconManager.SetIcon(startDestination.gameObject, IconManager.LabelIcon.Purple); IconManager.SetIcon(currentDestination.gameObject, IconManager.LabelIcon.Purple); SpawnGhost(); startDestination = currentDestination; currentDestination = dest; float pitch = 0.5f + (0.5f / (destMgr.destinations.Count - 2)) * (destMgr.destinationIndex - 1); sfxManager.Play(sfxManager.destinationReached, pitch); onNewDestination(); } } if (Time.time - lastTime > 1.0f) { lastTime = Time.time; AddWaypoint(transform.position); } pathShower.displayPath(agent.path); }