Пример #1
0
    public void Start()
    {
        GameObject TESTER = GameObject.FindGameObjectWithTag("GameController");

        Test = TESTER.GetComponent <test>();

        p = FindObjectsOfType <PathDefinition> ();
        for (int i = 0; i < p.Length; i++)
        {
            if (i == 0)
            {
                P1 = p [i];
            }
            else if (i == 1)
            {
                P2 = p [i];
            }
            else if (i == 2)
            {
                P3 = p [i];
            }
        }
        if (Test.randomSpawn == 1)
        {
            Path = P2;
        }
        else if (Test.randomSpawn == 2)
        {
            Path = P1;
        }
        else if (Test.randomSpawn == 3)
        {
            Path = P3;
        }



        //Path = FindObjectOfType<PathDefinition> ();
        if (Path == null)
        {
            Debug.LogError("Path cannot be null", gameObject);
            return;
        }

        _currentPoint = Path.GetPathsEnumerator();
        _currentPoint.MoveNext();

        if (_currentPoint.Current == null)
        {
            return;
        }

        //transform.position = _currentPoint.Current.position;
    }
Пример #2
0
    private IEnumerator <Transform> _currentPoint;   //声明一个迭代器

    void Start()
    {
        if (path == null)
        {
            Debug.Log("Path cannot be null", gameObject);
            return;
        }
        _currentPoint = path.GetPathsEnumerator(); //获得迭代器实例
        _currentPoint.MoveNext();                  //MoveNext ()会执行代码到迭代器中yiled 语句处停止(包括yiled 语句)
        if (_currentPoint.Current == null)         //Current代表迭代器当前返回值
        {
            return;
        }
        transform.position = _currentPoint.Current.position;//默认物体初始位置为路径点的第一个位置
    }
Пример #3
0
    public void Start()
    {
        if (Path == null)
        {
            Debug.LogError("Path cannot be null", gameObject);
            return;
        }

        _currentPoint = Path.GetPathsEnumerator();
        _currentPoint.MoveNext();
        if (_currentPoint.Current == null)
        {
            return;
        }
        transform.position = _currentPoint.Current.position;
    }
Пример #4
0
    private IEnumerator <Transform> currentPoint;       // the target point the object is moving towards.
    #endregion

    #region Unity Methods { Start(), Update()}
    public void Start()
    {
        if (path == null)                                      // Makes sure the path is not null.
        {
            Debug.LogError("Path cannot be null", gameObject); // Gives a log error if the path is null letting the user knwo they need a path.
            return;
        }

        currentPoint = path.GetPathsEnumerator();       // sets the current waypoint in the path.
        currentPoint.MoveNext();                        // Moves toward that waypoint.
        if (currentPoint.Current == null)               // checks if the current point is null.
        {
            return;
        }
        transform.position = currentPoint.Current.position;     // moves the object toward the waypoinys position.
    }
Пример #5
0
    public void Start()
    {
        Path = GameObject.FindGameObjectWithTag ("waterPath").GetComponent<PathDefinition> ();

        if (Path == null)
        {
            Debug.LogError("Path cannot be null", gameObject);
            return;
        }

        _currentPoint = Path.GetPathsEnumerator ();
        _currentPoint.MoveNext ();

        if (_currentPoint.Current == null)
            return;

        //transform.position = _currentPoint.Current.position;
    }
Пример #6
0
    // End Data Members --------------------------------------

    // Methods -----------------------------------------------------------------
    public void Start()
    {
        if (path == null)
        {
            Debug.LogError("Path cannot be null", gameObject);
            return;
        }

        _currentPoint = path.GetPathsEnumerator();
        _currentPoint.MoveNext();

        if (_currentPoint.Current == null)
        {
            // return, there is no point
            return;
        }
        // Platform starts on first point in the path
        transform.position = _currentPoint.Current.position;
    }
Пример #7
0
    public void Start()
    {
        Path = GameObject.FindGameObjectWithTag("waterPath").GetComponent <PathDefinition> ();

        if (Path == null)
        {
            Debug.LogError("Path cannot be null", gameObject);
            return;
        }

        _currentPoint = Path.GetPathsEnumerator();
        _currentPoint.MoveNext();

        if (_currentPoint.Current == null)
        {
            return;
        }

        //transform.position = _currentPoint.Current.position;
    }
Пример #8
0
    //private CollisionInfo _collidingColInfo;

    public void Start()
    {
        if (Path == null)
        {
            Debug.LogError("PATH IS NULL!", gameObject);
            return;
        }

        _debug = gameObject.GetComponent <CharacterDebug>();

        _lastPos      = Vector3.zero;
        _currentPoint = Path.GetPathsEnumerator();
        _currentPoint.MoveNext();

        if (_currentPoint.Current == null)
        {
            return;
        }

        transform.position = _currentPoint.Current.position;
    }