private void Update()
    {
        if (p_FrozenTimer > 0)
        {
            p_Velocity     = Vector2.zero;
            p_FrozenTimer -= Time.deltaTime;
            return;
        }
        else
        {
            p_FrozenTimer = 0;
        }

        //Ability use
        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];
            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    p_FrozenTimer = attack.FrozenTime;
                    DecreaseHealth(attack.HealthCost);
                    StartCoroutine(UseAttack(attack));
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
            }
        }
        //set how hard the palyer is pressing movement buttons
        float forward = Input.GetAxis("Vertical");
        float right   = Input.GetAxis("Horizontal");

        //Updating the animation
        cr_Anim.SetFloat("Speed", Mathf.Clamp01(Mathf.Abs(forward) + Mathf.Abs(right)));

        //Updateing velocity
        float moveThreshold = 0.3f;

        if (forward > 0 && forward < moveThreshold)
        {
            forward = 0;
        }
        else if (forward < 0 && forward > -moveThreshold)
        {
            forward = 0;
        }
        if (right > 0 && right < moveThreshold)
        {
            right = 0;
        }
        if (right < 0 && right > -moveThreshold)
        {
            right = 0;
        }
        p_Velocity.Set(right, forward);
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        //if already attacking do nothing else this frame
        if (Attacking)
        {
            return;
        }

        //access input values
        x_input = Input.GetAxisRaw("Horizontal");
        y_input = Input.GetAxisRaw("Vertical");
        Move();

        //check for attack executed
        bool punch_pressed = Input.GetKeyDown(KeyCode.Z);

        if (punch_pressed && punch_timer <= 0)
        {
            Punch();
        }

        //decrement all attack timers
        punch_timer -= Time.deltaTime;


        //Use Magic Attacks
        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];

            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    //p_FrozenTimer = attack.FrozenTime;
                    //DecreaseHealth(attack.HealthCost);
                    StartCoroutine(UseAttack(attack));
                    //UseAttacks(attack);
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
            }
        }
    }
Exemple #3
0
    private void Update()
    {
        if (p_KillTime > 0)
        {
            p_KillTime          -= Time.deltaTime;
            m_KillCountDown.text = "Killer Mode Activated! Time Left = " + p_KillTime;
        }
        else
        {
            m_KillCountDown.text = "";
        }

        if (p_FrozenTimer > 0)
        {
            p_Velocity     = Vector2.zero;
            p_FrozenTimer -= Time.deltaTime;
            return;
        }
        else
        {
            p_FrozenTimer = 0;
        }
        //Ability use -- see if ready
        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];

            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    p_FrozenTimer = attack.FrozenTime;
                    DecreaseHealth(attack.HealthCost);
                    StartCoroutine(UseAttack(attack));
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
            }
        }


        // see how hard player is pressomg movement buttons
        // up and down (+ and -)
        float forward = Input.GetAxis("Vertical");

        //right and left(+ and -)
        float right = Input.GetAxis("Horizontal");

        //updating the animation
        cr_Anim.SetFloat("Speed", Mathf.Clamp01(Mathf.Abs(forward) + Mathf.Abs(right)));

        // velocity
        float moveThreshold = 0.3f;

        if (forward > 0 && forward < moveThreshold)
        {
            forward = 0;
        }
        else if (forward < 0 && forward > -moveThreshold)
        {
            forward = 0;
        }

        if (right > 0 && right < moveThreshold)
        {
            right = 0;
        }
        else if (right < 0 && right > -moveThreshold)
        {
            right = 0;
        }
        p_Velocity.Set(right, forward);
    }
