Пример #1
0
        public InventorySave ToInventorySave()
        {
            InventorySave temp = new InventorySave();

            temp.InventoryName = GetType().Name;
            temp.InventoryCont = 1;
            WeaponSave ws = new WeaponSave();

            ws.Wname = Name;
            ws.Wtype = WeaponType;
            foreach (var item in WeaponCards)
            {
                ws.Cards.Add(item.ToCardSaveString());
            }

            temp.JsonString = Newtonsoft.Json.JsonConvert.SerializeObject(ws);
            return(temp);
        }
Пример #2
0
            public void GetPlayerDate()
            {
                Pname  = GameMainRecycle.PlayerInfo.PlayerUnit.Name;
                Pquest = GameMainRecycle.PlayerInfo.PlayerQuest;
                PFunctions
                    = GameMainRecycle.PlayerInfo.PlayerUnit.Functions;
                if (GameMainRecycle.PlayerInfo.PlayerUnit.Equipments.UnitWeapon != GameMainRecycle.PlayerInfo.PlayerUnit.Equipments.WeaponEmpty)
                {
                    if (GameMainRecycle.PlayerInfo.PlayerUnit.Equipments.UnitWeapon.GetType().Name == typeof(ManMadeWeapon).Name)
                    {
                        ManMadeWeapon temp = (ManMadeWeapon)GameMainRecycle.PlayerInfo.PlayerUnit.Equipments.UnitWeapon;
                        JpWeapon = temp.ToInventorySave().JsonString;
                    }
                    Pweapon = GameMainRecycle.PlayerInfo.PlayerUnit.Equipments.UnitWeapon.GetType().Name;
                }
                else
                {
                    Pweapon = string.Empty;
                }
                Pinventorys.Clear();
                foreach (var item in GameMainRecycle.PlayerInfo.PlayerUnit.Inventorys)
                {
                    InventorySave insave = new InventorySave();
                    insave.InventoryName = item.GetType().Name;
                    switch (item.InType)
                    {
                    case Inventory.InventoryType.equipment:
                        Equipment eq = (Equipment)item;
                        switch (eq.EqType)
                        {
                        case Equipment.EquipmentType.weapon:
                            if (item.GetType().Name == typeof(ManMadeWeapon).Name)
                            {
                                ManMadeWeapon mw = (ManMadeWeapon)item;
                                insave = mw.ToInventorySave();
                            }
                            break;

                        default:
                            break;
                        }

                        break;

                    case Inventory.InventoryType.funbook:
                        insave.InventoryCont = 1;
                        break;

                    case Inventory.InventoryType.resource:
                    case Inventory.InventoryType.stone:
                        Resource temp = (Resource)item;
                        insave.InventoryCont = temp.Amount;
                        break;

                    default:
                        break;
                    }

                    Pinventorys.Add(insave);
                }
            }