Exemplo n.º 1
0
        public int ConsumeStoreItem(BlackStoreManager _this, int storeId, int consumeCount)
        {
            var tbStore = Table.GetStore(storeId);

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

            if (null == storeData)
            {
                return((int)ErrorCodes.Unknow);
            }
            for (int i = 0; i < storeData.Count; i++)
            {
                var data = storeData[i];
                if (data.StoreItemId == storeId)
                {
                    if (_this.mDbData.BlackStoreInfo[i].StoreItemCount < consumeCount)
                    {
                        return((int)ErrorCodes.Error_TreasureStoreItemCountNotEnough);
                    }
                    else
                    {
                        _this.mDbData.BlackStoreInfo[i].StoreItemCount -= consumeCount;
                        return((int)ErrorCodes.OK);
                    }
                }
            }
            return((int)ErrorCodes.Error_TreasureStoreBuyFailed);
        }
Exemplo n.º 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.Id == record.LogicID && record.IsClientDisplay == 1 && ServerBlackStoreManager.Servers.ContainsKey(record.LogicID) == false)
                    {
                        BlackStoreManager temp = new BlackStoreManager();
                        temp.Init(record.LogicID);
                        ServerBlackStoreManager.Servers.Add(record.LogicID, temp);
                    }
                    return(true);
                });
            }
            if (v.tableName == "Store")
            {
                ResetStore();
            }
        }
Exemplo n.º 3
0
        public IEnumerator FlushAll(Coroutine coroutine, BlackStoreManager _this)
        {
            var co = CoroutineFactory.NewSubroutine(SaveDb, coroutine, _this);

            if (co.MoveNext())
            {
                yield return(co);
            }
        }
Exemplo n.º 4
0
        public BlackStoreManager GetBlackStoreManager(int serverId)
        {
            BlackStoreManager BlackStoreMgr = null;

            if (ServerBlackStoreManager.Servers.TryGetValue(serverId, out BlackStoreMgr) == false)
            {
                BlackStoreMgr = new BlackStoreManager();
                ServerBlackStoreManager.Servers.Add(serverId, BlackStoreMgr);
            }
            return(BlackStoreMgr);
        }
Exemplo n.º 5
0
 private IEnumerator SaveDb(Coroutine coroutine, BlackStoreManager _this)
 {
     if (_this.mDbData != null)
     {
         PlayerLog.WriteLog((int)LogType.BlackStoreSave,
                            "--------------------SaveBlackStoreData--------------------{0}"
                            , _this.mDbData);
         var ret = ActivityServer.Instance.DB.Set(coroutine, DataCategory.BlackStore, GetDbName(_this.ServerId), _this.mDbData);
         yield return(ret);
     }
 }
Exemplo n.º 6
0
        public void InitByBase(BlackStoreManager _this)
        {
            List <StoreRecord> tempList = new List <StoreRecord>();

            Table.ForeachStore(record =>
            {
                if (record.Type == 1100)//黑市商店
                {
                    tempList.Add(record);
                }
                return(true);
            });
            //Debug.Assert(false);
            GetBlackStoreItems(_this, tempList);
        }
Exemplo n.º 7
0
 public void Init()
 {
     Table.ForeachServerName(record =>
     {
         if (record.Id == record.LogicID && record.IsClientDisplay == 1 && ServerBlackStoreManager.Servers.ContainsKey(record.LogicID) == false)
         {
             BlackStoreManager temp = new BlackStoreManager();
             temp.Init(record.LogicID);
             ServerBlackStoreManager.Servers.Add(record.LogicID, temp);
         }
         return(true);
     });
     SetTrigger();
     EventDispatcher.Instance.AddEventListener(ReloadTableEvent.EVENT_TYPE, ReloadTable);
 }
Exemplo n.º 8
0
        private IEnumerator ReadDb(Coroutine coroutine, BlackStoreManager _this, int serverId)
        {
            var storeData = ActivityServer.Instance.DB.Get <DBBlackStore>(coroutine, DataCategory.BlackStore, GetDbName(serverId));

            yield return(storeData);

            _this.ServerId = serverId;
            if (storeData.Data == null)
            {
                _this.InitByBase();
                yield break;
            }
            _this.mDbData = storeData.Data;
            yield break;
        }
Exemplo n.º 9
0
        public int ApplyStoreInfo(BlackStoreManager _this, ref List <StoneItem> info)
        {
            var storeData = _this.mDbData.BlackStoreInfo;

            if (null == storeData || storeData.Count == 0)
            {
                return((int)ErrorCodes.Unknow);
            }
            foreach (var data in storeData)
            {
                var item = new StoneItem();
                item.itemid    = data.StoreItemId;
                item.itemcount = data.StoreItemCount;
                info.Add(item);
            }
            return((int)ErrorCodes.OK);
        }
Exemplo n.º 10
0
        private void GetBlackStoreItems(BlackStoreManager _this, List <StoreRecord> tempList)
        {
            _this.mDbData.BlackStoreInfo.Clear();
            var BlackStoreItems = new List <StoreRecord>();

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

            for (int i = 0; i < limitCount; i++)
            {
                var item = GetItemByWeight(BlackStoreItems);
                if (null != item)
                {
                    var tempItem = new BlackStoreItem();
                    tempItem.StoreItemId    = item.Id;
                    tempItem.StoreItemCount = item.FuBenCount;//策划指定使用黑市限购数量
                    BlackStoreItems.Remove(item);
                    _this.mDbData.BlackStoreInfo.Add(tempItem);
                }
            }
        }
Exemplo n.º 11
0
        public int GetStoreItemCount(BlackStoreManager _this, int storeId, ref int itemCount)
        {
            var tbStore = Table.GetStore(storeId);

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

            if (null == storeData)
            {
                return((int)ErrorCodes.Unknow);
            }
            foreach (var data in storeData)
            {
                if (data.StoreItemId == storeId)
                {
                    itemCount = data.StoreItemCount;
                    return((int)ErrorCodes.OK);
                }
            }
            return((int)ErrorCodes.OK);
        }
Exemplo n.º 12
0
 public void Init(BlackStoreManager _this, int serverId)
 {
     CoroutineFactory.NewCoroutine(ReadDb, _this, serverId).MoveNext();
 }