public override void ReactToCollisionEntry(PhysicalObject other) { if (other is Missile) { GameWorld.Instance.AddObject(new Powerup(this.GetCentre())); AudioManager.Instance.PlayAudioClip(AudioManager.AUDIOCLIPS.BRILLIANT); } base.ReactToCollisionEntry(other); }
//Called every tick that a collision is detected public override void ReactToCollision(PhysicalObject other) { if (other is Cloud) { switch (playerState) { //Keep the dampness timer at max whilst inside a cloud case PLAYER_STATE.PCS_WET: if (dampnessTimer != null) { dampnessTimer.ResetTimer(); } break; case PLAYER_STATE.PCS_NORMAL: case PLAYER_STATE.PCS_POWEREDUP: break; } } }
public bool Collided(PhysicalObject other) { //Check the other object can collide with this one bool ignoreOther = true; for (int i = 0; i < collidableTypes.Count; ++i) { if (collidableTypes[i].IsInstanceOfType(other)) { ignoreOther = false; } } if (ignoreOther) { return(false); } return(Collided(other.position, other.dimensions)); }
//Called when a new collision occurs public override void ReactToCollisionEntry(PhysicalObject other) { //TODO: Look into IDictionary and the Visitor pattern as possible alternatives to these if/else statements if (other is Projectile) { switch (playerState) { case PLAYER_STATE.PCS_NORMAL: case PLAYER_STATE.PCS_WET: AudioManager.Instance.PlayAudioClip(AudioManager.AUDIOCLIPS.PATHETIC); Destroy(); break; case PLAYER_STATE.PCS_POWEREDUP: AudioManager.Instance.PlayRandomPain(); SetState(PLAYER_STATE.PCS_NORMAL); break; } } else if (other is Powerup) { SetState(PLAYER_STATE.PCS_POWEREDUP); } else if (other is Cloud) { switch (playerState) { case PLAYER_STATE.PCS_NORMAL: AudioManager.Instance.PlayRandomPain(); SetState(PLAYER_STATE.PCS_WET); break; case PLAYER_STATE.PCS_WET: AudioManager.Instance.PlayRandomPain(); break; case PLAYER_STATE.PCS_POWEREDUP: break; } } }
public CollisionDetection(PhysicalObject a, PhysicalObject b) { object1 = a; object2 = b; }
public override void ReactToCollision(PhysicalObject other) { Destroy(); }
public virtual void ReactToCollisionExit(PhysicalObject other) { }
public void RemoveObject(PhysicalObject objToRemove) { allObjects.Remove(objToRemove); }
public void AddObject(PhysicalObject objToAdd) { allObjects.Add(objToAdd); }
public override void ReactToCollisionEntry(PhysicalObject other) { AudioManager.Instance.PlayAudioClip(AudioManager.AUDIOCLIPS.EXPLOSION); GraphicsManager.Instance.AddAnimation(new ExplosionAnimation(this.GetCentre())); Destroy(); }