Ejemplo n.º 1
0
    protected virtual IEnumerator MoveToTargetCoroutine()
    {
        mySquadState = Squad.SquadState.Moving;
        CompositeUnitBehaviour.Weights[0] = movementWeight;
        myBoxCollider.size = Vector3.zero;

        for (int nodeIndex = 1; nodeIndex < path.Count; ++nodeIndex)
        {
            Vector3 startPosition = transform.position;
            Vector3 destination   = path[nodeIndex].transform.position + nodePositionOffset;
            float   timer         = 0f;

            while (timer < 1f)
            {
                timer += Time.deltaTime * MaxSpeed * 0.2f;
                transform.position = Vector3.Lerp(startPosition, destination, timer);
                OnAnimateSquadPath?.Invoke();

                yield return(null);
            }

            if (path.Count > 0)
            {
                PreviousNode = path[0];
                path.RemoveAt(nodeIndex - 1);
                --nodeIndex;
            }
            else
            {
                PreviousNode = null;
            }
        }

        transform.position = targetNode.transform.position + nodePositionOffset;
        mySquadState       = SquadState.PendingUnitsReady;
        myBoxCollider.size = originalBoxColliderSize;

        path.Clear();
        SetCurrentNode();
        targetNode = null;

        OnAnimateSquadPath?.Invoke();
    }
Ejemplo n.º 2
0
 protected void AnimateSquadPath()
 {
     OnAnimateSquadPath?.Invoke();
 }