2023-12-25 22:53:30 +08:00
|
|
|
|
using System.Collections;
|
2023-12-30 18:22:40 +08:00
|
|
|
|
using System.Collections.Generic;
|
2023-12-25 22:53:30 +08:00
|
|
|
|
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;
|
2023-12-30 18:22:40 +08:00
|
|
|
|
|
2023-12-25 22:53:30 +08:00
|
|
|
|
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()
|
|
|
|
|
{
|
2023-12-30 18:22:40 +08:00
|
|
|
|
var count = ExcelManager.Instance.GetPlayerCount;
|
|
|
|
|
if (count == 0)
|
|
|
|
|
{
|
|
|
|
|
UIManager.Instance.OpenPanel(PanelType.Finish);
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 22:53:30 +08:00
|
|
|
|
SaveExcelData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClickStop()
|
|
|
|
|
{
|
|
|
|
|
isRoll = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator Roll()
|
|
|
|
|
{
|
2023-12-30 18:22:40 +08:00
|
|
|
|
var playerInfo = ExcelManager.Instance.GetPlayerInfo;
|
|
|
|
|
|
2023-12-25 22:53:30 +08:00
|
|
|
|
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;
|
2023-12-30 18:22:40 +08:00
|
|
|
|
|
|
|
|
|
SaveExcelData.SaveExcelDataInfo dataInfo = new SaveExcelData.SaveExcelDataInfo(new string[4]);
|
|
|
|
|
dataInfo.strings = new[] { playerInfo.id, playerInfo.name, txt_TeamContent.text, txt_CultureContent.text };
|
|
|
|
|
|
|
|
|
|
var summaryInfo = new SummaryInfo();
|
|
|
|
|
summaryInfo.id = int.Parse(playerInfo.id);
|
|
|
|
|
summaryInfo.team = txt_TeamContent.text;
|
|
|
|
|
summaryInfo.culture = txt_CultureContent.text;
|
|
|
|
|
GlobalManager.Instance.list.Add(summaryInfo);
|
|
|
|
|
|
|
|
|
|
_list.Add(dataInfo);
|
2023-12-25 22:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-30 18:22:40 +08:00
|
|
|
|
private List<SaveExcelData.SaveExcelDataInfo> _list = new List<SaveExcelData.SaveExcelDataInfo>();
|
|
|
|
|
|
2023-12-25 22:53:30 +08:00
|
|
|
|
void SaveExcelData()
|
|
|
|
|
{
|
|
|
|
|
SaveExcelData.SaveExcelDataInfo dataInfo = new SaveExcelData.SaveExcelDataInfo(new string[4]);
|
|
|
|
|
dataInfo.strings = new[] { "", "", txt_TeamContent.text, txt_CultureContent.text };
|
2023-12-30 18:22:40 +08:00
|
|
|
|
// ExcelManager.Instance.SaveAndExpIndex(dataInfo, index);
|
2023-12-25 22:53:30 +08:00
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|