public int TryPickUp(BagInfo bag, int pick_num)
    {
        int finalltPick = CheckMaxGet(bag);

        Left -= pick_num > finalltPick ? finalltPick : pick_num;
        return(pick_num > finalltPick ? finalltPick : pick_num);
    }
Beispiel #2
0
        /// <summary>
        /// 获取可使用的药水。
        /// </summary>
        /// <returns>可使用的药水所在的背包格子信息。</returns>
        public static ItemInfo GetPotion()
        {
            int     level   = PlayerData.Instance.BaseAttr.Level;
            BagInfo baginfo = PlayerData.Instance.BagData.GetBagInfo(BagType.ITEM_BAG_TYPE_COMMON);

            if (baginfo == null)
            {
                return(null);
            }
            foreach (var kvp in baginfo.ItemInfos)
            {
                ItemInfo iteminfo = kvp.Value;
                if (Potions.Contains(iteminfo.ID))
                {
                    LuaTable cfg = ConfigManager.Instance.BagItem.GetItemConfig(iteminfo.ID);
                    if (cfg == null)
                    {
                        continue;
                    }
                    if (level >= cfg.Get <int>("level"))
                    {
                        return(iteminfo);
                    }
                }
            }
            LogMgr.LogAI("AutoAICheckPotion.GetPotion. Can not find useful potion!");
            return(null);
        }
 public void LoadFromBagInfo()
 {
     if (!isInit)
     {
         return;
     }
     bagInfo = PlayerInfoManager.Instance.PlayerInfo.bag;
     if (bagInfo == null)
     {
         return;
     }
     Clear();
     SetBagCells();
     //Debug.Log("当前背包中物品数量" + PlayerInfoManager.Self.playerInfo.bag.itemList.Count);
     //Debug.Log(PlayerInfoManager.Self.playerInfo.bag.itemList.Find(i => i.Item == item) != null ? PlayerInfoManager.Self.playerInfo.bag.itemList.Find(i => i.Item == item).Quantity.ToString() : string.Empty);
     foreach (ItemInfo item in bagInfo.itemList)
     {
         for (int i = 0; i < bagCells.Count; i++)
         {
             if (bagCells[i].transform.childCount <= 0)
             {
                 if (item != null && item.Quantity > 0)
                 {
                     ItemAgent tempCell = (Instantiate(itemCellPrefab, bagCells[i].transform) as GameObject).GetComponent <ItemAgent>();
                     tempCell.itemInfo = item;
                     tempCell.isStored = false;
                     itemAgents.Add(tempCell);
                 }
                 break;
             }
         }
     }
 }
Beispiel #4
0
 public void OnSell(int sell_num, BagInfo bag)
 {
     if (sell_num <= 0)
     {
         return;
     }
     if (isSoldOut)
     {
         throw new System.Exception("已售罄");
     }
     if (sellOutAble)
     {
         int finallySell = NumForSell > sell_num ? sell_num : NumForSell;
         NumForSell -= Item.OnBuy(bag, finallySell);
         //Debug.Log(NumForSell);
         if (NumForSell <= 0)
         {
             isSoldOut = true;
         }
     }
     else
     {
         Item.OnBuy(bag, sell_num);
     }
 }
Beispiel #5
0
    public CardBag()
    {
        SetPropertyObjectID((int)MVCPropertyID.enCardBag);

        //m_raceSelected                  = new List<int>();

        //m_occSelected                   = new List<int>();

        WorldParamInfo worldParamInfo = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enCardBagID);

        if (null == worldParamInfo)
        {
            return;
        }

        BagInfo bagInfo = GameTable.BagTableAsset.LookUp(worldParamInfo.IntTypeValue);

        if (null == bagInfo)
        {
            return;
        }


        m_bagTableInfo = bagInfo;

        InitSortString();
    }
