コード例 #1
0
ファイル: ShipManager.cs プロジェクト: bsed/Freecon-Galactic
        public ShipManager(MessageManager mm, IAreaLocator gm, WarpManager wm, ConnectionManager cm, IDatabaseManager dbm)
        {
            _messageManager    = mm;
            _areaLocator       = gm;
            _warpManager       = wm;
            _connectionManager = cm;
            _databaseManager   = dbm;

            _ships = new ConcurrentDictionary <int, IShip>();
        }
コード例 #2
0
ファイル: KillManager.cs プロジェクト: bsed/Freecon-Galactic
 public KillManager(CargoSynchronizer cargoSynchronizer, IPlayerLocator pl, IAreaLocator al, MessageManager mm, ConnectionManager cm, WarpManager wm, ChatManager chatManager, ITradeTerminator tradeTerminator)
 {
     _cargoSynchronizer = cargoSynchronizer;
     _messageManager    = mm;
     _connectionManager = cm;
     _warpManager       = wm;
     _areaLocator       = al;
     _playerLocator     = pl;
     _chatManager       = chatManager;
     _tradeTerminator   = tradeTerminator;
 }
コード例 #3
0
        /// <summary>
        /// Returns true if colonization succesful
        /// </summary>
        /// <param name="colonizingShip"></param>
        /// <param name="xPos">ref in case positions are modified to accomodate placement (e.g. snap to nearest tile)</param>
        /// <param name="yPos">ref in case positions are modified to accomodate placement (e.g. snap to nearest tile)</param>
        /// <returns></returns>
        public bool TryColonizePlanet(Planet planet, IShip colonizingShip, WarpManager wm, LocatorService ls, float xPos, float yPos, out string resultMessage, IDatabaseManager databaseManager)
        {
            if (planet.IsColonized)
            {
                resultMessage = "Planet is already colonized!";
                return(false);
            }
            else if (colonizingShip.CurrentEnergy != colonizingShip.ShipStats.Energy)//Is energy full?
            {
                resultMessage = "Not enough energy.";
                return(false);
            }
            else if (!planet.GetValidStructurePosition(new CommandCenterStats(), ref xPos, ref yPos))//Check for wall overlap here
            {
                resultMessage = "Invalid placement location.";
                return(false);
            }
            else if (colonizingShip.Cargo.GetCargoAmount(StatelessCargoTypes.Biodome) > 0)
            {//if everything checks out
                ColonyFactory.CreateColony(xPos, yPos, colonizingShip.GetPlayer(), planet, ls);

                List <IShip> ShipsToMove = new List <IShip>(1);
                //Kick all non-allied players into space
                foreach (var s in planet.GetShips())
                {
                    if (s.Value != colonizingShip)
                    {
                        if (s.Value is NPCShip && !_teamLocator.AreAllied(((NPCShip)s.Value), planet.GetOwner()))
                        {
                            ShipsToMove.Add(s.Value);
                        }
                        else if (s.Value is PlayerShip && !_teamLocator.AreAllied(s.Value.GetPlayer(), planet.GetOwner()))
                        {
                            ShipsToMove.Add(s.Value);
                        }
                    }
                }

                foreach (var s in ShipsToMove)
                {
                    wm.ChangeArea((int)planet.ParentAreaID, s, false, true);
                }
                resultMessage = "Colonization Successful.";
                return(true);
            }
            else
            {
                resultMessage = "No biodome found in ship cargo.";
                return(false);
            }
        }