Exemplo n.º 1
0
        private IEnumerator BuySpaceBagCoroutine()
        {
            using (new BlockingLayerHelper(0))
            {
                var msg = NetManager.Instance.BuySpaceBag(mUnLockBagId, mUnLockindex, mKeyCost);
                yield return(msg.SendAndWaitUntilDone());

                if (msg.State == MessageState.Reply)
                {
                    if (msg.ErrorCode == (int)ErrorCodes.OK)
                    {
                        EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(304));
                        var bagData = PlayerDataManager.Instance.GetBag(mUnLockBagId);

                        var isFull = bagData.Size == bagData.Capacity;

                        var count = 0;
                        for (var i = 0; i <= mUnLockindex; i++)
                        {
                            if (bagData.Items[i].Status == (int)eBagItemType.Lock ||
                                bagData.Items[i].Status == (int)eBagItemType.FreeLock)
                            {
                                bagData.Items[i].Status = (int)eBagItemType.UnLock;
                                count++;
                            }
                        }


                        var tbBagBase = Table.GetBagBase(mUnLockBagId);
                        var star      = mUnLockindex + 1 - tbBagBase.InitCapacity;

                        if (star >= bagData.Items.Count)
                        {
                            yield break;
                        }
                        star = star / tbBagBase.ChangeBagCount;
                        var tbUpgrade = Table.GetSkillUpgrading(tbBagBase.Expression);
                        var result    = tbUpgrade.GetSkillUpgradingValue(star);
                        result            *= tbBagBase.TimeMult * 60;
                        bagData.UnlockTime = Game.Instance.ServerTime.AddSeconds(result);

                        if (mUnLockBagId == 0)
                        {
                            if (isFull)
                            {
                                var playerData = PlayerDataManager.Instance.PlayerDataModel;
                                playerData.Bags.IsEquipFull = false;
                                var e = new EquipBagNotFullChange();
                                EventDispatcher.Instance.DispatchEvent(e);
                            }
                        }
                        SetFreeIcon();
                        bagData.Capacity += count;
                    }
                    else if (msg.ErrorCode == (int)ErrorCodes.DiamondNotEnough)
                    {
                        EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(305));
                    }
                    else
                    {
                        UIManager.Instance.ShowNetError(msg.ErrorCode);
                        Logger.Error("BuySpaceBag Error!............ErrorCode..." + msg.ErrorCode);
                    }
                }
                else
                {
                    Logger.Error("BuySpaceBag Error!............State..." + msg.State);
                }
            }
        }
Exemplo n.º 2
0
        //回收包
        private IEnumerator RebirthCoroutine(Int32Array TempEquipList)
        {
            using (new BlockingLayerHelper(0))
            {
                var _msg = NetManager.Instance.RecoveryEquip(RecycleType, TempEquipList);
                yield return(_msg.SendAndWaitUntilDone());

                if (_msg.State == MessageState.Reply)
                {
                    if (_msg.ErrorCode == (int)ErrorCodes.OK)
                    {
                        //var _list = new Int32Array();
                        //_list.Items.Add(2800);
                        //PlayerDataManager.Instance.SetFlagNet(_list);

                        if (RecycleType == 0)
                        {
                            RecycleData.IsSellEffect = true;
                            RecycleData.IsSellEffect = false;

                            for (int i = 0; i < TempEquipList.Items.Count; i++)
                            {
                                var _item = PlayerDataManager.Instance.GetItem((int)eBagType.Equip, TempEquipList.Items[i]);
                                if (_item != null)
                                {
                                    PlatformHelper.UMEvent("EquipSell", _item.ItemId.ToString());
                                }
                            }
                        }
                        else
                        {
                            RecycleData.IsRecycleEffect = true;
                            RecycleData.IsRecycleEffect = false;


                            for (int i = 0; i < TempEquipList.Items.Count; i++)
                            {
                                var _item = PlayerDataManager.Instance.GetItem((int)eBagType.Equip, TempEquipList.Items[i]);

                                if (_item != null)
                                {
                                    PlatformHelper.UMEvent("EquipRecycle", _item.ItemId.ToString());
                                }
                            }
                        }


                        var _baseData = PlayerDataManager.Instance.GetBag((int)eBagType.Equip);
                        var _isFull   = _baseData.Size == _baseData.Capacity;
                        for (var i = 0; i < TempEquipList.Items.Count; i++)
                        {
                            var _index = TempEquipList.Items[i];
                            if (_index < _baseData.Items.Count)
                            {
                                _baseData.Items[_index].ItemId   = -1;
                                _baseData.Items[_index].IsChoose = false;
                            }
                        }
                        InitializeRebirthBags();
                        RefurbishBags();
                        _baseData.Size -= TempEquipList.Items.Count;
                        if (_isFull && TempEquipList.Items.Count > 0)
                        {
                            var _e = new EquipBagNotFullChange();
                            EventDispatcher.Instance.DispatchEvent(_e);
                        }
                        RecycleData.UIGetShow = 0;
                    }
                    else
                    {
                        UIManager.Instance.ShowNetError(_msg.ErrorCode);
                    }
                }
                else
                {
                    var _e = new ShowUIHintBoard(220821);
                    EventDispatcher.Instance.DispatchEvent(_e);
                }
            }
        }