示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.J))
        {
            playerAnimations.Defend(true);
            shield.ActivateShield(true);
        }

        if (Input.GetKeyUp(KeyCode.J))
        {
            playerAnimations.UnfreezeAnimation();
            playerAnimations.Defend(false);
            shield.ActivateShield(false);
        }

        if (Input.GetKeyDown(KeyCode.K))
        {
            if (Random.Range(0, 2) > 0)
            {
                playerAnimations.Attack1();
                soundFX.Attack1();
            }
            else
            {
                playerAnimations.Attack2();
                soundFX.Attack1();
            }
        }
    }
示例#2
0
    } // awake

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.J)) // defend
        {
            playerAnimation.Defend(true);

            shield.ActivateShield(true);
        }
        if (Input.GetKeyUp(KeyCode.J)) // defend
        {
            playerAnimation.UnfreezeAnimation();
            playerAnimation.Defend(false);

            shield.ActivateShield(false);
        }

        if (Input.GetKeyDown(KeyCode.K)) // attack
        {
            if (Random.Range(0, 2) > 0)  // Range(inclusive, exclusive) but with float the second param is included
            {
                playerAnimation.Attack_1();
                soundFx.Attack1();
            }
            else
            {
                playerAnimation.Attack_2();
                soundFx.Attack2();
            }
        }
    } // update