Ejemplo n.º 1
0
    // TODO: Put the attack conditions on the Update()
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.G))
        {
            godMode = !godMode;                                     // Changes between godmode and normal mode whenever the G key is pressed. G for God
        }
        if (godMode)
        {
            playerSphereCollider.enabled  = false;                        // Sets the sphereCollider from the player to false.
            playerCapsuleCollider.enabled = false;                        // Sets the capsuleCollider from the player to false.
        }
        else
        {
            playerSphereCollider.enabled  = true;                        // Sets the sphereCollider from the player to false.
            playerCapsuleCollider.enabled = true;                        // Sets the capsuleCollider from the player to false.
        }

        switch (state)
        {
        case PlayerStates.AWAKE:
            AwakeBehaviour();
            break;

        case PlayerStates.STUNNED:
            StunnedBehaviour();
            break;

        case PlayerStates.DEAD:
            DeadBehaviour();
            break;

        case PlayerStates.VICTORY:
            VictoryBehaviour();
            break;
        }

        if (currentHealth <= 10)
        {
            playerAudio.clip = lowHpClip;
            playerAudio.Play();
        }

        // TODO: Review that shit. Redo.

        /*if (score.pointsCounter >= 100)
         * {
         *  sword10Active = true;
         *  sword10Sprite.enabled = true;
         *  if (alphaValue >= 0) newAbility.color = new Color(1.0f, 1.0f, 1.0f, alphaValue -= 0.2f * Time.deltaTime);
         * }
         */
        if (playerAttack.sword10CD >= 0)
        {
            playerAttack.sword10CD -= 1 * Time.deltaTime;
            cooldownSword10.enabled = true;
            cooldownSword10.text    = "" + playerAttack.sword10CD;
            //sword10Sprite.color = new Color(1.0f, sword10ColorGValue += 1 / playerAttack.sword10CDAux * Time.deltaTime, sword10ColorBValue += 1 / playerAttack.sword10CDAux * Time.deltaTime);
        }
        else if (playerAttack.sword10CD <= 0)
        {
            cooldownSword10.enabled = false;
            //sword10Sprite.color = new Color(1.0f, 1.0f, 1.0f);
        }

        // Attack
        if (playerAnimation.attackRatio <= 0)
        {
            characterBehaviour.speed = baseSpeed;

            if (Input.GetMouseButtonDown(0))
            {
                playerAttack.Attack10(playerAttack.damageAttack10);                                                                     // Calls the setAttack10 function if mouse left button is pressed.
            }
            else if (Input.GetMouseButtonDown(1))
            {
                playerAttack.Attack01(playerAttack.damageAttack01);                                                                     // Calls the setAttack01 function if mouse right button is pressed.
            }
            else if (Input.GetKeyDown(KeyCode.Alpha1) && sword10Active)
            {
                playerAttack.Sword10(playerAttack.damageSword10);                                                                       // Calls the setSword10 function if the 1 keypad is pressed, and if is not in chain mode.
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                playerAttack.Chain01(playerAttack.damageChain01);                                                                       // If the chain mode is active, goes to the setChain01.
            }
            else if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                playerAttack.Dash();                                                                                                    // Calls the setDash function if left shift key is pressed.
            }
            Debug.Log("baseSpeed: " + baseSpeed);
        }
        else if (playerAnimation.attackRatio > 0)
        {
            characterBehaviour.speed     = 0.0f;
            playerAnimation.attackRatio -= Time.deltaTime;
            Debug.Log("baseSpeed: " + baseSpeed);
        }
    }