Beispiel #6
0
    public bool Check(BagInfo bag, int multiple)
    {
        if (Material == null)
        {
            return(false);
        }
        ItemInfo find = bag.itemList.Find(i => i.ItemID == Material.ID);

        if (find != null)
        {
            State = Material.Name + find.Quantity + "/" + Required + "\n";
            if (find.Quantity / (Required * multiple) > 0)
            {
                IsEnough = true;
                return(true);
            }
            else
            {
                IsEnough = false;
                return(false);
            }
        }
        State    = Material.Name + "0/" + Required + "\n";
        IsEnough = false;
        return(false);
    }
Beispiel #7
0
        private void ShowSearchResultExecuted()
        {
            //ProgressBarVisible = true;
            BagInfo mBagInfo = new BagInfo();

            if (Mvx.Resolve <IValidation>().Is10Digits(BagtagNo) && !String.IsNullOrEmpty(BagtagNo))
            {
                GetBagInfoInput baginput = new GetBagInfoInput()
                {
                    Bagtag = BagtagNo, DeviceName = "Apple", Station = "123", Username = "******", Version = "1"
                };
                var bagInfo = new GetBagInfoResponse();
                try
                {
                    if (Mvx.Resolve <IValidation>().ObjectIsNotNull(baginput))
                    {
                        bagInfo = Mvx.Resolve <IRestService>().GetBagInfo(baginput);
                    }
                }
                catch (Exception e)
                {
                    Mvx.Resolve <IUserDialogs>().Toast("An error occurred!", null);
                    _logger.Trace("ShowSearchResultExecuted ex: " + e.ToString() + "");
                }

                if (bagInfo.StatusCode == "0")
                {
                    BagScanPoint        scanPoint;
                    List <BagScanPoint> mscanHistory = new List <BagScanPoint>();
                    foreach (var item in bagInfo.BagHistory)
                    {
                        scanPoint           = new BagScanPoint();
                        scanPoint.Icon      = item.ScanType;
                        scanPoint.ScanPoint = item.Location;
                        scanPoint.ScanTime  = item.DateTime;
                        mscanHistory.Add(scanPoint);
                    }
                    mBagInfo.Bagtag        = BagtagNo;
                    mBagInfo.PaxName       = bagInfo.PaxName;
                    mBagInfo.PaxItinerary  = bagInfo.PaxItinerary;
                    mBagInfo.Latitude      = bagInfo.Latitude;
                    mBagInfo.Longitude     = bagInfo.Longitude;
                    mBagInfo.FltCode       = bagInfo.FltCode;
                    mBagInfo.FltDate       = bagInfo.FltDate;
                    mBagInfo.FltNum        = bagInfo.FltNum;
                    mBagInfo.BagScanPoints = mscanHistory;
                    ISqliteService <BagInfo> bagRepo = new SqliteService <BagInfo>();
                    var user = bagRepo.InsertUpdate(mBagInfo);
                    _navigationService.Navigate <BottomNavigationViewModel, BagInfo>(mBagInfo);
                    _navigationService.Navigate <BagInfoViewModel, BagInfo>(mBagInfo);
                }
            }
            else
            {
                Mvx.Resolve <IUserDialogs>().Alert("Bagtag no must contains 10 digits.", "Invalid Bagtag no!", "Dismiss");
            }

            //ProgressBarVisible = false;
        }
    public int TryPickUpAll(BagInfo bag)
    {
        int finallyPick = CheckMaxGet(bag);

        //Debug.Log(finallyPick);
        Left -= finallyPick;
        return(finallyPick);
    }
Beispiel #9
0
        private int GetCountOfBagsInside(BagInfo info, BagInfo[] bags)
        {
            if (!info.SubBags.Any())
            {
                return(0);
            }

            return(info.SubBags.Select(it => it.count + (it.count * GetCountOfBagsInside(bags.First(b => b.Kind == it.kind), bags))).Sum());
        }
 // Use this for initialization
 public void Init()
 {
     isInit     = true;
     bagInfo    = PlayerInfoManager.Instance.PlayerInfo.bag;
     bagCells   = new List <GameObject>();
     itemAgents = new List <ItemAgent>();
     LoadFromBagInfo();
     CloseUI();
 }
