예제 #1
0
    public Vector3 DoMovement()
    {
        if (_SavedMovement != AnimatorInfo.MovementType)
        {
            ChangedMovementType = true;
            _SavedMovement      = AnimatorInfo.MovementType;
        }

        if (AnimatorInfo.MovementType == 0)          //0 == With Pathfinding And Walking From Node To Node
        {
            myVariables.GetNodeInfo().MyAStar.StartRunning(myVariables.GetObjectNodeInfo(), myVariables.GetNodeInfo(), myVariables.GetWhatToTarget().MyMovementTarget);

            if (myVariables.GetNodeInfo().MyNodePath [2] == null)            //If There Is Less Then 2 Nodes Left, Including That StartNode;
            {
                return(Vector3.zero);
            }
            if (myVariables.GetNodeInfo().MyNodePath [1] == null)
            {
                return(Vector3.zero);
            }
            else
            {
                MovementVector.x = ((myVariables.GetNodeInfo().MyNodePath [1].PosX - (myVariables.GetNodeInfo().MyNodePath [0].PosX)));
                MovementVector.y = ((myVariables.GetNodeInfo().MyNodePath [1].PosY - (myVariables.GetNodeInfo().MyNodePath [0].PosY)));
            }

            return(MovementVector.normalized);
        }
        else if (AnimatorInfo.MovementType == 1)            //Direct Targeting

        {
            MovementVector = (myVariables.GetWhatToTarget().MyMovementTarget.transform.position - myVariables.transform.position).normalized;


            return(MovementVector);
        }
        else if (AnimatorInfo.MovementType == 2)            //Locked Direct Targeting

        {
            if (ChangedMovementType == true)
            {
                ChangedMovementType = false;

                MovementVector = (myVariables.GetWhatToTarget().MyMovementTarget.transform.position - myVariables.transform.position).normalized;


                return(MovementVector);
            }


            return(MovementVector);
        }
        else            //Locking My Vector;


        {
            return(MovementVector);
        }
    }