void spawnBadGuys(Difficulty dif) { for (int i = 0; i < 4; i++) { badGuys.Add(new BadGuy()); } badGuys[0] = new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, dif, blocks, 2); badGuys[1] = new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, dif, blocks, 2); badGuys[2] = new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, dif, blocks, 2); badGuys[3] = new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, dif, blocks, 2); }
void moveRandomly(BadGuy b) { Direction randomDir = b.direction; if (difficulty == Difficulty.EASY) { if (TIMER3_ELAPSED % 550 == 0 || TIMER3_ELAPSED % 2990 == 0) { int whereTo = random.Next(101); if (whereTo <= 25) { randomDir = Direction.BOTTOM; } else if (whereTo > 25 && whereTo <= 50) { randomDir = Direction.LEFT; } else if (whereTo > 50 && whereTo <= 75) { randomDir = Direction.TOP; } else { randomDir = Direction.RIGHT; } } } else if (difficulty == Difficulty.NORMAL) { if (TIMER3_ELAPSED % 1000 == 0 || TIMER3_ELAPSED % 2990 == 0) { int whereTo = random.Next(101); if (whereTo <= 25) { randomDir = Direction.BOTTOM; } else if (whereTo > 25 && whereTo <= 50) { randomDir = Direction.LEFT; } else if (whereTo > 50 && whereTo <= 75) { randomDir = Direction.TOP; } else { randomDir = Direction.RIGHT; } } } else if (difficulty == Difficulty.HARD) { if (TIMER3_ELAPSED % 800 == 0 || TIMER3_ELAPSED % 2990 == 0) { int whereTo = random.Next(101); if (whereTo <= 25) { randomDir = Direction.BOTTOM; } else if (whereTo > 25 && whereTo <= 50) { randomDir = Direction.LEFT; } else if (whereTo > 50 && whereTo <= 75) { randomDir = Direction.TOP; } else { randomDir = Direction.RIGHT; } } } else { if (TIMER3_ELAPSED % 800 == 0 || TIMER3_ELAPSED % 2990 == 0) { int whereTo = random.Next(101); if (whereTo <= 25) { randomDir = Direction.BOTTOM; } else if (whereTo > 25 && whereTo <= 50) { randomDir = Direction.LEFT; } else if (whereTo > 50 && whereTo <= 75) { randomDir = Direction.TOP; } else { randomDir = Direction.RIGHT; } } } if (b.checkBounds(randomDir)) { b.Move(randomDir); } else { b.Move(Opposite(randomDir)); } }
void timer2_Tick(object sender, EventArgs e) // DVIZENJE NA DOBRITE PROEKTILI { DoubleBuffered = true; List <Projectile> toBeRemoved = new List <Projectile>(); for (int i = 0; i < goodProjectiles.Count; i++) { for (int j = 0; j < badGuys.Count; j++) { if (badGuys[j].isWithinArea(goodProjectiles[i].X, goodProjectiles[i].Y)) { BadGuy b = badGuys[j]; badGuys.Remove(b); tanksDestroyed++; } } for (int k = 0; k < blocks.Count; k++) { if (blocks[k].Type() != BlockType.ICE) { if (blocks[k].isWithinArea(goodProjectiles[i].X, goodProjectiles[i].Y)) { Projectile p = goodProjectiles[i]; toBeRemoved.Add(p); } } } } foreach (Projectile p in toBeRemoved) { goodProjectiles.Remove(p); } moveGoodProjectiles(); if (arcade) { if (!ended) { if (badGuys.Count < 4) { int a = random.Next(4); if (tanksDestroyed >= 1 && tanksDestroyed < 10) { if (a == 0) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 2)); } else if (a == 1) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 2)); } else if (a == 2) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 2)); } else { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 2)); } } else if (tanksDestroyed >= 10 && tanksDestroyed < 20) { if (a == 0) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 3)); } else if (a == 1) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 3)); } else if (a == 2) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 3)); } else { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 3)); } } else if (tanksDestroyed >= 20 && tanksDestroyed < 30) { if (a == 0) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 4)); } else if (a == 1) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 4)); } else if (a == 2) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 4)); } else { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 4)); } } else if (tanksDestroyed >= 30 && tanksDestroyed < 40) { if (a == 0) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 5)); } else if (a == 1) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 5)); } else if (a == 2) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 5)); } else { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 5)); } } else if (tanksDestroyed >= 40 && tanksDestroyed < 50) { if (a == 0) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 6)); } else if (a == 1) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 6)); } else if (a == 2) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 6)); } else { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 6)); } } else { if (a == 0) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 7)); } else if (a == 1) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 - 380, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 7)); } else if (a == 2) { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 + 215, Direction.TOP, this.Width, this.Height, Difficulty.ARCADE, blocks, 7)); } else { badGuys.Add(new BadGuy(this.Bounds.Width / 2 + 320, this.Bounds.Height / 2 - 290, Direction.BOTTOM, this.Width, this.Height, Difficulty.ARCADE, blocks, 7)); } } } } } if (badGuys.Count == 0) { End(EndGame.WIN); } }