Exemple #1
0
        //Hit method
        public override void HitDetected()
        {
            if (ColliderDetected.gameObject.tag == "Player")                                 //if is player
            {
                Stats            playerStats      = ColliderDetected.GetComponent <Stats>(); //Get data component from object
                PlayerController playerController = ColliderDetected.gameObject.GetComponent <PlayerController>();

                if (playerController != null && !playerController.inRoll)
                {
                    playerController.audioSource.PlayOneShot(playerController.enemyMeleeHitSound);
                }

                if (playerController != null && !playerController.inRoll)
                {
                    //Make visual hit effect
                    HitEffect hitEffect = ColliderDetected.GetComponentInChildren <HitEffect>();
                    hitEffect.PlayEffect();

                    float damage = damageRange.Random();        //get 1 random value damage of 2 (min,max)

                    MeleeAttack(playerStats, damage);           //Damage

                    CameraManager.Instance.cameraShake.Shake(); //Camera shake
                }
            }
            else
            {
                if (enemyController != null)
                {
                    enemyController.audioSource.PlayOneShot(enemyController.attackSound);
                }
            }
        }
Exemple #2
0
        //Hit method
        public override void HitDetected()
        {
            if (ColliderDetected.gameObject.tag == "Enemy")                                //if is enemy
            {
                Stats           enemyStats      = ColliderDetected.GetComponent <Stats>(); //Get data component from object
                EnemyController enemyController = ColliderDetected.gameObject.GetComponent <EnemyController>();

                if (enemyController != null)
                {
                    enemyController.audioSource.PlayOneShot(enemyController.meleeHitSound);
                }

                //Make visual hit effect
                HitEffect hitEffect = ColliderDetected.GetComponentInChildren <HitEffect>();
                if (hitEffect != null)
                {
                    hitEffect.PlayEffect();
                }

                float damage = damageRange.Random(); //get 1 random value damage of 2 (min,max)

                MeleeAttack(enemyStats, damage);

                CameraManager.Instance.cameraShake.Shake(); //Damage
            }
        }
Exemple #3
0
        //Hit method
        public override void HitDetected()
        {
            if (ColliderDetected.gameObject.tag == "Player")                 //if is player
            {
                Stats playerStats = ColliderDetected.GetComponent <Stats>(); //Get data component from object

                //Make visual hit effect
                HitEffect hitEffect = ColliderDetected.GetComponentInChildren <HitEffect>();
                hitEffect.PlayEffect();

                float damage = damageRange.Random();        //get 1 random value damage of 2 (min,max)

                MeleeAttack(playerStats, damage);           //Damage

                CameraManager.Instance.cameraShake.Shake(); //Camera shake
            }
        }