Exemple #1
0
 // Событие даблклика по элементу
 protected override bool DoOnDblClick()
 {
     // Проверим хоткей на выбор всех юнитов
     if (Engine.HotKey(KeyCode.LeftControl, true))
     {
         foreach (Ship LShip in FSelf.Planet.Ships)
         {
             if ((FSelf.Owner == LShip.Owner) &&
                 (!LShip.Tech(ShipTech.Stationary).Supported) &&
                 (LShip.IsAvail() || LShip.IsMove()) &&
                 (!Engine.ShipGroup.Ships.Contains(LShip)))
             {
                 Engine.ShipGroup.AddShip(LShip);
             }
         }
     }
     else
     {
         // Иначе уравняем стеки если есть хотя бы два корабля одного типа
         foreach (Ship LShip in FSelf.Planet.Ships)
         {
             if ((FSelf.ShipType == LShip.ShipType) && (FSelf.Owner == LShip.Owner) && (FSelf != LShip))
             {
                 Engine.SocketWriter.ShipHypodispersion(FSelf);
                 return(false);
             }
         }
     }
     return(false);
 }
Exemple #2
0
        // Удаление последней планеты пути следования
        public void RemovePath(Planet APlanet)
        {
            Planets.Remove(APlanet);

            foreach (Ship LShip in Ships)
            {
                LShip.PathRemove();
            }
        }
Exemple #3
0
        // Добавление планеты в путь полета
        private void DoAddPath(Planet APlanet)
        {
            Planets.Add(APlanet);

            foreach (Ship LShip in Ships)
            {
                LShip.PathAdd(APlanet);
            }

            LastPlanet = APlanet;
        }
Exemple #4
0
        public Board(BoardSetup setup)
        {
            tileMap = new Tile[Globals.boardSize, Globals.boardSize];
            for (int i = 0; i < Globals.boardSize; i++)
            {
                for (int j = 0; j < Globals.boardSize; j++)
                {
                    tileMap[i, j] = new Tile(i, j);
                }
            }

            unitsList = new List <Unit>();
            shipsList = new List <Ship>();

            var unitDataIterator = new UnitDataContainer(setup.placedEntities).GetIterator();

            while (unitDataIterator.HasNext())
            {
                UnitData    unitData  = (UnitData)unitDataIterator.Next();
                List <Tile> unitTiles = new List <Tile>();
                for (int j = 0; j < unitData.positions.Count; j += 2)
                {
                    unitTiles.Add(tileMap[unitData.positions[j], unitData.positions[j + 1]]);
                }

                Ship ship = null;
                switch (unitData.layout.type)
                {
                case UnitLayout.Type.SShip:
                    ship = new SShip(unitTiles);
                    break;

                case UnitLayout.Type.MShip:
                    ship = new MShip(unitTiles);
                    break;

                case UnitLayout.Type.LShip:
                    ship = new LShip(unitTiles);
                    break;

                case UnitLayout.Type.XLShip:
                    ship = new XLShip(unitTiles);
                    break;
                }

                shipsList.Add(ship);
                unitsList.Add(ship);
            }
        }