Exemple #4
0
    private void Update()
    {
        if (p_FrozenTimer > 0)
        {
            p_Velocity     = Vector2.zero;
            p_FrozenTimer -= Time.deltaTime;
            return;
        }
        else
        {
            p_FrozenTimer = 0;
        }

        if (p_ManaTimer > 0)
        {
            p_elaspedtime += Time.fixedDeltaTime;
            p_ManaTimer   -= p_elaspedtime;
        }
        else
        {
            IncreaseMana(p_ManaRegen);
            p_ManaTimer   = m_TimeToRegen;
            p_elaspedtime = 0;
        }

        //Abiltiy Use
        for (int i = 0; i < m_attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_attacks[i];

            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    p_FrozenTimer = attack.FrozenTime;
                    if (p_CurrMana >= attack.ManaCost)
                    {
                        DecreaseMana(attack.ManaCost);
                    }
                    else if (p_CurrMana > 0 && p_CurrMana < attack.ManaCost)
                    {
                        float rest = attack.ManaCost - p_CurrMana;
                        DecreaseMana(p_CurrMana);
                        DecreaseHealth(rest);
                    }
                    else
                    {
                        DecreaseHealth(attack.HealthCost);
                    }
                    StartCoroutine(UseAttack(attack));
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
            }
        }

        // Set how hard Player is pushing movement buttons
        float forward = Input.GetAxis("Vertical");
        float right   = Input.GetAxis("Horizontal");

        //Updating the Animation
        cr_anim.SetFloat("Speed", Mathf.Clamp01(Mathf.Abs(forward) + Mathf.Abs(right)));

        // Updating velocity
        float moveThreshold = 0.3f;

        if (forward > 0 && forward < moveThreshold)
        {
            forward = 0;
        }
        else if (forward < 0 && forward > -moveThreshold)
        {
            forward = 0;
        }
        if (right > 0 && right < moveThreshold)
        {
            right = 0;
        }
        else if (right < 0 && right > -moveThreshold)
        {
            right = 0;
        }
        p_Velocity.Set(right, forward);
    }
    private void Update()
    {
        if (p_FrozenTimer > 0)
        {
            p_Velocity     = Vector2.zero;
            p_FrozenTimer -= Time.deltaTime;
            return;
        }
        else
        {
            p_FrozenTimer = 0;
        }


        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];


            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    if (attack.AttackName.Equals("MegaLaser"))
                    {
                        if (p_CurPower > attack.PowerCost)
                        {
                            p_FrozenTimer = attack.FrozenTime;
                            DecreasePower(attack.PowerCost);
                            StartCoroutine(UseAttack(attack));
                        }
                        break;
                    }
                    else
                    {
                        p_FrozenTimer = attack.FrozenTime;
                        StartCoroutine(UseAttack(attack));
                        break;
                    }
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
            }
        }


        float forward = Input.GetAxis("Vertical");
        float right   = Input.GetAxis("Horizontal");

        cr_Anim.SetFloat("Speed", Mathf.Clamp01(Mathf.Abs(forward) + Mathf.Abs(right)));

        float moveThreshold = 0.3f;

        if (forward > 0 && forward < moveThreshold)
        {
            forward = 0;
        }
        else if (forward < 0 && forward > -moveThreshold)
        {
            forward = 0;
        }

        if (right > 0 && right < moveThreshold)
        {
            right = 0;
        }
        else if (right < 0 && right > -moveThreshold)
        {
            right = 0;
        }

        p_Velocity.Set(right, forward);
    }
Exemple #6
0
    private void Update()
    {
        if (p_FrozenTimer > 0)
        {
            p_Velocity     = Vector2.zero;
            p_FrozenTimer -= Time.deltaTime;
            return;
        }
        else
        {
            p_FrozenTimer = 0;
        }

        /* Ability use timers */
        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];

            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    p_FrozenTimer = attack.FrozenTime;
                    StartCoroutine(UseAttack(attack));
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
            }
            else
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    attack.Cooldown -= 0.5f * Time.deltaTime;
                }
            }
        }

        /* Player inputs */
        float forward = Input.GetAxis("Vertical");
        float right   = Input.GetAxis("Horizontal");

        /* Updating the animation */
        cr_Anim.SetFloat("Speed", Mathf.Clamp01(Mathf.Abs(forward) + Mathf.Abs(right)));

        /* Establish a "deadzone" for movement */
        float moveThreshold = 0.3f;

        if (forward > -moveThreshold && forward < moveThreshold)
        {
            forward = 0;
        }
        if (right > -moveThreshold && right < moveThreshold)
        {
            right = 0;
        }

        p_Velocity.Set(right, forward);
    }
Exemple #7
0
    private void Update()
    {
        if (p_FrozenTimer > 0)
        {
            p_FrozenTimer -= Time.deltaTime;
            p_Velocity     = Vector2.zero;
            return;
        }
        else
        {
            p_FrozenTimer = 0;
        }

        RaycastHit hit;

        if (Physics.Raycast(transform.position, Vector3.down, out hit, 100, 1 << LayerMask.NameToLayer("Floor")))
        {
            cc_Spring.targetPosition = new Vector3(0, -hit.point.y, 0);
            if (p_isJumping && Mathf.Abs(transform.position.y - hit.point.y) < 1.05f)
            {
                p_isJumping = false;
            }
        }
        else
        {
            cc_Spring.targetPosition = new Vector3(0, 100, 0);
        }

        float forward = Input.GetAxisRaw("Vertical");
        float right   = Input.GetAxisRaw("Horizontal");

        p_Velocity.Set(right, forward);
        p_Velocity.Normalize();

        p_AnimForwardSpeed = Mathf.Lerp(p_AnimForwardSpeed, p_Velocity.magnitude, .3f);
        cr_Anim.SetFloat("Speed", p_AnimForwardSpeed);

        if (Input.GetButtonDown("Jump") && !p_isJumping)
        {
            cc_Rb.AddForce(Vector3.up * m_JumpStrength, ForceMode.Impulse);
            p_isJumping = true;
        }

        p_rotationAmount = Input.GetAxis("Mouse X");

        for (int i = 0; i < m_Attacks.Length; i++)
        {
            PlayerAttackInfo attack = m_Attacks[i];
            if (attack.IsReady())
            {
                if (Input.GetButtonDown(attack.Button))
                {
                    p_FrozenTimer = attack.FrozenTime;
                    DecreaseHealth(attack.HealthCost);
                    StartCoroutine(UseAttack(attack));
                    break;
                }
            }
            else
            {
                attack.Cooldown -= Time.deltaTime;
            }
        }
    }