Пример #1
0
        public int ConsumeStoreItem(MysteryStoreManager _this, int storeId, int consumeCount)
        {
            var tbStore = Table.GetStore(storeId);

            if (null == tbStore)
            {
                return((int)ErrorCodes.Error_StoreID);
            }
            var storeData = _this.mDbData.MysteryStoreInfo;

            if (null == storeData)
            {
                return((int)ErrorCodes.Unknow);
            }
            for (int i = 0; i < storeData.Count; i++)
            {
                var data = storeData[i];
                if (data.ItemId == storeId)
                {
                    if (_this.mDbData.MysteryStoreInfo[i].ItemCount < consumeCount)
                    {
                        return((int)ErrorCodes.Error_TreasureStoreItemCountNotEnough);
                    }
                    else
                    {
                        _this.mDbData.MysteryStoreInfo[i].ItemCount -= consumeCount;
                        return((int)ErrorCodes.OK);
                    }
                }
            }
            return((int)ErrorCodes.Error_TreasureStoreBuyFailed);
        }
Пример #2
0
        private void ReloadTable(IEvent ievent)
        {
            var v = ievent as ReloadTableEvent;

            if (v == null)
            {
                return;
            }
            if (v.tableName == "ServerName")
            {
                Table.ForeachServerName(record =>
                {
                    if (record.LogicID == record.Id && ServerMysteryStoreManager.Servers.ContainsKey(record.LogicID) == false && (record.IsClientDisplay == 1 || record.IsClientDisplay == 2))
                    {
                        MysteryStoreManager temp = new MysteryStoreManager();
                        temp.Init(record.LogicID);
                        ServerMysteryStoreManager.Servers.Add(record.LogicID, temp);
                    }
                    return(true);
                });
            }
            if (v.tableName == "Store")
            {
                ResetStore();
            }
        }
Пример #3
0
        public IEnumerator FlushAll(Coroutine coroutine, MysteryStoreManager _this)
        {
            var co = CoroutineFactory.NewSubroutine(SaveDb, coroutine, _this);

            if (co.MoveNext())
            {
                yield return(co);
            }
        }
Пример #4
0
        public MysteryStoreManager GetMysteryStoreManager(int serverId)
        {
            MysteryStoreManager MysteryStoreMgr = null;

            if (ServerMysteryStoreManager.Servers.TryGetValue(serverId, out MysteryStoreMgr) == false)
            {
                MysteryStoreMgr = new MysteryStoreManager();
                ServerMysteryStoreManager.Servers.Add(serverId, MysteryStoreMgr);
            }
            return(MysteryStoreMgr);
        }
Пример #5
0
 private IEnumerator SaveDb(Coroutine coroutine, MysteryStoreManager _this)
 {
     if (_this.mDbData != null)
     {
         PlayerLog.WriteLog((int)LogType.MysteryStoreSave,
                            "--------------------SaveMysteryStoreData--------------------{0}"
                            , _this.mDbData);
         var ret = ActivityServer.Instance.DB.Set(coroutine, DataCategory.MysteryStore, GetDbName(_this.ServerId), _this.mDbData);
         yield return(ret);
     }
 }
Пример #6
0
        public void InitByBase(MysteryStoreManager _this)
        {
            List <StoreRecord> tempList = new List <StoreRecord>();

            Table.ForeachStore(record =>
            {
                if (record.Type == 1106)//珍宝商店
                {
                    tempList.Add(record);
                }
                return(true);
            });
            //Debug.Assert(false);
            GetMysteryStoreItems(_this, tempList);
        }
Пример #7
0
        private IEnumerator ReadDb(Coroutine coroutine, MysteryStoreManager _this, int serverId)
        {
            var storeData = ActivityServer.Instance.DB.Get <DBMysteryStore>(coroutine, DataCategory.MysteryStore, GetDbName(serverId));

            yield return(storeData);

            _this.ServerId = serverId;
            if (storeData.Data == null)
            {
                _this.InitByBase();
                yield break;
            }
            _this.mDbData = storeData.Data;
            yield break;
        }
Пример #8
0
        public void Init()
        {
            Table.ForeachServerName(record =>
            {
                if (record.LogicID == record.Id && ServerMysteryStoreManager.Servers.ContainsKey(record.LogicID) == false && (record.IsClientDisplay == 1 || record.IsClientDisplay == 2))
                {
                    MysteryStoreManager temp = new MysteryStoreManager();
                    temp.Init(record.LogicID);
                    ServerMysteryStoreManager.Servers.Add(record.LogicID, temp);
                }
                return(true);
            });

            SetTrigger();
            EventDispatcher.Instance.AddEventListener(ReloadTableEvent.EVENT_TYPE, ReloadTable);
        }
Пример #9
0
        public int ApplyStoreInfo(MysteryStoreManager _this, ref List <StoneItem> info)
        {
            var storeData = _this.mDbData.MysteryStoreInfo;

            if (null == storeData || storeData.Count == 0)
            {
                return((int)ErrorCodes.Unknow);
            }
            foreach (var data in storeData)
            {
                var item = new StoneItem();
                item.itemid    = data.ItemId;
                item.itemcount = data.ItemCount;
                info.Add(item);
            }
            return((int)ErrorCodes.OK);
        }
Пример #10
0
        private void GetMysteryStoreItems(MysteryStoreManager _this, List <StoreRecord> tempList)
        {
            _this.mDbData.MysteryStoreInfo.Clear();
            var MysteryStoreItems = new List <StoreRecord>();

            for (int i = 0; i < tempList.Count; i++)
            {
                MysteryStoreItems.Add(tempList[i]);
            }
            var limitCount = Table.GetServerConfig(1204).ToInt();

            for (int i = 0; i < limitCount; i++)
            {
                var item = GetItemByWeight(MysteryStoreItems);
                if (null != item)
                {
                    var tempItem = new MysteryStoreItem();
                    tempItem.ItemId    = item.Id;
                    tempItem.ItemCount = item.FuBenCount;//策划指定使用黑市限购数量
                    MysteryStoreItems.Remove(item);
                    _this.mDbData.MysteryStoreInfo.Add(tempItem);
                }
            }
        }
Пример #11
0
        public int GetStoreItemCount(MysteryStoreManager _this, int storeId, ref int itemCount)
        {
            var tbStore = Table.GetStore(storeId);

            if (null == tbStore)
            {
                return((int)ErrorCodes.Error_StoreID);
            }
            var storeData = _this.mDbData.MysteryStoreInfo;

            if (null == storeData)
            {
                return((int)ErrorCodes.Unknow);
            }
            foreach (var data in storeData)
            {
                if (data.ItemId == storeId)
                {
                    itemCount = data.ItemCount;
                    return((int)ErrorCodes.OK);
                }
            }
            return((int)ErrorCodes.OK);
        }
Пример #12
0
 public void Init(MysteryStoreManager _this, int serverId)
 {
     CoroutineFactory.NewCoroutine(ReadDb, _this, serverId).MoveNext();
 }