/// <summary> /// A constructor that sets the projectile ID, player ID and the color of the projectile /// </summary> public Projectile(int projID, int playerID) { ID = projID; died = false; owner = playerID; Tank t = new Tank(owner, location, orientation); color = t.GetColor(); }
/// <summary> /// A constructor that sets the projectile ID, player ID, location, orientation, and the color of the projectile /// </summary> public Projectile(int projID, int playerID, Vector2D loc, Vector2D orient) { ID = projID; location = new Vector2D(loc); orientation = new Vector2D(orient); died = false; owner = playerID; Tank t = new Tank(owner, location, orientation); color = t.GetColor(); }
/// <summary> /// Draws a turret /// </summary> private void TurretDrawer(object o, PaintEventArgs e) { //Converts the object to a tank Tank t = o as Tank; //Sets the turret width of a tank int turretWidth = 50; //Doesn not smoothen the drawing e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; //Centers the turret Rectangle r = new Rectangle(-(turretWidth / 2), -(turretWidth / 2), turretWidth, turretWidth); //Draws the turret based on the color of the tank if (t.GetColor() == Color.Red) { e.Graphics.DrawImage(redTurret, r); } else if (t.GetColor() == Color.Yellow) { e.Graphics.DrawImage(yellowTurret, r); } else if (t.GetColor() == Color.Blue) { e.Graphics.DrawImage(blueTurret, r); } else if (t.GetColor() == Color.DarkBlue) { e.Graphics.DrawImage(darkBlueTurret, r); } else if (t.GetColor() == Color.Purple) { e.Graphics.DrawImage(purpleTurret, r); } else if (t.GetColor() == Color.Orange) { e.Graphics.DrawImage(orangeTurret, r); } else if (t.GetColor() == Color.Green) { e.Graphics.DrawImage(greenTurret, r); } else if (t.GetColor() == Color.LightGreen) { e.Graphics.DrawImage(lightGreenTurret, r); } }
/// <summary> /// Draws a tank /// </summary> private void TankDrawer(object o, PaintEventArgs e) { //Converts the object as a Tank Tank t = o as Tank; //Creates a tank of size 60 int tankWidth = 60; //Doesn't attempt to smoothen the drawing e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; //Centers the tank Rectangle r = new Rectangle(-(tankWidth / 2), -(tankWidth / 2), tankWidth, tankWidth); //Draws the tank based on the tank's color if (t.GetColor() == Color.Red) { e.Graphics.DrawImage(redTank, r); } else if (t.GetColor() == Color.Yellow) { e.Graphics.DrawImage(yellowTank, r); } else if (t.GetColor() == Color.Blue) { e.Graphics.DrawImage(blueTank, r); } else if (t.GetColor() == Color.DarkBlue) { e.Graphics.DrawImage(darkBlueTank, r); } else if (t.GetColor() == Color.Purple) { e.Graphics.DrawImage(purpleTank, r); } else if (t.GetColor() == Color.Orange) { e.Graphics.DrawImage(orangeTank, r); } else if (t.GetColor() == Color.Green) { e.Graphics.DrawImage(greenTank, r); } else if (t.GetColor() == Color.LightGreen) { e.Graphics.DrawImage(lightGreenTank, r); } }
/// <summary> /// Draws a projectile /// </summary> private void ProjectileDrawer(object o, PaintEventArgs e) { //Converts the object to a projectile Projectile p = o as Projectile; //Sets the width to 30 int width = 30; //Doesn't smoothen the projectile drawing e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; using (System.Drawing.SolidBrush blueBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Blue)) using (System.Drawing.SolidBrush yellowBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow)) using (System.Drawing.SolidBrush darkBlueBrush = new System.Drawing.SolidBrush(System.Drawing.Color.DarkBlue)) using (System.Drawing.SolidBrush greenBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Green)) using (System.Drawing.SolidBrush lightGreenBrush = new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen)) using (System.Drawing.SolidBrush redBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red)) using (System.Drawing.SolidBrush orangeBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Orange)) using (System.Drawing.SolidBrush purpleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Purple)) { //Centers the projectile Rectangle r = new Rectangle(-(width / 2), -(width / 2), width, width); Color c = new Color(); foreach (int id in world.GetTanks().Keys) { //Sets the color based on the tank's color Tank t = world.GetTanks()[id]; if (t.GetID() == p.GetOwnerID()) { c = t.GetColor(); } } //Draws the projectile based on what the tank's color is if (c == Color.Red) { e.Graphics.DrawImage(redShot, r); } else if (c == Color.Yellow) { e.Graphics.DrawImage(yellowShot, r); } else if (c == Color.Blue) { e.Graphics.DrawImage(blueShot, r); } else if (c == Color.DarkBlue) { e.Graphics.DrawImage(whiteShot, r); } else if (c == Color.Purple) { e.Graphics.DrawImage(purpleShot, r); } else if (c == Color.Orange) { e.Graphics.DrawImage(brownShot, r); } else if (c == Color.Green) { e.Graphics.DrawImage(greenShot, r); } else if (c == Color.LightGreen) { e.Graphics.DrawImage(greyShot, r); } } }