void RefreshActivity(Dictionary <int, ActivityListRef> _list) { //Debug.Log("刷新所有的活动提示"); if (actGo != null) { foreach (GameObject obj in actDic.Values) { if (obj != null) { obj.SetActive(false); } //Debug.Log("隐藏活动提示"); } if (itemGird != null) { itemGird.maxPerLine = _list.Count; } int i = 0; using (var e = _list.GetEnumerator()) { while (e.MoveNext()) { ActivityListRef _data = e.Current.Value; ActivityDataInfo info = GameCenter.activityMng.GetActivityDataInfo(_data.id); if (info != null && info.State == ActivityState.HASENDED) { continue; } //Debug.Log("_data name:" + _data.name + ",id:" + _data.id); GameObject go = null; if (!actDic.ContainsKey(i)) { go = Instantiate(actGo) as GameObject; actDic[i] = go; } else { go = actDic[i]; } go.transform.parent = actGo.transform.parent; go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; go.SetActive(true); //Debug.Log("展示活动提示"); if (go != null && _data != null) { ActivityBtnUI activityBtnUI = go.GetComponent <ActivityBtnUI>(); if (activityBtnUI != null) { activityBtnUI.Refresh(_data); } UIEventListener.Get(go).onClick = delegate { if (GameCenter.activityMng.ActivityOnGoingList.ContainsKey(_data.id)) { GameCenter.activityMng.ActivityOnGoingList.Remove(_data.id); GameCenter.activityMng.haveTipDic[_data.id] = _data; } ActivityType type = (ActivityType)_data.id; if (type == ActivityType.UNDERBOSS) { BossChallengeWnd.OpenAndGoWndByType(BossChallengeWnd.ToggleType.UnderBoss); } else { GameCenter.activityMng.OpenStartSeleteActivity(type); } go.SetActive(false); }; } i++; } } if (itemGird != null) { itemGird.repositionNow = true; } } }
/// <summary> /// 按钮功能 /// </summary> public void GoActivityButtonFunc(ActivityButtonRef refdata, int id) { if (refdata == null) { return; } if (!activityDic.ContainsKey(id)) { return; } if (!activityDic[id].ActivityLev) { GameCenter.messageMng.AddClientMsg(13); return; } ActivityType type = (ActivityType)id; //=============fix 完全没必要每次判断都进行一次强制转换,可以先声明一个变量,强制转换一次,然后拿该变量去判断 if (type == ActivityType.FAIRYAUBONFIRE || type == ActivityType.FAIRYAUSHIPMENTDART || type == ActivityType.FAIRYAUSIEGE || type == ActivityType.FAIRYDOMAINTOPROTECT) { if (!GameCenter.mainPlayerMng.MainPlayerInfo.HavaGuild) { GameCenter.messageMng.AddClientMsg(235); return; } } if (type == ActivityType.BATTLEFAGIHT) { GameCenter.battleFightMng.C2S_ReqFlyBattleFeild(); return; } if (type == ActivityType.DAILYTRANSPORTDART) { GameCenter.uIMng.SwitchToUI(GUIType.NONE); GameCenter.activityMng.C2S_ReqDartPos(DartType.DailyDart); return; } if (type == ActivityType.FAIRYAUSHIPMENTDART) { GameCenter.activityMng.C2S_ReqDartPos(DartType.GuildDart); return; } if (type == ActivityType.FAIRYAUBONFIRE) { GameCenter.activityMng.C2S_FlyMyGuildFire(); return; } if (type == ActivityType.UNDERBOSS) { BossChallengeWnd.OpenAndGoWndByType(BossChallengeWnd.ToggleType.UnderBoss); return; } if (activityDic[id].State != ActivityState.ONGOING) { GameCenter.messageMng.AddClientMsg(173); return; } if (type == ActivityType.RAIDERARK) { //Debug.Log("跳转夺宝奇兵界面!!!"); GameCenter.activityMng.C2S_FlyRaiderArk(); return; } //=============fix 没有使用枚举,而是使用魔数======== if (refdata.type == (int)ButtonType.GUI) { GameCenter.uIMng.SwitchToUI((GUIType)Enum.Parse(typeof(GUIType), refdata.pageId)); } else if (refdata.type == (int)ButtonType.FengShen) { GameCenter.activityMng.C2S_FlyFengShen(id); } else if (refdata.type == (int)ButtonType.ToPoint) {//寻路点 GameCenter.taskMng.TraceToScene(refdata.mapId, new Vector3(refdata.mapXY[0], 0, refdata.mapXY[1])); GameCenter.curMainPlayer.GoTraceSearchTreasure(); } else if (refdata.type == (int)ButtonType.subGUI) { GameCenter.uIMng.SwitchToSubUI((SubGUIType)Enum.Parse(typeof(SubGUIType), refdata.pageId)); } else if (refdata.type == (int)ButtonType.fly) {//飞副本, GameCenter.mainPlayerMng.C2S_Fly_Pint(refdata.mapId, refdata.mapXY[0], refdata.mapXY[1]); } else if (refdata.type == (int)ButtonType.ToNpc) {//寻路NPC GameCenter.taskMng.PublicTraceToNpc(refdata.mapId); GameCenter.curMainPlayer.GoTraceSearchTreasure(); } }