Beispiel #1
0
        private void AttackCall(bool mbPress)
        {
            //Check the timer if it is time to attack
            if ((Time.time - timer) > gameObject.GetComponent <Stats>().attackSpeed.Value)
            {
                //We enable the hitbox to check for collisions for the weapon
                //weaponHitBox.SetActive(true);
                //Move the hit box a miniscule amount to get a reaction from the hit box while the animation has not yet been inplimented
                //NOTE: Take out this movement when the animation has been implimented
                weaponHitBox.GetComponent <HitBox>().startCheckingCollision();
                //NOTE: play attack animation from here

                //Call to the attack event callback system
                AttackEvent attackEventInfo = new AttackEvent();
                attackEventInfo.baseGO = gameObject;
                attackEventInfo.FireEvent();
                //Reset the timer for the next attack time check
                timer = Time.time;
            }

            //Check the timer if it is time to attack
            if ((Time.time - timer) > gameObject.GetComponent <Stats>().attackSpeed.Value)
            {
                //We disable the hitbox when the timer for the attack has run down
                weaponHitBox.GetComponent <HitBox>().stopCheckingCollision();
            }
        }
Beispiel #2
0
    private void Attack(AI controller)
    {
        //If the attack attack speed value is higher than the attack timer then we run the attack code
        if ((Time.time - controller.attackTimer) > controller.GetComponent <Stats>().attackSpeed.Value)
        {
            //We enable the hitbox to check for collisions for the weapon
            controller.weaponHitBox.SetActive(true);

            //NOTE: play attack animation from here

            //Call to the attack event callback system
            AttackEvent attackEventInfo = new AttackEvent();
            attackEventInfo.baseGO = controller.gameObject;
            attackEventInfo.FireEvent();
            //Reset the timer for the next attack time check
            controller.attackTimer = Time.time;
        }
        //If the attack time has elapsed we disable the hitbox object
        if ((Time.time - controller.attackTimer) > controller.gameObject.GetComponent <Stats>().attackSpeed.Value)
        {
            //We disable the hitbox when the timer for the attack has run down
            controller.weaponHitBox.SetActive(false);
        }
    }