Ejemplo n.º 1
0
    public virtual void MoveHorizontal()
    {
        //Debug.Log(Speed + " is speed for " + Owner.gameObject.name);
        if (Speed == 0)
        {
            Owner.AnimHelper.StopWalk();
        }

        //if(MyPhysics.Velocity.x != 0f && Owner.AnimHelper.GetBool("moving") == true)
        //{
        //    Owner.AnimHelper.PlayOrStopAnimBool("sliding", true);
        //}
        //else
        //{
        //    Owner.AnimHelper.PlayOrStopAnimBool("sliding", false);
        //}

        bool underMovementAffecting = StatusManager.CheckForStatus(Owner.gameObject, Constants.StatusType.MovementAffecting);
        bool underKnockback         = StatusManager.CheckForStatus(Owner.gameObject, Constants.StatusType.Knockback);

        if (underMovementAffecting == true || underKnockback == true)
        {
            return;
        }

        if (currentHorizontalDirection == 0f)
        {
            Owner.AnimHelper.StopWalk();
            //Debug.Log("Not walking");
        }
        else
        {
            if (IsGrounded)
            {
                //Debug.Log("Walking");
                Owner.AnimHelper.PlayWalk();
            }
        }

        if (Mathf.Abs(MyPhysics.Velocity.x) <= Speed)
        {
            //Debug.Log(currentHorizontalDirection * Acceleration);
            //Debug.Log(MyPhysics.Velocity.x);
            MyPhysics.AddForce(new Vector3(currentHorizontalDirection * Acceleration, 0f, 0f));
        }

        //MyPhysics.SetVelocity(new Vector3(currentHorizontalDirection * Speed, MyPhysics.Velocity.y, 0f));
    }