Beispiel #1
0
    IEnumerator CO_Move()
    {
        animator.SetBool("IsCollide", false);
        while (true)
        {
            if (curDest != null)
            {
                Vector3 dir = curDest.transform.position - transform.position;
                if (dir.sqrMagnitude <= 0.7f)
                {
                    curDest = LoadManger.Instance.GetNextPoint();
                    LoadManger.Instance.MoveNext();
                    agent.SetDestination(curDest.transform.position);
                }
            }

            if (curDest.transform.position.x > transform.position.x)
            {
                skeleton.ScaleX = -1;
            }
            else
            {
                skeleton.ScaleX = 1;
            }
            yield return(new WaitForSeconds(.05f));
        }
    }
    private IEnumerator Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            DestroyImmediate(this);
        }

        yield return(new WaitUntil(() => { return LeaderManager.Instance != null; }));

        CurrentPoint = startPoint;

        yield return(new WaitForSeconds(lifeVesselTime));

        var lifeVessel = Instantiate(lifevessel, CurrentPoint.transform.position, Quaternion.identity);

        lifeVessel.tag = "LifeVessel";

        yield return(new WaitForSeconds(monsterFactoryTime));

        Instantiate(enemySpawner, spawnerPos.position, Quaternion.identity);
    }
Beispiel #3
0
 private void Start()
 {
     skeleton = skeletonMecanim.skeleton;
     curDest  = LoadManger.Instance.GetNextPoint();
     LoadManger.Instance.MoveNext();
     agent.SetDestination(curDest.transform.position);
     StartCoroutine(CO_Move());
 }
    //========================================================================================
    //                                     private
    //========================================================================================

    private RelayPoint GetNearRelayPoint(Vector3 pos)
    {
        float      length = 9999f;
        RelayPoint p      = null;

        for (int i = 0; i < PointList.Length; i++)
        {
            float l = (PointList[i].transform.position - pos).magnitude;
            if (l < length)
            {
                length = l;
                p      = PointList[i];
            }
        }
        return(p);
    }
 public void MoveNext()
 {
     CurrentPoint = CurrentPoint.CanGoShortCut && CurrentPoint.HaveShortCut ?
                    CurrentPoint.ShortCut : CurrentPoint.NextPoint;
 }