Beispiel #11
0
    public virtual int OnBuy(BagInfo bag, int buy_num)
    {
        if (buy_num <= 0)
        {
            return(0);
        }
        if (bag.Money < BuyPrice * buy_num)
        {
            throw new System.Exception("金钱不足");
        }
        int finallyBuy = 0;

        if (StackAble)
        {
            ItemInfo itemInBag = bag.itemList.Find(i => i.ItemID == ID);
            try
            {
                if (itemInBag != null)
                {
                    finallyBuy = itemInBag.Quantity;
                    bag.GetItem(this, buy_num);
                    itemInBag  = bag.itemList.Find(i => i.ItemID == ID);
                    finallyBuy = Mathf.Abs(itemInBag.Quantity - finallyBuy);
                }
                else
                {
                    //finallyBuy = MaxCount > buy_num ? buy_num : MaxCount;
                    bag.GetItem(this, buy_num);
                    itemInBag = bag.itemList.Find(i => i.ItemID == ID);
                    if (itemInBag != null)
                    {
                        finallyBuy = itemInBag.Quantity;
                    }
                }
                bag.LoseMoney(BuyPrice * finallyBuy);
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(ex.Message);
            }
        }
        else
        {
            try
            {
                finallyBuy = bag.itemList.FindAll(i => i.ItemID == ID).Count;
                bag.GetItem(this, buy_num);
                finallyBuy = bag.itemList.FindAll(i => i.ItemID == ID).Count - finallyBuy;
                bag.LoseMoney(BuyPrice * finallyBuy);
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(ex.Message);
            }
        }
        return(finallyBuy);
    }
Beispiel #12
0
        public async Task RegisterNewBag(ushort trainId, BagInfo bagInfo)
        {
            var bags = new List <BagInfo>(await LoadBags(trainId));

            bags.Add(bagInfo);
            var fp = Path.Combine(metaFolder, $"bgs_{trainId:D3}");

            File.WriteAllText(fp,
                              JsonConvert.SerializeObject(bags.ToArray()));
        }
Beispiel #13
0
    public int GetBagCapcity()
    {
        BagInfo info    = GameTable.BagTableAsset.LookUp((int)BAGTYPEENUM.enCardBagType);
        int     capcity = 50;

        if (info != null)
        {
            capcity = info.m_initalSize;
        }
        return(capcity + UserProps.GetProperty_Int32(UserProperty.bagCapcity_expandedSize));
    }
Beispiel #14
0
    public BagInfo LookUp(int id)
    {
        BagInfo info = null;

        if (m_map.TryGetValue(id, out info))
        {
            return(info);
        }

        return(null);
    }
Beispiel #15
0
    public void ShowAddCardBagPanel(int addNum, int expandNum)
    {
        string         text      = string.Format(Localization.Get("ExpandBagSpace"), addNum);
        string         titelText = Localization.Get("ExpandBagSuccess");
        BagInfo        info      = GameTable.BagTableAsset.LookUp((int)BAGTYPEENUM.enCardBagType);
        string         useText   = string.Format(Localization.Get("BagSpaceStatus"), (expandNum + info.m_initalSize));
        WorldParamInfo param     = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enExtendBagTipsIconId);
        int            iconId    = param.IntTypeValue;

        RUSure.Singleton.ShowPanelText(text, titelText, useText, iconId);
    }
    /// <summary>
    /// 仅用于检查掉落物品的拾取量,
    /// 进行这一步是为了避免物品的拾取不符合背包的设计逻辑
    /// </summary>
    /// <param name="bag">用于检查的背包数据</param>
    /// <returns>最大拾取量</returns>
    public int CheckMaxGet(BagInfo bag)
    {
        ItemInfo info   = bag.itemList.Find(i => i.ItemID == ItemID);
        int      maxGet = 0;

        if (info == null)
        {
            maxGet = bag.IsMax ? 0 : StackAble ? Left : bag.MaxSize - bag.Current_Size > Left ? Left : bag.MaxSize - bag.Current_Size;
            if (maxGet == 0)
            {
                return(0);
            }
            if ((bag.Current_Weight + Item.Weight * maxGet) / bag.MaxWeight > 1.5f)
            {
                int i = 0;
                while (i < maxGet)
                {
                    if ((bag.Current_Weight + Item.Weight * i) / bag.MaxWeight <= 1.5f && ((bag.Current_Weight + Item.Weight * (i + 1)) / bag.MaxWeight > 1.5f))
                    {
                        maxGet = i;
                        break;
                    }
                    i++;
                }
            }
        }
        else
        {
            maxGet = StackAble ?
                     ((info.MaxCount - info.Quantity > Left) ?
                      Left
        : (info.MaxCount - info.Quantity))
          : bag.IsMax ? 0 : bag.MaxSize - bag.Current_Size > Left ? Left : bag.MaxSize - bag.Current_Size;
            if (maxGet == 0)
            {
                return(0);
            }
            if ((bag.Current_Weight + Item.Weight * maxGet) / bag.MaxWeight > 1.5f)
            {
                int i = 0;
                while (i < maxGet)
                {
                    if ((bag.Current_Weight + Item.Weight * i) / bag.MaxWeight <= 1.5f && ((bag.Current_Weight + Item.Weight * (i + 1)) / bag.MaxWeight > 1.5f))
                    {
                        maxGet = i;
                        break;
                    }
                    i++;
                }
            }
        }
        return(maxGet);
    }
