コード例 #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();
 }