Пример #1
0
        public override void MoveShipHere(IShip s)
        {
            if (s.GetArea() != null)
            {
                s.GetArea().RemoveShip(s);
            }

            addShip(s);
        }
Пример #2
0
        public virtual void MoveShipHere(IShip s)
        {
            if (s.GetArea() != null)
            {
                s.GetArea().RemoveShip(s);
            }

            AddShip(s);
        }
Пример #3
0
        /// <summary>
        /// Changes IShip area and moves IShip to specified position
        /// </summary>
        /// <param name="s"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        public virtual void MoveShipHere(IShip s, float xPos, float yPos)
        {
            if (s.GetArea() != null)
            {
                s.GetArea().RemoveShip(s);
            }

            AddShip(s);

            s.PosX = xPos;
            s.PosY = yPos;
        }
Пример #4
0
 public override bool CanFire(IShip ship)
 {
     return(TimeKeeper.MsSinceInitialization - lastTimeStampAtFire >= Stats.FirePeriod &&
            ship.CurrentEnergy >= Stats.EnergyCost && ship.GetArea().SecurityLevel != 255 &&
            ship.Cargo.GetCargoAmount(((MissileLauncherStats)Stats).MissileType) > 0);
 }
Пример #5
0
 public virtual bool CanFire(IShip ship)
 {
     return(TimeKeeper.MsSinceInitialization - lastTimeStampAtFire >= Stats.FirePeriod &&
            ship.CurrentEnergy >= Stats.EnergyCost && ship.GetArea().SecurityLevel != 255);
 }
Пример #6
0
        public IShip KillShip(IShip s, ICanFire killingObject)
        {
            if (s.IsDead)
            {
                ConsoleManager.WriteLine("Killing a ship which was already dead.", ConsoleMessageType.Warning);
                return(s);
            }


            s.IsDead           = true;
            s.KillTimeStamp    = TimeKeeper.MsSinceInitialization;
            s.RespawnTimeDelay = 3000;//TODO: This will be a problem later, if a IShip warps into a new system where a dead IShip is waiting to respawn, the warping IShip will see a live ship. Needs to be fully implemented.
            s.CurrentHealth    = 0;

            if (s.GetPlayer().IsTrading)
            {
                _tradeTerminator.TerminateTrade(s.Id, true);
            }

            var currentArea = s.GetArea();

            if (currentArea.NumOnlinePlayers > 0)
            {
                MessageRemoveKillRevive msgData = new MessageRemoveKillRevive();
                msgData.ActionType = ActionType.Kill;
                msgData.ObjectType = RemovableObjectTypes.Ship;
                msgData.ObjectIDs.Add(s.Id);

                currentArea.BroadcastMessage(new NetworkMessageContainer(msgData, MessageTypes.RemoveKillRevive));

                // Send chat messages
                if (killingObject is IShip)
                {
                    ((IShip)killingObject).GetPlayer().PlayersKilled++;
                    var killingPlayer = ((IShip)killingObject).GetPlayer();

                    killingPlayer.PlayersKilled++;

                    var killText = string.Format("{0} was shot down by {1}!", s.GetPlayer().Username, killingPlayer.Username);

                    _chatManager.BroadcastSimpleChat(s.GetArea(), "", killText, ChatTypes.None);
                }
                else if (killingObject is Turret)
                {
                    _playerLocator.GetPlayerAsync(((Turret)killingObject).OwnerID).Result.PlayersKilled++;

                    var killedPlayer = s.GetPlayer();

                    var defensesOwner = _playerLocator.GetPlayerAsync(((Turret)killingObject).OwnerID).Result.Username;

                    var killText = string.Format("{0} was shot down by defenses of {1}!", killedPlayer.Username, defensesOwner);

                    _chatManager.BroadcastSimpleChat(s.GetArea(), "", killText, ChatTypes.None);
                }
            }

            #region Modules
            //For now, just make the ship drop one mod to space. Later we'll figure out how many to destroy/keep with the ship
            var moduleToRemove = s.Cargo.GetAnyStatefulCargo(StatefulCargoTypes.Module);
            if (moduleToRemove != null)
            {
                var ct = new TransactionRemoveStatefulCargo(s, StatefulCargoTypes.Module, moduleToRemove.Id);
                ct.OnCompletion += s.CargoRemoved;
                ct.OnCompletion += _messageManager.NotifyCargoRemoved;
                ct.OnCompletion += _addCargoToArea;


                var mod = moduleToRemove as Module;
                mod.PosX       = s.PosX;
                mod.PosY       = s.PosY;
                mod.Rotation   = s.Rotation;
                mod.NextAreaID = (int)s.CurrentAreaId;

                _cargoSynchronizer.RequestTransaction(ct);
            }


            #endregion


            s.CurrentHealth = s.ShipStats.MaxHealth;
            //s.IsDead = false;
            float tempx = 0;
            float tempy = 0;
            SpatialOperations.GetRandomPointInRadius(ref tempx, ref tempy, 10, 20);

            s.PosX = tempx;
            s.PosY = tempy;


            return(s);
        }