public void Play() { while (true) { foreach (var Tank in Tanks) { Tank.Run(); } packman.Run(); packman.SnaryadRun(); CheckTanksCollision(); PackmanEatApple(); if (PackmanTanksCollision() || CheckSnaryadPackmanCollision()) { MessageBox.Show("--Game Over--"); break; } CheckSnaryadTanksCollision(); if (YOUWIN()) { MessageBox.Show("--You Win--"); break; } Thread.Sleep(GameSpeed); } }
public void PackmanRun() { if (isADown) { packman.Run(); } else if (isDDown) { packman.Run(); } else if (isWDown) { packman.Run(); } else if (isSDown) { packman.Run(); } }
private void MovementAllObject() { ((Hunter)tanks[0]).Run(packman.X, packman.Y); for (int i = 1; i < tanks.Count; i++) { tanks[i].Run(); } projectile.Run(); packman.Run(); for (int i = 0; i < fireTanks.Count; i++) { fireTanks[i].Fire(); } }
private void RunAllObjectsOnField() // Запуск движения всех объектов на поле { projectile.Run(); packman.Run(); ((Hunter)tanks[0]).Run(packman.X, packman.Y); for (int i = 1; i < tanks.Count; i++) { tanks[i].Run(); } for (int i = 0; i < fireTanks.Count; i++) { fireTanks[i].Fire(); } }
public void Play() { while (gameStatus == GameStatus.playing) { Thread.Sleep(speedGame); projectile.Run(); packman.Run(); // run for hunter ((Hunter)tanks[0]).Run(packman.X, packman.Y); for (int i = 1; i < tanks.Count; i++) { tanks[i].Run(); } //burning tank foreach (FireTank ft in fireTank) { ft.Burn(); } for (int i = 1; i < tanks.Count; i++) { if (Math.Abs(tanks[i].X - projectile.X) < 11 && Math.Abs(tanks[i].Y - projectile.Y) < 11) { fireTank.Add(new FireTank(tanks[i].X, tanks[i].Y)); tanks.RemoveAt(i); projectile.DefaultSettings(); } } //tank+tank for (int i = 0; i < tanks.Count - 1; i++) { for (int j = i + 1; j < tanks.Count; j++) { if ( (Math.Abs(tanks[i].X - tanks[j].X) <= 20 && (tanks[i].Y == tanks[j].Y)) || (Math.Abs(tanks[i].Y - tanks[j].Y) <= 20 && (tanks[i].X == tanks[j].X)) || (Math.Abs(tanks[i].X - tanks[j].X) <= 20) && (Math.Abs(tanks[i].Y - tanks[j].Y) <= 20) ) { if (i == 0) { ((Hunter)tanks[i]).TurnAround(); } else { tanks[i].TurnAround(); } tanks[j].TurnAround(); } } } // packman+tank for (int i = 0; i < tanks.Count; i++) { if ( (Math.Abs(tanks[i].X - packman.X) <= 20 && (tanks[i].Y == packman.Y)) || (Math.Abs(tanks[i].Y - packman.Y) <= 20 && (tanks[i].X == packman.X)) || (Math.Abs(tanks[i].X - packman.X) <= 20) && (Math.Abs(tanks[i].Y - packman.Y) <= 20) ) { gameStatus = GameStatus.loser; } } if (changeStreep != null) { changeStreep(); } //packman+apple for (int i = 0; i < apples.Count; i++) { if (Math.Abs(packman.X - apples[i].X) < 4 && Math.Abs(packman.Y - apples[i].Y) < 4) { apples[i] = new Apple(0 + collectedApples * 20, 260); collectedApples++; } } if (collectedApples > 4) { gameStatus = GameStatus.winner; } if (changeStreep != null) { changeStreep(); } } }