public override void Collision(GameObject o) { if (!stopwatch.IsRunning) if (o is Enemy) { o.Collision(this); stopwatch.Start(); if (o is FireEnemy) { EnemyCollision(o.Direction); Health -= 5; } else if (o is WindEnemy) { EnemyCollision(o.Direction); Health -= 5; } else if (o is FireBoss) { EnemyCollision(o.Direction); Health -= 10; } Globals.PhitFX.Play(Globals.FXVolume(), 0, 0); } }
public override void Collision(GameObject o) { if (o is Enemy && originatingType == OriginatingType.Player) { o.Health -= 20; //switch (Direction) // stuns the enemy backwards for 20 units //{ // case FacingDirection.Left: // o.SpriteAnimation.Position.X -= 20; // o.WorldCollision(); // break; // case FacingDirection.Right: // o.SpriteAnimation.Position.X += 20; // o.WorldCollision(); // break; // case FacingDirection.Up: // o.SpriteAnimation.Position.Y -= 20; // o.WorldCollision(); // break; // case FacingDirection.Down: // o.SpriteAnimation.Position.Y += 20; // o.WorldCollision(); // break; //} Dead = true; } else if (o is Player && originatingType == OriginatingType.Enemy) { o.Health -= 5; //switch (Direction) // stuns the player backwards for 20 units //{ // case FacingDirection.Left: // o.SpriteAnimation.Position.X -= 20; // break; // case FacingDirection.Right: // o.SpriteAnimation.Position.X += 20; // break; // case FacingDirection.Up: // o.SpriteAnimation.Position.Y -= 20; // break; // case FacingDirection.Down: // o.SpriteAnimation.Position.Y += 20; // break; //} Dead = true; } checkClipCollision(this, o); }
public override void Collision(GameObject o) { if (o is Enemy) //if collision is with an enemy { if (originatingType == OriginatingType.Player) //and if the Player threw the spell if (o is FireEnemy || o is FireBoss) o.Health -= 35; //the enemy's health is decreased else if (o is WindEnemy) o.Health -= 20; Globals.EhitFX.Play(Globals.FXVolume(), 0, 0); } else if (o is Player && originatingType == OriginatingType.Enemy) //if collision is with player and Enemy threw spell { o.Health -= 10; //player takes 10 damage Globals.PhitFX.Play(Globals.FXVolume(), 0, 0); } Dead = true; //spell is dead }
/// <summary> /// Logic for Collision between enemy and other GameObject /// </summary> /// <param name="obj">GameObject being collided with</param> public override void Collision(GameObject obj) { if (obj is Player) { //if GameObject is the player, if (!GameWorld.Player.HasBeenHit) if (!stopwatch.IsRunning) //and stopwatch isn't running stopwatch.Start(); //start the stopwatch (so enemy doesn't move) } else WorldCollision(); //else, use worldcollision logic }
public virtual void Collision(GameObject o) { }
// wind spell throws off the player / enemy upon collision // this method checks whether the new position after collision is inside a Clip map tile // if it is, set the new position to outside the tile private void checkClipCollision(GameObject oHits, GameObject oGotHit) { Rectangle futureRectangle = oGotHit.SpriteAnimation.Bounds; switch (oHits.Direction) { case FacingDirection.Left: futureRectangle.X -= 20; foreach (Rectangle clip in GameWorld.ClipMap.Values) if (clip.Intersects(futureRectangle)) { oGotHit.SpriteAnimation.Position.X = clip.Right + 5; return; } oGotHit.SpriteAnimation.Position.X -= 20; break; case FacingDirection.Right: futureRectangle.X += 20; foreach (Rectangle clip in GameWorld.ClipMap.Values) if (clip.Intersects(futureRectangle)) { oGotHit.SpriteAnimation.Position.X = clip.Left - 5 - oGotHit.SpriteAnimation.Bounds.Width; return; } oGotHit.SpriteAnimation.Position.X += 20; break; case FacingDirection.Up: futureRectangle.Y -= 20; foreach (Rectangle clip in GameWorld.ClipMap.Values) if (clip.Intersects(futureRectangle)) { oGotHit.SpriteAnimation.Position.Y = clip.Bottom + 5; return; } oGotHit.SpriteAnimation.Position.Y -= 20; break; case FacingDirection.Down: futureRectangle.Y += 20; foreach (Rectangle clip in GameWorld.ClipMap.Values) if (clip.Intersects(futureRectangle)) { oGotHit.SpriteAnimation.Position.Y = clip.Top - 5 - oGotHit.SpriteAnimation.Bounds.Height; return; } oGotHit.SpriteAnimation.Position.Y += 20; break; } }