fix Q15
資料移到GlobalData 串接星星與回覆,調整星星顯示與觸發
This commit is contained in:
parent
97a229e150
commit
4ede3ccfa6
@ -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:
|
||||
|
||||
@ -21,6 +21,8 @@ public class ClientHomeSceneController : MonoBehaviour
|
||||
void Start()
|
||||
{
|
||||
SetupScene();
|
||||
//清除遊戲資料
|
||||
GlobalData.ResetGameData();
|
||||
}
|
||||
|
||||
void SetupScene()
|
||||
|
||||
@ -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<SurveyManager>(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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,8 @@ public class ServerHomeSceneController : MonoBehaviour
|
||||
void Start()
|
||||
{
|
||||
SetupScene();
|
||||
//清除遊戲資料
|
||||
GlobalData.ResetGameData();
|
||||
}
|
||||
|
||||
void SetupScene()
|
||||
|
||||
@ -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];
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,4 +32,84 @@ public class GlobalData
|
||||
/// 詩籤的倒數時間
|
||||
/// </summary>
|
||||
public const int WORD_COUNTDOWN_TIME = 60;
|
||||
|
||||
/// <summary>
|
||||
/// 聖杯數
|
||||
/// </summary>
|
||||
public static int CUP_YES_COUNT = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 笑杯數
|
||||
/// </summary>
|
||||
public static int CUP_NOT_SURE_COUNT = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 蓋杯數
|
||||
/// </summary>
|
||||
public static int CUP_NO_COUNT = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 詩籤數
|
||||
/// </summary>
|
||||
public static int WORD_COUNT = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 陰德值
|
||||
/// </summary>
|
||||
public static int VIRTUE_SCORE = 60;
|
||||
|
||||
/// <summary>
|
||||
/// 業力值
|
||||
/// </summary>
|
||||
public static int KARMA_SCORE = 60;
|
||||
|
||||
/// <summary>
|
||||
/// 誠意度
|
||||
/// </summary>
|
||||
public static int SINCERITY_SCORE = 60;
|
||||
|
||||
/// <summary>
|
||||
/// 神力值
|
||||
/// </summary>
|
||||
public static int GODLY_POWER = 60;
|
||||
|
||||
/// <summary>
|
||||
/// 滿意度 - 星星1
|
||||
/// </summary>
|
||||
public static int SURVEY_STAR1 = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 滿意度 - 星星2
|
||||
/// </summary>
|
||||
public static int SURVEY_STAR2 = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 滿意度 - 星星3
|
||||
/// </summary>
|
||||
public static int SURVEY_STAR3 = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 滿意度 - 建議
|
||||
/// </summary>
|
||||
public static string SURVEY_TEXT = "";
|
||||
|
||||
/// <summary>
|
||||
/// 清除遊戲資料
|
||||
/// </summary>
|
||||
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 = "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定為不能點擊
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,8 @@ public class SurveyManager : MonoBehaviour
|
||||
public float countdownTime = 30f;
|
||||
private float currentTime;
|
||||
private bool isGameRunning = false;
|
||||
|
||||
public System.Action<int, int, int, string> 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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user