Пример #1
0
 /// <summary>
 /// 在物品列表中增加指定type和index的物品num个
 /// </summary>
 /// <param name="type"></param>
 /// <param name="index"></param>
 /// <param name="num"></param>
 public void AddGoods(int type, int index, int num)
 {
     if (type >= 1 && type <= 7)
     {
         // 装备
         if (EquipList.Where(m => m.Type == type && m.Index == index).FirstOrDefault() is BaseGoods equip)   //已有物品
         {
             equip.AddGoodsNum(num);
         }
         else    //增加物品
         {
             BaseGoods newGoods = Context.LibData.GetGoods(type, index);
             newGoods.GoodsNum = num;
             EquipList.Add(newGoods);
         }
     }
     else if (type >= 8 && type <= 14)
     {
         // 物品
         if (GoodsList.Where(m => m.Type == type && m.Index == index).FirstOrDefault() is BaseGoods goods)   //已有物品
         {
             goods.AddGoodsNum(num);
         }
         else    //增加物品
         {
             BaseGoods newGoods = Context.LibData.GetGoods(type, index);
             newGoods.GoodsNum = num;
             GoodsList.Add(newGoods);
         }
     }
 }
Пример #2
0
    public BattlePlayerData(MapPlayerData mapPlayerData, BattlePlayer owner) : base(null, null)
    {
        Name           = mapPlayerData.Name;
        Level          = mapPlayerData.Level;
        HP             = mapPlayerData.HP;
        MaxHP          = mapPlayerData.MaxHP;
        MP             = mapPlayerData.MP;
        MaxMP          = mapPlayerData.MaxMP;
        HeadIcon       = mapPlayerData.HeadIcon;
        MapSkillID     = mapPlayerData.MapSkillID;
        BattleSkillID  = mapPlayerData.BattleSkillID;
        UsingCharacter = mapPlayerData.UsingCharacter;
        Food           = mapPlayerData.Food;
        MaxFood        = mapPlayerData.MaxFood;
        Gold           = mapPlayerData.Gold;
        SkillId        = mapPlayerData.BattleSkillID;
        ClassData      = mapPlayerData.ClassData;
        //玩家的行动值初始
        AP = MaxAP = 0;

        CardList.Clear();

        EquipList.Capacity = (mapPlayerData.EquipList.Count);
        for (int i = 0; i < mapPlayerData.EquipList.Count; i++)
        {
            List <int> actions = mapPlayerData.EquipList[i].Data.ActionTypes;
            for (int j = 0; j < actions.Count; j++)
            {
                if (actions[i] == (int)BattleActionType.AddEquipment)
                {
                    EquipList.Add(new BattleEquipData(mapPlayerData.EquipList[j].Data.ActionParams[0], owner));
                    break;
                }
            }
        }
        CardList.Capacity = mapPlayerData.CardList.Count;
        for (int i = 0; i < mapPlayerData.CardList.Count; i++)
        {
            CardList.Add(new BattleCardData(mapPlayerData.CardList[i].CardId, owner));
        }
        BuffList.Capacity = mapPlayerData.BuffList.Count;
        for (int i = 0; i < mapPlayerData.BuffList.Count; i++)
        {
            BuffList.Add(new BattleBuffData(mapPlayerData.BuffList[i].Data.ActionParams[0], -1, 0, new BattleCardData(mapPlayerData.BuffList[i].CardId, owner), owner, owner));
        }

        CurrentCardList.Capacity = CardList.Count;
        for (int i = 0; i < CardList.Count; i++)
        {
            CurrentCardList.Add(new BattleCardData(CardList[i].CardId, owner));
        }
    }
Пример #3
0
        public void Deserialize(BinaryReader binaryReader)
        {
            Clear();

            int size = binaryReader.ReadInt32();

            for (int i = 0; i < size; i++)
            {
                BaseGoods equipment = Context.LibData.GetGoods(binaryReader.ReadInt32(), binaryReader.ReadInt32());
                equipment.GoodsNum = binaryReader.ReadInt32();
                EquipList.Add(equipment);
            }

            size = binaryReader.ReadInt32();
            for (int i = 0; i < size; i++)
            {
                BaseGoods goods = Context.LibData.GetGoods(binaryReader.ReadInt32(), binaryReader.ReadInt32());
                goods.GoodsNum = binaryReader.ReadInt32();
                GoodsList.Add(goods);
            }
        }