예제 #1
0
    void PlayerInput()
    {
        if (cc.isGrounded)
        {
            if (currentChar == characterTags.wings)
            {
                jumpAgain = true;
            }
            else
            {
                jumpAgain = false;
            }
            physicsFlag = physicsStates.run;
            if (Input.GetAxis("Horizontal") == 0)
            {
                physicsFlag = physicsStates.idle;
            }
        }
        else
        {
            if (physicsFlag == physicsStates.fall)
            {
                Fall();
            }
        }


        if (Input.GetButtonDown("Jump"))
        {
            if (cc.isGrounded)
            {
                Jump(1);
            }
            else if (jumpAgain)
            {
                Jump(0.65f);
            }

            print("Jump");
            //Keyboard - Space
            //Controller - A
        }
        if (Input.GetButtonDown("Special"))
        {
            Special();
            print("Special");
            //Keyboard - Q or E
            //Controller - Right Trigger or Y
        }
        if (Input.GetButtonDown("Punch"))
        {
            Punch();
            print("Punch");
            //Keyboard - Left click
            //Controller - X
        }
    }
예제 #2
0
    void PhysicsFlags()
    {
        switch (physicsFlag)
        {
        case physicsStates.idle:
            PlayAnimation("Idle", 1);
            running = false;
            break;

        case physicsStates.run:
            float animSpeed = Mathf.Abs(Input.GetAxis("Horizontal"));
            if (moveDirection.x > 0)
            {
                PlayAnimation("RunRight", animSpeed * 2);
            }
            else
            {
                PlayAnimation("RunLeft", animSpeed * 2);
            }
            break;

        case physicsStates.jump:
            if (ySpeed < 0)
            {
                physicsFlag = physicsStates.fall;
            }
            break;

        case physicsStates.punch:
            PlayAnimation("RightPunch", 1);
            break;

        case physicsStates.special:
            PlayAnimation("Idle", 1);
            break;

        case physicsStates.swap:
            PlayAnimation("Idle", 1);
            break;

        case physicsStates.death:
            PlayAnimation("Idle", 1);
            break;
        }
    }
예제 #3
0
 void Jump(float jumpMultiplier)
 {
     if (moveDirection.x > 0)
     {
         PlayAnimation("RightJump", 1, .2f);
     }
     else if (moveDirection.x < 0)
     {
         PlayAnimation("LeftJump", 1, .2f);
     }
     else
     {
         PlayAnimation("Jump", 1, .2f);
     }
     ySpeed      = jumpSpeed * jumpMultiplier;
     physicsFlag = physicsStates.jump;
     if (!cc.isGrounded)
     {
         jumpAgain = false;
     }
 }
예제 #4
0
 void Swap()
 {
     physicsFlag = physicsStates.swap;
 }
예제 #5
0
 void Special()
 {
     physicsFlag = physicsStates.special;
 }
예제 #6
0
 void Punch()
 {
     physicsFlag = physicsStates.punch;
 }