Ejemplo n.º 1
0
 public void Turn(Civilization civ, mapObject[,] map)
 {
     civ.ClearTurnShips();
     civ.CollectResources();
     TurnShip(civ, map);
     Build(civ, map);
 }
Ejemplo n.º 2
0
 public GameLogic(mapObject[,] map)
 {
     r = new Random();
     You = new Civilization();
     enemy = new Civilization();
     planets = new Dictionary<Point, Planet>();
     turnEnemy = new Enemy();
     InitPlanets(map);
 }
Ejemplo n.º 3
0
 public void Kill(Civilization enemy, mapObject[,] map, Dictionary<Point, Ship> you)
 {
     foreach (var pointShip in enemy.Ships.Keys)
     {
         Point pointKill = Ship.SearchInArea(map, pointShip, mapObject.DestroyerYou);
         if (pointKill != pointShip)
         {
             if (you.ContainsKey(pointKill))
             {
                 you.Remove(pointKill);
                 map[pointKill.X, pointKill.Y] = mapObject.None;
                 enemy.Ships[pointShip].Turn = true;
             }
         }
     }
 }
Ejemplo n.º 4
0
        private void TurnShip(Civilization civ, mapObject[,] map)
        {
            temp.Clear();
            foreach (var shipCrd in civ.Ships.Keys)
            {
                Point[] freeArea = Ship.GetFreeArea(map, shipCrd);
                if (freeArea.Length != 0 && !civ.Ships[shipCrd].Turn)
                {
                    Point move = freeArea[r.Next(0, freeArea.Length - 1)];
                    map[shipCrd.X, shipCrd.Y] = mapObject.None;
                    map[move.X, move.Y] = mapObject.DestroyerEnemy;
                    temp.Add(move, civ.Ships[shipCrd]);
                    temp[move].Turn = true;

                }
            }
            civ.Ships = new Dictionary<Point, Ship>(temp);
        }
Ejemplo n.º 5
0
 private void Build(Civilization civ, mapObject[,] map)
 {
     while (civ.Titanium >= 8 && civ.Iridium >= 17 && civ.Gold >= 450)
     {
         Point planet = civ.Planets[r.Next(0, civ.Planets.Count - 1)].Location; // строим новый корабль на рандомной планете противники
         Point loc = Ship.SearchInArea(map, planet, mapObject.None);
         if (map[loc.X, loc.Y] == mapObject.None)
         {
             civ.Ships.Add(loc, new Ship());
             map[loc.X, loc.Y] = mapObject.DestroyerEnemy;
             civ.Titanium -= 8;
             civ.Iridium -= 17;
             civ.Gold -= 450;
         }
         else
             break;
     }
 }
Ejemplo n.º 6
0
 public void ChangeCiv(Civilization civ)
 {
     this.civ = civ;
     createObj = new CreateObject(name, Food, Titanium, Iridium, Gold);
 }