//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); } } }
//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 } }
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); }
void Damage(Collider2D collision) { Stats collInfo = collision.GetComponent <Stats>(); collInfo.GetDamage(damage); //Hit visual effect HitEffect hitEffect = collision.GetComponentInChildren <HitEffect>(); hitEffect.PlayEffect(); Destroy(gameObject); }
//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 } }