Exemple #1
0
    void Update()
    {
        if (m_isMoving)
        {
            float distanceToGo = speed * Time.deltaTime;
            var   evt          = path.Move(pathData, distanceToGo);

            transform.position = pathData.position;

            if (evt == PathSystem.PathEvent.Finished)
            {
                Destroy(this);
            }
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (m_SpawnQueue.Count > 0)
        {
            var elem = m_SpawnQueue.Peek();
            elem.remainingTime -= Time.deltaTime;

            if (elem.remainingTime <= 0)
            {
                Dequeue();
            }
        }

        float distanceToGo = speed * Time.deltaTime;

        for (int i = 0; i < m_ActiveElements.Count; ++i)
        {
            var currentElem = m_ActiveElements[i];

            //the target was already destroyed no need to update its position.
            if (currentElem.target.Destroyed)
            {
                continue;
            }

            var evt = path.Move(currentElem.pathData, distanceToGo);

            switch (evt)
            {
            case PathSystem.PathEvent.Finished:
                m_ActiveElements.RemoveAt(i);
                i--;
                break;

            default:
                currentElem.rb.MovePosition(currentElem.pathData.position);
                break;
            }
        }
    }