public void Init(GeneralActivity _this, int serverId) { _this.serverId = serverId; CoroutineFactory.NewCoroutine(ReadDb, _this, serverId).MoveNext(); ActivityServerControl.Timer.CreateTrigger(DateTime.Now.Date.AddDays(1).AddSeconds(5), () => { OnDayTimer(_this); }, 60 * 60 * 24 * 1000); OnDayTimer(_this); }
public GeneralActivity GetActivity(int serverId) { GeneralActivity tmp = null; GeneralActivityManager.servers.TryGetValue(serverId, out tmp); return(tmp); }
private void OnDayTimer(GeneralActivity _this) {//每日回调 var serverInfo = Table.GetServerName(_this.serverId); DateTime ServerOpenDate = DateTime.Parse(serverInfo.OpenTime); var week = (int)ServerOpenDate.DayOfWeek; var todayWeek = (int)DateTime.Now.DayOfWeek; if (week == 0) { week = 7; } var tbActivity = Table.GetMainActivity(week); if (tbActivity == null) { return; } //本次状态 _this.bActivity = tbActivity.Week[todayWeek] == 3; if (_this.mDbData.LastTime != 0) { DateTime last = DateTime.FromBinary(_this.mDbData.LastTime); if (last.Date != DateTime.Now.Date) { FinalActivity(_this); } } if (_this.bActivity == true) { _this.mDbData.LastTime = DateTime.Now.ToBinary(); } _this.bDirty = true; }
public void AddPlayerScore(GeneralActivity _this, Dictionary <ulong, int> dic) { foreach (var v in dic) { _this.mDbData.ID2Score.modifyValue(v.Key, v.Value); } _this.bDirty = true; }
public IEnumerator SaveDb(Coroutine coroutine, GeneralActivity _this) { if (_this.mDbData != null) { var ret = ActivityServer.Instance.DB.Set(coroutine, DataCategory.GeneralActivity, GetDbName(_this.serverId), _this.mDbData); yield return(ret); } }
private IEnumerator ReadDb(Coroutine coroutine, GeneralActivity _this, int serverId) { var tasks = ActivityServer.Instance.DB.Get <DBGeneralActivityData>(coroutine, DataCategory.GeneralActivity, GetDbName(serverId)); yield return(tasks); if (tasks.Data == null) { yield break; } _this.mDbData.ID2Score.AddRange(tasks.Data.ID2Score); }
public void Init() { Table.ForeachServerName(record => { if (record.LogicID == record.Id && (record.IsClientDisplay == 1 || record.IsClientDisplay == 2) && GeneralActivityManager.servers.ContainsKey(record.LogicID) == false) { GeneralActivity act = new GeneralActivity(); act.Init(record.LogicID); GeneralActivityManager.servers.Add(record.LogicID, act); } return(true); }); ActivityServerControl.Timer.CreateTrigger(DateTime.Now.AddSeconds(30), Update, 30000); //30秒一次 EventDispatcher.Instance.AddEventListener(ReloadTableEvent.EVENT_TYPE, ReloadTable); }
public void FinalActivity(GeneralActivity _this) { List <KeyValuePair <ulong, int> > tmpList = new List <KeyValuePair <ulong, int> >(); foreach (var v in _this.mDbData.ID2Score) { tmpList.Add(v); } tmpList.Sort((a, b) => { return(a.Value - b.Value); }); for (int i = 0; i < tmpList.Count; i++) { var tbArenaReward = GetArenaReward(i); if (tbArenaReward != null) { var tbMail = Table.GetMail(97); var reward = new Dictionary <int, int>(); if (tbArenaReward.DayMoney > 0) { reward.Add((int)eResourcesType.GoldRes, tbArenaReward.DayMoney); } if (tbArenaReward.DayDiamond > 0) { reward.Add((int)eResourcesType.DiamondBind, tbArenaReward.DayDiamond); } var index = 0; foreach (var v in tbArenaReward.DayItemID) { if (i > 0 && tbArenaReward.DayItemCount[index] > 0) { reward.Add(v, tbArenaReward.DayItemCount[index]); } index++; } string content = string.Format(tbMail.Text, i); var items = new Dict_int_int_Data(); items.Data.AddRange(reward); CoroutineFactory.NewCoroutine(SendMailCoroutine, tmpList[i].Key, tbMail.Title, content, items).MoveNext(); } } _this.mDbData.ID2Score.Clear(); _this.bDirty = true; }
private static 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 && (record.IsClientDisplay == 1 || record.IsClientDisplay == 2) && GeneralActivityManager.servers.ContainsKey(record.LogicID) == false) { GeneralActivity act = new GeneralActivity(); act.Init(record.LogicID); GeneralActivityManager.servers.Add(record.LogicID, act); } return(true); }); } }
public void AddPlayerScore(GeneralActivity _this, ulong guid, int score) { _this.mDbData.ID2Score.modifyValue(guid, score); _this.bDirty = true; }