public void InitData(ProductData d, int i) { data = d; Debug.Log("id" + d.csv_id + "pid" + d.g_prop_csv_id); timer = new PassiveTimer(1); SetInfo(); }
/// <summary> /// 设置除cd 外所有信息 /// </summary> /// <param name="resp"></param> public void SelectLevelCallback(C2sSprotoType.checkpoint_hanging_choose.response resp) { if (curView != null && resp.errorcode == 1) { curFousLevel = curView.data.data.checkpoint; levelTimer = null; if (curChapterData.curLevel[(int)curType] > curFousLevel) { levelpop.prograss.gameObject.SetActive(false); levelpop.time.gameObject.SetActive(false); } else { levelpop.prograss.gameObject.SetActive(true); levelpop.time.gameObject.SetActive(true); BattleEnter(); } levelpop.SetInfo(curView); if (levelpop.prograss.value < 1) { levelpop.battleBtn.isEnabled = false; } else { levelpop.battleBtn.isEnabled = true; } UserManager.Instance.curLeveldata = curView.data.data; } }
public void InitData() { duanTime = DateTime.Now; goldTime = DateTime.Now; timer = new PassiveTimer(1); DailyMgr.Instance.OpenPop(this); }
public void InitData(LotteryPop p, LotteryData d, int i) { pop = p; data = d; index = i; SetInfoAfter(); SetInfo(); isBuyLayer = false; time.text = Comm.DateDiff(data.refresh_time, DateTime.Now); timer = new PassiveTimer(1); }
public void StrengthCallback(C2sSprotoType.lilian_get_phy_power.response resp) { Debug.Log("resp.left_cd_time" + resp.left_cd_time + "resp.phy_power" + resp.phy_power); if (resp.errorcode == 1) { UserManager.Instance.strength = (int)resp.phy_power; ChangeStrength(resp.left_cd_time); t = DateTime.Now.AddSeconds(resp.left_cd_time); } else if (resp.errorcode == 81 || resp.errorcode == 85) { tiliTimer = new PassiveTimer(resp.left_cd_time); ChangeStrength(resp.left_cd_time); t = DateTime.Now.AddSeconds(resp.left_cd_time); } }
public void ChangeStrength(long time, long cd = 0) { if (pop != null) { //体力条 float a = (float)UserManager.Instance.strength / data.phy_pwoer; pop.strengthBar.value = a; pop.strength.text = UserManager.Instance.strength.ToString(); pop.strengthBarTxt.text = UserManager.Instance.strength + "/" + data.phy_pwoer; //体力倒计时 long at = 0; if (present_phy_power_num < data.phy_pwoer) { long n = data.phy_pwoer - present_phy_power_num; at = ((n - 1) * GameShared.Instance.config.strength_time) + time; t = DateTime.Now.AddSeconds((int)time); //总的倒计时 tt = DateTime.Now.AddSeconds(at); } else { } if (time != 0) { tiliTimer = new PassiveTimer(time); } } if (cd > 0 && UserManager.Instance.strength < data.phy_pwoer) { tiliTimer = new PassiveTimer(cd); } //else if (UserManager.Instance.strength >= data.phy_pwoer) //{ // tiliTimer = null; //} }
void StartTimer() { timer = new PassiveTimer(1); }
public void TimerEmpty() { expTimer = null; hangingTimer = null; }
public void TimerRest() { expTimer = new PassiveTimer(1); hangingTimer = new PassiveTimer(Def.HangingRefreshTime); }
public void DisconnectFromThisAndOtherThread() { const int clientCount = 400; var started = _server.Start(); Assert.True(started, "Could not start server"); Thread.Sleep(100); Assert.Empty(_server.Clients); var clients1 = new List <SocketCommandClient>(); for (var cx = 1; cx <= (clientCount / 2); cx++) { var client = new SocketCommandClient("localhost", _testServerPort, _ => { }); var connected = client.Connect(); Assert.True(connected, "[1] Could not connect to server: " + client.LastResult); clients1.Add(client); } var clients2 = new List <SocketCommandClient>(); for (var cx = 1; cx <= (clientCount / 2); cx++) { var client = new SocketCommandClient("localhost", _testServerPort, _ => { }); var connected = client.Connect(); Assert.True(connected, "[2] Could not connect to server: " + client.LastResult); clients2.Add(client); } Assert.Equal(clientCount / 2, clients1.Count); Assert.Equal(clientCount / 2, clients2.Count); var waitConnected = new PassiveTimer(TimeSpan.FromSeconds(10)); while (!waitConnected.Timeout) { if (_server.Clients.Count == clientCount) { break; } Thread.Sleep(10); } Assert.Equal(clientCount, _server.Clients.Count); // ReSharper disable once IdentifierTypo var disconnector = new Thread(() => { Thread.Sleep(100); while (clients1.Count > 0) { clients1[0].Disconnect(); clients1.RemoveAt(0); Thread.Sleep(0); } }); disconnector.Start(); Thread.Sleep(100); while (clients2.Count > 0) { clients2[0].Disconnect(); clients2.RemoveAt(0); Thread.Sleep(0); } while (disconnector.IsAlive) { Thread.Sleep(10); } Thread.Sleep(100); Assert.Empty(clients1); Assert.Empty(clients2); Assert.Empty(_server.Clients); }
public void LiLianInfoCallback(C2sSprotoType.get_lilian_info.response resp) { Debug.Log("get_lilian_info" + "phy_power:" + resp.phy_power + "level:" + resp.level + "lilian_exp:" + resp.lilian_exp + "resp.lilian_exp:" + resp.lilian_exp + "purch_phy_power_num:" + resp.purch_phy_power_num + "present_phy_power_num:" + resp.present_phy_power_num); present_phy_power_num = (int)resp.present_phy_power_num; //信息 UserManager.Instance.strength = (int)resp.phy_power; UserManager.Instance.lilian_level = (int)resp.level; UserManager.Instance.lilian_exp = (int)resp.lilian_exp; purch_phy_power_num = (int)resp.purch_phy_power_num; pop.NumTxt.text = purch_phy_power_num + "/" + UserManager.Instance.curVipdata.purchase_hp_count; pop.totalTimeTxt.text = ""; pop.timeTxt.text = ""; data = GameShared.Instance.GetLiLianLevelById(UserManager.Instance.lilian_level); //正在历练de runList = new List <LiLianRunData>(); for (int r = 0; r < data.queue; r++) { runList.Add(InitLiLianRunData()); } runEvent = InitLiLianRunData(); runEvent.view = pop.eventView.time; pop.eventView.RestView(runEvent); SetExpPrograss(); ChangeStrength(resp.phy_power_left_cd_time); pop.name.text = ""; data = GameShared.Instance.GetLiLianLevelById(UserManager.Instance.lilian_level); pop.levelBar.value = (float)UserManager.Instance.lilian_exp / data.experience; pop.level.text = UserManager.Instance.lilian_level.ToString(); pop.levelBarTxt.text = UserManager.Instance.lilian_exp + "/" + data.experience; //拳官 List <LiLianViewData> hallList = new List <LiLianViewData>(); foreach (KeyValuePair <int, LiLianViewData> pair in UserManager.Instance.hallTable) { pair.Value.unlock = false; if (UserManager.Instance.lilian_level >= pair.Value.data.open_level) { pair.Value.unlock = true; } hallList.Add(pair.Value); } if (resp.lilian_num_list != null) { for (int r = 0; r < resp.lilian_num_list.Count; r++) { Debug.Log("get_lilian_info--lilian_num_list:[" + r + "]: quanguan_id" + resp.lilian_num_list[r].quanguan_id + "num ; " + resp.lilian_num_list[r].num + "reset_num" + resp.lilian_num_list[r].reset_num); LiLianViewData d = new LiLianViewData(); d.data = GameShared.Instance.GetLiLianHallById((int)resp.lilian_num_list[r].quanguan_id); d.num = (int)resp.lilian_num_list[r].num; d.rest_num = (int)resp.lilian_num_list[r].reset_num; if (UserManager.Instance.hallTable.ContainsKey(d.data.csv_id)) { UserManager.Instance.hallTable[d.data.csv_id] = d; } else { UserManager.Instance.hallTable.Add(d.data.csv_id, d); } } } timer = new PassiveTimer(1); pop.SetLiLianList(hallList); pop.SetLiLianRun(runList); int ind = 0; swardList = new List <ItemViewData>(); if (resp.basic_info != null) { for (int i = 0; i < resp.basic_info.Count; i++) { LiLianRunData d = new LiLianRunData(); d.quanguan_id = (int)resp.basic_info[i].quanguan_id; d.card_id = (int)resp.basic_info[i].invitation_id; d.triggr_id = (int)resp.basic_info[i].eventid; d.hall = GameShared.Instance.GetLiLianHallById((int)resp.basic_info[i].quanguan_id); d.time = DateTime.Now.AddSeconds(resp.basic_info[i].left_cd_time); d.if_event_reward = (int)resp.basic_info[i].if_event_reward; d.if_lilian_reward = (int)resp.basic_info[i].if_lilian_reward; d.type = (Def.LiLianType)resp.basic_info[i].delay_type; d.swaredList = new List <ItemViewData>(); string debugss = ""; if (resp.basic_info[i].reward != null) { for (int r = 0; r < resp.basic_info[i].reward.Count; r++) { ItemViewData v = new ItemViewData(); v.data = GameShared.Instance.GetItemData((int)resp.basic_info[i].reward[r].propid); debugss += resp.basic_info[i].reward[r].propid.ToString() + "-"; v.curCount = (int)resp.basic_info[i].reward[r].propnum; d.swaredList.Add(v); } } Debug.Log("get_lilian_info--basic_info:[" + i + "]: quanguan_id:" + resp.basic_info[i].quanguan_id + "left_cd_time" + resp.basic_info[i].left_cd_time + "delay_type " + resp.basic_info[i].delay_type + "if_lilian_reward" + resp.basic_info[i].if_lilian_reward + "if_event_reward" + resp.basic_info[i].if_event_reward + "if_trigger_event" + resp.basic_info[i].if_trigger_event + "invitation_id" + resp.basic_info[i].invitation_id + "reward:" + debugss); if (d.if_lilian_reward == 1) { d.card = GameShared.Instance.GetLiLianCardById((int)resp.basic_info[i].invitation_id); List <GameShared.StrData> str2 = GameShared.Instance.GetStrData(d.card.reward); for (int j = 0; j < str2.Count; j++) { ItemViewData item = new ItemViewData(); item.data = GameShared.Instance.GetItemData(str2[j].id); item.curCount = str2[j].num; d.swaredList.Add(item); } } if (d.if_event_reward == 1) { runEvent = d; runEvent.view = pop.eventView.time; } if (d.type == Def.LiLianType.Lilian) { ind++; } if (resp.basic_info[i].left_cd_time > 0) { d.time = DateTime.Now.AddSeconds(resp.basic_info[i].left_cd_time); //runList.Add(d.quanguan_id, d); d.runid = ind; AddLiLianRun(d); } else { d.runid = ind; RemoveInitLiLianRun(d); } } } }
public void InitData() { ArenaMgr.Instance.ArenaOpen(this); timer = new PassiveTimer(1); }