|
@@ -1,3 +1,4 @@
|
|
|
|
+using System.Collections.Generic;
|
|
using ET;
|
|
using ET;
|
|
using FairyGUI;
|
|
using FairyGUI;
|
|
using UI.League;
|
|
using UI.League;
|
|
@@ -9,6 +10,8 @@ namespace GFGGame
|
|
public class LeagueAnsweringView : BaseWindow
|
|
public class LeagueAnsweringView : BaseWindow
|
|
{
|
|
{
|
|
private UI_LeagueAnsweringUI _ui;
|
|
private UI_LeagueAnsweringUI _ui;
|
|
|
|
+ private LeagueDataManager _dataManager;
|
|
|
|
+ private List<long> _memberIds;
|
|
|
|
|
|
public override void Dispose()
|
|
public override void Dispose()
|
|
{
|
|
{
|
|
@@ -29,24 +32,45 @@ namespace GFGGame
|
|
isfullScreen = true;
|
|
isfullScreen = true;
|
|
|
|
|
|
_ui.m_loaBg.url = ResPathUtil.GetBgImgPath("lm_beijing");
|
|
_ui.m_loaBg.url = ResPathUtil.GetBgImgPath("lm_beijing");
|
|
|
|
+
|
|
_ui.m_btnBack.onClick.Add(OnBtnBackClick);
|
|
_ui.m_btnBack.onClick.Add(OnBtnBackClick);
|
|
|
|
+ _ui.m_btnRule.onClick.Add(OnBtnRuleClick);
|
|
|
|
+ _ui.m_btnSend.onClick.Add(OnBtnSendClick);
|
|
|
|
|
|
|
|
+ _ui.m_listResult.itemRenderer = RenderListResultItem;
|
|
|
|
+ _ui.m_listJoin.itemRenderer = RenderListJoinItem;
|
|
|
|
+ _ui.m_listChat.itemRenderer = RenderListChatItem;
|
|
|
|
+ _ui.m_listChat.itemProvider = GetListItemResource;
|
|
|
|
+ _ui.m_listChat.SetVirtual();
|
|
}
|
|
}
|
|
protected override void AddEventListener()
|
|
protected override void AddEventListener()
|
|
{
|
|
{
|
|
base.AddEventListener();
|
|
base.AddEventListener();
|
|
-
|
|
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.LEAGUE_ANSWER_START, UpdateQuestion);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.LEAGUE_ANSWER_END, UpdateResult);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.LEAGUE_ANSWER_RESULT_CHANGE, UpdateResult);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.LEAGUE_ANSWER_RESULT_CHANGE, UpdateJoinList);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.LEAGUE_ANSWER_MEMBER_CHANGE, UpdateJoinList);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.NOTICE_CHAT_MESSAGE, UpdateChatList);
|
|
}
|
|
}
|
|
- protected override void OnShown()
|
|
|
|
|
|
+ protected override async void OnShown()
|
|
{
|
|
{
|
|
base.OnShown();
|
|
base.OnShown();
|
|
|
|
+ _dataManager = LeagueDataManager.Instance;
|
|
|
|
+ _ui.m_listChat.numItems = ChatDataManager.Instance.ChatDatas[ChatType.LeagueQuestion].Count;
|
|
|
|
+ _ui.m_listChat.scrollPane.ScrollBottom();
|
|
|
|
|
|
|
|
+ bool result = await LeagueSproxy.ReqJoinAnswer();
|
|
|
|
+ if (result)
|
|
|
|
+ {
|
|
|
|
+ UpdateJoinList();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnHide()
|
|
protected override void OnHide()
|
|
{
|
|
{
|
|
base.OnHide();
|
|
base.OnHide();
|
|
-
|
|
|
|
|
|
+ Timers.inst.Remove(UpdateAnswerTime);
|
|
}
|
|
}
|
|
|
|
|
|
protected override void RemoveEventListener()
|
|
protected override void RemoveEventListener()
|
|
@@ -59,6 +83,171 @@ namespace GFGGame
|
|
{
|
|
{
|
|
ViewManager.GoBackFrom(typeof(LeagueAnsweringView).FullName);
|
|
ViewManager.GoBackFrom(typeof(LeagueAnsweringView).FullName);
|
|
}
|
|
}
|
|
|
|
+ private void OnBtnRuleClick()
|
|
|
|
+ {
|
|
|
|
+ ViewManager.Show<LeagueAnswerRewardView>();
|
|
|
|
+ }
|
|
|
|
+ private void OnBtnSendClick()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void UpdateQuestionState()
|
|
|
|
+ {
|
|
|
|
+ if (_dataManager.GetNumeriValue(LeagueNumericType.LeagueQuestionStatus) == LeagueQuestionStatus.Open)//答题中
|
|
|
|
+ {
|
|
|
|
+ UpdateQuestion();
|
|
|
|
+ }
|
|
|
|
+ else//cd中、答题结束
|
|
|
|
+ {
|
|
|
|
+ UpdateResult();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void UpdateQuestion()
|
|
|
|
+ {
|
|
|
|
+ _ui.m_txtRightCount.text = string.Format("全员已答对{0}题", _dataManager.GetNumeriValue(LeagueNumericType.LeagueQuestionTrueCount));
|
|
|
|
+ _ui.m_ctrlQuestionState.selectedIndex = 0;
|
|
|
|
+ int questionId = (int)_dataManager.GetNumeriValue(LeagueNumericType.LeagueQuestionId);
|
|
|
|
+ LeagueQuestionCfg questionCfg = LeagueQuestionCfgArray.Instance.GetCfg(questionId);
|
|
|
|
+
|
|
|
|
+ _ui.m_txtAnswerNum.text = string.Format("第{0}/{1}题", _dataManager.GetNumeriValue(LeagueNumericType.LeagueQuestionCount), GlobalCfgArray.globalCfg.leagueQuestionNum);
|
|
|
|
+ _ui.m_ctrlHasIcon.selectedIndex = string.IsNullOrEmpty(questionCfg.res) ? 1 : 0;
|
|
|
|
+ _ui.m_loaIocn.url = string.IsNullOrEmpty(questionCfg.res) ? "" : ResPathUtil.GetIconPath(questionCfg.res, "png");
|
|
|
|
+ _ui.m_txtContent.text = questionCfg.question;
|
|
|
|
+ _ui.m_ctrlQuestionType.selectedIndex = questionCfg.type;
|
|
|
|
+ if (questionCfg.type == 1)
|
|
|
|
+ {
|
|
|
|
+ _ui.m_listResult.numItems = questionCfg.answerArr.Length;
|
|
|
|
+ }
|
|
|
|
+ _ui.m_txtTime.text = "";
|
|
|
|
+
|
|
|
|
+ Timers.inst.Remove(UpdateAnswerTime);
|
|
|
|
+ Timers.inst.Add(1, 0, UpdateAnswerTime);
|
|
|
|
+ }
|
|
|
|
+ private void UpdateAnswerTime(object param)
|
|
|
|
+ {
|
|
|
|
+ long curTime = TimeHelper.ServerNow();
|
|
|
|
+ long endTime = LeagueDataManager.Instance.GetNumeriValue(LeagueNumericType.LeagueQuestionStatusEndTime);
|
|
|
|
+ if (LeagueDataManager.Instance.GetNumeriValue(LeagueNumericType.LeagueQuestionStatus) > LeagueQuestionStatus.End
|
|
|
|
+ || endTime - curTime < 0)
|
|
|
|
+ {
|
|
|
|
+ Timers.inst.Remove(UpdateAnswerTime);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ _ui.m_txtTime.text = TimeUtil.FormattingTime5((int)(endTime - curTime));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private void UpdateResult()
|
|
|
|
+ {
|
|
|
|
+ _ui.m_txtRightCount.text = string.Format("全员已答对{0}题", _dataManager.GetNumeriValue(LeagueNumericType.LeagueQuestionTrueCount));
|
|
|
|
+ _ui.m_ctrlQuestionState.selectedIndex = 1;
|
|
|
|
+ if (_dataManager.LastAnswerRoleData.LastQuestionResult == LastQuestionResult.SomeBodyRight)
|
|
|
|
+ {
|
|
|
|
+ _ui.m_comRightHead.visible = true;
|
|
|
|
+ _ui.m_imgFail.visible = false;
|
|
|
|
+ OtherRoleInfoData roleInfoData = _dataManager.GetMemberRoleInfo(_dataManager.LastAnswerRoleData.RightRoleId);
|
|
|
|
+ RoleInfoManager.Instance.UpdateHeadWithLv(_ui.m_comRightHead, roleInfoData.headId, roleInfoData.headBorderId, roleInfoData.roleLv);
|
|
|
|
+ _ui.m_txtInfo.text = string.Format("{0} 答对了!", roleInfoData.roleName);
|
|
|
|
+ Timers.inst.Remove(UpdateResultTime);
|
|
|
|
+ Timers.inst.Add(1, 0, UpdateResultTime);
|
|
|
|
+ }
|
|
|
|
+ else if (_dataManager.LastAnswerRoleData.LastQuestionResult == LastQuestionResult.NobodyRight)
|
|
|
|
+ {
|
|
|
|
+ _ui.m_comRightHead.visible = false;
|
|
|
|
+ _ui.m_imgFail.visible = true;
|
|
|
|
+ _ui.m_txtInfo.text = "哎呀,没人答对呀,大家加油鸭~";
|
|
|
|
+ Timers.inst.Remove(UpdateResultTime);
|
|
|
|
+ Timers.inst.Add(1, 0, UpdateResultTime);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ _ui.m_comRightHead.visible = false;
|
|
|
|
+ _ui.m_imgFail.visible = false;
|
|
|
|
+ if (_dataManager.GetNumeriValue(LeagueNumericType.LeagueQuestionCount) == GlobalCfgArray.globalCfg.leagueQuestionNum)//全部答完
|
|
|
|
+ {
|
|
|
|
+ _ui.m_txtInfo.text = "全部题目答完啦~";
|
|
|
|
+ }
|
|
|
|
+ else//答题时间结束
|
|
|
|
+ {
|
|
|
|
+ _ui.m_txtInfo.text = "活动结束啦~";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void UpdateResultTime(object param)
|
|
|
|
+ {
|
|
|
|
+ long curTime = TimeHelper.ServerNow();
|
|
|
|
+ long endTime = LeagueDataManager.Instance.GetNumeriValue(LeagueNumericType.LeagueQuestionStatusEndTime);
|
|
|
|
+ if (LeagueDataManager.Instance.GetNumeriValue(LeagueNumericType.LeagueQuestionStatus) != LeagueQuestionStatus.WaitNext
|
|
|
|
+ || endTime - curTime < 0)
|
|
|
|
+ {
|
|
|
|
+ Timers.inst.Remove(UpdateResultTime);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ _ui.m_txtTime.text = (endTime - curTime) / 1000 + "秒后开始下一题";
|
|
|
|
+ }
|
|
|
|
+ private void UpdateJoinList()
|
|
|
|
+ {
|
|
|
|
+ _memberIds = new List<long>(_dataManager.ListAnsweringDatas.Keys);
|
|
|
|
+ _ui.m_listJoin.numItems = _memberIds.Count;
|
|
|
|
+ }
|
|
|
|
+ private void UpdateChatList()
|
|
|
|
+ {
|
|
|
|
+ _ui.m_listChat.numItems = ChatDataManager.Instance.ChatDatas[ChatType.LeagueQuestion].Count;
|
|
|
|
+ _ui.m_listChat.scrollPane.ScrollBottom(true);
|
|
|
|
+ }
|
|
|
|
+ private void RenderListResultItem(int index, GObject obj)
|
|
|
|
+ {
|
|
|
|
+ LeagueQuestionCfg cfg = LeagueQuestionCfgArray.Instance.dataArray[index];
|
|
|
|
+ GButton item = obj as GButton;
|
|
|
|
+ int data = index + 1;
|
|
|
|
+ item.title = string.Format("{0}.{1}", data, cfg.answerArr[index]);
|
|
|
|
+ if (item.data == null)
|
|
|
|
+ {
|
|
|
|
+ item.onClick.Add(OnBtnChooseClick);
|
|
|
|
+ }
|
|
|
|
+ item.data = data;
|
|
|
|
+ }
|
|
|
|
+ private async void OnBtnChooseClick(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
|
+ string answer = obj.data.ToString();
|
|
|
|
+ ChatSProxy.ReqSendChatMsg(ChatType.LeagueQuestion, answer).Coroutine();
|
|
|
|
+ int questionId = (int)_dataManager.GetNumeriValue(LeagueNumericType.LeagueQuestionId);
|
|
|
|
+ LeagueQuestionCfg cfg = LeagueQuestionCfgArray.Instance.GetCfg(questionId);
|
|
|
|
+ bool result = await LeagueSproxy.ReqAnswerQuestion(questionId, answer);
|
|
|
|
+ if (result
|
|
|
|
+ && _dataManager.GetNumeriValue(LeagueNumericType.LeagueQuestionId) == _dataManager.LastAnswerRoleData.LastQuestionId
|
|
|
|
+ && _dataManager.LastAnswerRoleData.MyAnswer != cfg.answerCorrect)
|
|
|
|
+ {
|
|
|
|
+ _ui.m_listResult.numItems = cfg.answerArr.Length;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void RenderListJoinItem(int index, GObject obj)
|
|
|
|
+ {
|
|
|
|
+ OtherRoleInfoData roleInfo = _dataManager.LeagueData.LeagueMemberDatas[_memberIds[index]].RoleInfo;
|
|
|
|
+ UI_ListAnswerJoinItem item = UI_ListAnswerJoinItem.Proxy(obj);
|
|
|
|
+ RoleInfoManager.Instance.UpdateHead(item.m_comHead, roleInfo.headId, roleInfo.headBorderId);
|
|
|
|
+ item.m_txtName.text = roleInfo.roleName;
|
|
|
|
+ item.m_txtAnswerCount.text = string.Format("答对数量:{0}", _dataManager.ListAnsweringDatas[roleInfo.roleId]);
|
|
|
|
+ UI_ListAnswerJoinItem.ProxyEnd();
|
|
|
|
+ }
|
|
|
|
+ private void RenderListChatItem(int index, GObject obj)
|
|
|
|
+ {
|
|
|
|
+ ChatData chatData = ChatDataManager.Instance.ChatDatas[ChatType.LeagueQuestion][index];
|
|
|
|
+ OtherRoleInfoData roleInfo = _dataManager.LeagueData.LeagueMemberDatas[_memberIds[index]].RoleInfo;
|
|
|
|
+ UI_ListChatItem item = UI_ListChatItem.Proxy(obj);
|
|
|
|
+
|
|
|
|
+ RoleInfoManager.Instance.UpdateHeadWithLv(item.m_comHead, roleInfo.headId, roleInfo.headBorderId, roleInfo.roleLv);
|
|
|
|
+ item.m_txtName.text = roleInfo.roleName;
|
|
|
|
+ item.m_txtChatContent.text = chatData.Content;
|
|
|
|
|
|
|
|
+ UI_ListChatItem.ProxyEnd();
|
|
|
|
+ }
|
|
|
|
+ private string GetListItemResource(int index)
|
|
|
|
+ {
|
|
|
|
+ if (_memberIds[index] == RoleDataManager.roleId)
|
|
|
|
+ return "ui://League/ListChatItemMine";
|
|
|
|
+ else
|
|
|
|
+ return "ui://League/ListChatItem";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|