Beispiel #17
0
 public Bag(ushort trainId, BagInfo bagInfo,
            IMetaStorage metaStorage,
            IBucketFactory bucketFactory)
 {
     this.trainId       = trainId;
     BagInfo            = bagInfo;
     this.metaStorage   = metaStorage;
     this.bucketFactory = bucketFactory;
     if (bagInfo.BagSettings.PerBucketMessages > (2 << 16))
     {
         throw new ArgumentException("PerBucketMessages must be < 2^16");
     }
 }
    public int CheckMaxMake(BagInfo bag)
    {
        List <int> nums = new List <int>();

        foreach (MaterialInfo minfo in Item.MaterialsList)
        {
            ItemInfo find = bag.itemList.Find(i => i.ItemID == minfo.Material.ID);
            if (find != null)
            {
                nums.Add(find.Quantity / minfo.Required);
            }
            else
            {
                nums.Add(0);
            }
        }
        nums.Sort((x, y) => {
            if (x < y)
            {
                return(1);
            }
            else if (x > y)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        });
        MaxMake = nums[0];
        ItemInfo find2 = bag.itemList.Find(i => i.ItemID == Item.ID);

        if (find2 != null)
        {
            if (find2.IsMax)
            {
                MaxMake = 0;
            }
            if (MaxMake <= 0)
            {
                return(0);
            }
            MaxMake = find2.MaxCount - find2.Quantity > MaxMake ? find2.StackAble ? MaxMake : find2.MaxCount - find2.Quantity : 1;
        }
        else
        {
            MaxMake = Item.MaxCount > MaxMake ? MaxMake : Item.MaxCount;
        }
        return(MaxMake);
    }
Beispiel #19
0
        public BagItemPicker(BagInfo bagInfo) : base()
        {
            m_bagInfo                = bagInfo;
            m_rand                   = new Random();
            m_lastItem               = -1;
            m_copyBagItemsCallback   = null;
            m_deleteBagItemsCallback = null;
            InitializeComponent();
            CeebeetleWindowInit();
            PopulateItems();
            CheckBagItems();
            cbSelectionMode.SelectedIndex = 0;
            string strDeleteButtonTooltip = btnDelete.ToolTip.ToString();

            SetTooltip(btnDelete, string.Format(strDeleteButtonTooltip, m_bagInfo.Bag.Name));
        }
Beispiel #20
0
    public void Load(byte[] bytes)
    {
        m_map = new Dictionary <int, BagInfo>();
        BinaryHelper helper = new BinaryHelper(bytes);

        int sceneCount = helper.ReadInt();

        for (int index = 0; index < sceneCount; ++index)
        {
            BagInfo info = new BagInfo();

            info.Load(helper);

            m_map.Add(info.m_id, info);
        }
    }
