// Цей метод варто вказати з модифікатором private public void OnBulletDraw(BulletEngine bullet) { if (BulletDraw != null) { BulletDraw(bullet); } }
public void OnBulletErase(BulletEngine bullet) { if (BulletErase != null) { BulletErase(bullet); } }
public MoveDirection Control(out ControlActions enemyAction, List <TankFragment> enemyTank, List <TankFragment> myTank, EnemyTankEngine tank, ControlActions enemyTankLastAction, MoveDirection direction, BulletEngine bullet, MapBase map) { ControlActions nextEnemyAction; MoveDirection nextEnemyDirection = 0; EnemyTankChoseActions(out nextEnemyAction, enemyTank, myTank, enemyTankLastAction); if (nextEnemyAction == ControlActions.Shoot) { tank.Shoot(enemyTank[1].X, enemyTank[1].Y, direction); enemyAction = enemyTankLastAction; } else { enemyAction = nextEnemyAction; } switch (enemyAction) { case ControlActions.MoveUp: nextEnemyDirection = MoveDirection.Up; break; //дивитись коментар до GameEngineControl case ControlActions.MoveDown: nextEnemyDirection = MoveDirection.Down; break; case ControlActions.MoveLeft: nextEnemyDirection = MoveDirection.Left; break; case ControlActions.MoveRight: nextEnemyDirection = MoveDirection.Right; break; } return(nextEnemyDirection); }
public bool BulletNearBorder(BulletEngine bulletEngine, List <int> borders) { var bulletNearBorder = false; switch (bulletEngine.Direction) { case MoveDirection.Up: if (bulletEngine.Y - 1 == borders[0] || bulletEngine.Y - 2 == borders[0]) { bulletNearBorder = true; } break; case MoveDirection.Down: if (bulletEngine.Y + 1 == borders[2] || bulletEngine.Y + 2 == borders[2]) { bulletNearBorder = true; } break; case MoveDirection.Left: if (bulletEngine.X - 1 == borders[0] || bulletEngine.X - 2 == borders[0]) { bulletNearBorder = true; } break; case MoveDirection.Right: if (bulletEngine.X + 2 == borders[3] || bulletEngine.X + 3 == borders[3]) { bulletNearBorder = true; } break; } return(bulletNearBorder); }
public bool BulletNearWall(BulletEngine bulletEngine, int[,] mapPoints) { var bulletNearWall = false; switch (bulletEngine.Direction) { case MoveDirection.Up: if (mapPoints[bulletEngine.Y - 1, bulletEngine.X] == 1) { bulletNearWall = true; } break; case MoveDirection.Down: if (mapPoints[bulletEngine.Y + 1, bulletEngine.X] == 1) { bulletNearWall = true; } break; case MoveDirection.Left: if (mapPoints[bulletEngine.Y, bulletEngine.X - 1] == 1) { bulletNearWall = true; } break; case MoveDirection.Right: if (mapPoints[bulletEngine.Y, bulletEngine.X + 1] == 1) { bulletNearWall = true; } break; } return(bulletNearWall); }
public void MakeShoot(int x, int y, MoveDirection direction) { var lBulletEngine = new BulletEngine(x, y, direction); Bullets.Add(lBulletEngine); }
public GameEngineControl(TankEngine tank, EnemyTankEngine enemyTank, BulletEngine bullet, ControlBase controlBase, MapBase map, MoveDirection direction, MoveDirection enemyDirection) { PlayerWin = false; GameOver = false; _tank = tank; _enemyTank = enemyTank; _bullet = bullet; _controlBase = controlBase; _map = map; _lastDirection = direction; _direction = direction; _lastEnemyDirection = enemyDirection; _enemyDirection = enemyDirection; _bulletsTimer = new Timer(10000); _bulletsTimer.Elapsed += BulletsTimerOnElapsed; _bulletsTimer.Interval = _bullesSpeed; _tanksTimer = new Timer(10000); _tanksTimer.Elapsed += TanksTimerOnElapsed; _tanksTimer.Interval = _tanksSpeed; //тут двічі, і ще в методі Control класу EnemyTankEngine, де ми отримуємо ControlAction є код, який повторюється // public static ControlAction GetControlAction(MoveDirection direction) // switch (direction) // { // case MoveDirection.Up: // return ControlActions.MoveUp; // break; // case MoveDirection.Down: // return = ControlActions.MoveDown; // break; // case MoveDirection.Right: // return = ControlActions.MoveRight; // break; // case MoveDirection.Left: // return = ControlActions.MoveLeft; // break; // } // return ControlActions.MoveUp; //_action = GetControlAction(direction) //_enemyAction = GetControlAction(enemyDirection) switch (direction) { case MoveDirection.Up: _action = ControlActions.MoveUp; break; case MoveDirection.Down: _action = ControlActions.MoveDown; break; case MoveDirection.Right: _action = ControlActions.MoveRight; break; case MoveDirection.Left: _action = ControlActions.MoveLeft; break; } switch (enemyDirection) { case MoveDirection.Up: _enemyAction = ControlActions.MoveUp; break; case MoveDirection.Down: _enemyAction = ControlActions.MoveDown; break; case MoveDirection.Right: _enemyAction = ControlActions.MoveRight; break; case MoveDirection.Left: _enemyAction = ControlActions.MoveLeft; break; } }
public void BulletMoveUp(BulletEngine bulletEngine) { bulletEngine.Y = bulletEngine.Y - 1; }
public void BulletMoveDown(BulletEngine bulletEngine) { bulletEngine.Y = bulletEngine.Y + 1; }
public void BulletMoveLeft(BulletEngine bulletEngine) { bulletEngine.X = bulletEngine.X - 1; }
public void BulletMoveRight(BulletEngine bulletEngine) { bulletEngine.X = bulletEngine.X + 1; }
public void BulletDeleteFromMap(BulletEngine bulletEngine, MapBase map) { map.GameMap[bulletEngine.Y, bulletEngine.X] = 0; }
public void BulletCreateOnMap(BulletEngine bulletEngine, MapBase map) { map.GameMap[bulletEngine.Y, bulletEngine.X] = 4; }