757 lines
25 KiB
C#
757 lines
25 KiB
C#
using UnityEngine;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine.UI;
|
||
using GCGame.Table;
|
||
using Games.Mission;
|
||
using System;
|
||
|
||
public class ImpreialExamPanelCtr : MonoBehaviour
|
||
{
|
||
public static ImpreialExamPanelCtr Instance;
|
||
private void Awake()
|
||
{
|
||
Instance = this;
|
||
}
|
||
private void OnDestroy()
|
||
{
|
||
Instance = null;
|
||
}
|
||
|
||
public enum Question_Type
|
||
{
|
||
QUESTION_INVALID = -1,
|
||
QUESTION_XIANGSHI,
|
||
QUESTION_HUISHI,
|
||
QUESTION_DIANSHI,
|
||
QUESTION_BAOLINGDAN,
|
||
QUESTION_XINGJIULING,
|
||
}
|
||
Question_Type m_QuestionType = Question_Type.QUESTION_INVALID;
|
||
|
||
public Text ReaminTimeText; //活动剩余时间
|
||
public Text ActivityDescText; //活动描述
|
||
public Text ActivityAwardDescText; //活动奖励描述
|
||
|
||
public Text CurrentQuestionIndexText; //当前第几道
|
||
public Text QuestionDescText; //问题描述
|
||
public ToggleGroup m_ToggleGroup;
|
||
public Text[] m_AllAnswerTexts; //问题选项
|
||
public Toggle[] m_AllAnswerToggles; //问题Toggle
|
||
public Image[] m_AnswwerMarkIcon; //答案正确与否的标记
|
||
|
||
public Button closeBtn; //关闭按钮
|
||
public Button submitBtn; //提交按钮
|
||
|
||
//正确错误Icon
|
||
public Sprite wrongIcon;
|
||
public Sprite rightIcon;
|
||
|
||
|
||
public int m_SelectedAnswer; //选择的答案
|
||
public bool isSubmit = false; //当前问题是否已经提交答案
|
||
|
||
//乡试面板
|
||
public GameObject TimeAndAwardInfoPanel;
|
||
//会试殿试排行榜面板
|
||
public GameObject RankingListPanel;
|
||
//答案
|
||
public GameObject answerPanel;
|
||
public ImperialWaitTimePanel waitPanel;
|
||
|
||
|
||
//是否开启乡试计时器
|
||
private bool isImperialCountTime = false;
|
||
private int m_CurServerTime = 0;
|
||
private int m_ImperialExamOverTime = -1;
|
||
|
||
//答对的题目数
|
||
public int RightCountNum = 0;
|
||
|
||
public Text titleName; //当前活动名字
|
||
|
||
//屏蔽点击蒙版
|
||
public Image ClickMask;
|
||
|
||
public Text curWeekRightCount;
|
||
|
||
//超过活动时间屏蔽页面(文档没写)
|
||
public GameObject _ImperialPanel;
|
||
public GameObject _TimeOutPanel;
|
||
|
||
public Image _ItemIcon;
|
||
public Image _ItemQuality;
|
||
private static int _ItemId = 88001;
|
||
//乡试的时候显示的是奖励和答题信息
|
||
public void InitMyTimeAndAwardDescPanel()
|
||
{
|
||
ActivityDescText.text = StrDictionary.GetClientDictionaryString("#{9102}"); //活动描述
|
||
ActivityAwardDescText.text = StrDictionary.GetClientDictionaryString("#{9103}"); //活动奖励描述
|
||
|
||
//获取会试结束时间(秒)
|
||
GetAndAetImperialExamOverTime();
|
||
//开启乡试计时器
|
||
isImperialCountTime = true;
|
||
//获取当前服务器时间。
|
||
m_CurServerTime = GlobalData.ServerAnsiTime;
|
||
}
|
||
|
||
public void GetAndAetImperialExamOverTime()
|
||
{
|
||
if(m_ImperialExamOverTime == -1)
|
||
{
|
||
var m_ActivityOverTimeHour = 0;
|
||
var m_ActivityOverTimeMinute = 0;
|
||
var activityBase = ActivityDataManager.Instance.GetActivityTabByServerType(ActivityDataManager.Activity_Type.ACTIVITY_IMPERIALEXAM);
|
||
if (activityBase != null)
|
||
{
|
||
string[] m_ActivityTime = activityBase.GetTimebyIndex(0).Split('|');
|
||
m_ActivityOverTimeHour = int.Parse(m_ActivityTime[1]) / 100;
|
||
m_ActivityOverTimeMinute = int.Parse(m_ActivityTime[1]) % 100;
|
||
}
|
||
//结束时间
|
||
DateTime DateOverTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, m_ActivityOverTimeHour, m_ActivityOverTimeMinute, 0);
|
||
m_ImperialExamOverTime = Convert.ToInt32((DateOverTime - DateTime.Now).TotalSeconds);
|
||
|
||
isImperialCountTime = m_ImperialExamOverTime > 0;
|
||
SwitchPanel();
|
||
}
|
||
}
|
||
|
||
private void SwitchPanel()
|
||
{
|
||
if (m_ImperialExamOverTime > 0)
|
||
{
|
||
_ImperialPanel.SetActive(true);
|
||
_TimeOutPanel.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
_ImperialPanel.SetActive(false);
|
||
_TimeOutPanel.SetActive(true);
|
||
}
|
||
}
|
||
|
||
private float _CountRemainTime = 0.0f;
|
||
private float CountSecond = 0;
|
||
private string m_ShowHour = "0";
|
||
private string m_ShowMinute = "0";
|
||
private string m_ShowSecond = "0";
|
||
private void Update()
|
||
{
|
||
//乡试计时
|
||
if (isImperialCountTime)
|
||
{
|
||
CountSecond += Time.deltaTime;
|
||
if (CountSecond >= 1.0f)
|
||
{
|
||
m_ImperialExamOverTime--;
|
||
if (m_ImperialExamOverTime <= 0)
|
||
{
|
||
isImperialCountTime = false;
|
||
ReaminTimeText.text = "0:00:00";
|
||
CountSecond = 0.0f;
|
||
//CloseImperialAct();
|
||
SwitchPanel();
|
||
return;
|
||
}
|
||
//显示剩余的时间
|
||
m_ShowHour = (m_ImperialExamOverTime / 3600).ToString(); //小时
|
||
m_ShowMinute = ((m_ImperialExamOverTime - int.Parse(m_ShowHour) * 3600) / 60).ToString(); //分钟
|
||
m_ShowSecond = ((m_ImperialExamOverTime - int.Parse(m_ShowHour) * 3600 - int.Parse(m_ShowMinute) * 60)).ToString(); //秒
|
||
if (int.Parse(m_ShowSecond) < 10) //秒数小于0 就在前面加个0
|
||
{
|
||
m_ShowSecond = "0" + m_ShowSecond;
|
||
}
|
||
if (int.Parse(m_ShowMinute) < 10)
|
||
{
|
||
m_ShowMinute = "0" + m_ShowMinute;
|
||
}
|
||
//显示
|
||
ReaminTimeText.text = m_ShowHour + ":" + m_ShowMinute + ":" + m_ShowSecond;
|
||
//重置时间
|
||
CountSecond = 1.0f - CountSecond;
|
||
}
|
||
}
|
||
|
||
if (_IsCountRemainTime)
|
||
{
|
||
if(waitRemainTime <= 0)
|
||
{
|
||
_IsCountRemainTime = false;
|
||
return;
|
||
}
|
||
|
||
_CountRemainTime += Time.deltaTime;
|
||
if(_CountRemainTime >= 1.0f)
|
||
{
|
||
_CountRemainTime -= 1.0f;
|
||
waitRemainTime--;
|
||
SetRemainTime();
|
||
}
|
||
}
|
||
}
|
||
|
||
private int waitRemainTime = 0;
|
||
private bool _IsCountRemainTime = false;
|
||
public void CalculateRemainTime()
|
||
{
|
||
DateTime curTime = new DateTime(1970, 1, 1, 8, 0, 0).AddSeconds(GlobalData.ServerAnsiTime);
|
||
DateTime overTime = new DateTime(curTime.Year, curTime.Month, curTime.Day, 19, 1, 0); //当天19.01
|
||
waitRemainTime = (int)(overTime - curTime).TotalSeconds > 0 ? (int)(overTime - curTime).TotalSeconds - 1 : 0; //提前一秒(宁快勿慢)
|
||
if(waitRemainTime > 0)
|
||
{
|
||
_IsCountRemainTime = true;
|
||
}else
|
||
{
|
||
_IsCountRemainTime = false;
|
||
}
|
||
SetRemainTime();
|
||
}
|
||
|
||
public void SetRemainTime()
|
||
{
|
||
if(waitRemainTime <= 0)
|
||
{
|
||
_WaitTime.text = "0";
|
||
_IsCountRemainTime = false;
|
||
}
|
||
else
|
||
{
|
||
_WaitTime.text = waitRemainTime.ToString();
|
||
}
|
||
}
|
||
|
||
public Text _WaitTime;
|
||
public void ShowWaitPanel()
|
||
{
|
||
waitPanel.gameObject.SetActive(true);
|
||
waitPanel.SetWaitType();
|
||
_ImperialPanel.SetActive(true);
|
||
_TimeOutPanel.SetActive(false);
|
||
|
||
TimeAndAwardInfoPanel.SetActive(false);
|
||
RankingListPanel.SetActive(false);
|
||
answerPanel.SetActive(false);
|
||
}
|
||
|
||
public void InitRew()
|
||
{
|
||
var commonItem = TableManager.GetCommonItemByID(_ItemId, 0);
|
||
if (commonItem == null)
|
||
{
|
||
if (_ItemIcon)
|
||
_ItemIcon.gameObject.SetActive(false);
|
||
if (_ItemQuality)
|
||
_ItemQuality.gameObject.SetActive(false);
|
||
}
|
||
if (_ItemIcon)
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(_ItemIcon, commonItem.Icon);
|
||
if (commonItem.QualityEffect > 0)
|
||
{
|
||
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, _ItemIcon.transform);
|
||
}
|
||
else
|
||
{
|
||
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, _ItemIcon.transform);
|
||
}
|
||
|
||
}
|
||
if (_ItemQuality)
|
||
LoadAssetBundle.Instance.SetImageSprite(_ItemQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
||
}
|
||
|
||
public void HideWaitPanel()
|
||
{
|
||
_ImperialPanel.SetActive(true);
|
||
_TimeOutPanel.SetActive(false);
|
||
|
||
waitPanel.gameObject.SetActive(false);
|
||
answerPanel.SetActive(true);
|
||
if(m_QuestionType == Question_Type.QUESTION_XIANGSHI)
|
||
{
|
||
TimeAndAwardInfoPanel.SetActive(true);
|
||
InitRew();
|
||
RankingListPanel.SetActive(false);
|
||
}else
|
||
{
|
||
TimeAndAwardInfoPanel.SetActive(false);
|
||
RankingListPanel.SetActive(true);
|
||
}
|
||
}
|
||
|
||
public void CloseImperialAct()
|
||
{
|
||
UIManager.CloseUI(UIInfo.ImperialExamPanel);
|
||
if (RightCountNum > 0)
|
||
{
|
||
MessageBoxLogic.OpenOKBox(StrDictionary.GetClientDictionaryString("#{44003}", RightCountNum), "", OnOKBtnClick);
|
||
}
|
||
}
|
||
public void OnOKBtnClick()
|
||
{
|
||
UIManager.CloseUI(UIInfo.MessageBox);
|
||
}
|
||
|
||
public void SetMyQuestionType(Question_Type type)
|
||
{
|
||
m_QuestionType = type;
|
||
SetMyExamDescImage();
|
||
}
|
||
|
||
//设置当前考试的类型
|
||
public void SetMyQuestionType(int m_Type, int Sub_Type = 0)
|
||
{
|
||
answerPanel.SetActive(false);
|
||
waitPanel.gameObject.SetActive(false);
|
||
|
||
switch (m_Type)
|
||
{
|
||
case (int)ActivityDataManager.Activity_Type.ACTIVITY_IMPERIALEXAM:
|
||
|
||
if (!TimeAndAwardInfoPanel.activeInHierarchy)
|
||
{
|
||
TimeAndAwardInfoPanel.SetActive(true);
|
||
InitRew();
|
||
}
|
||
if (RankingListPanel.gameObject.activeInHierarchy)
|
||
{
|
||
RankingListPanel.gameObject.SetActive(false); //打开排行榜panel
|
||
}
|
||
|
||
m_QuestionType = Question_Type.QUESTION_XIANGSHI;
|
||
//左边的面板是乡试描述
|
||
TimeAndAwardInfoPanel.gameObject.SetActive(true);
|
||
InitMyTimeAndAwardDescPanel();
|
||
ResetMyLastAnswer();
|
||
AskQuestionInfo((int)m_QuestionType);
|
||
break;
|
||
default:
|
||
if (Sub_Type == 1)
|
||
{
|
||
m_QuestionType = Question_Type.QUESTION_HUISHI;
|
||
AskQuestionInfo((int)m_QuestionType);
|
||
}
|
||
else if (Sub_Type == 2)
|
||
{
|
||
m_QuestionType = Question_Type.QUESTION_DIANSHI;
|
||
AskQuestionInfo((int)m_QuestionType);
|
||
}
|
||
if (TimeAndAwardInfoPanel.activeInHierarchy)
|
||
{
|
||
TimeAndAwardInfoPanel.SetActive(false);
|
||
}
|
||
if (!RankingListPanel.gameObject.activeInHierarchy)
|
||
{
|
||
RankingListPanel.gameObject.SetActive(true); //打开排行榜panel
|
||
}
|
||
if (ImperialExamWaitPanelCtr.Instance)
|
||
{
|
||
UIManager.CloseUI(UIInfo.ImperialExamWaitPanel);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
//答案0查询信息 不答题
|
||
public void AskQuestionInfo(int type)
|
||
{
|
||
CG_REQ_QUESTION answerQuestion = (CG_REQ_QUESTION)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_QUESTION);
|
||
answerQuestion.SetReqType(type);
|
||
answerQuestion.SetAnswer(0);
|
||
answerQuestion.SendPacket();
|
||
}
|
||
|
||
public void SetMyExamDescImage()
|
||
{
|
||
switch (m_QuestionType)
|
||
{
|
||
case Question_Type.QUESTION_XIANGSHI:
|
||
titleName.text = StrDictionary.GetClientDictionaryString("#{6519}");// "科举乡试";
|
||
break;
|
||
case Question_Type.QUESTION_HUISHI:
|
||
titleName.text = StrDictionary.GetClientDictionaryString("#{6520}");// "科举会试";
|
||
break;
|
||
case Question_Type.QUESTION_DIANSHI:
|
||
titleName.text = StrDictionary.GetClientDictionaryString("#{6521}");// "科举殿试";
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
//请求开始答题
|
||
public void RequestQuestionStart()
|
||
{
|
||
CG_REQ_QUESTION answerQuestion = (CG_REQ_QUESTION)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_QUESTION);
|
||
answerQuestion.SetReqType((int)Question_Type.QUESTION_XIANGSHI);
|
||
answerQuestion.SetAnswer(m_SelectedAnswer);
|
||
answerQuestion.SendPacket();
|
||
}
|
||
|
||
//每次刷新题目的时候重置上一次的选择
|
||
public void ResetMyLastAnswer()
|
||
{
|
||
for (int index = 0; index < m_AllAnswerToggles.Length; index++)
|
||
{
|
||
m_AllAnswerToggles[index].isOn = false;
|
||
m_AnswwerMarkIcon[index].gameObject.SetActive(false); //清空正确错误标记
|
||
}
|
||
m_SelectedAnswer = -1;
|
||
isSubmit = false; //当前问题还没有提交
|
||
ClickMask.gameObject.SetActive(false);
|
||
}
|
||
|
||
|
||
//通过ID设置当前的问题描述以及左边面板的显示
|
||
private int m_QuestionId = -1; //当前问题的ID
|
||
private int m_RemainTime = 0;
|
||
private int m_RightCount;
|
||
private int m_HuishiCount = 0;
|
||
private int m_TodayRightCount;
|
||
private bool isFirst = true;
|
||
|
||
private void OnEnable()
|
||
{
|
||
isFirst = true;
|
||
}
|
||
|
||
public void AskForInfo()
|
||
{
|
||
CG_REQ_QUESTION answerQuestion = (CG_REQ_QUESTION)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_QUESTION);
|
||
answerQuestion.SetReqType((int)ImpreialExamPanelCtr.Question_Type.QUESTION_XIANGSHI);
|
||
answerQuestion.SetAnswer(0);
|
||
answerQuestion.SendPacket();
|
||
}
|
||
|
||
|
||
public void SetMyQuestionInfo(int questionId, int remainTime, int RightCount, int huishiCount, int todayRightCount)
|
||
{
|
||
//设置Title图片
|
||
SetMyExamDescImage();
|
||
if (m_QuestionType != Question_Type.QUESTION_XIANGSHI && huishiCount == 0)
|
||
{
|
||
//活动尚未开始
|
||
ShowWaitPanel();
|
||
return;
|
||
}
|
||
|
||
HideWaitPanel();
|
||
m_QuestionId = questionId;
|
||
m_RemainTime = remainTime;
|
||
m_RightCount = RightCount;
|
||
m_HuishiCount = huishiCount;
|
||
m_TodayRightCount = todayRightCount;
|
||
|
||
if (m_QuestionType == Question_Type.QUESTION_XIANGSHI)
|
||
{
|
||
if(isFirst)
|
||
{
|
||
isFirst = false;
|
||
SetXiangShiQuestion();
|
||
}else
|
||
{
|
||
Invoke("SetXiangShiQuestion", 2.5f); //2.5S后刷新下一题
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (remainTime > 0)
|
||
{
|
||
ResetMyLastAnswer();
|
||
}
|
||
SetHuiShiQuestion();
|
||
}
|
||
}
|
||
|
||
public void SetXiangShiQuestion()
|
||
{
|
||
ResetMyLastAnswer();
|
||
SetMyAnswerAndFontColor(); //设置可以选择的答案以及答案的颜色
|
||
Tab_QuestionBank questionBank = TableManager.GetQuestionBankByID(m_QuestionId, 0);
|
||
if (questionBank == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
QuestionDescText.text = questionBank.QuestionDesc; //设置问题描述
|
||
|
||
curWeekRightCount.text = StrDictionary.GetClientDictionaryString("#{44001}", m_RightCount);
|
||
RightCountNum = m_RightCount; //记录答对的数量
|
||
int complete = ActivityDataManager.Instance.GetActivityCompleteTimes((int)ActivityDataManager.Activity_Type.ACTIVITY_IMPERIALEXAM,false);
|
||
CurrentQuestionIndexText.text = StrDictionary.GetClientDictionaryString("#{44002}", complete + 1 > 20 ? complete - 19 : complete + 1);
|
||
}
|
||
|
||
public void SetHuiShiQuestion()
|
||
{
|
||
SetMyAnswerAndFontColor(); //设置可以选择的答案以及答案的颜色
|
||
Tab_QuestionBank questionBank = TableManager.GetQuestionBankByID(m_QuestionId, 0);
|
||
if (questionBank == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
QuestionDescText.text = questionBank.QuestionDesc; //设置问题描述
|
||
|
||
curWeekRightCount.text = StrDictionary.GetClientDictionaryString("#{44001}", m_RightCount);
|
||
RightCountNum = m_RightCount; //记录答对的数量
|
||
|
||
//服务器同步
|
||
if (m_HuishiCount < 21)
|
||
{
|
||
CurrentQuestionIndexText.text = StrDictionary.GetClientDictionaryString("#{44002}", m_HuishiCount.ToString()); //当前是会试阶段
|
||
if (m_QuestionType != Question_Type.QUESTION_HUISHI)
|
||
SetMyQuestionType((int)ActivityDataManager.Activity_Type.ACTIVITY_HUISHI, 1);
|
||
}
|
||
else if (m_HuishiCount == 21)
|
||
{
|
||
//当前是否已经竞猜
|
||
CG_QUESTION_GUESSING_INFO req = (CG_QUESTION_GUESSING_INFO)PacketDistributed.CreatePacket(MessageID.PACKET_CG_QUESTION_GUESSING_INFO);
|
||
req.SetParam(1);
|
||
req.SendPacket();
|
||
}
|
||
else if (m_HuishiCount > 21)
|
||
{
|
||
//殿试
|
||
CurrentQuestionIndexText.text = StrDictionary.GetClientDictionaryString("#{44002}", m_HuishiCount - 21); //(huishiCount - 21).ToString(); //当前是殿试阶段
|
||
if (m_QuestionType != Question_Type.QUESTION_DIANSHI)
|
||
SetMyQuestionType((int)ActivityDataManager.Activity_Type.ACTIVITY_HUISHI, 2);
|
||
|
||
//if (m_HuishiCount == 41)
|
||
//{
|
||
// // Invoke("CompleteDianshi", 16); //写死
|
||
//}
|
||
}
|
||
|
||
//通知会试计时器
|
||
if (m_RemainTime > 0)
|
||
RankingPanelCtr.Instance.SetMyQuestionRemainTime(m_RemainTime, m_QuestionType);
|
||
}
|
||
|
||
public void OnGuessingPacketReceive(GC_QUESTION_GUESSING_INFO packet)
|
||
{
|
||
if((long)packet.Targetguid > 0 || IsOnRankPanel())
|
||
{
|
||
ShowWaitPanel();
|
||
}else
|
||
{
|
||
//CloseImperialAct();
|
||
//因为弹出竞猜 所以答题被关闭 所以殿试时协议通知可以再次打开答题面板
|
||
if (ImperialExamManager.GetInstance().GetMyRankInfoList().Count > 0 && !IsOnRankPanel()) //有人上榜的时候才会弹出竞猜界面
|
||
{
|
||
ImperialExamManager.GetInstance().GuessingRemainTime = m_RemainTime;
|
||
//竞猜 打开竞猜面板 关闭答题面板
|
||
UIManager.ShowUI(UIInfo.ImperialGuessingPanel, delegate (bool bSucess, object param)
|
||
{
|
||
if (bSucess)
|
||
{
|
||
ImperialGuessingPanelCtr.Instance.SetMyRoleInfoPanel(ImperialExamManager.GetInstance().GetMyRankInfoList(),
|
||
ImperialExamManager.GetInstance().GuessingRemainTime);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
public bool IsOnRankPanel()
|
||
{
|
||
for(int index = 0; index < ImperialExamManager.GetInstance().GetMyRankInfoList().Count; index++)
|
||
{
|
||
if(Singleton<ObjManager>.Instance.MainPlayer != null
|
||
&& Singleton<ObjManager>.Instance.MainPlayer.GUID == ImperialExamManager.GetInstance().GetMyRankInfoList()[index].guid)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public void CompleteDianshi()
|
||
{
|
||
UIManager.CloseUI(UIInfo.ImperialExamPanel);
|
||
}
|
||
|
||
//设置答案 以及 答案颜色
|
||
public void SetMyAnswerAndFontColor()
|
||
{
|
||
Tab_QuestionBank questionBank = TableManager.GetQuestionBankByID(m_QuestionId, 0);
|
||
if (questionBank == null)
|
||
{
|
||
return;
|
||
}
|
||
for (int index = 0; index < m_AllAnswerToggles.Length; index++)
|
||
{
|
||
m_AllAnswerTexts[index].text = questionBank.GetAnswerbyIndex(index);
|
||
}
|
||
}
|
||
|
||
|
||
//设置选择的答案
|
||
public void OnToggleVlueChange(int index)
|
||
{
|
||
switch (index)
|
||
{
|
||
case 1:
|
||
m_SelectedAnswer = 1;
|
||
break;
|
||
case 2:
|
||
m_SelectedAnswer = 2;
|
||
break;
|
||
case 3:
|
||
m_SelectedAnswer = 3;
|
||
break;
|
||
case 4:
|
||
m_SelectedAnswer = 4;
|
||
break;
|
||
default:
|
||
m_SelectedAnswer = -1;
|
||
break;
|
||
}
|
||
if (m_AllAnswerToggles[m_SelectedAnswer - 1].isOn) //每次重置的时候会改变Toggle值 这里要判断有打开的Toggle才发送答案
|
||
{
|
||
//直接发送答案
|
||
SubmitBtnClick();
|
||
}
|
||
//改变颜色
|
||
SetMyAnswerAndFontColor();
|
||
}
|
||
|
||
//协议发送当前的答案
|
||
public void SubmitBtnClick()
|
||
{
|
||
if(m_QuestionType != Question_Type.QUESTION_XIANGSHI
|
||
&& !GameManager.gameManager.PlayerDataPool.IsHaveImperialEligible)
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{4610}"));
|
||
return;
|
||
}
|
||
if (isSubmit || m_SelectedAnswer == -1)
|
||
{
|
||
return; //不做处理
|
||
}
|
||
if (!isSubmit)
|
||
{
|
||
isSubmit = true; //当前问题已经提交 只有在服务器通知刷新题目的时候才会重置
|
||
ClickMask.gameObject.SetActive(true);
|
||
}
|
||
switch (m_QuestionType)
|
||
{
|
||
case Question_Type.QUESTION_XIANGSHI:
|
||
//显示答案的对错
|
||
ShowAnswerWrongOrRight();
|
||
//等待一秒 发送协议
|
||
SendMyAnswer();
|
||
break;
|
||
default:
|
||
//直接发协议
|
||
SendMyAnswer(); //不显示答案对错 在倒计时结束的时候才显示
|
||
break;
|
||
}
|
||
}
|
||
|
||
public void SendMyAnswer()
|
||
{
|
||
CG_REQ_QUESTION answerQuestion = (CG_REQ_QUESTION)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_QUESTION);
|
||
answerQuestion.SetReqType((int)m_QuestionType);
|
||
answerQuestion.SetAnswer(m_SelectedAnswer);
|
||
answerQuestion.SendPacket();
|
||
var complete = ActivityDataManager.Instance.GetActivityCompleteTimes((int)ActivityDataManager.Activity_Type.ACTIVITY_IMPERIALEXAM, false);
|
||
//判断次数 完成科举
|
||
if (m_QuestionType == Question_Type.QUESTION_XIANGSHI
|
||
&& complete + 1 == 20)
|
||
{
|
||
//只有乡试才会弹
|
||
CompleteImperialExam();
|
||
}
|
||
}
|
||
|
||
public void CompleteImperialExam()
|
||
{
|
||
// UIManager.CloseUI(UIInfo.ImperialExamPanel);
|
||
if (RightCountNum > 0)
|
||
{
|
||
MessageBoxLogic.OpenOKBox(StrDictionary.GetClientDictionaryString("#{6518}", m_TodayRightCount), null, CloseMyMessageBoxAndImperial);
|
||
}
|
||
}
|
||
|
||
public void CloseMyMessageBoxAndImperial()
|
||
{
|
||
UIManager.CloseUI(UIInfo.MessageBox);
|
||
}
|
||
|
||
public void ShowAnswerWrongOrRight()
|
||
{
|
||
//读表读取正确答案
|
||
Tab_QuestionBank questionBank = TableManager.GetQuestionBankByID(m_QuestionId, 0);
|
||
if (questionBank == null)
|
||
{
|
||
return;
|
||
}
|
||
int m_RightAnswer = -1;
|
||
switch (questionBank.RightAnswer)
|
||
{
|
||
case "A":
|
||
m_RightAnswer = 1;
|
||
break;
|
||
case "B":
|
||
m_RightAnswer = 2;
|
||
break;
|
||
case "C":
|
||
m_RightAnswer = 3;
|
||
break;
|
||
case "D":
|
||
m_RightAnswer = 4;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
//选择正确
|
||
if (m_SelectedAnswer == m_RightAnswer)
|
||
{
|
||
var complete = ActivityDataManager.Instance.GetActivityCompleteTimes((int)ActivityDataManager.Activity_Type.ACTIVITY_IMPERIALEXAM, false);
|
||
//判断次数 完成科举
|
||
if (m_QuestionType == Question_Type.QUESTION_XIANGSHI
|
||
&& complete + 1 == 20)
|
||
{
|
||
//只有乡试才会弹
|
||
m_TodayRightCount += 1;
|
||
}
|
||
|
||
//正确答案显示绿色对号
|
||
m_AnswwerMarkIcon[m_SelectedAnswer - 1].gameObject.SetActive(true);
|
||
m_AnswwerMarkIcon[m_SelectedAnswer - 1].sprite = rightIcon;
|
||
m_AnswwerMarkIcon[m_SelectedAnswer - 1].SetNativeSize();
|
||
}
|
||
else if (m_SelectedAnswer == -1)
|
||
{
|
||
//正确的答案显示正确的标记
|
||
m_AnswwerMarkIcon[m_RightAnswer - 1].gameObject.SetActive(true);
|
||
m_AnswwerMarkIcon[m_RightAnswer - 1].sprite = rightIcon;
|
||
m_AnswwerMarkIcon[m_RightAnswer - 1].SetNativeSize();
|
||
}
|
||
else if (m_SelectedAnswer != m_RightAnswer) //选择错误
|
||
{
|
||
//选择的答案显示错误标记
|
||
m_AnswwerMarkIcon[m_SelectedAnswer - 1].gameObject.SetActive(true);
|
||
m_AnswwerMarkIcon[m_SelectedAnswer - 1].sprite = wrongIcon;
|
||
m_AnswwerMarkIcon[m_SelectedAnswer - 1].SetNativeSize();
|
||
//正确的答案显示正确的标记
|
||
m_AnswwerMarkIcon[m_RightAnswer - 1].gameObject.SetActive(true);
|
||
m_AnswwerMarkIcon[m_RightAnswer - 1].sprite = rightIcon;
|
||
m_AnswwerMarkIcon[m_RightAnswer - 1].SetNativeSize();
|
||
}
|
||
}
|
||
|
||
public void OnRewardClick()
|
||
{
|
||
ItemTooltipsLogic.ShowItemTooltip(88001, ItemTooltipsLogic.ShowType.Info, transform.position);
|
||
}
|
||
|
||
public void CloseBtnClick()
|
||
{
|
||
GlobalData.HasOpenedImperialExamPanel = true; //手动关闭记录(同步试题的时候不再自动打开UI)
|
||
UIManager.CloseUI(UIInfo.ImperialExamPanel);
|
||
}
|
||
}
|