73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Game
|
|
{
|
|
[UIType(UIType.GameSceneMainUI)]
|
|
public class GameSceneMainUI : UIBase
|
|
{
|
|
private Button btn_Back;
|
|
private Button btn_Help;
|
|
private TMP_Dropdown dropdown;
|
|
private Button btn_Investment;
|
|
private TMP_Text txt_Jinbei;
|
|
private TMP_Text txt_Message;
|
|
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
this.btn_Back = self.transform.FindChildDeep<Button>("btn_Back");
|
|
this.btn_Help = self.transform.FindChildDeep<Button>("btn_Help");
|
|
this.btn_Investment = self.transform.FindChildDeep<Button>("btn_Investment");
|
|
this.dropdown = self.transform.FindChildDeep<TMP_Dropdown>("dropdown");
|
|
this.txt_Jinbei = self.transform.FindChildDeep<TMP_Text>("txt_Jinbei");
|
|
this.txt_Message = self.transform.FindChildDeep<TMP_Text>("txt_Message");
|
|
|
|
this.btn_Back.onClick.AddListener(ClickBackButton);
|
|
this.btn_Help.onClick.AddListener(ClickHelpButton);
|
|
this.btn_Investment.onClick.AddListener(ClickInvestmentButton);
|
|
}
|
|
|
|
public override void Dispose()
|
|
{
|
|
base.Dispose();
|
|
this.btn_Back.onClick.RemoveListener(ClickBackButton);
|
|
this.btn_Help.onClick.RemoveListener(ClickHelpButton);
|
|
this.btn_Investment.onClick.RemoveListener(ClickInvestmentButton);
|
|
}
|
|
|
|
private void ClickInvestmentButton()
|
|
{
|
|
var inputFieldText = this.dropdown.captionText.text;
|
|
if (string.IsNullOrEmpty(inputFieldText))
|
|
return;
|
|
|
|
var ji = float.Parse(inputFieldText);
|
|
EventManager.Instance.FireNow(this, new PlayerJinbeiChangeEventArgs(ji, ShowResult));
|
|
}
|
|
|
|
void ShowResult(bool result)
|
|
{
|
|
if (result) Debug.Log("投注成功");
|
|
else Debug.Log("投注失败");
|
|
|
|
//TODO:
|
|
}
|
|
|
|
public void UpdateMessage(string message)
|
|
{
|
|
this.txt_Message.text = message;
|
|
}
|
|
|
|
private void ClickHelpButton()
|
|
{
|
|
Game.uiManager.ShowUI(UIType.GameSceneHelpUI);
|
|
}
|
|
|
|
private void ClickBackButton()
|
|
{
|
|
//TODO:
|
|
}
|
|
}
|
|
} |