97 lines
2.9 KiB
C#
97 lines
2.9 KiB
C#
using NUnit.Framework;
|
|
using System;
|
|
using System.Threading;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ServerWorkMessageReplyWordsPanel : MonoBehaviour
|
|
{
|
|
public static ServerWorkMessageReplyWordsPanel Instance;
|
|
|
|
public Button sampleLeftButton;
|
|
public Button sampleRightButton;
|
|
public Button submitButton;
|
|
public TMP_InputField replyMessageInputField;
|
|
|
|
private int currentSampleWordsIndex = 0;
|
|
private string[] sampleWords = {
|
|
"福在心間非遠方行誠一步百事昌天開一線容人渡前路微光漸放芒",
|
|
"命裡有時終必至急行反失遠行期靜看潮起潮又落好風自會送舟歸",
|
|
"心誠萬事皆能順莫急莫慌自有門天道酬勤終不負善念長存歸本根",
|
|
"汝問蒼天天不語早知汝路自難移命數原非神可改徒然叩首費心思",
|
|
"求財無財空添亂問愛無愛更心煩問命問天徒自苦不如回家補個眠"
|
|
};
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
if (sampleLeftButton)
|
|
{
|
|
sampleLeftButton.onClick.AddListener(sampleLeftButton_onClicked);
|
|
}
|
|
if (sampleRightButton)
|
|
{
|
|
sampleRightButton.onClick.AddListener(sampleRightButton_onClicked);
|
|
}
|
|
if (submitButton)
|
|
{
|
|
submitButton.onClick.AddListener(submitButton_onClicked);
|
|
}
|
|
}
|
|
|
|
private void submitButton_onClicked()
|
|
{
|
|
GlobalData.WORD_COUNT += 1;
|
|
|
|
GameMessageWorkResult msgObj = new GameMessageWorkResult {
|
|
count = ServerWorkMessagePanel.workMessageCount,
|
|
result = ServerWorkMessageReplyPanel.messageReply,
|
|
resultText = replyMessageInputField.text
|
|
};
|
|
string payloadStr = JsonUtility.ToJson(msgObj);
|
|
|
|
NetworkMessageHandler.Instance.SendMessageToClient("workMessageResult", payloadStr);
|
|
if (ServerWorkSceneController.Instance != null)
|
|
{
|
|
ServerWorkSceneController.Instance.processStep(5);
|
|
}
|
|
|
|
}
|
|
|
|
private void sampleRightButton_onClicked()
|
|
{
|
|
if (replyMessageInputField)
|
|
{
|
|
currentSampleWordsIndex++;
|
|
if (currentSampleWordsIndex >= sampleWords.Length)
|
|
currentSampleWordsIndex = sampleWords.Length - 1;
|
|
|
|
replyMessageInputField.text = sampleWords[currentSampleWordsIndex];
|
|
}
|
|
}
|
|
|
|
private void sampleLeftButton_onClicked()
|
|
{
|
|
if (replyMessageInputField)
|
|
{
|
|
currentSampleWordsIndex--;
|
|
if (currentSampleWordsIndex < 0)
|
|
currentSampleWordsIndex = 0;
|
|
|
|
replyMessageInputField.text = sampleWords[currentSampleWordsIndex];
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|