//private GameObject explosionEffect; protected override void OnTrigger() { ParticleController.GetInstance().InstantiateParticle(ParticleController.Explosion, transform.position); //Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius, ~(1 << LayerMask.NameToLayer("Environment"))); //foreach (Collider collider in colliders) //{ // Rigidbody rb = collider.gameObject.GetComponent<Rigidbody>(); // // If this RB has a destructible, it receives damage. // IDestructable destructable = rb.gameObject.GetComponent<IDestructable>(); // if (destructable != null) // { // //destructable.ReceiveDamage(CalculateDamage(rb.gameObject)); // //continue; // } // // If this is a bullet, the bullet gets destroyed. // Bullet bullet = rb.gameObject.GetComponent<Bullet>(); // if (bullet != null) // { // Destroy(bullet.gameObject); // } // //rb.AddExplosionForce(explosionForce, transform.position, explosionRadius); //} Destroy(gameObject); }
public override void OnAdvantage(GameObject collider, GameObject other) { Debug.Log("LASER ADVANTAGE"); isReflecting = false; // If this is a weapon spawn, destroy it. if (other.GetComponent <IWeaponSpawn>() != null) { Destroy(other); } // If this is a destructible, attempt to inflict damage. IDestructable destructable = other.GetComponent <IDestructable>(); if (destructable != null) { destructable.ReceiveDamage(DamageCalculator.CalculateByDistance(collider.transform.position, other.transform.position, damageMultiplier)); ParticleController.GetInstance().InstantiateParticle(ParticleController.PlayerLaserCollision, other.transform.position, transform.position); return; } // Finally, jam the laser if applicable. if (charge != null) { charge.Jam(); Debug.Log("LASER JAMMED"); } }
/// <summary> /// On advantage, the other Gameobject gets destroyed. /// </summary> /// <param name="collider"></param> /// <param name="other"></param> public void OnAdvantage(GameObject collider, GameObject other) { Debug.Log("OBSTACLE ADVANTAGE:" + name + " destroyed (" + other + ")"); if (other != this.gameObject) { other.GetComponent <IPooledObject>().Despawn(); } ParticleController.GetInstance().InstantiateParticle(ParticleController.ObstacleNegate, transform.position); }
public void ReceiveDamage(float damageReceived) { healthPoints -= damageReceived; //Debug.Log(damageReceived + "," + healthPoints); ParticleController.GetInstance().InstantiateParticle(ParticleController.ObstacleDamage, transform.position); if (!HasHealth()) { OnZeroHealth(); } }
/// <summary> /// Decrease the number of lives this player has. /// </summary> private void LoseLife() { lives -= 1; ParticleController.GetInstance().InstantiateParticle(ParticleController.PlayerDeath, transform.position); TimeController.GetInstance().SlowTimeForDuration(0.005f, 1.7f, 0); // Give the player Iframes. if (HasHealth()) { lifeCollider.enabled = false; iframeTimer.StartTimer(); } }
public void OnZeroHealth() { ParticleController.GetInstance().InstantiateParticle(ParticleController.ObstacleDestroy, transform.position); Destroy(this.gameObject); }