private IEnumerator UseAttack(PlayerAttackInfo attack)
    {
        cc_Rb.rotation = Quaternion.Euler(0, m_CameraTransform.eulerAngles.y, 0);
        cr_Anim.SetTrigger(attack.TriggerName);

        // change color from default to the attack color
        IEnumerator toColor = ChangeColor(attack.AbilityColor, 10);

        StartCoroutine(toColor);

        // wait for windup time to be over
        yield return(new WaitForSeconds(attack.WindUpTime));

        Vector3 offset = transform.forward * attack.Offset.z +
                         transform.right * attack.Offset.x + transform.up * attack.Offset.y;
        GameObject go = Instantiate(attack.AbilityGO, transform.position + offset, cc_Rb.rotation);

        go.GetComponent <Ability>().Use(transform.position + offset);

        // change color back to default after the attack is over
        StopCoroutine(toColor);
        StartCoroutine(ChangeColor(p_DefaultColor, 50));

        yield return(new WaitForSeconds(attack.Cooldown));

        attack.ResetCooldown();
    }
Example #2
0
    private IEnumerator UseAttack(PlayerAttackInfo attack)
    {
        //cc_Rb.rotation = Quaternion.Euler(0, m_CameraTransform.eulerAngles.y, 0);
        //Quaternion new_Rotation = cc_Rb.rotation;
        //cr_Anim.SetTrigger(attack.TriggerName);
        //IEnumerator toColor = ChangeColor(attack.AbilityColor, 10);
        //StartCoroutine(toColor);
        //yield return new WaitForSeconds(attack.WindUpTime);

        //Vector3 offset = transform.forward * attack.Offset.z + transform.right * attack.Offset.x + transform.up * attack.Offset.y;
        Vector3 spawnPos = transform.position;// + offset;

        /*if (attack.Bomb)
         * {
         *  spawnPos = new Vector3(transform.position.x, 40, transform.position.z);
         *  Quaternion current_Rotation = attack.AbilityGO.transform.rotation;
         *  new_Rotation = new Quaternion(-current_Rotation.x, current_Rotation.y, current_Rotation.z, current_Rotation.w);
         *
         * }*/
        GameObject go = Instantiate(attack.AbilityGO, spawnPos, transform.rotation);

        go.GetComponent <Ability>().Use(spawnPos);

        //StopCoroutine(toColor);
        //StartCoroutine(ChangeColor(p_DefaultColor, 50));
        yield return(new WaitForSeconds(attack.Cooldown));

        attack.ResetCooldown();
    }
Example #3
0
    private IEnumerator UseAttack(PlayerAttackInfo attack)
    {
        cr_Anim.SetTrigger(attack.TriggerName);
        IEnumerator toColor = ChangeColor(attack.AbilityColor, 10);

        StartCoroutine(toColor);
        yield return(new WaitForSeconds(attack.WindupTime));

        Vector3    hitpoint = transform.forward * attack.AbilityGO.GetComponent <Ability>().Range;
        GameObject go       = Instantiate(attack.AbilityGO, transform.position + transform.forward * 0.2f, transform.rotation);

        go.GetComponent <Ability>().Use(transform.position, hitpoint);
        StopCoroutine(toColor);
        StartCoroutine(ChangeColor(p_DefaultColor, 50));
        yield return(new WaitForSeconds(attack.FrozenTime - attack.WindupTime));

        attack.ResetCooldown();
    }
Example #4
0
    private IEnumerator UseAttack(PlayerAttackInfo attack)
    {
        cc_Rb.rotation = Quaternion.Euler(0, m_CameraTransform.eulerAngles.y, 0);
        cr_Anim.SetTrigger(attack.TriggerName);
        IEnumerator toColor = ChangeColor(attack.AbilityColor, 10);

        StartCoroutine(toColor);
        yield return(new WaitForSeconds(attack.Windup));

        Vector3    offset = transform.forward * attack.Offset.z + transform.right * attack.Offset.x + transform.up * attack.Offset.y;
        GameObject go     = Instantiate(attack.AbilityGO, transform.position + offset, cc_Rb.rotation);

        go.GetComponent <Ability>().Use(transform.position + offset);
        DecreaseHealth(attack.HealthCost);

        StopCoroutine(toColor);
        StartCoroutine(ChangeColor(p_DefaultColor, 50));
        yield return(new WaitForSeconds(attack.Cooldown));

        attack.ResetCooldown();
    }
Example #5
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 (i == 0)
                {
                    m_HUD.UpdateAttackCooldown(1.0f);
                }
                else if (i == 1)
                {
                    m_HUD.UpdateHealCooldown(1.0f);
                }
                if (Input.GetButtonDown(attack.Button))
                {
                    attack.ResetCooldown();
                    StartCoroutine(UseAttack(attack));
                    break;
                }
            }
            else if (attack.Cooldown > 0)
            {
                attack.Cooldown -= Time.deltaTime;
                if (i == 0)
                {
                    m_HUD.UpdateAttackCooldown(1.0f * (attackCooldown - attack.Cooldown) / attackCooldown);
                }
                else if (i == 1)

                {
                    m_HUD.UpdateHealCooldown(1.0f * (10 - attack.Cooldown) / healCooldown);
                }
            }
        }
    }