Ejemplo n.º 1
0
    public void PlayerMove()
    {
        theScale = transform.localScale;
        var move = new Vector3(Input.GetAxis("Horizontal"), 0, 0);

        if (GameManager.paused == false)
        {
            if (Input.GetKey(KeyCode.RightArrow))
            {
                if (!animator.GetCurrentAnimatorStateInfo(0).IsName("PlayerAttack"))
                {
                    if (theScale.x < 0)
                    {
                        theScale.x          *= -1;
                        transform.localScale = theScale;
                    }
                    transform.position += move * speed * Time.deltaTime;
                    animator.SetTrigger("PlayerMove");
                }
            }
            else if (Input.GetKey(KeyCode.LeftArrow))
            {
                if (!animator.GetCurrentAnimatorStateInfo(0).IsName("PlayerAttack"))
                {
                    if (theScale.x > 0)
                    {
                        theScale.x          *= -1;
                        transform.localScale = theScale;
                    }
                    transform.position += move * speed * Time.deltaTime;
                    animator.SetTrigger("PlayerMove");
                }
            }

            else if (Input.GetKeyDown(KeyCode.Z))
            {
                if (theScale.x >= 0)
                {
                    animator.SetTrigger("PlayerAttack");
                    SoundManager.instance.PlaySingle(swordSound);
                }
            }

            else if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                if (skill.getCurrentCooldown(0) >= skill.getCooldown(0))
                {
                    if (GameManager.currentMana >= damageMana)
                    {
                        damageAura.enabled = true;
                        Debug.Log(damageAura.enabled);
                        damageTimer = 30f;
                        attack.enableDoubleDamage();
                        sliceScript.enableDoubleDamage();
                        GameManager.useSkill(damageMana);
                        skill.setCurrentCooldownZero(0);
                        SoundManager.instance.PlaySingle(rageSound);
                    }
                }
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                //skill aura
                if (skill.getCurrentCooldown(1) >= skill.getCooldown(1))
                {
                    if (GameManager.currentMana >= shieldMana)
                    {
                        SoundManager.instance.PlaySingle(skillSound);
                        shieldAura.enabled = true;
                        shielded           = true;
                        shieldTimer        = 50f;
                        GameManager.useSkill(shieldMana);
                        skill.setCurrentCooldownZero(1);
                        SoundManager.instance.PlaySingle(auraSound);
                    }
                    else
                    {
                        Debug.Log("Not Enough Mana for SHIELD!");
                    }
                }
            }
            else if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                //skill slice
                if (skill.getCurrentCooldown(2) >= skill.getCooldown(2))
                {
                    if (GameManager.currentMana >= sliceMana && theScale.x >= 0)
                    {
                        SoundManager.instance.PlaySingle(skillSound);
                        Instantiate(slice, skillSpawn.position, skillSpawn.rotation);
                        GameManager.useSkill(sliceMana);
                        skill.setCurrentCooldownZero(2);
                    }
                    else
                    {
                        Debug.Log("Not Enough Mana for SLICE!");
                    }
                }
            }
            else
            {
                animator.SetTrigger("PlayerIdle");
            }
        }
    }