Example #1
0
 private void Explode()
 {
     Instantiate(explosionPrefab, this.transform.position, Quaternion.identity);
     arrowMgr.HideArrow();
     pathShower.hidePath();
     GameObject.Destroy(this.gameObject);
     sfxManager.Play(sfxManager.explode);
 }
Example #2
0
    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);
        }
    }