public void placeShip(ref combatMap cMap) { if (this.player == 1) { while (true) { Random rand = new Random(); int randomBox = rand.Next(0, cMap.height * 2); if (cMap.boxes[randomBox].spaceObject == null) { cMap.boxes[randomBox].spaceObject = this; boxId = randomBox; break; } } } else if (this.player != 1) { while (true) { Random rand = new Random(); int randomBox = rand.Next(cMap.boxes.Count - cMap.height * 2, cMap.boxes.Count); if (cMap.boxes[randomBox].spaceObject == null) { cMap.boxes[randomBox].spaceObject = this; boxId = randomBox; break; } } } x = cMap.boxes[boxId].xcenter; y = cMap.boxes[boxId].ycenter; }
public int attack(combatMap cMap, int pointB, ref System.Drawing.Bitmap bmap, System.Media.SoundPlayer player, ref PictureBox pictureMap, ref Bitmap bmBackground, ref Bitmap bmFull) { double dmg; int flag = 0; if (actionsLeft >= equippedWeapon.energyСonsumption && equippedWeapon.shotsleft > 0) { equippedWeapon.drawAttack(cMap.boxes[boxId].xcenter + weaponPointX, cMap.boxes[boxId].ycenter + weaponPointY, cMap.boxes[pointB].xcenter, cMap.boxes[pointB].ycenter, ref bmap, player, ref pictureMap, ref bmBackground, ref bmFull ); Random rand = new Random(); dmg = (sumWeapon * rand.Next(equippedWeapon.minAttackPower * 10, equippedWeapon.maxAttackPower * 10)) / 10.0; cMap.boxes[pointB].spaceObject.currentHealth -= dmg; actionsLeft -= equippedWeapon.energyСonsumption; equippedWeapon.shotsleft -= 1; if (cMap.boxes[pointB].spaceObject.currentHealth <= 0) { cMap.clearBox(pointB, ref bmBackground, ref bmFull); flag = 1; } pictureMap.Image = bmFull; pictureMap.Refresh(); } return(flag); }
public override void drawSpaceShit(ref combatMap cMap, ref System.Drawing.Bitmap bmap) { Graphics g = Graphics.FromImage(bmap); SolidBrush generalBrush; if (player == 1) { generalBrush = new SolidBrush(Color.Blue); } else if (player == 2) { generalBrush = new SolidBrush(Color.Red); } else { generalBrush = new SolidBrush(Color.Gray); } Point[] myPointArray = { new Point(cMap.boxes[boxId].xcenter + xpoints[0], cMap.boxes[boxId].ycenter + ypoints[0]), new Point(cMap.boxes[boxId].xcenter + xpoints[1], cMap.boxes[boxId].ycenter + ypoints[1]), new Point(cMap.boxes[boxId].xcenter + xpoints[2], cMap.boxes[boxId].ycenter + ypoints[2]), }; g.FillPolygon(generalBrush, myPointArray); g.DrawString(actionsLeft.ToString(), new Font("Arial", 8.0F), Brushes.Blue, new PointF(cMap.boxes[boxId].xpoint1 + 25, cMap.boxes[boxId].ypoint1 + 15)); g.DrawString(currentHealth.ToString(), new Font("Arial", 8.0F), Brushes.Red, new PointF(cMap.boxes[boxId].xpoint1 + 20, cMap.boxes[boxId].ypoint1 - 25)); }
public override void drawSpaceShit(ref combatMap cMap, ref System.Drawing.Bitmap bmap) { Graphics g = Graphics.FromImage(bmap); SolidBrush grayBrush = new SolidBrush(Color.Gray); g.FillEllipse(grayBrush, cMap.boxes[boxId].xcenter - 14, cMap.boxes[boxId].ycenter - 14, 28, 28); g.DrawString(currentHealth.ToString(), new Font("Arial", 8.0F), Brushes.Red, new PointF(cMap.boxes[boxId].xpoint1 + 20, cMap.boxes[boxId].ypoint1 - 25)); }
public void moveMeteors(combatMap cMap, Bitmap bmBackground, Bitmap bmFull) { for (int i = 0; i < meteors.Count; i++) { if (meteors[i].boxId >= 0) { meteors[i].move(cMap, bmBackground, bmFull); } } }
public void moveShip(combatMap cMap, int pointAId, int pointBId, int range) { if (actionsLeft >= range) { boxId = pointBId; x = cMap.boxes[boxId].xcenter; y = cMap.boxes[boxId].ycenter; cMap.boxes[pointAId].spaceObject = null; cMap.boxes[pointBId].spaceObject = this; actionsLeft -= range; } }
public Meteor(combatMap cMap, int box, int health, int dmg, int xdirect, int ydirect) { boxId = box; objectType = Constants.METEOR; player = 0; maxHealth = health; currentHealth = maxHealth; explodeDmg = dmg; xdirection = xdirect; ydirection = ydirect; x = cMap.boxes[boxId].xcenter; y = cMap.boxes[boxId].ycenter; objectImg = Image.FromFile(@"Sprites/objects/meteor.png"); }
public void move(combatMap cMap, Bitmap bmBackground, Bitmap bmFull) { int newx; int newy; int pointB; Rectangle rect; Image bg; Graphics g = Graphics.FromImage(bmFull); int boxWidth = (cMap.boxes[0].xpoint3 - cMap.boxes[0].xpoint2); int boxHeight = (cMap.boxes[0].xpoint5 - cMap.boxes[0].ypoint3); newx = cMap.boxes[boxId].x + xdirection; newy = cMap.boxes[boxId].y + ydirection; rect = new Rectangle( x - boxWidth / 2, y - boxHeight / 2, boxWidth, boxHeight); bg = bmBackground.Clone(rect, bmBackground.PixelFormat); g.DrawImage(bg, x - boxWidth / 2, y - boxHeight / 2); if (newx < 0 || newx > cMap.width - 1 || newy < 0 || newy > cMap.height * 2 - 1) { cMap.boxes[boxId].spaceObject.player = -1; cMap.boxes[boxId].spaceObject = null; boxId = -1; } else { pointB = cMap.getBoxByCoords(newx, newy).id; if (cMap.boxes[pointB].spaceObject == null) { cMap.boxes[boxId].spaceObject = null; cMap.boxes[pointB].spaceObject = this; boxId = cMap.boxes[pointB].id; x = cMap.boxes[boxId].xcenter; y = cMap.boxes[boxId].ycenter; g.DrawImage(objectImg, new Rectangle(x - boxWidth / 6, y - boxHeight / 6, boxWidth / 3, boxHeight / 3)); g.DrawString(currentHealth.ToString(), new Font("Arial", 8.0F), Brushes.Red, new PointF(cMap.boxes[boxId].xpoint1 + 20, cMap.boxes[boxId].ypoint1 - 25)); } else { rect = new Rectangle( cMap.boxes[pointB].xpoint2, cMap.boxes[pointB].ypoint2, boxWidth, boxHeight + 5); bg = bmBackground.Clone(rect, bmBackground.PixelFormat); g.DrawImage(bg, cMap.boxes[pointB].xpoint2, cMap.boxes[pointB].ypoint2); cMap.boxes[pointB].spaceObject.currentHealth -= explodeDmg; if (cMap.boxes[pointB].spaceObject.currentHealth <= 0) { cMap.clearBox(pointB, ref bmBackground, ref bmFull); } else { if (cMap.boxes[pointB].spaceObject.objectType != Constants.METEOR) { g.DrawImage(cMap.boxes[pointB].spaceObject.objectImg, new Rectangle(cMap.boxes[pointB].xcenter - cMap.boxes[pointB].spaceObject.objectImg.Width / 2, cMap.boxes[pointB].ycenter - cMap.boxes[pointB].spaceObject.objectImg.Height / 2, cMap.boxes[pointB].spaceObject.objectImg.Width, cMap.boxes[pointB].spaceObject.objectImg.Height)); cMap.boxes[pointB].spaceObject.statusRefresh(ref bmBackground, ref bmFull); } } cMap.boxes[boxId].spaceObject.player = -1; cMap.boxes[boxId].spaceObject = null; boxId = -1; } } }
public Meteor meteorCreate(combatMap cMap) { int flag = 1; int box4meteor = 0; int meteorHealth; int meteorDmg; int xWay = Constants.RIGHT; int yWay = Constants.MEDIUM_TOP; Meteor newMeteor = null; int i; Random rand = new Random(); int randomNum = rand.Next(1, 100) % 4; // место появления и направление полёта switch (randomNum) { case 1: // left box4meteor = rand.Next(0, cMap.height); for (i = 0; i < 10; i++) { if (cMap.boxes[box4meteor].spaceObject != null) { box4meteor += 1; if (box4meteor >= cMap.height - 1) { box4meteor = 0; } } else { break; } } if (i == 10) { flag = 0; } xWay = Constants.RIGHT; if (rand.Next(1, 100) > 50) { yWay = Constants.MEDIUM_TOP; } else { yWay = Constants.MEDIUM_BOTTOM; } break; case 2: // top box4meteor = cMap.getBoxByCoords(rand.Next(0, cMap.width / 2 - 1) * 2, 0).id; for (i = 0; i < 10; i++) { if (cMap.boxes[box4meteor].spaceObject != null) { box4meteor += cMap.height * 2; if (box4meteor > cMap.width + 1) { box4meteor = 0; } } else { break; } } if (i == 10) { flag = 0; } if (rand.Next(1, 100) > 50) { xWay = Constants.RIGHT; } else { xWay = Constants.LEFT; } yWay = Constants.MEDIUM_BOTTOM; break; case 3: // right box4meteor = rand.Next(cMap.boxes.Count - 1 - cMap.height, cMap.boxes.Count - 1); for (i = 0; i < 10; i++) { if (cMap.boxes[box4meteor].spaceObject != null) { box4meteor += 1; if (box4meteor > cMap.boxes.Count - 1) { box4meteor = cMap.boxes.Count - cMap.height; } } else { break; } } if (i == 10) { flag = 0; } xWay = Constants.LEFT; if (rand.Next(1, 100) > 50) { yWay = Constants.MEDIUM_TOP; } else { yWay = Constants.MEDIUM_BOTTOM; } break; case 0: // bottom box4meteor = cMap.getBoxByCoords(rand.Next(0, cMap.width / 2 - 1) * 2 + 1, cMap.height * 2 - 1).id; for (i = 0; i < 10; i++) { if (cMap.boxes[box4meteor].spaceObject != null) { box4meteor += cMap.height * 2; if (box4meteor > cMap.boxes.Count - 1) { box4meteor = cMap.height - 1; } } else { break; } } if (i == 10) { flag = 0; } if (rand.Next(1, 100) > 50) { xWay = Constants.RIGHT; } else { xWay = Constants.LEFT; } yWay = Constants.MEDIUM_TOP; break; } if (flag == 1) { meteorHealth = rand.Next(1, 150); meteorDmg = meteorHealth / 4; newMeteor = new Meteor(cMap, box4meteor, meteorHealth, meteorDmg, xWay, yWay); meteors.Add(newMeteor); cMap.boxes[box4meteor].spaceObject = newMeteor; } return(newMeteor); }
public override void drawSpaceShit(ref combatMap cMap, ref System.Drawing.Bitmap bmap) { }
public abstract void drawSpaceShit(ref combatMap cMap, ref System.Drawing.Bitmap bmap);