122 lines
3.1 KiB
C#
122 lines
3.1 KiB
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ServerWorkMessagePanel : MonoBehaviour
|
|
{
|
|
public static ServerWorkMessagePanel Instance;
|
|
public static string workMessageType = "";
|
|
public static string workMessage = "";
|
|
public static string workPresent = "";
|
|
public static int workMessageCount = 0;
|
|
|
|
[Header("UI 元件")]
|
|
public GameObject messageLoadPanel;
|
|
public GameObject messageReceivedPanel;
|
|
public TMP_Text messageInfoText;
|
|
public TMP_Text typeText;
|
|
public TMP_Text messageText;
|
|
public TMP_Text presentText;
|
|
public Button replyButton;
|
|
|
|
public static void cleanData()
|
|
{
|
|
//workMessageType = "";
|
|
//workMessage = "";
|
|
//workPresent = "";
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
if (messageLoadPanel)
|
|
{
|
|
messageLoadPanel.SetActive(false);
|
|
}
|
|
if (messageReceivedPanel)
|
|
{
|
|
messageReceivedPanel.SetActive(false);
|
|
}
|
|
if (replyButton)
|
|
{
|
|
replyButton.onClick.AddListener(replyButton_onClicked);
|
|
}
|
|
onReceivedData();
|
|
}
|
|
|
|
public void onReceivedData()
|
|
{
|
|
if (string.IsNullOrEmpty(workMessageType))
|
|
{
|
|
if (messageLoadPanel)
|
|
{
|
|
messageLoadPanel.SetActive(true);
|
|
}
|
|
if (messageInfoText)
|
|
{
|
|
messageInfoText.text = "系統提示:請稍後,連接客戶的願望中...";
|
|
}
|
|
return;
|
|
}
|
|
if ( messageInfoText)
|
|
{
|
|
messageInfoText.text = "系統提示:客戶已傳達願望給您,是否要幫助此客戶?請點擊回覆";
|
|
}
|
|
if (messageLoadPanel)
|
|
{
|
|
messageLoadPanel.SetActive(false);
|
|
}
|
|
if (messageReceivedPanel)
|
|
{
|
|
messageReceivedPanel.SetActive(true);
|
|
}
|
|
if (typeText)
|
|
{
|
|
switch(workMessageType)
|
|
{
|
|
case "TypeMoneyButton":
|
|
typeText.text = "財運";
|
|
break;
|
|
case "TypeHealthButton":
|
|
typeText.text = "健康";
|
|
break;
|
|
case "TypeLoveButton":
|
|
typeText.text = "愛情";
|
|
break;
|
|
default: // "TypeWorkButton"
|
|
typeText.text = "工作";
|
|
break;
|
|
}
|
|
|
|
}
|
|
if (messageText)
|
|
{
|
|
messageText.text = workMessage;
|
|
}
|
|
if (presentText)
|
|
{
|
|
presentText.text = workPresent;
|
|
}
|
|
}
|
|
|
|
private void replyButton_onClicked()
|
|
{
|
|
//this.gameObject.SetActive(false);
|
|
if (ServerWorkSceneController.Instance != null)
|
|
{
|
|
ServerWorkSceneController.Instance.processStep(3);
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|