Ejemplo n.º 1
0
        /// <summary>
        /// receivingPlayers get mines in cargo, owningPlayers get the mines added to the receivingSystems (deployed in space)
        /// </summary>
        /// <param name="receivingPlayers"></param>
        /// <param name="receivingSystems"></param>
        /// <param name="owningPlayers"></param>
        void AddMines(IEnumerable <Player> receivingPlayers, IEnumerable <PSystem> receivingSystems, IEnumerable <Player> owningPlayers, CargoSynchronizer cargoSynchronizer, GalaxyManager galaxyManager, LocalIDManager galaxyIDManager, StructureManager structureManager, LocatorService locatorService)
        {
            foreach (Player p in receivingPlayers)
            {
                for (int i = 0; i < _config.CARGO_NumMines; i++)
                {
                    TransactionAddStatefulCargo t = new TransactionAddStatefulCargo(p.GetActiveShip(), new StatefulCargo(galaxyIDManager.PopFreeID(), StatefulCargoTypes.DefensiveMine), true);
                    cargoSynchronizer.RequestTransaction(t);
                }
            }


            if (owningPlayers.Count() < 2)
            {
                return;
            }

            var itr = new CyclicalIterator <Player>(owningPlayers);

            itr.MoveNext();

            foreach (var system in galaxyManager.Systems)
            {
                for (int i = 0; i < _config.NumMinesPerSystem; i++)
                {
                    int ownerID = itr.Current.Id;
                    var mine    = new DefensiveMine(Rand.Random.Next(-system.AreaSize / 100, system.AreaSize / 100), Rand.Random.Next(-system.AreaSize / 100, system.AreaSize / 100), galaxyIDManager.PopFreeID(), ownerID, system.Id, locatorService.PlayerLocator);
                    structureManager.RegisterObject(mine);
                    system.AddStructure(mine);

                    itr.MoveNext();
                }
            }
        }
Ejemplo n.º 2
0
        public void CreateColonies(IEnumerable <Player> owningPlayers)
        {
            if (owningPlayers.Count() == 0)
            {
                return;
            }

            //PSystem sol = _galaxyManager.Systems.Find(ss => ss.Id == _dbFiller.gp.SolID);

            var areaList = _galaxyManager.GetAllAreas();

            string resultMessage = "";

            var itr = new CyclicalIterator <Player>(owningPlayers);

            itr.MoveNext();

            for (int i = 0; i < areaList.Count; i++)
            {
                if (areaList[i].AreaType != AreaTypes.Planet)
                {
                    continue;
                }

                var xPos = ((Planet)areaList[i]).Warpholes[0].PosX + 1;
                var yPos = ((Planet)areaList[i]).Warpholes[0].PosY + 1;

                var player = itr.Current;
                var ship   = player.GetActiveShip();

                var success = _galaxyManager.TryColonizePlanet((Planet)areaList[i], ship, null, _locatorService, xPos, yPos,
                                                               out resultMessage, _databaseManager);

                itr.MoveNext();
            }
        }