Beispiel #1
0
        public void SendRepairImpossible(GameSession gameSession, short currency)
        {
            if (gameSession.Player.UsingNewClient)
            {
                new NotImplementedException();
            }
            else
            {
                var player       = gameSession.Player;
                var killscreen   = Killscreen.Load(player);
                var price        = killscreen.Price;
                var options      = new List <KillScreenOptionModule>();
                var optionModule = new KillScreenOptionModule(
                    new KillScreenOptionTypeModule(KillScreenOptionTypeModule.BASIC_REPAIR),
                    new PriceModule(price.Item1, price.Item2),
                    true,
                    0,
                    new MessageLocalizedWildcardCommand(currency == PriceModule.URIDIUM ? "desc_killscreen_repair_impossible" : "desc_killscreen_repair_credits_impossible", new List <MessageWildcardReplacementModule>()),
                    new MessageLocalizedWildcardCommand("", new List <MessageWildcardReplacementModule>()),
                    new MessageLocalizedWildcardCommand("ttip_killscreen_free_phoenix", new List <MessageWildcardReplacementModule>()),
                    new MessageLocalizedWildcardCommand(currency == PriceModule.URIDIUM ? "btn_killscreen_payment" : "btn_killscreen_get_phoenix", new List <MessageWildcardReplacementModule>()));
                options.Add(optionModule);

                Packet.Builder.KillScreenUpdateCommand(gameSession, options);
            }
        }
Beispiel #2
0
        public void RespawnPlayer()
        {
            Character.EntityState = EntityStates.ALIVE;
            Character.Range.Clear();

            var player     = (Player)Character;
            var killscreen = Killscreen.Load(player);

            //TODO: fix
            //player.CurrentHealth = killscreen.SelectedOption == netty.commands.old_client.KillScreenOptionTypeModule.AT_DEATHLOCATION_REPAIR ? (player.Hangar.Ship.Health / 100) * 10 : 1000; //if its location repair %10 of base ship hp else just 1000 hp

            if (player.Controller == null)
            {
                player.Controller = new PlayerController(Character);
            }
            var closestStation = player.GetClosestStation();
            var newPos         = closestStation.Item1;

            player.VirtualWorldId = 0;

            player.Spacemap = closestStation.Item2;

            Character.SetPosition(newPos);

            if (!Character.Spacemap.Entities.ContainsKey(Character.Id))
            {
                Character.Spacemap.AddEntity(Character);
            }

            player.Refresh();

            player.Controller.Setup();
            player.Controller.Initiate();
            player.Save();
        }
Beispiel #3
0
        public void RespawnPlayer()
        {
            lock (ThreadLock)
            {
                var player = (Player)Character;
                if (player.EntityState == EntityStates.ALIVE)
                {
                    return;
                }

                var killscreen = Killscreen.Load(player);
                if (killscreen == null)
                {
                    player.CurrentHealth = 1000;
                }
                else
                {
                    player.CurrentHealth =
                        killscreen.SelectedOption ==
                        netty.commands.old_client.KillScreenOptionTypeModule.AT_DEATHLOCATION_REPAIR
                            ? (player.Hangar.Ship.Health / 100) * 10
                            : 1000; //if its location repair %10 of base ship hp else just 1000 hp
                }

                Character.EntityState = EntityStates.ALIVE;

                if (player.Controller == null)
                {
                    player.Controller = new PlayerController(Character);
                }

                player.Controller.StopController = false;

                var(newPos, spacemap) = player.GetClosestStation();

                player.VirtualWorldId = 0;

                player.MoveToMap(spacemap, newPos, 0);

                if (!Character.Spacemap.Entities.ContainsKey(Character.Id))
                {
                    Character.Spacemap.AddEntity(Character);
                }


                player.Setup();
                player.Controller.Setup();
                player.Controller.Initiate();
                player.Refresh();
                player.Save();
                player.State.StartLoginProtection();
            }
        }
Beispiel #4
0
        public void execute(GameSession gameSession, IByteBuffer buffer)
        {
            if (gameSession.Player.UsingNewClient)
            {
                Console.WriteLine("TODO: Update KillscreenRepairRequestHandler for new client");
                //new NotImplementedException();
            }
            else
            {
                if (gameSession?.Client == null)
                {
                    return;
                }
                var player = gameSession.Player;

                var cmd = new KillScreenRepairRequest();
                cmd.readCommand(buffer);

                short repairTypeValue = cmd.selection.repairTypeValue;

                var killscreen = Killscreen.Load(player);
                if (killscreen == null)
                {
                    throw new ArgumentNullException();                     // handle null
                }
                switch (repairTypeValue)
                {
                case KillScreenOptionTypeModule.BASIC_REPAIR:
                    killscreen.SelectedOption = 1;
                    break;

                case KillScreenOptionTypeModule.AT_JUMPGATE_REPAIR:
                    killscreen.SelectedOption = 2;
                    break;

                case KillScreenOptionTypeModule.AT_DEATHLOCATION_REPAIR:
                    killscreen.SelectedOption = 3;
                    break;
                }

                var price = killscreen.Price;
                switch (price.Item1)
                {
                case PriceModule.CREDITS:
                    if (player.Information.Credits.Get() >= price.Item2)
                    {
                        player.Information.Credits.Remove(price.Item2);
                        player.Controller.Destruction.RespawnPlayer();
                        break;
                    }
                    SendRepairImpossible(gameSession, PriceModule.CREDITS);
                    break;

                case PriceModule.URIDIUM:
                    if (player.Information.Uridium.Get() >= price.Item2)
                    {
                        player.Information.Uridium.Remove(price.Item2);
                        player.Controller.Destruction.RespawnPlayer();
                        break;
                    }
                    SendRepairImpossible(gameSession, PriceModule.URIDIUM);
                    break;
                }
                player.Save();
            }
        }
Beispiel #5
0
 public override void Execute()
 {
     SendSettings();
     SendLegacy();
     Packet.Builder.KillScreenCommand(GameSession, Killscreen.Load(GameSession.Player));
 }