/// <summary> /// Draw the pattern of the specified enemy /// </summary> /// <param name="spriteBatch"></param> /// <param name="badguy"></param> public static void DrawMovePattern(TGPASpriteBatch spriteBatch, BadGuy badguy, List <Node> nodes) { if (badguy.Pattern == null) { return; } for (int i = 0; i < badguy.Pattern.Points.Count; i++) { bool first = true; Point lastPoint = Point.Zero; foreach (Node n in nodes) { //Draw line between node and player if (first) { first = false; Node.DrawLine(spriteBatch, new Point((int)badguy.Location.X, (int)badguy.Location.Y), n.Point); } else { //Draw lines between 2 points Node.DrawLine(spriteBatch, lastPoint, n.Point); } n.Draw(spriteBatch); lastPoint = n.Point; } } }
public void Initialize(BadGuy badguy) { switch (identifer) { case DefinedMovePattern.Up: AddPoint(new Point((int)badguy.Location.X, -badguy.DstRect.Height)); break; case DefinedMovePattern.Down: AddPoint(new Point((int)badguy.Location.X, TGPAContext.Instance.ScreenHeight + badguy.DstRect.Height)); break; case DefinedMovePattern.Right: AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, (int)badguy.Location.Y)); break; case DefinedMovePattern.Left: AddPoint(new Point(-badguy.DstRect.Width, (int)badguy.Location.Y)); break; case DefinedMovePattern.LeftDownCorner: AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight + badguy.DstRect.Height)); break; case DefinedMovePattern.LeftUpCorner: AddPoint(new Point(-badguy.DstRect.Width, -badguy.DstRect.Height)); break; case DefinedMovePattern.RightUpCorner: AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, -badguy.DstRect.Height)); break; case DefinedMovePattern.RightDownCorner: AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight + badguy.DstRect.Height)); break; case DefinedMovePattern.SmallUpAndDown: int upOrDown = (badguy.Location.Y > (TGPAContext.Instance.ScreenHeight / 2)) ? 3 : 1; if (badguy.Flip == SpriteEffects.FlipHorizontally) { for (int i = 1; i < 9; i++) { AddPoint(new Point(2 * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 4)); upOrDown = upOrDown == 3 ? 1 : 3; } AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } else { for (int i = 8; i > 0; i--) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 4)); upOrDown = upOrDown == 3 ? 1 : 3; } AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } break; case DefinedMovePattern.BigUpAndDown: upOrDown = (badguy.Location.Y > (TGPAContext.Instance.ScreenHeight / 2)) ? 7 : 1; if (badguy.Flip == SpriteEffects.FlipHorizontally) { for (int i = 2; i < 9; i++) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 8)); upOrDown = upOrDown == 7 ? 1 : 7; } AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } else if (badguy.Flip == SpriteEffects.None) { for (int i = 8; i > 0; i--) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 8)); upOrDown = upOrDown == 7 ? 1 : 7; } AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } break; case DefinedMovePattern.BigAndFastUpAndDown: upOrDown = (badguy.Location.Y > (TGPAContext.Instance.ScreenHeight / 2)) ? 7 : 1; if (badguy.Flip == SpriteEffects.FlipHorizontally) { for (int i = 2; i < 9; i++) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 8)); upOrDown = upOrDown == 7 ? 1 : 7; } AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } else if (badguy.Flip == SpriteEffects.None) { for (int i = 4; i > 0; i--) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 4, upOrDown * TGPAContext.Instance.ScreenHeight / 6)); upOrDown = upOrDown == 6 ? 2 : 6; } AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } break; case DefinedMovePattern.LeftAndRight: int leftOrRight = (badguy.Location.X > (TGPAContext.Instance.ScreenWidth / 2)) ? 3 : 1; for (int i = 1; i < 9; i++) { AddPoint(new Point(leftOrRight * TGPAContext.Instance.ScreenWidth / 4, i * TGPAContext.Instance.ScreenHeight / 8)); leftOrRight = leftOrRight == 3 ? 1 : 3; } AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, TGPAContext.Instance.ScreenHeight + badguy.DstRect.Height)); break; case DefinedMovePattern.SmallLace: if (badguy.Flip == SpriteEffects.FlipHorizontally) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); AddPoint(new Point(2 * TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); //Small looping AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 150)); AddPoint(new Point(5 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 250)); AddPoint(new Point(4 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 250)); AddPoint(new Point(6 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 150)); AddPoint(new Point(7 * TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } else { AddPoint(new Point(7 * TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); AddPoint(new Point(6 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 150)); AddPoint(new Point(4 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 250)); AddPoint(new Point(5 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 250)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 150)); AddPoint(new Point(2 * TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } break; case DefinedMovePattern.SmallV: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.SmallInverseV: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, badguy.DstRect.Y - TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, badguy.DstRect.Y - TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.V: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.InverseV: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.SmallU: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.U: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.Z: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(0, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(-badguy.DstRect.Width, 3 * TGPAContext.Instance.ScreenHeight / 4)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, 3 * TGPAContext.Instance.ScreenHeight / 4)); } break; default: throw new Exception("Unimplemented MovePattern : " + identifer.ToString()); } this.initialized = true; }
/// <summary> /// Add an enemy to the list /// </summary> /// <param name="e"></param> public void AddEnemy(BadGuy e) { Enemies.Add(e); }
public void Initialize(BadGuy badguy) { switch (identifer) { case DefinedMovePattern.Up: AddPoint(new Point((int)badguy.Location.X, -badguy.DstRect.Height)); break; case DefinedMovePattern.Down: AddPoint(new Point((int)badguy.Location.X, TGPAContext.Instance.ScreenHeight + badguy.DstRect.Height)); break; case DefinedMovePattern.Right: AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, (int)badguy.Location.Y)); break; case DefinedMovePattern.Left: AddPoint(new Point(-badguy.DstRect.Width, (int)badguy.Location.Y)); break; case DefinedMovePattern.LeftDownCorner: AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight + badguy.DstRect.Height)); break; case DefinedMovePattern.LeftUpCorner: AddPoint(new Point(-badguy.DstRect.Width, -badguy.DstRect.Height)); break; case DefinedMovePattern.RightUpCorner: AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, -badguy.DstRect.Height)); break; case DefinedMovePattern.RightDownCorner: AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight + badguy.DstRect.Height)); break; case DefinedMovePattern.SmallUpAndDown: int upOrDown = (badguy.Location.Y > (TGPAContext.Instance.ScreenHeight / 2)) ? 3 : 1; if (badguy.Flip == SpriteEffects.FlipHorizontally) { for (int i = 1; i < 9; i++) { AddPoint(new Point(2 * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 4)); upOrDown = upOrDown == 3 ? 1 : 3; } AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } else { for (int i = 8; i > 0; i--) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 4)); upOrDown = upOrDown == 3 ? 1 : 3; } AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } break; case DefinedMovePattern.BigUpAndDown: upOrDown = (badguy.Location.Y > (TGPAContext.Instance.ScreenHeight / 2)) ? 7 : 1; if (badguy.Flip == SpriteEffects.FlipHorizontally) { for (int i = 2; i < 9; i++) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 8)); upOrDown = upOrDown == 7 ? 1 : 7; } AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } else if (badguy.Flip == SpriteEffects.None) { for (int i = 8; i > 0; i--) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 8)); upOrDown = upOrDown == 7 ? 1 : 7; } AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } break; case DefinedMovePattern.BigAndFastUpAndDown: upOrDown = (badguy.Location.Y > (TGPAContext.Instance.ScreenHeight / 2)) ? 7 : 1; if (badguy.Flip == SpriteEffects.FlipHorizontally) { for (int i = 2; i < 9; i++) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 8, upOrDown * TGPAContext.Instance.ScreenHeight / 8)); upOrDown = upOrDown == 7 ? 1 : 7; } AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } else if (badguy.Flip == SpriteEffects.None) { for (int i = 4; i > 0; i--) { AddPoint(new Point(i * TGPAContext.Instance.ScreenWidth / 4, upOrDown * TGPAContext.Instance.ScreenHeight / 6)); upOrDown = upOrDown == 6 ? 2 : 6; } AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } break; case DefinedMovePattern.LeftAndRight: int leftOrRight = (badguy.Location.X > (TGPAContext.Instance.ScreenWidth / 2)) ? 3 : 1; for (int i = 1; i < 9; i++) { AddPoint(new Point(leftOrRight * TGPAContext.Instance.ScreenWidth / 4, i * TGPAContext.Instance.ScreenHeight / 8)); leftOrRight = leftOrRight == 3 ? 1 : 3; } AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, TGPAContext.Instance.ScreenHeight + badguy.DstRect.Height)); break; case DefinedMovePattern.SmallLace: if (badguy.Flip == SpriteEffects.FlipHorizontally) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); AddPoint(new Point(2 * TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); //Small looping AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 150)); AddPoint(new Point(5 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 250)); AddPoint(new Point(4 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 250)); AddPoint(new Point(6 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 150)); AddPoint(new Point(7 * TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } else { AddPoint(new Point(7 * TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); AddPoint(new Point(6 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 150)); AddPoint(new Point(4 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 250)); AddPoint(new Point(5 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 250)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 8, (TGPAContext.Instance.ScreenHeight / 2) - 150)); AddPoint(new Point(2 * TGPAContext.Instance.ScreenWidth / 8, TGPAContext.Instance.ScreenHeight / 2)); AddPoint(new Point(-badguy.DstRect.Width, TGPAContext.Instance.ScreenHeight / 2)); } break; case DefinedMovePattern.SmallV: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.SmallInverseV: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, badguy.DstRect.Y - TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, badguy.DstRect.Y - TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.V: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, 7* TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.InverseV: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 2, TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.SmallU: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(3*TGPAContext.Instance.ScreenWidth / 4, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, badguy.DstRect.Y + TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.U: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(-badguy.DstRect.Width, badguy.DstRect.Y)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, 7 * TGPAContext.Instance.ScreenHeight / 8)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, badguy.DstRect.Y)); } break; case DefinedMovePattern.Z: if (badguy.Flip == SpriteEffects.None) { AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(0, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(-badguy.DstRect.Width, 3 * TGPAContext.Instance.ScreenHeight / 4)); } else { AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth / 4, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(3 * TGPAContext.Instance.ScreenWidth / 4, 3 * TGPAContext.Instance.ScreenHeight / 4)); AddPoint(new Point(TGPAContext.Instance.ScreenWidth + badguy.DstRect.Width, 3 * TGPAContext.Instance.ScreenHeight / 4)); } break; default: throw new Exception("Unimplemented MovePattern : " + identifer.ToString()); } this.initialized = true; }
/// <summary> /// Draw the pattern of the specified enemy /// </summary> /// <param name="spriteBatch"></param> /// <param name="badguy"></param> public static void DrawMovePattern(TGPASpriteBatch spriteBatch, BadGuy badguy, List<Node> nodes) { if (badguy.Pattern == null) return; for (int i = 0; i < badguy.Pattern.Points.Count; i++) { bool first = true; Point lastPoint = Point.Zero; foreach (Node n in nodes) { //Draw line between node and player if (first) { first = false; Node.DrawLine(spriteBatch, new Point((int)badguy.Location.X, (int)badguy.Location.Y), n.Point); } else { //Draw lines between 2 points Node.DrawLine(spriteBatch, lastPoint, n.Point); } n.Draw(spriteBatch); lastPoint = n.Point; } } }
/// <summary> /// Collision between context.Enemies and context.Shots /// </summary> /// <param name="gameTime"></param> /// <param name="x"></param> protected bool CollisionEnemy(GameTime gameTime, BadGuy enemy) { //Enemy hurt a shot for (int i = 0; i < context.Shots.Count; i++) { if (enemy.Hitbox.Collide(context.Shots[i].Hitbox) && !context.Shots[i].EnemyFire) { //Destroy enemy enemy.IsHit = true; int dmg = (int)((float)context.Shots[i].Weapon.Damage * context.DamageMulti); if (dmg == 0) dmg = 1; //Flamethrower enemy.HP -= dmg; KillShot(context.Player1.Index, context.Shots[i], true, gameTime); Player player = (Player)context.Shots[i].Weapon.Owner; if (KillEnemy(player.Index, enemy, false, gameTime)) { return true; } } } return false; }
/// <summary> /// Destroy enemy /// </summary> public bool KillEnemy(PlayerIndex playerIndex, BadGuy e, bool force, bool explosion, GameTime gameTime) { Player player = context.GetPlayer(playerIndex); if ((e.HP <= 0) || force) { //Score if (!force) { e.TodoOnDeath(); int score = (int)((float)e.Points * context.ScoreMulti); if (!( (context.Cheatcodes.IsInvincible) || (context.Cheatcodes.HasMaxPower) || (context.Cheatcodes.IsGiantMode))) { player.Score += score; } //Draw score if (context.Saver.OptionsData.ShowScore) { FlyingScores fs = new FlyingScores(e.Location, "+" + score); flyScores.Add(fs); } //Drop bonus if (e.BonusToDrop != null) { e.BonusToDrop.Location = Vectors.ConvertPointToVector2(e.DstRect.Center); context.Bonuses.Add(e.BonusToDrop); } enemieskilled++; } //Explosion if (explosion) { //context.ParticleManager.MakeExplosionWithoutQuake(Vectors.ConvertPointToVector2(e.DstRect.Center)); } if (e.Removable) { if (!enemiesToDelete.Contains(e)) { enemiesToDelete.Add(e); } } return true; } return false; }
protected bool KillEnemy(PlayerIndex playerIndex, BadGuy e, bool force, GameTime gameTime) { return KillEnemy(playerIndex, e, force, true, gameTime); }