Beispiel #1
0
        public PlayerUnit()
        {
            Name   = "赵日天";
            UnitHp = UnitMaxHp = 50;
            Inventorys.Add(new GoldStone(0));
            Inventorys.Add(new WoodStone(0));
            Inventorys.Add(new WaterStone(0));
            Inventorys.Add(new FireStone(0));
            Inventorys.Add(new SoilStone(0));

            ManMadeWeapon temp = new ManMadeWeapon();

            temp.Name       = "千机伞";
            temp.WeaponType = TheFiveElements.Gold;
            temp.WeaponCards.Add(new BasalAtkCard());
            temp.WeaponCards.Add(new BaseSwordAtkCard());
            temp.WeaponCards.Add(new GiveShieldCard());
            temp.WeaponCards.Add(new LingSwordAtkCard());
            Inventorys.Add(temp);
            Inventorys.Add((ManMadeWeapon)temp.Clone());
        }
            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);
                }
            }
            public void SetPlayerDate()
            {
                GameMainRecycle.PlayerInfo.PlayerQuest = Pquest;
                GameUnit Punit = GameMainRecycle.PlayerInfo.PlayerUnit;

                Punit.Name = Pname;
                if (Pweapon != "")
                {
                    if (Pweapon == typeof(ManMadeWeapon).Name)
                    {
                        ManMadeWeapon temp = new ManMadeWeapon();
                        temp.SetManMadeByJson(JpWeapon);
                        Punit.Equipments.UnitWeapon = temp;
                    }
                    else
                    {
                        Punit.Equipments.UnitWeapon = (Weapon)GameMainRecycle.Inventorys.Group[Pweapon].Clone();
                    }
                }

                Punit.Functions.Clear();
                foreach (var item in PFunctions)
                {
                    Punit.Functions.Add(item);
                }
                Punit.Inventorys.Clear();
                foreach (var item in Pinventorys)
                {
                    Inventory temp = (Inventory)GameMainRecycle.Inventorys.Group[item.InventoryName].Clone();
                    switch (temp.InType)
                    {
                    case Inventory.InventoryType.equipment:
                        Equipment eq = (Equipment)temp;
                        switch (eq.EqType)
                        {
                        case Equipment.EquipmentType.weapon:
                            if (item.InventoryName == typeof(ManMadeWeapon).Name)
                            {
                                ManMadeWeapon mw = new ManMadeWeapon();
                                mw.SetManMadeByJson(item.JsonString);
                                temp = mw;
                            }
                            break;

                        default:
                            break;
                        }
                        break;

                    case Inventory.InventoryType.funbook:
                        break;

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

                    default:
                        break;
                    }
                    Punit.Inventorys.Add(temp);
                }
            }