private void BotTankMove(BotTank botTank) { int i = 1; if (botTank.IsMove() && Dispatcher.Invoke(() => IsBeingOnTheMap(tank)) && Dispatcher.Invoke(() => CheckListObjectMap(tank))) { switch (botTank.OrientationMove) { case 1: Dispatcher.Invoke(() => botTank.Move("Up")); Dispatcher.Invoke(() => botTank.passed += i); break; case 2: Dispatcher.Invoke(() => botTank.Move("Down")); Dispatcher.Invoke(() => botTank.passed += i); break; case 3: Dispatcher.Invoke(() => botTank.Move("Right")); Dispatcher.Invoke(() => botTank.passed += i); break; case 4: Dispatcher.Invoke(() => botTank.Move("Left")); Dispatcher.Invoke(() => botTank.passed += i); break; } } else { NotMoveBotTank(botTank); } }// Движеие согласно выбранному направлению
}// Получение случайного направления танка private void СonditionTurnTheTank(BotTank tank) { bool IsRangeTankShotX = tank.IsRangeShot(windowTank[0].GetCoordinates.CordinateToX, tank.GetCoordinates.CordinateToX); bool IsRangeTankShotY = tank.IsRangeShot(windowTank[0].GetCoordinates.CordinateToY, tank.GetCoordinates.CordinateToY); if (Math.Abs(windowTank[0].GetCoordinates.CordinateToX - tank.GetCoordinates.CordinateToX) < 33) { if (windowTank[0].GetCoordinates.CordinateToY > tank.GetCoordinates.CordinateToY && Dispatcher.Invoke(() => CheckListRange(tank, true)) && IsRangeTankShotY) { Dispatcher.Invoke(() => tank.MoveShot = false); Dispatcher.Invoke(() => tank.Turn("Down")); Dispatcher.Invoke(() => tank.Shot(ref windowBullet)); } else if (windowTank[0].GetCoordinates.CordinateToY < tank.GetCoordinates.CordinateToY && Dispatcher.Invoke(() => CheckListRange(tank, true)) && IsRangeTankShotY) { Dispatcher.Invoke(() => tank.MoveShot = false); Dispatcher.Invoke(() => tank.Turn("Up")); Dispatcher.Invoke(() => tank.Shot(ref windowBullet)); } } else if (Math.Abs(windowTank[0].GetCoordinates.CordinateToY - tank.GetCoordinates.CordinateToY) < 33) { if (windowTank[0].GetCoordinates.CordinateToX > tank.GetCoordinates.CordinateToX && IsRangeTankShotX && Dispatcher.Invoke(() => CheckListRange(tank, false))) { Dispatcher.Invoke(() => tank.MoveShot = false); Dispatcher.Invoke(() => tank.Turn("Right")); Dispatcher.Invoke(() => tank.Shot(ref windowBullet)); } else if (windowTank[0].GetCoordinates.CordinateToX < tank.GetCoordinates.CordinateToX && IsRangeTankShotX && Dispatcher.Invoke(() => CheckListRange(tank, false))) { Dispatcher.Invoke(() => tank.MoveShot = false); Dispatcher.Invoke(() => tank.Turn("Left")); Dispatcher.Invoke(() => tank.Shot(ref windowBullet)); } } }//Условия поворота танка и выстрела
}// Движеие согласно выбранному направлению private void NotMoveBotTank(BotTank botTank) { Dispatcher.Invoke(() => botTank.passed = 0); Dispatcher.Invoke(() => botTank.OrientationMove = Roll()); botTank.motionСancellation = false; }// отмена бвижения танка