Ejemplo n.º 1
0
        Task <bool> IServerPlayer.PurchaseGood(string item, int count)
        {
            if (BaseData == null)
            {
                return(Task.FromResult(false));
            }
            var g = BaseData.SoldGoods.FirstOrDefault(x =>
                                                      x.Good.Equipment.Nickname.Equals(item, StringComparison.OrdinalIgnoreCase));

            if (g == null)
            {
                return(Task.FromResult(false));
            }
            var cost = (long)(g.Price * (ulong)count);

            if (Character.Credits >= cost)
            {
                string hp;
                if (count == 1 && (hp = FirstAvailableHardpoint(g.Good.Equipment.HpType)) != null)
                {
                    Character.AddCargo(g.Good.Equipment, hp, 1);
                }
                else
                {
                    Character.AddCargo(g.Good.Equipment, null, count);
                }
                Character.UpdateCredits(Character.Credits - cost);
                rpcClient.UpdateInventory(Character.Credits, GetShipWorth(), Character.EncodeLoadout());
                return(Task.FromResult(true));
            }
            return(Task.FromResult(false));
        }
Ejemplo n.º 2
0
        public void OpenSaveGame(SaveGame sg)
        {
            Orientation = Quaternion.Identity;
            Position    = sg.Player.Position;
            Base        = sg.Player.Base;
            System      = sg.Player.System;
            Character   = new NetCharacter();
            Character.UpdateCredits(sg.Player.Money);
            string ps;

            if (sg.Player.ShipArchetype != null)
            {
                ps = sg.Player.ShipArchetype;
            }
            else
            {
                ps = Game.GameData.GetShip(sg.Player.ShipArchetypeCrc).Nickname;
            }
            Character.Ship  = Game.GameData.GetShip(ps);
            Character.Items = new List <NetCargo>();
            foreach (var eq in sg.Player.Equip)
            {
                var hp = eq.Hardpoint;
                if (string.IsNullOrEmpty(hp))
                {
                    hp = "internal";
                }
                Equipment equip;
                if (eq.EquipName != null)
                {
                    equip = Game.GameData.GetEquipment(eq.EquipName);
                }
                else
                {
                    equip = Game.GameData.GetEquipment(eq.EquipHash);
                }
                if (equip != null)
                {
                    Character.Items.Add(new NetCargo()
                    {
                        Equipment = equip, Hardpoint = hp, Health = 1, Count = 1
                    });
                }
            }
            foreach (var cg in sg.Player.Cargo)
            {
                Equipment equip;
                if (cg.CargoName != null)
                {
                    equip = Game.GameData.GetEquipment(cg.CargoName);
                }
                else
                {
                    equip = Game.GameData.GetEquipment(cg.CargoHash);
                }
                if (equip != null)
                {
                    Character.Items.Add(new NetCargo()
                    {
                        Equipment = equip, Count = cg.Count
                    });
                }
            }
            rpcClient.UpdateInventory(Character.Credits, GetShipWorth(), Character.EncodeLoadout());
            if (Base != null)
            {
                InitStory(sg);
                PlayerEnterBase();
            }
            else
            {
                InitStory(sg);
                SpaceInitialSpawn(sg);
            }
        }