96 lines
2.2 KiB
C#
96 lines
2.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class ClientLastWordsSceneController : MonoBehaviour
|
|
{
|
|
public static ClientLastWordsSceneController Instance;
|
|
public static string words;
|
|
|
|
public GameObject wordsPanel;
|
|
public GameObject surveyPanel;
|
|
|
|
public Button wordsNextButton;
|
|
public Button surveySubmitButton;
|
|
public TMP_Text wordsText;
|
|
|
|
private SurveyManager surveyManager;
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
surveyManager = surveyPanel.GetComponentInChildren<SurveyManager>(includeInactive: true);
|
|
}
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
if (wordsNextButton)
|
|
{
|
|
wordsNextButton.onClick.AddListener(wordsNextButton_onClick);
|
|
}
|
|
init();
|
|
}
|
|
|
|
public void init()
|
|
{
|
|
processStep(1);
|
|
|
|
if (wordsText)
|
|
{
|
|
wordsText.text = words;
|
|
}
|
|
|
|
surveyManager.OnSurveyConfirmed = OnSurveyConfirmed;
|
|
}
|
|
|
|
private void OnSurveyConfirmed(int val1, int val2, int val3, string text)
|
|
{
|
|
if (ClientMessageHandler.Instance)
|
|
{
|
|
GameMessageSurvey msgObj = new GameMessageSurvey {
|
|
val1 = val1,
|
|
val2 = val2,
|
|
val3 = val3,
|
|
text1 = text
|
|
};
|
|
|
|
string payload = JsonUtility.ToJson(msgObj);
|
|
|
|
ClientMessageHandler.Instance.SendMessageToServer("gameSurveyFinish", payload);
|
|
}
|
|
StartCoroutine(LoadNextScene());
|
|
}
|
|
|
|
private void wordsNextButton_onClick()
|
|
{
|
|
processStep(2);
|
|
}
|
|
|
|
public void processStep(int step)
|
|
{
|
|
if (wordsPanel)
|
|
{
|
|
wordsPanel.SetActive(step == 1);
|
|
}
|
|
if (surveyPanel)
|
|
{
|
|
surveyPanel.SetActive(step == 2);
|
|
}
|
|
}
|
|
|
|
IEnumerator LoadNextScene()
|
|
{
|
|
yield return new WaitForSeconds(0f);
|
|
SceneManager.LoadScene("ClientFinalScene");
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|