Example #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);
                }
            }
        }
Example #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
            }
        }
Example #3
0
        void Damage(Collider2D collision)
        {
            Stats collInfo = collision.GetComponent<Stats>();
            if(collision.gameObject.tag == "Enemy") collInfo.GetDamage(playerDamage);
            if(collision.gameObject.tag == "Player") collInfo.GetDamage(enemyDamage);

            //Hit visual effect
            HitEffect hitEffect = collision.GetComponentInChildren<HitEffect>();
            if(hitEffect != null) hitEffect.PlayEffect();

            Destroy(gameObject);
        }
Example #4
0
        void Damage(Collider2D collision)
        {
            Stats collInfo = collision.GetComponent <Stats>();

            collInfo.GetDamage(damage);

            //Hit visual effect
            HitEffect hitEffect = collision.GetComponentInChildren <HitEffect>();

            hitEffect.PlayEffect();

            Destroy(gameObject);
        }
Example #5
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
            }
        }