public void Damage(int dmgValue) { if (m_RecievedDamage == false) { m_HealthManager.DamageHealth(dmgValue); m_RecievedDamage = true; } }
protected void DamagePlayer(int damage) { if (IsEnemyAlive()) { bool playersTogether = GameObject.FindWithTag("Canvas").GetComponent <GameStats>().PlayersTogether; if (!playersTogether) { GameObject.Find("Camera" + targetPlayer.PlayerObject.name).GetComponent <CameraShaker> ().shake = 0.25f; } else { GameObject.Find("CameraP1").GetComponent <CameraShaker> ().shake = 0.25f; } if (transform.GetComponent <EnemyStats>().currentHP > 0) { HealthManager.DamageHealth(damage); nextHit = Time.time + 1f; } } }
void OnTriggerStay(Collider other) { if (other.tag == "Player" && Time.time > nextHit) { if (!HealthManager.isGameOver) { bool playersTogether = GameObject.FindWithTag("Canvas").GetComponent <GameStats>().PlayersTogether; if (!playersTogether) { GameObject.Find("Camera" + other.name).GetComponent <CameraShaker> ().shake = 0.15f; } else { GameObject.Find("CameraP1").GetComponent <CameraShaker> ().shake = 0.15f; } HealthManager.DamageHealth(1); nextHit = Time.time + 1; dir = other.transform.position - transform.position; other.GetComponent <Rigidbody>().AddForce(dir * 50); } } }
void OnTriggerEnter(Collider c) { GameObject other = c.gameObject; //If it hits a player don't disappear if (other.tag != "Enemy" && other.tag != "Bullet" && other.tag != "Room" && other.tag != "Pipe") { Destroy(gameObject); } if (other.tag == "Bullet") { Physics.IgnoreCollision(other.GetComponent <Collider> (), GetComponent <Collider> ()); } if (other.tag == "Player") { string damageType = "none"; bool playersTogether = GameObject.FindWithTag("Canvas").GetComponent <GameStats>().PlayersTogether; if (!playersTogether) { GameObject.Find("Camera" + other.name).GetComponent <CameraShaker> ().shake = 0.1f; } else { GameObject.Find("CameraP1").GetComponent <CameraShaker> ().shake = 0.1f; } if (augment != null) { Debug.Log(""); //Destroy (collision.gameObject); augment.onHitEffect(other); damageType = augment.Element; } HealthManager.DamageHealth(bulletDamage); } }