Beispiel #21
0
 public void CopyInfo(PlayerInfo source)
 {
     ID                  = source.ID;
     CharacterName       = source.CharacterName;
     level               = source.level;
     IsAlive             = source.IsAlive;
     IsTired             = source.IsTired;
     IsExhausted         = source.IsExhausted;
     equipments          = source.equipments;
     Li                  = source.Li;
     Ti                  = source.Ti;
     Qi                  = source.Qi;
     Ji                  = source.Ji;
     Min                 = source.Min;
     HP                  = source.HP;
     Current_HP          = source.Current_HP;
     MP                  = source.MP;
     Current_MP          = source.Current_MP;
     Endurance           = source.Endurance;
     Current_Endurance   = source.Current_Endurance;
     BlockAmount         = source.BlockAmount;
     Current_BlockAmount = source.Current_BlockAmount;
     NextExp             = source.NextExp;
     Current_Exp         = source.Current_Exp;
     SkillPointOne       = source.SkillPointOne;
     SkillPointTwo       = source.SkillPointTwo;
     Neili               = source.Neili;
     ATK                 = source.ATK;
     DEF                 = source.DEF;
     Hit                 = source.Hit;
     Dodge               = source.Dodge;
     Crit                = source.Crit;
     Res_Blowed          = source.Res_Blowed;
     Res_Floated         = source.Res_Floated;
     Res_Repulsed        = source.Res_Repulsed;
     Res_Rigidity        = source.Res_Rigidity;
     Res_Stuned          = source.Res_Stuned;
     Res_Falled          = source.Res_Falled;
     //status = new List<StatuInfo>();
     //buffs = source.buffs;
     bag           = source.bag;
     warehouseInfo = source.warehouseInfo;
     mount         = source.mount;
     //MoveSpeed = source.MoveSpeed;
 }
Beispiel #22
0
    public int TakeOutItem(ItemInfo item, BagInfo bagInfo, int take_num)
    {
        if (item == null || take_num <= 0)
        {
            return(0);
        }
        if (Current_Size <= 0)
        {
            throw new System.Exception("仓库为空");
        }
        ItemInfo tempitem = itemList.Find(i => i.Item == item.Item);

        if (tempitem == null)
        {
            throw new System.Exception("该物品未在仓库中");
        }
        if (tempitem.Quantity <= 0)
        {
            throw new System.Exception("该物品为空");
        }
        int      finallyTake = tempitem.StackAble ? tempitem.Quantity - take_num > 0 ? take_num : tempitem.Quantity : 1;
        ItemInfo itemInBag   = bagInfo.itemList.Find(i => i.ItemID == item.ItemID);
        int      temp        = 0;

        if (itemInBag != null)
        {
            temp = itemInBag.Quantity;
        }
        bagInfo.GetItem(item.Item, finallyTake);
        itemInBag          = bagInfo.itemList.Find(i => i.ItemID == item.ItemID);
        temp               = itemInBag.Quantity - temp;
        finallyTake        = finallyTake > temp ? temp : finallyTake;
        tempitem.Quantity -= finallyTake;
        if (tempitem.Quantity <= 0)
        {
            Current_Size -= 1;
            itemList.Remove(tempitem);
        }
        if (Current_Size < MaxSize)
        {
            IsMax = false;
        }
        return(finallyTake);
    }
 public void Make(BagInfo bag, int num)
 {
     if (num <= 0)
     {
         return;
     }
     CheckMaxMake(bag);
     if (num > MaxMake)
     {
         throw new System.Exception("无法制作该数量的该物品");
     }
     if (bag.Money < Cost * num)
     {
         throw new System.Exception("制作费用不足");
     }
     if (bag.IsMax)
     {
         throw new System.Exception("行囊空间不足");
     }
     if (bag.IsMaxWeight)
     {
         throw new System.Exception("超重状态无法制作");
     }
     if ((bag.Current_Weight + Item.Weight * num) / bag.MaxWeight >= 1.5f)
     {
         throw new System.Exception("该物品太重了");
     }
     Check(bag, num);
     if (!MakeAble)
     {
         throw new System.Exception("材料不足,无法制作");
     }
     foreach (MaterialInfo minfo in Item.MaterialsList)
     {
         ItemBase find = bag.itemList.Find(m => m.ItemID == minfo.Material.ID).Item;
         if (find == null)
         {
             throw new System.Exception("找不到该材料");
         }
         bag.LoseItem(find, minfo.Required * num);
     }
     bag.GetItem(Item, num);
     bag.LoseMoney(Cost * num);
 }
