diff --git a/Assets/Scenes/Server/ServerWorkScene.unity b/Assets/Scenes/Server/ServerWorkScene.unity index f6b7a00..b463f2c 100644 --- a/Assets/Scenes/Server/ServerWorkScene.unity +++ b/Assets/Scenes/Server/ServerWorkScene.unity @@ -8571,7 +8571,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1742061934084195943, guid: 8c3e8d5430f6ce145b97407a9411b8a2, type: 3} propertyPath: m_IsActive - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 2133268950409196476, guid: 8c3e8d5430f6ce145b97407a9411b8a2, type: 3} propertyPath: m_IsActive @@ -26404,6 +26404,7 @@ MonoBehaviour: val2StarRating: {fileID: 237290980} val3StarRating: {fileID: 2072546777} text1Text: {fileID: 1279154712} + scoreText: {fileID: 544098749} okButton: {fileID: 1025418928} --- !u!1 &1999690699 GameObject: diff --git a/Assets/Scripts/Client/ClientHomeSceneController.cs b/Assets/Scripts/Client/ClientHomeSceneController.cs index 39bc3df..99ba49c 100644 --- a/Assets/Scripts/Client/ClientHomeSceneController.cs +++ b/Assets/Scripts/Client/ClientHomeSceneController.cs @@ -21,6 +21,8 @@ public class ClientHomeSceneController : MonoBehaviour void Start() { SetupScene(); + //清除遊戲資料 + GlobalData.ResetGameData(); } void SetupScene() diff --git a/Assets/Scripts/Client/ClientLastWordsSceneController.cs b/Assets/Scripts/Client/ClientLastWordsSceneController.cs index 722deb8..8a07e5d 100644 --- a/Assets/Scripts/Client/ClientLastWordsSceneController.cs +++ b/Assets/Scripts/Client/ClientLastWordsSceneController.cs @@ -16,10 +16,13 @@ public class ClientLastWordsSceneController : MonoBehaviour public Button wordsNextButton; public Button surveySubmitButton; public TMP_Text wordsText; + + private SurveyManager surveyManager; private void Awake() { Instance = this; + surveyManager = surveyPanel.GetComponentInChildren(includeInactive: true); } // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() @@ -28,10 +31,6 @@ public class ClientLastWordsSceneController : MonoBehaviour { wordsNextButton.onClick.AddListener(wordsNextButton_onClick); } - if (surveySubmitButton) - { - surveySubmitButton.onClick.AddListener(surveySubmitButton_onClick); - } init(); } @@ -44,17 +43,18 @@ public class ClientLastWordsSceneController : MonoBehaviour wordsText.text = words; } + surveyManager.OnSurveyConfirmed = OnSurveyConfirmed; } - private void surveySubmitButton_onClick() + private void OnSurveyConfirmed(int val1, int val2, int val3, string text) { if (ClientMessageHandler.Instance) { GameMessageSurvey msgObj = new GameMessageSurvey { - val1 = 1, - val2 = 2, - val3 = 3, - text1 = "" + val1 = val1, + val2 = val2, + val3 = val3, + text1 = text }; string payload = JsonUtility.ToJson(msgObj); diff --git a/Assets/Scripts/Server/NetworkMessageHandler.cs b/Assets/Scripts/Server/NetworkMessageHandler.cs index 06fb77f..4bdd518 100644 --- a/Assets/Scripts/Server/NetworkMessageHandler.cs +++ b/Assets/Scripts/Server/NetworkMessageHandler.cs @@ -44,8 +44,7 @@ public class NetworkMessageHandler : MonoBehaviour SendMessageToClient("welcome", "hello"); // clean data - - ServerWorkTopRightScore.cleanData(); + GlobalData.ResetGameData(); ServerWorkMessagePanel.cleanData(); ServerWorkMessagePanel.workMessageCount = 0; @@ -167,6 +166,10 @@ public class NetworkMessageHandler : MonoBehaviour if (msgObj != null) { + GlobalData.SURVEY_STAR1 = msgObj.val1; + GlobalData.SURVEY_STAR2 = msgObj.val2; + GlobalData.SURVEY_STAR3 = msgObj.val3; + GlobalData.SURVEY_TEXT = msgObj.text1; ServerWorkMessageReplyExitSurveyPanel.val1 = msgObj.val1; ServerWorkMessageReplyExitSurveyPanel.val2 = msgObj.val2; ServerWorkMessageReplyExitSurveyPanel.val3 = msgObj.val3; @@ -175,10 +178,10 @@ public class NetworkMessageHandler : MonoBehaviour { ServerWorkSceneController.Instance.processStep(19); } - //if (ServerWorkGameFinalPanel.Instance) - //{ - //ServerWorkGameFinalPanel.Instance.loadSurveyData(); - //} + if (ServerGameFinalSurveyPanel.Instance) + { + ServerGameFinalSurveyPanel.Instance.loadSurveyData(); + } } } break; diff --git a/Assets/Scripts/Server/ServerGameFinalSurveyPanel.cs b/Assets/Scripts/Server/ServerGameFinalSurveyPanel.cs index c2c4bd6..5ee16db 100644 --- a/Assets/Scripts/Server/ServerGameFinalSurveyPanel.cs +++ b/Assets/Scripts/Server/ServerGameFinalSurveyPanel.cs @@ -8,16 +8,12 @@ public class ServerGameFinalSurveyPanel : MonoBehaviour { public static ServerGameFinalSurveyPanel Instance; - public static string val1; - public static string val2; - public static string val3; - public static string text1; - public StarRating val1StarRating; public StarRating val2StarRating; public StarRating val3StarRating; public TMP_Text text1Text; + public TMP_Text scoreText; public Button okButton; private void Awake() @@ -33,10 +29,13 @@ public class ServerGameFinalSurveyPanel : MonoBehaviour okButton.onClick.AddListener(okButton_onClicked); } - if (text1Text) - { - text1Text.text = text1; - } + //讓星星按鈕不能被點擊 + val1StarRating.SetNotInteractable(); + val2StarRating.SetNotInteractable(); + val3StarRating.SetNotInteractable(); + + loadSurveyData(); + updateServerReport(); } private void okButton_onClicked() @@ -48,11 +47,25 @@ public class ServerGameFinalSurveyPanel : MonoBehaviour } } - - - // Update is called once per frame - void Update() + public void loadSurveyData() { - + val1StarRating.SetRating(GlobalData.SURVEY_STAR1); + val2StarRating.SetRating(GlobalData.SURVEY_STAR2); + val3StarRating.SetRating(GlobalData.SURVEY_STAR3); + text1Text.text = GlobalData.SURVEY_TEXT; + } + + public void updateServerReport() + { + string text = +@$"聖杯數:{GlobalData.CUP_YES_COUNT} +笑杯數:{GlobalData.CUP_NOT_SURE_COUNT} +蓋杯數:{GlobalData.CUP_NO_COUNT} +賜籤數:{GlobalData.WORD_COUNT} +客戶陰德值:{GlobalData.VIRTUE_SCORE} +客戶業力值:{GlobalData.KARMA_SCORE} +客戶誠意度:{GlobalData.SINCERITY_SCORE} +神力值:{GlobalData.GODLY_POWER}"; + scoreText.text = text; } } diff --git a/Assets/Scripts/Server/ServerGameTalkingPanel.cs b/Assets/Scripts/Server/ServerGameTalkingPanel.cs index 46a0220..002c17c 100644 --- a/Assets/Scripts/Server/ServerGameTalkingPanel.cs +++ b/Assets/Scripts/Server/ServerGameTalkingPanel.cs @@ -85,9 +85,9 @@ public class ServerGameTalkingPanel : MonoBehaviour if (values.Length < 3) { return; } if (ServerWorkTopRightScore.Instance == null) { return; } - ServerWorkTopRightScore.ScoreVal1 = values[0]; - ServerWorkTopRightScore.ScoreVal2 = values[1]; - ServerWorkTopRightScore.ScoreVal3 = values[2]; + GlobalData.VIRTUE_SCORE = values[0]; + GlobalData.KARMA_SCORE = values[1]; + GlobalData.SINCERITY_SCORE = values[2]; ServerWorkTopRightScore.Instance.UpdateScoreVals(); } diff --git a/Assets/Scripts/Server/ServerGameTypingPanel.cs b/Assets/Scripts/Server/ServerGameTypingPanel.cs index 1952a99..d895982 100644 --- a/Assets/Scripts/Server/ServerGameTypingPanel.cs +++ b/Assets/Scripts/Server/ServerGameTypingPanel.cs @@ -173,9 +173,9 @@ public class ServerGameTypingPanel : MonoBehaviour if (values.Length < 3) { return; } if (ServerWorkTopRightScore.Instance == null) { return; } - ServerWorkTopRightScore.ScoreVal1 = values[0]; - ServerWorkTopRightScore.ScoreVal2 = values[1]; - ServerWorkTopRightScore.ScoreVal3 = values[2]; + GlobalData.VIRTUE_SCORE = values[0]; + GlobalData.KARMA_SCORE = values[1]; + GlobalData.SINCERITY_SCORE = values[2]; ServerWorkTopRightScore.Instance.UpdateScoreVals(); } diff --git a/Assets/Scripts/Server/ServerHomeSceneController.cs b/Assets/Scripts/Server/ServerHomeSceneController.cs index 58f77c3..82cc014 100644 --- a/Assets/Scripts/Server/ServerHomeSceneController.cs +++ b/Assets/Scripts/Server/ServerHomeSceneController.cs @@ -20,6 +20,8 @@ public class ServerHomeSceneController : MonoBehaviour void Start() { SetupScene(); + //清除遊戲資料 + GlobalData.ResetGameData(); } void SetupScene() diff --git a/Assets/Scripts/Server/ServerWorkGameFinalPanel.cs b/Assets/Scripts/Server/ServerWorkGameFinalPanel.cs index e6a27ca..3cbfe32 100644 --- a/Assets/Scripts/Server/ServerWorkGameFinalPanel.cs +++ b/Assets/Scripts/Server/ServerWorkGameFinalPanel.cs @@ -99,6 +99,8 @@ public class ServerWorkGameFinalPanel : MonoBehaviour private void wordsSubmitButton_onClicked() { + GlobalData.WORD_COUNT += 1; + if (string.IsNullOrEmpty(wordsInputField.text)) { wordsInputField.text = sampleWords[0]; diff --git a/Assets/Scripts/Server/ServerWorkMessageReplyPanel.cs b/Assets/Scripts/Server/ServerWorkMessageReplyPanel.cs index 32ea15b..a8e130c 100644 --- a/Assets/Scripts/Server/ServerWorkMessageReplyPanel.cs +++ b/Assets/Scripts/Server/ServerWorkMessageReplyPanel.cs @@ -42,6 +42,8 @@ public class ServerWorkMessageReplyPanel : MonoBehaviour private void noButton_onClicked() { messageReply = "no"; + GlobalData.CUP_NO_COUNT += 1; + if (ServerWorkSceneController.Instance != null) { if (ServerWorkMessagePanel.workMessageCount == 0) @@ -66,6 +68,8 @@ public class ServerWorkMessageReplyPanel : MonoBehaviour private void notSureButton_onClicked() { messageReply = "notsure"; + GlobalData.CUP_NOT_SURE_COUNT += 1; + if (ServerWorkSceneController.Instance != null) { if (ServerWorkMessagePanel.workMessageCount == 0) @@ -91,6 +95,7 @@ public class ServerWorkMessageReplyPanel : MonoBehaviour private void yesButton_onClicked() { messageReply = "yes"; + GlobalData.CUP_YES_COUNT += 1; GameMessageWorkResult msgObj = new GameMessageWorkResult { diff --git a/Assets/Scripts/Server/ServerWorkMessageReplyWordsPanel.cs b/Assets/Scripts/Server/ServerWorkMessageReplyWordsPanel.cs index 47e5eec..8c274c1 100644 --- a/Assets/Scripts/Server/ServerWorkMessageReplyWordsPanel.cs +++ b/Assets/Scripts/Server/ServerWorkMessageReplyWordsPanel.cs @@ -47,6 +47,8 @@ public class ServerWorkMessageReplyWordsPanel : MonoBehaviour private void submitButton_onClicked() { + GlobalData.WORD_COUNT += 1; + GameMessageWorkResult msgObj = new GameMessageWorkResult { count = ServerWorkMessagePanel.workMessageCount, result = ServerWorkMessageReplyPanel.messageReply, diff --git a/Assets/Scripts/Server/ServerWorkTopRightScore.cs b/Assets/Scripts/Server/ServerWorkTopRightScore.cs index e138dba..d2c43e7 100644 --- a/Assets/Scripts/Server/ServerWorkTopRightScore.cs +++ b/Assets/Scripts/Server/ServerWorkTopRightScore.cs @@ -5,18 +5,6 @@ public class ServerWorkTopRightScore : MonoBehaviour { public static ServerWorkTopRightScore Instance; - public static int ScoreVal1 = 60; - public static int ScoreVal2 = 60; - public static int ScoreVal3 = 60; - - public static void cleanData() - { - ScoreVal1 = 60; - ScoreVal2 = 60; - ScoreVal3 = 60; - } - - public TMP_Text Val1; public TMP_Text Val2; public TMP_Text Val3; @@ -43,17 +31,17 @@ public class ServerWorkTopRightScore : MonoBehaviour { if (Val1) { - Val1.text = ScoreVal1.ToString(); + Val1.text = GlobalData.VIRTUE_SCORE.ToString(); } if (Val2) { - Val2.text = ScoreVal2.ToString(); + Val2.text = GlobalData.KARMA_SCORE.ToString(); } if (Val3) { - Val3.text = ScoreVal3.ToString(); + Val3.text = GlobalData.SINCERITY_SCORE.ToString(); } } } diff --git a/Assets/Scripts/Utils/GlobalData.cs b/Assets/Scripts/Utils/GlobalData.cs index a2d15b4..e3e18fa 100644 --- a/Assets/Scripts/Utils/GlobalData.cs +++ b/Assets/Scripts/Utils/GlobalData.cs @@ -32,4 +32,84 @@ public class GlobalData /// 詩籤的倒數時間 /// public const int WORD_COUNTDOWN_TIME = 60; + + /// + /// 聖杯數 + /// + public static int CUP_YES_COUNT = 0; + + /// + /// 笑杯數 + /// + public static int CUP_NOT_SURE_COUNT = 0; + + /// + /// 蓋杯數 + /// + public static int CUP_NO_COUNT = 0; + + /// + /// 詩籤數 + /// + public static int WORD_COUNT = 0; + + /// + /// 陰德值 + /// + public static int VIRTUE_SCORE = 60; + + /// + /// 業力值 + /// + public static int KARMA_SCORE = 60; + + /// + /// 誠意度 + /// + public static int SINCERITY_SCORE = 60; + + /// + /// 神力值 + /// + public static int GODLY_POWER = 60; + + /// + /// 滿意度 - 星星1 + /// + public static int SURVEY_STAR1 = 0; + + /// + /// 滿意度 - 星星2 + /// + public static int SURVEY_STAR2 = 0; + + /// + /// 滿意度 - 星星3 + /// + public static int SURVEY_STAR3 = 0; + + /// + /// 滿意度 - 建議 + /// + public static string SURVEY_TEXT = ""; + + /// + /// 清除遊戲資料 + /// + public static void ResetGameData() + { + CUP_YES_COUNT = 0; + CUP_NOT_SURE_COUNT = 0; + CUP_NO_COUNT = 0; + WORD_COUNT = 0; + VIRTUE_SCORE = 60; + KARMA_SCORE = 60; + SINCERITY_SCORE = 60; + GODLY_POWER = 60; + + SURVEY_STAR1 = 0; + SURVEY_STAR2 = 0; + SURVEY_STAR3 = 0; + SURVEY_TEXT = ""; + } } diff --git a/Assets/export_canvas/script/StarRating.cs b/Assets/export_canvas/script/StarRating.cs index 5bd7c02..7cf3104 100644 --- a/Assets/export_canvas/script/StarRating.cs +++ b/Assets/export_canvas/script/StarRating.cs @@ -11,7 +11,7 @@ public class StarRating : MonoBehaviour private int currentRating = 0; - void Start() + void Awake() { Debug.Log("=== " + gameObject.name + " 開始初始化 ==="); @@ -165,4 +165,19 @@ public class StarRating : MonoBehaviour currentRating = 0; UpdateStarDisplay(); } + + /// + /// 設定為不能點擊 + /// + public void SetNotInteractable(Color? color = null) + { + foreach (var button in stars) + { + button.interactable = false; + + ColorBlock colors = button.colors; + colors.disabledColor = color ?? Color.white ; + button.colors = colors; + } + } } \ No newline at end of file diff --git a/Assets/export_canvas/script/SurveyManager.cs b/Assets/export_canvas/script/SurveyManager.cs index adccb4d..6972edc 100644 --- a/Assets/export_canvas/script/SurveyManager.cs +++ b/Assets/export_canvas/script/SurveyManager.cs @@ -21,6 +21,8 @@ public class SurveyManager : MonoBehaviour public float countdownTime = 30f; private float currentTime; private bool isGameRunning = false; + + public System.Action OnSurveyConfirmed; void Start() { @@ -76,6 +78,9 @@ public class SurveyManager : MonoBehaviour } isGameRunning = false; + + //強制送出 + OnSurveySubmit(true); } } } @@ -117,7 +122,11 @@ public class SurveyManager : MonoBehaviour void OnSubmitButtonClicked() { Debug.Log(">>> 點擊送出按鈕"); - + OnSurveySubmit(); + } + + private void OnSurveySubmit(bool isForce = false) + { // 取得三題的評分 int rating1 = 0; int rating2 = 0; @@ -128,7 +137,7 @@ public class SurveyManager : MonoBehaviour if (question3Stars != null) rating3 = question3Stars.GetRating(); // 檢查是否至少填寫了一個星星評分 - if (rating1 == 0 && rating2 == 0 && rating3 == 0) + if (rating1 == 0 && rating2 == 0 && rating3 == 0 && isForce == false) { ShowWarning(); return; @@ -147,6 +156,7 @@ public class SurveyManager : MonoBehaviour // 送出資料 SubmitSurvey(rating1, rating2, rating3, userComment); + OnSurveyConfirmed?.Invoke(rating1, rating2, rating3, userComment); } void ShowWarning()