void OnDeath() { explosionState = ExplosionStates.explosionInitiated; }
void OnHitByBomb() { explosionState = ExplosionStates.explosionInitiated; }
//step1: Destoy or deactivate bomb renderer and collider //step2: Activate an ellipsoid the explosion //step3: Cause the explosion to expand //step4: Have the explosion hover at max //step5: fade away //step6: destroy the cube game object! void ExplosionSwitchStatement() { switch (explosionState) { case (ExplosionStates.noDetonation): break; case (ExplosionStates.explosionInitiated): if (timer != null) { //this destroys the timer if the bomb is triggered prematurely timer.gameObject.SetActive(false); } //Disable the bomb rendering gameObject.GetComponent <Renderer>().enabled = false; gameObject.GetComponent <Collider2D>().enabled = false; transform.GetComponent <Rigidbody2D>().gravityScale = 0.0f; foreach (Transform r in transform) { if (r.name != "Explosion") { r.GetComponent <Renderer>().enabled = false; } } //Activate the explosion //transform.FindChild("Explosion").gameObject.SetActive(true); //transform.FindChild("ExplosionMessage").gameObject.SetActive(true); bombExplosionSpawner.bombPosition = transform.position; if (!lorentzContraction.IsBeingHeld) { //Debug.Log ("The x velocity goal is ="+lorentzContraction.XVelocityGoal); bombExplosionSpawner.velOfBomb = new Vector2(lorentzContraction.XVelocityGoal , transform.GetComponent <Rigidbody2D>().velocity.y); } else { bombExplosionSpawner.velOfBomb = new Vector2(platformerController.movement.speed * Mathf.Sign(platformerController.movement.direction.x) , transform.GetComponent <Rigidbody2D>().velocity.y); //Debug.Log ("The x velocity goal is ="+platformerController.movement.speed); } //Let go of the bomb if (lorentzContraction.IsBeingHeld) { //the object is no longer being held platformerController.holdingSomething = false; lorentzContraction.IsBeingHeld = false; } bombExplosionSpawner.goBoom = true; explosionState = ExplosionStates.explosionEnding; goto case ExplosionStates.explosionEnding; case (ExplosionStates.explosionEnding): //Send a message to potential parent that the bomb has been destroyed and we //may need a new one spawned if (transform.parent.transform.parent != null) { transform.parent.transform.parent. SendMessage("BombGoBoom", SendMessageOptions.DontRequireReceiver); } //Destroy the bomb Destroy(gameObject); //Destroy the bomb parent //Destroy(transform.parent.gameObject); break; } }