93 lines
2.7 KiB
C#
93 lines
2.7 KiB
C#
|
using System.Collections;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace Script.UI
|
|||
|
{
|
|||
|
public class DrawPanel : PanelBase
|
|||
|
{
|
|||
|
public Text txt_TeamContent;
|
|||
|
public Text txt_CultureContent;
|
|||
|
public Button btn_Start;
|
|||
|
public Button btn_Stop;
|
|||
|
public Button btn_Close;
|
|||
|
|
|||
|
private bool isRoll;
|
|||
|
private int index;
|
|||
|
|
|||
|
public override void Init()
|
|||
|
{
|
|||
|
base.Init();
|
|||
|
btn_Start.onClick.AddListener(ClickStart);
|
|||
|
btn_Stop.onClick.AddListener(ClickStop);
|
|||
|
btn_Close.onClick.AddListener(ClickClose);
|
|||
|
btn_Start.gameObject.SetActive(true);
|
|||
|
btn_Stop.gameObject.SetActive(false);
|
|||
|
btn_Close.gameObject.SetActive(false);
|
|||
|
index = 0;
|
|||
|
isRoll = false;
|
|||
|
|
|||
|
txt_TeamContent.text = "";
|
|||
|
txt_CultureContent.text = "";
|
|||
|
}
|
|||
|
|
|||
|
public override void Dispose()
|
|||
|
{
|
|||
|
base.Dispose();
|
|||
|
btn_Start.onClick.RemoveListener(ClickStart);
|
|||
|
btn_Stop.onClick.RemoveListener(ClickStop);
|
|||
|
btn_Close.onClick.RemoveListener(ClickClose);
|
|||
|
}
|
|||
|
|
|||
|
public override void Open()
|
|||
|
{
|
|||
|
base.Open();
|
|||
|
btn_Start.gameObject.SetActive(true);
|
|||
|
btn_Stop.gameObject.SetActive(false);
|
|||
|
btn_Close.gameObject.SetActive(false);
|
|||
|
index = 0;
|
|||
|
isRoll = false;
|
|||
|
}
|
|||
|
|
|||
|
private void ClickStart()
|
|||
|
{
|
|||
|
isRoll = true;
|
|||
|
StartCoroutine(Roll());
|
|||
|
}
|
|||
|
|
|||
|
private void ClickClose()
|
|||
|
{
|
|||
|
SaveExcelData();
|
|||
|
}
|
|||
|
|
|||
|
private void ClickStop()
|
|||
|
{
|
|||
|
isRoll = false;
|
|||
|
}
|
|||
|
|
|||
|
IEnumerator Roll()
|
|||
|
{
|
|||
|
while (isRoll)
|
|||
|
{
|
|||
|
yield return new WaitForSeconds(0.02f);
|
|||
|
var teamData = ExcelManager.Instance.GetTeamRandomInfo;
|
|||
|
txt_TeamContent.text = teamData.teamName;
|
|||
|
var cultureData = ExcelManager.Instance.GetCultureRandomInfo;
|
|||
|
txt_CultureContent.text = cultureData.cultureName;
|
|||
|
}
|
|||
|
|
|||
|
var teamData1 = ExcelManager.Instance.GetTeamRandomInfo;
|
|||
|
txt_TeamContent.text = teamData1.teamName;
|
|||
|
var cultureData1 = ExcelManager.Instance.GetCultureRandomInfo;
|
|||
|
txt_CultureContent.text = cultureData1.cultureName;
|
|||
|
}
|
|||
|
|
|||
|
void SaveExcelData()
|
|||
|
{
|
|||
|
SaveExcelData.SaveExcelDataInfo dataInfo = new SaveExcelData.SaveExcelDataInfo(new string[4]);
|
|||
|
dataInfo.strings = new[] { "", "", txt_TeamContent.text, txt_CultureContent.text };
|
|||
|
ExcelManager.Instance.SaveAndExpIndex(dataInfo, index);
|
|||
|
index++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|