Ejemplo n.º 1
0
    public IEnumerator DirectMovement(Transform aObject, FloorNode aTargetNode, float aTimeUntilDone)
    {
        Vector3 NewNodePosition = new Vector3(aTargetNode.transform.position.x, aTargetNode.transform.position.y,
                                              aTargetNode.transform.position.z);

        float timeTaken = 0.0f;

        aTargetNode.SetWalkOnTopDelegate(WalkOnTopActivation);
        m_CurrentNode = aTargetNode;
        m_Animator.SetBool("b_IsWalking", true);
        while (aTimeUntilDone - timeTaken > 0)
        {
            if (Vector3.Distance(aObject.transform.position, NewNodePosition) < 0.05f)
            {
                timeTaken = aTimeUntilDone;
            }

            timeTaken       += Time.deltaTime;
            aObject.position = Vector3.Lerp(aObject.position, NewNodePosition, timeTaken / aTimeUntilDone);
            yield return(null);
        }


        m_Animator.SetBool("b_IsWalking", false);
        aObject.position = NewNodePosition;
        MovementEnd();
        yield return(0);
    }
Ejemplo n.º 2
0
    public void EnemyMovement()
    {
        m_PreviousNode.SetWalkOnTopDelegate(null);

        FloorNode NextNode = GetNextNode();

        if (NextNode == null)
        {
            Debug.Log("Cant Find Node ");
            return;
        }

        StartCoroutine(DirectMovement(transform, NextNode, 0.6f));
    }