Beispiel #24
0
    public EquipBag()
    {
        SetPropertyObjectID((int)MVCPropertyID.enEquipBag);

        m_equipList    = new Dictionary <int, Equip>();
        m_materialList = new Dictionary <int, int>();

        m_sortedEquipList = new Dictionary <int, Equip>();

        WorldParamInfo worldParamInfo = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enEquipBagID);

        if (null == worldParamInfo)
        {
            return;
        }

        BagInfo bagInfo = GameTable.BagTableAsset.LookUp(worldParamInfo.IntTypeValue);

        if (null == bagInfo)
        {
            return;
        }

        m_equipBagInfo = bagInfo;

        m_equipCapacity = bagInfo.m_initalSize;

        worldParamInfo = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enMaterialBagID);
        if (null == worldParamInfo)
        {
            return;
        }

        bagInfo = GameTable.BagTableAsset.LookUp(worldParamInfo.IntTypeValue);

        if (null == bagInfo)
        {
            return;
        }

        m_materialBagInfo = bagInfo;

        m_materialCapacity = bagInfo.m_initalSize;
    }
Beispiel #25
0
 public void OnDiscardAll(ItemBase item, BagInfo bag)
 {
     if (Quantity <= 0)
     {
         throw new System.Exception("该物品为空");
     }
     if (!bag.itemList.Exists(i => i.Item == Item))
     {
         throw new System.Exception("该物品未在行囊里");
     }
     if (!StackAble)
     {
         throw new System.Exception("该物品不可全数丢弃");
     }
     bag.Current_Weight -= item.Weight * Quantity;
     Quantity            = 0;
     bag.itemList.RemoveAll(i => i.Item == item);
     bag.Current_Size--;
     bag.CheckSizeAndWeight();
 }
Beispiel #26
0
 public PlayerInfo()
 {
     ID                             = 100000;
     CharacterName                  = "大侠";
     Level                          = 0;
     IsAlive                        = true;
     IsMounting                     = false;
     IsTired                        = false;
     IsExhausted                    = false;
     Li                             = 5;
     Ti                             = 5;
     Qi                             = 5;
     Ji                             = 5;
     Min                            = 5;
     HP                             = Ti * 100;
     Current_HP                     = HP;
     MP                             = Li * 20 + Ti * 30;
     Current_MP                     = MP;
     Endurance                      = Ti * 2 + Qi;
     Current_Endurance              = Endurance;
     Neili                          = Qi;
     ATK                            = Li * 3;
     DEF                            = Qi * 3;
     Hit                            = Ji * 0.4f;
     Dodge                          = Min;
     Crit                           = Ji * 0.1f;
     Res_Blowed                     =
         Res_Floated                =
             Res_Repulsed           =
                 Res_Rigidity       =
                     Res_Stuned     =
                         Res_Falled = 0.0f;
     status                         = new List <StatuInfo>();
     //buffs = new List<BuffInfo>();
     equipments    = new Equipments();
     bag           = new BagInfo(39, 150);
     warehouseInfo = new WarehouseInfo(300);
     mount         = null;
     //MoveSpeed = 5.0f;
 }
        private void ShowSearchResultExecuted()
        {
            //Sample
            var             bagInfo  = new GetBagInfoResponse();
            GetBagInfoInput baginput = new GetBagInfoInput()
            {
                Bagtag = "1234", DeviceName = "Apple", Station = "123", Username = "******", Version = "1"
            };

            try
            {
                bagInfo = Mvx.Resolve <IRestService>().GetBagInfo(baginput);
                var                 mBagInfo = new BagInfo();
                BagScanPoint        scanPoint;
                List <BagScanPoint> mscanHistory = new List <BagScanPoint>();
                foreach (var item in bagInfo.BagHistory)
                {
                    scanPoint           = new BagScanPoint();
                    scanPoint.Icon      = item.ScanType;
                    scanPoint.ScanPoint = item.Location;
                    scanPoint.ScanTime  = item.DateTime;
                    mscanHistory.Add(scanPoint);
                }
                mBagInfo.Bagtag        = "1111111111";
                mBagInfo.PaxName       = bagInfo.PaxName;
                mBagInfo.PaxItinerary  = bagInfo.PaxItinerary;
                mBagInfo.Latitude      = bagInfo.Latitude;
                mBagInfo.Longitude     = bagInfo.Longitude;
                mBagInfo.FltCode       = bagInfo.FltCode;
                mBagInfo.FltDate       = bagInfo.FltDate;
                mBagInfo.FltNum        = bagInfo.FltNum;
                mBagInfo.BagScanPoints = mscanHistory;
                _navigationService.Navigate <BottomNavigationViewModel, BagInfo>(mBagInfo);
                _navigationService.Navigate <BagInfoViewModel, BagInfo>(mBagInfo);
            }
            catch (Exception e)
            {
                Mvx.Resolve <IUserDialogs>().Toast("An error occurred!", null);
            }
        }
