public void Clear() { _drawableObjs.Clear(); Apples.Clear(); }
public void Start(MainForm main_f) { UnSubscribe(); Apples.Clear(); Tanks.Clear(); Obstacles.Clear(); ShotsKolobok.Clear(); ShotsTanks.Clear(); kolobok = null; gameOver = false; Score = 0; Delta = 30; DeltaShots = 30; map = main_f.map; backgroundMap = new Bitmap(map.Width, map.Height); mapGraphics = Graphics.FromImage(backgroundMap); mapGraphics.FillRectangle(Brushes.Black, 0, 0, map.Width, map.Height); for (int i = 0; i < mapFix.Count(); i++) { for (int j = 0; j < mapFix[i].Length; j++) { if (mapFix[i][j] == 'X') { Obstacles.Add(new FixedObject(j, i, 0)); mapGraphics.DrawImage(Obstacles.Last().Img, Obstacles.Last().X *MainForm.sizeCell, Obstacles.Last().Y *MainForm.sizeCell, MainForm.sizeCell, MainForm.sizeCell); } if (mapFix[i][j] == 'Y') { Obstacles.Add(new FixedObject(j, i, 1)); mapGraphics.DrawImage(Obstacles.Last().Img, Obstacles.Last().X *MainForm.sizeCell, Obstacles.Last().Y *MainForm.sizeCell, MainForm.sizeCell, MainForm.sizeCell); } } } RespOfApples(); while (Tanks.Count < tanksCount) { Tanks.Add(new TankView()); foreach (var item in Obstacles) { if (Tanks.Last().Collide(item)) { Tanks.RemoveAt(Tanks.Count - 1); break; } } } for (int i = 0; i < Apples.Count; i++) { mapGraphics.DrawImage(Apples[i].Img, Apples[i].X * MainForm.sizeCell, Apples[i].Y * MainForm.sizeCell, MainForm.sizeCell, MainForm.sizeCell); } for (int i = 0; i < Tanks.Count; i++) { mapGraphics.DrawImage(Tanks[i].Img, Tanks[i].X * MainForm.sizeCell, Tanks[i].Y * MainForm.sizeCell, MainForm.sizeCell, MainForm.sizeCell); } while (true) { kolobok = new KolobokView(); if (!kolobok.CollideWithFixedObjects(Obstacles)) { break; } } Subscribe(); mapGraphics.DrawImage(kolobok.Img, kolobok.X * MainForm.sizeCell, kolobok.Y * MainForm.sizeCell, MainForm.sizeCell, MainForm.sizeCell); map.Image = backgroundMap; }
public void ResetLevel() { TilesSolid.Clear(); TilesOneWayPlatform.Clear(); TilesSpike.Clear(); Apples.Clear(); Grounders.Clear(); Flyer.Clear(); windRs.Clear(); Sneakers.Clear(); SneakerTimers.Clear(); if (windDir != Direction.None) { PreLoadWind(random); } for (var j = 0; j < LEVEL_HEIGHT; j++) { for (var i = 0; i < LEVEL_WIDTH; i++) { switch (tilemap[i, j]) { case Tile.Player: InitializePlayer(i * 16, j * 16); break; case Tile.Goal: goal = new Hitbox(i * 16, j * 16, 16, 16); break; case Tile.Wall: TilesSolid.Add(new Hitbox(i * 16, j * 16, 16, 16)); break; case Tile.NoGrapple: TilesSolid.Add(new Hitbox(i * 16, j * 16, 16, 16)); break; case Tile.OneWayPlatform: TilesOneWayPlatform.Add(new Hitbox(i * 16, j * 16, 16, 16)); break; case Tile.Spike: TilesSpike.Add(new Hitbox(i * 16, j * 16 + 8, 16, 8)); break; case Tile.Apple: Apples.Add(new Hitbox(i * 16 + 2, j * 16 + 2, 12, 12)); break; case Tile.Grounder: Grounders.Add(new Mobile(i * 16, j * 16, GROUNDER_SPEED, 0, 16, 16)); break; case Tile.Flyer: Flyer.Add(new Mobile(i * 16, j * 16, FLYER_SPEED, 0, 16, 16)); break; case Tile.Sneaker: Sneakers.Add(new Hitbox(i * 16, j * 16, 16, 16)); SneakerTimers.Add(-1); break; } } } }
public void Start(TanksForm fm) { UnSubscribe(); Apples.Clear(); Tanks.Clear(); Walls.Clear(); ShotsKolobok.Clear(); ShotsTanks.Clear(); kolobok = null; gameOver = false; Score = 0; Delta = 30; DeltaShots = 30; map = fm.map; backgroundMap = new Bitmap(map.Width, map.Height); mapGraphics = Graphics.FromImage(backgroundMap); mapGraphics.FillRectangle(Brushes.Black, 0, 0, map.Width, map.Height); for (int i = 0; i < example.Count(); i++) { for (int j = 0; j < example[i].Length; j++) { if (example[i][j] == 'X') { Walls.Add(new Wall(j, i)); mapGraphics.DrawImage(Walls.Last().Img, Walls.Last().X *TanksForm.sizeCell, Walls.Last().Y *TanksForm.sizeCell, TanksForm.sizeCell, TanksForm.sizeCell); } } } SpawnApples(); while (Tanks.Count < tanksCount) { Tanks.Add(new Tank()); foreach (var item in Walls) { if (Tanks.Last().CollidesWith(item)) { Tanks.RemoveAt(Tanks.Count - 1); break; } } } for (int i = 0; i < Apples.Count; i++) { mapGraphics.DrawImage(Apples[i].Img, Apples[i].X * TanksForm.sizeCell, Apples[i].Y * TanksForm.sizeCell, TanksForm.sizeCell, TanksForm.sizeCell); } for (int i = 0; i < Tanks.Count; i++) { mapGraphics.DrawImage(Tanks[i].Img, Tanks[i].X * TanksForm.sizeCell, Tanks[i].Y * TanksForm.sizeCell, TanksForm.sizeCell, TanksForm.sizeCell); } while (true) { kolobok = new Kolobok(); if (!kolobok.CollidesWithWalls(Walls)) { break; } } Subscribe(); mapGraphics.DrawImage(kolobok.Img, kolobok.X * TanksForm.sizeCell, kolobok.Y * TanksForm.sizeCell, TanksForm.sizeCell, TanksForm.sizeCell); map.Image = backgroundMap; }