コード例 #1
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();
            }
        }
コード例 #2
0
ファイル: DBFiller.cs プロジェクト: bsed/Freecon-Galactic
        async Task FillPorts(GalaxyManager galaxyManager, LocalIDManager galaxyIDManager, CargoSynchronizer cargoSynchronizer)
        {
            var ports = galaxyManager.GetAllAreas().Where(a => a.AreaType == AreaTypes.Port);
            CargoTransaction lastTransaction = null;

            foreach (var p in ports)
            {
                var port = p as Port;
                foreach (var s in _config.PortConfig.StatefulCargoCounts)
                {
                    StatefulCargo sc;
                    for (int i = 0; i < s.Value; i++)//Yes, this loop is lazy, but it's 11:30PM...
                    {
                        //TODO: make a StatefulCargoFactory
                        switch (s.Key)
                        {
                        case StatefulCargoTypes.Barge:
                        {
                            sc = new CargoShip(galaxyIDManager.PopFreeID(), 666, ShipStats[ShipTypes.Barge]);
                            break;
                        }

                        case StatefulCargoTypes.BattleCruiser:
                        {
                            sc = new CargoShip(galaxyIDManager.PopFreeID(), 666, ShipStats[ShipTypes.BattleCruiser]);
                            break;
                        }

                        case StatefulCargoTypes.Penguin:
                        {
                            sc = new CargoShip(galaxyIDManager.PopFreeID(), 666, ShipStats[ShipTypes.Penguin]);
                            break;
                        }

                        case StatefulCargoTypes.Reaper:
                        {
                            sc = new CargoShip(galaxyIDManager.PopFreeID(), 666, ShipStats[ShipTypes.Reaper]);
                            break;
                        }

                        case StatefulCargoTypes.LaserTurret:
                        {
                            sc = new CargoLaserTurret(galaxyIDManager.PopFreeID(), 666, new LaserWeaponStats());
                            break;
                        }

                        default:
                        {
                            sc = new StatefulCargo(galaxyIDManager.PopFreeID(), s.Key);
                            break;
                        }
                        }


                        CargoTransaction tr = new TransactionAddStatefulCargo(port, sc, true);
                        cargoSynchronizer.RequestTransaction(tr);
                        lastTransaction = tr;
                    }
                }

                foreach (var s in _config.PortConfig.StatelessCargoCounts)
                {
                    var tr = new TransactionAddStatelessCargo(port, s.Key, s.Value, true);
                    cargoSynchronizer.RequestTransaction(tr);
                    lastTransaction = tr;
                }

                foreach (var s in _config.PortConfig.ModuleCounts)
                {
                    Module m  = ModuleFactory.CreateModule(s.Key, galaxyIDManager.PopFreeID(), 1);
                    var    tr = new TransactionAddStatefulCargo(port, m, true);
                    cargoSynchronizer.RequestTransaction(tr);
                    lastTransaction = tr;
                }
            }
            if (lastTransaction != null)
            {
                await lastTransaction.ResultTask;
            }
        }