Ejemplo n.º 1
0
        private static void ReloadTable(IEvent ievent)
        {
            var v = ievent as ReloadTableEvent;

            if (v == null)
            {
                return;
            }
            if (v.tableName == "ServerName")
            {
                Table.ForeachServerName(record =>
                {
                    var id = record.LogicID;
                    if (!AcientBattleManager.Boss.ContainsKey(id) && record.IsClientDisplay == 1)
                    {
                        var serverTemp = new AcientBattle(id);
                        AcientBattleManager.Boss.Add(id, serverTemp);
                        if (serverTemp.DBData == null)
                        {
                            serverTemp.DBData = new DBAcientBattleActivityData();
                        }
                        Table.ForeachAcientBattleField(recordAcient =>
                        {
                            //1:死亡   0:活着
                            serverTemp.DBData.BossState.Add(recordAcient.Id, 0);

                            //-1:未死亡     不是-1:死亡倒计时
                            serverTemp.DBData.BossDieTime.Add(recordAcient.Id, -1);
                            return(true);
                        });
                    }
                    return(true);
                });
            }
        }
Ejemplo n.º 2
0
        private IEnumerator GetDbActiDataCoroutine(Coroutine co, AcientBattle _this)
        {
            if (_this == null)
            {
                yield break;
            }
            var dbActiList = ActivityServer.Instance.DB.Get <DBAcientBattleActivityData>(co, DataCategory.AcientBattle,
                                                                                         DbKey + _this.ServerId);

            yield return(dbActiList);

            if (dbActiList.Status != DataStatus.Ok)
            {
                Logger.Fatal("GetDbActiData get data from db faild!");
                yield break;
            }
            if (dbActiList.Data != null)
            {
                SetActiData(_this, dbActiList.Data);
            }
            else
            {
                InitData(_this);
            }
        }
Ejemplo n.º 3
0
        public void Init()
        {
            Table.ForeachServerName(record =>
            {
                var id = record.LogicID;
                if (!AcientBattleManager.Boss.ContainsKey(id) && record.IsClientDisplay == 1)
                {
                    var serverTemp = new AcientBattle(id);
                    AcientBattleManager.Boss.Add(id, serverTemp);
                    if (serverTemp.DBData == null)
                    {
                        serverTemp.DBData = new DBAcientBattleActivityData();
                    }
                    Table.ForeachAcientBattleField(recordAcient =>
                    {
                        //1:死亡   0:活着
                        serverTemp.DBData.BossState.Add(recordAcient.Id, 0);

                        //-1:未死亡     不是-1:死亡倒计时
                        serverTemp.DBData.BossDieTime.Add(recordAcient.Id, -1);
                        return(true);
                    });
                }
                return(true);
            });
            EventDispatcher.Instance.AddEventListener(ReloadTableEvent.EVENT_TYPE, ReloadTable);
        }
Ejemplo n.º 4
0
        private void InitData(AcientBattle _this)
        {
            var item = new DBAcientBattleActivityData();

            Table.ForeachAcientBattleField(record =>
            {
                //1:死亡   0:活着
                item.BossState.Add(record.Id, 0);
                //-1:未死亡     不是-1:死亡倒计时
                item.BossDieTime.Add(record.Id, -1);
                return(true);
            });
            _this.DBData = item;
            if (AcientBattleManager.Boss == null)
            {
                AcientBattleManager.Boss = new Dictionary <int, AcientBattle>();
            }
            if (AcientBattleManager.Boss.ContainsKey(_this.ServerId))
            {
                AcientBattleManager.Boss[_this.ServerId] = _this;
            }
            else
            {
                AcientBattleManager.Boss.Add(_this.ServerId, _this);
            }
        }
Ejemplo n.º 5
0
        private IEnumerator SaveCoroutine(Coroutine co, AcientBattle oData)
        {
            if (oData == null || AcientBattleManager.Boss == null || AcientBattleManager.Boss[oData.ServerId] == null)
            {
                yield break;
            }
            var ret = ActivityServer.Instance.DB.Set(co, DataCategory.AcientBattle, DbKey + oData.ServerId,
                                                     AcientBattleManager.Boss[oData.ServerId].DBData);

            yield return(ret);
        }
Ejemplo n.º 6
0
 public void SetActiData(AcientBattle _this, DBAcientBattleActivityData data)
 {
     if (data == null)
     {
         return;
     }
     _this.DBData = data;
     if (AcientBattleManager.Boss == null)
     {
         AcientBattleManager.Boss = new Dictionary <int, AcientBattle>();
     }
     if (AcientBattleManager.Boss.ContainsKey(_this.ServerId))
     {
         AcientBattleManager.Boss[_this.ServerId] = _this;
     }
     else
     {
         AcientBattleManager.Boss.Add(_this.ServerId, _this);
     }
 }
Ejemplo n.º 7
0
 private void GetDbActiData(AcientBattle _this)
 {
     CoroutineFactory.NewCoroutine(GetDbActiDataCoroutine, _this).MoveNext();
 }
Ejemplo n.º 8
0
 private void Save(AcientBattle oData)
 {
     CoroutineFactory.NewCoroutine(SaveCoroutine, oData).MoveNext();
 }
Ejemplo n.º 9
0
 public void Construct(AcientBattle _this, int serverId)
 {
     _this.ServerId = serverId;
     GetDbActiData(_this);
 }