Beispiel #28
0
        /// <summary>
        /// 增加金钱
        /// </summary>
        /// <param name="sm"></param>
        /// <param name="roleId"></param>
        /// <param name="item"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public async Task <BagInfo> GoldCtrl(int itemId, long count)
        {
            BagInfo result = new BagInfo();
            var     item   = GetItemById(itemId);

            if (item == null)
            {
                return(null);
            }
            var money  = item.Count * count;
            var bgInfo = LogicServer.User.bag;

            bgInfo.Items.TryGetValue(item.Id, out Model.Data.General.Item value);

            checked
            {
                try
                {
                    value.CurCount += money;    //更新值
                }
                catch (OverflowException ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            await BagDataHelper.Instance.UpdateBagByRoleId(bgInfo, LogicServer.User.role.Id);    //保存

            result.CurUsedCell   = bgInfo.CurUsedCell;
            result.MaxCellNumber = bgInfo.MaxCellNumber;
            foreach (var i in bgInfo.Items)
            {
                result.Items.Add(i.Key, new LoadRoleBagInfo()
                {
                    CurCount = i.Value.CurCount,
                    OnSpace  = i.Value.OnSpace
                });
            }
            return(result);
        }
Beispiel #29
0
 public virtual void OnSell(BagInfo bag, int sell_num)
 {
     if (sell_num <= 0)
     {
         return;
     }
     if (SellAble)
     {
         ItemInfo itemInBag = bag.itemList.Find(i => i.Item == this);
         if (itemInBag == null)
         {
             throw new System.Exception("行囊中不存在该物品");
         }
         int finallySell = itemInBag.Quantity > sell_num ? sell_num : itemInBag.Quantity;
         bag.GetMoney(SellPrice * finallySell);
         bag.LoseItem(itemInBag.Item, finallySell);
     }
     else
     {
         throw new System.Exception("该物品不可贩卖");
     }
 }
Beispiel #30
0
    ///   <summary>
    ///   检查材料收集进度
    ///   </summary>
    ///   <param name="bag">指定要产生影响的背包数据</param>
    ///   <param name="num">指定数量</param>
    ///   <param name="info">传出材料收集进度及信息以便显示在UI中</param>
    /// <returns>材料收集足够,可以制作时返回True</returns>
    public bool CheckMaterials(BagInfo bag, int num, out List <string> info)
    {
        info = new List <string>();
        if (MaterialsList == null)
        {
            return(false);
        }
        List <bool> checklist = new List <bool>();

        foreach (MaterialInfo minfo in MaterialsList)
        {
            minfo.Check(bag, num);
            checklist.Add(minfo.IsEnough);
            minfo.IsEnough = false;
            info.Add(minfo.State);
        }
        bool result = true;

        foreach (bool check in checklist)
        {
            result = result && check;
        }
        return(result);
    }