Преглед изворни кода

5/7更新

2025/5/7 基本完成客户端voiceCall / Command功能,待测试后完善
修正messagebox No button 错误
Jees пре 1 месец
родитељ
комит
31ed54613a

+ 40 - 40
Assets/Resources/Data/languages.json

@@ -231,160 +231,160 @@
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "voiceCall_10": {
-            "en": "Now your dog knows its own name. In the future, you can call it by pressing the voice recording button.<br>Call it often, and it will be more obedient.",
-            "zh-cn": "现在知道自己的名字了。以后按下录音键就可以呼唤它了。<br>经常呼叫他,它会更听话哦。"
+            "en": "Now <<dog_name>> knows its own name. In the future, you can call it by pressing the voice recording button.<br>Call it often, and it will be more obedient.",
+            "zh-cn": "现在<<dog_name>>知道自己的名字了。以后按下录音键就可以呼唤它了。<br>经常呼叫他,它会更听话哦。"
         },
         "voiceCall_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "commandSit_00": {
-            "en": "Are you ready? Now you can give him the command to sit down.",
-            "zh-cn": "准备好了吗?现在可以说出口令让坐下。"
+            "en": "Are you ready? Now you can give <<dog_name>> the command to sit down.",
+            "zh-cn": "准备好了吗?现在可以说出口令让<<dog_name>>坐下。"
         },
         "commandSit_01": {
             "en": "Record again. Ensure that the two recordings are consistent.",
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "commandSit_10": {
-            "en": "Now your dog will sit down when you give it a command.<br>Talk to it often, and it will be more obedient.",
-            "zh-cn": "现在会听从你的指令坐下了。<br>经常训练他,它会更听话哦。"
+            "en": "Now <<dog_name>> will sit down when you give it a command.<br>Talk to <<dog_name>> often, and it will be more obedient.",
+            "zh-cn": "<<dog_name>>现在会听从你的指令坐下了。<br>经常训练他,它会更听话哦。"
         },
         "commandSit_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "commandStand_00": {
-            "en": "Are you ready? Now you can give him the command to stand up.",
-            "zh-cn": "准备好了吗?现在可以说出口令让站起来。"
+            "en": "Are you ready? Now you can give <<dog_name>> the command to stand up.",
+            "zh-cn": "准备好了吗?现在可以说出口令让<<dog_name>>站起来。"
         },
         "commandStand_01": {
             "en": "Record again. Ensure that the two recordings are consistent.",
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "commandStand_10": {
-            "en": "Now your dog will stand up when you give it a command.<br>Talk to it often, and it will be more obedient.",
-            "zh-cn": "他现在会听从你的指令站起来了。<br>经常训练他,它会更听话哦。"
+            "en": "Now <<dog_name>> will stand up when you give it a command.<br>Talk to <<dog_name>> often, and it will be more obedient.",
+            "zh-cn": "<<dog_name>>现在会听从你的指令站起来了。<br>经常训练<<dog_name>>,它会更听话哦。"
         },
         "commandStand_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "commandBark_00": {
-            "en": "Are you ready? Now you can give him the command to bark.",
-            "zh-cn": "准备好了吗?现在可以说出口令让叫几声。"
+            "en": "Are you ready? Now you can give <<dog_name>> the command to bark.",
+            "zh-cn": "准备好了吗?现在可以说出口令让<<dog_name>>叫几声。"
         },
         "commandBark_01": {
             "en": "Record again. Ensure that the two recordings are consistent.",
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "commandBark_10": {
-            "en": "Now your dog will sit down when you give it a command.<br>Talk to it often, and it will be more obedient.",
-            "zh-cn": "他现在会听从你的指令了。<br>经常训练他,它会更听话哦。"
+            "en": "Now <<dog_name>> will sit down when you give it a command.<br>Talk to <<dog_name>> often, and it will be more obedient.",
+            "zh-cn": "<<dog_name>>现在会听从你的指令了。<br>经常训练<<dog_name>>,它会更听话哦。"
         },
         "commandBark_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "commandLieDown_00": {
-            "en": "Are you ready? Now you can give him the command to lie down.",
-            "zh-cn": "准备好了吗?现在可以说出口令让躺下。"
+            "en": "Are you ready? Now you can give <<dog_name>> the command to lie down.",
+            "zh-cn": "准备好了吗?现在可以说出口令让<<dog_name>>躺下。"
         },
         "commandLieDown_01": {
             "en": "Record again. Ensure that the two recordings are consistent.",
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "commandLieDown_10": {
-            "en": "Now your dog will lie down when you give it a command.<br>Talk to it often, and it will be more obedient.",
-            "zh-cn": "他现在会听从你的指令躺下了。<br>经常训练他,它会更听话哦。"
+            "en": "Now <<dog_name>> will lie down when you give it a command.<br>Talk to <<dog_name>> often, and it will be more obedient.",
+            "zh-cn": "<<dog_name>>现在会听从你的指令躺下了。<br>经常训练<<dog_name>>,它会更听话哦。"
         },
         "commandLieDown_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "commandRotate_00": {
-            "en": "Are you ready? Now you can give him the command to rotate.",
-            "zh-cn": "准备好了吗?现在可以说出口令让转圈。"
+            "en": "Are you ready? Now you can give <<dog_name>> the command to rotate.",
+            "zh-cn": "准备好了吗?现在可以说出口令让<<dog_name>>转圈。"
         },
         "commandRotate_01": {
             "en": "Record again. Ensure that the two recordings are consistent.",
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "commandRotate_10": {
-            "en": "Now your dog will rotate when you give it a command.<br>Talk to it often, and it will be more obedient.",
-            "zh-cn": "他现在会听从你的指令转圈了。<br>经常训练他,它会更听话哦。"
+            "en": "Now <<dog_name>> will rotate when you give it a command.<br>Talk to <<dog_name>> often, and it will be more obedient.",
+            "zh-cn": "<<dog_name>>现在会听从你的指令转圈了。<br>经常训练<<dog_name>>,它会更听话哦。"
         },
         "commandRotate_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "commandDeath_00": {
-            "en": "Are you ready? Now you can give him the command to pretend to be dead.",
-            "zh-cn": "准备好了吗?现在可以说出口令让装死。"
+            "en": "Are you ready? Now you can give <<dog_name>> the command to pretend to be dead.",
+            "zh-cn": "准备好了吗?现在可以说出口令让<<dog_name>>装死。"
         },
         "commandDeath_01": {
             "en": "Record again. Ensure that the two recordings are consistent.",
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "commandDeath_10": {
-            "en": "Now your dog will pretend to be dead when you give it a command.<br>Talk to it often, and it will be more obedient.",
-            "zh-cn": "他现在会听从你的指令了。<br>经常训练他,它会更听话哦。"
+            "en": "Now <<dog_name>> will pretend to be dead when you give it a command.<br>Talk to <<dog_name>> often, and it will be more obedient.",
+            "zh-cn": "<<dog_name>>现在会听从你的指令了。<br>经常训练<<dog_name>>,它会更听话哦。"
         },
         "commandDeath_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "commandHug_00": {
-            "en": "Are you ready? Now you can give him the command to hug.",
-            "zh-cn": "准备好了吗?现在可以说出口令让抱抱。"
+            "en": "Are you ready? Now you can give <<dog_name>> the command to hug.",
+            "zh-cn": "准备好了吗?现在可以说出口令让<<dog_name>>抱抱。"
         },
         "commandHug_01": {
             "en": "Record again. Ensure that the two recordings are consistent.",
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "commandHug_10": {
-            "en": "Now your dog will hug when you give it a command.<br>Talk to it often, and it will be more obedient.",
-            "zh-cn": "他现在会听从你的抱抱指令了。<br>经常训练他,它会更听话哦。"
+            "en": "Now <<dog_name>> will hug when you give it a command.<br>Talk to <<dog_name>> often, and it will be more obedient.",
+            "zh-cn": "<<dog_name>>现在会听从你的抱抱指令了。<br>经常训练<<dog_name>>,它会更听话哦。"
         },
         "commandHug_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "commandTurnL_00": {
-            "en": "Are you ready? Now you can give him the command to turn left.",
-            "zh-cn": "准备好了吗?现在可以说出口令让左转。"
+            "en": "Are you ready? Now you can give <<dog_name>> the command to turn left.",
+            "zh-cn": "准备好了吗?现在可以说出口令让<<dog_name>>左转。"
         },
         "commandTurnL_01": {
             "en": "Record again. Ensure that the two recordings are consistent.",
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "commandTurnL_10": {
-            "en": "Now your dog will turn left when you give it a command.<br>Talk to it often, and it will be more obedient.",
-            "zh-cn": "他现在会听从你的左转指令了。<br>经常训练他,它会更听话哦。"
+            "en": "Now <<dog_name>> will turn left when you give it a command.<br>Talk to <<dog_name>> often, and it will be more obedient.",
+            "zh-cn": "<<dog_name>>现在会听从你的左转指令了。<br>经常训练<<dog_name>>,它会更听话哦。"
         },
         "commandTurnL_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "commandTurnR_00": {
-            "en": "Are you ready? Now you can give him the command to turn right.",
-            "zh-cn": "准备好了吗?现在可以说出口令让右转。"
+            "en": "Are you ready? Now you can give <<dog_name>> the command to turn right.",
+            "zh-cn": "准备好了吗?现在可以说出口令让<<dog_name>>右转。"
         },
         "commandTurnR_01": {
             "en": "Record again. Ensure that the two recordings are consistent.",
             "zh-cn": "再输入一次。确保两次录音一致。"
         },
         "commandTurnR_10": {
-            "en": "Now your dog will turn right when you give it a command.<br>Talk to it often, and it will be more obedient.",
-            "zh-cn": "他现在会听从你的右转指令了。<br>经常训练他,它会更听话哦。"
+            "en": "Now <<dog_name>> will turn right when you give it a command.<br>Talk to <<dog_name>> often, and it will be more obedient.",
+            "zh-cn": "<<dog_name>>现在会听从你的右转指令了。<br>经常训练<<dog_name>>,它会更听话哦。"
         },
         "commandTurnR_20": {
             "en": "Record fail. Please try again.",
             "zh-cn": "录音失败。请再试一次。"
         },
         "first_touch_interactive": {
-            "en": "Try to touch the dog. He will be very happy.",
-            "zh-cn": "尝试抚摸一下狗狗吧。会很开心。"
+            "en": "Try to touch the dog. <<dog_name>> will be very happy.",
+            "zh-cn": "尝试抚摸一下狗狗吧。<<dog_name>>会很开心。"
         },
         "quit_game": {
             "en": "Are you sure to quit the game?",

+ 4 - 4
Assets/Resources/Dog/AnimatorController/shibaInu/HomeDogInteractController.controller

@@ -160,7 +160,7 @@ AnimatorStateTransition:
   m_Name: 
   m_Conditions:
   - m_ConditionMode: 2
-    m_ConditionEvent: Die_status
+    m_ConditionEvent: Death_status
     m_EventTreshold: 0
   m_DstStateMachine: {fileID: 0}
   m_DstState: {fileID: 533779715773965248}
@@ -404,7 +404,7 @@ AnimatorStateTransition:
   m_Name: to Death
   m_Conditions:
   - m_ConditionMode: 1
-    m_ConditionEvent: Die
+    m_ConditionEvent: Death
     m_EventTreshold: 0
   m_DstStateMachine: {fileID: 0}
   m_DstState: {fileID: -961187681864823423}
@@ -601,7 +601,7 @@ AnimatorController:
     m_DefaultInt: 0
     m_DefaultBool: 0
     m_Controller: {fileID: 9100000}
-  - m_Name: Die_status
+  - m_Name: Death_status
     m_Type: 4
     m_DefaultFloat: 0
     m_DefaultInt: 0
@@ -691,7 +691,7 @@ AnimatorController:
     m_DefaultInt: 0
     m_DefaultBool: 0
     m_Controller: {fileID: 9100000}
-  - m_Name: Die
+  - m_Name: Death
     m_Type: 9
     m_DefaultFloat: 0
     m_DefaultInt: 0

+ 10 - 2
Assets/Resources/MessageBox/MessageBoxController.cs

@@ -72,13 +72,21 @@ public class MessageBoxController : MonoBehaviour
             GameObject btnYObject = GameObject.Find("btn_Y");
             Button btnY = btnYObject.GetComponent<Button>();
             btnY.onClick.AddListener(DestoryMessageBox);
-            btnY.onClick.AddListener(delegate { yesAction(); });
+            if (yesAction != null)
+            {
+                btnY.onClick.AddListener(delegate { yesAction(); });
+            }
+
 
             // bundle N button actions
             GameObject btnNObject = GameObject.Find("btn_N");
             Button btnN = btnNObject.GetComponent<Button>();
             btnN.onClick.AddListener(DestoryMessageBox);
-            btnN.onClick.AddListener(delegate { noAction(); });
+            if (noAction != null)
+            {
+                btnN.onClick.AddListener(delegate { noAction(); });
+            }
+
 
             //disable OK button
             GameObject btnDisable = GameObject.Find("btn_OK");

+ 2 - 2
Assets/Resources/Status/StatusUI.uxml

@@ -16,8 +16,8 @@
             <ui:Label tabindex="-1" text="   状态" parse-escape-sequences="true" display-tooltip-when-elided="true" name="status" class="Labels" style="top: auto; left: auto; height: auto; width: 100%; align-self: auto; align-items: center; justify-content: center; -unity-text-align: lower-left; border-top-width: 0; border-right-width: 0; border-bottom-width: 4px; border-left-width: 0; right: auto; padding-bottom: 0; padding-right: 0; padding-top: 0; padding-left: 10px; color: rgb(255, 162, 11); position: relative;" />
             <ui:Label tabindex="-1" text="&lt;To summarize status here&gt;" parse-escape-sequences="true" display-tooltip-when-elided="true" name="statusValue" class="Labels" style="top: auto; left: auto; height: auto; width: 100%; -unity-text-align: upper-left; right: auto; border-top-width: 0; border-right-width: 0; border-bottom-width: 0; border-left-width: 0; margin-right: auto; margin-left: auto; margin-top: auto; margin-bottom: auto; position: relative;" />
         </ui:VisualElement>
-        <ui:Button text="Back" parse-escape-sequences="true" display-tooltip-when-elided="true" name="back" style="position: relative; bottom: -90%; -unity-text-align: middle-center; white-space: nowrap; top: auto; left: auto; background-color: rgba(22, 131, 245, 0.78); border-left-color: rgba(149, 149, 149, 0); border-right-color: rgba(149, 149, 149, 0); border-top-color: rgba(149, 149, 149, 0); border-bottom-color: rgba(149, 149, 149, 0); border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; width: 100px; height: 30px; -unity-font: resource(&apos;Font/MaoKenZhuYuanTi-MaokenZhuyuanTi-2&apos;); font-size: 16px; color: rgb(255, 255, 255); -unity-font-style: bold; -unity-font-definition: url(&quot;project://database/Assets/Font/MaoKenZhuYuanTi-MaokenZhuyuanTi-2.ttf?fileID=12800000&amp;guid=50a63638b44907e46a3fa871d63b7d39&amp;type=3#MaoKenZhuYuanTi-MaokenZhuyuanTi-2&quot;);" />
-        <ui:VisualElement name="subMenu" style="flex-grow: initial; position: absolute; height: 5%; top: auto; width: 60%; background-color: rgba(116, 116, 116, 0); border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; align-items: center; justify-content: space-around; flex-direction: row; bottom: 8%; flex-shrink: initial;">
+        <ui:Button text="Back" parse-escape-sequences="true" display-tooltip-when-elided="true" name="back" style="position: absolute; bottom: 1%; -unity-text-align: middle-center; white-space: nowrap; top: auto; left: auto; background-color: rgba(22, 131, 245, 0.78); border-left-color: rgba(149, 149, 149, 0); border-right-color: rgba(149, 149, 149, 0); border-top-color: rgba(149, 149, 149, 0); border-bottom-color: rgba(149, 149, 149, 0); border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; width: 100px; height: 30px; -unity-font: resource(&apos;Font/MaoKenZhuYuanTi-MaokenZhuyuanTi-2&apos;); font-size: 16px; color: rgb(255, 255, 255); -unity-font-style: bold; -unity-font-definition: url(&quot;project://database/Assets/Font/MaoKenZhuYuanTi-MaokenZhuyuanTi-2.ttf?fileID=12800000&amp;guid=50a63638b44907e46a3fa871d63b7d39&amp;type=3#MaoKenZhuYuanTi-MaokenZhuyuanTi-2&quot;);" />
+        <ui:VisualElement name="subMenu" style="flex-grow: initial; position: absolute; height: 5%; top: auto; width: 60%; background-color: rgba(116, 116, 116, 0); border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; align-items: center; justify-content: space-around; flex-direction: row; bottom: 9%; flex-shrink: initial;">
             <ui:Label name="add" class="subMenu" />
             <ui:Label name="transfer" class="subMenu" style="background-image: url(&quot;project://database/Assets/Packages/2D%20Casual%20UI/Sprite/GUI.png?fileID=21300116&amp;guid=1eaee135ce037439d925cee5e41ce026&amp;type=3#GUI_65&quot;);" />
             <ui:Label name="remove" class="subMenu" style="background-image: url(&quot;project://database/Assets/Packages/2D%20Casual%20UI/Sprite/GUI.png?fileID=21300120&amp;guid=1eaee135ce037439d925cee5e41ce026&amp;type=3#GUI_67&quot;); display: none;" />

+ 1 - 0
Assets/Resources/UserInfo/UserInfo.uxml

@@ -11,6 +11,7 @@
             <ui:VisualElement style="flex-grow: 1; flex-direction: column-reverse; bottom: 80px; align-self: flex-end;">
                 <ui:Button text="Log out" name="logout" class="tranparentBtn" style="display: flex; -unity-font-style: italic; font-size: 12px;" />
                 <ui:Button text="注销" name="delete_account" class="tranparentBtn" style="align-self: flex-end; -unity-font-definition: url(&quot;project://database/Assets/Font/MaoKenZhuYuanTi-MaokenZhuyuanTi-2.ttf?fileID=12800000&amp;guid=50a63638b44907e46a3fa871d63b7d39&amp;type=3#MaoKenZhuYuanTi-MaokenZhuyuanTi-2&quot;); display: none;" />
+                <ui:VisualElement name="feedback" style="flex-grow: initial; background-image: url(&quot;project://database/Assets/Packages/2D%20Casual%20UI/Sprite/GUI.png?fileID=21300058&amp;guid=1eaee135ce037439d925cee5e41ce026&amp;type=3#GUI_29&quot;); flex-shrink: initial; height: 20px; width: 24px; align-self: center;" />
             </ui:VisualElement>
             <ui:Instance template="confirmArea" name="confirmArea" style="bottom: 0; position: absolute; width: 100%;" />
         </ui:VisualElement>

+ 15 - 1
Assets/Resources/UserInfo/UserInfoController.cs

@@ -13,6 +13,7 @@ public class UserInfoController : MonoBehaviour
     private TextField userName, password, mobile, email;
     private Button confirm, cancel, logout, deleteAccount;
     private Label errorMsgLabel;
+    private VisualElement feedback;
     private string errorText = null;      // 错误信息汇总
     private string deleteAlertMsg;
     private Dictionary<string, string> errorMessageDict = new();
@@ -29,6 +30,7 @@ public class UserInfoController : MonoBehaviour
         errorMsgLabel = root.Q<Label>("error_msg");
         logout = root.Q<Button>("logout");
         deleteAccount = root.Q<Button>("delete_account");
+        feedback = root.Q<VisualElement>("feedback");
 
         logout.clicked += LogoutClick;
         confirm.clicked += ConfirmClick;
@@ -37,6 +39,8 @@ public class UserInfoController : MonoBehaviour
         errorMessageDict.Clear();
         InitSetting();
         UserInfoLoad();
+
+        feedback.RegisterCallback<ClickEvent>(ev => FeedbackClick());
     }
 
     // Update is called once per frame
@@ -123,7 +127,17 @@ public class UserInfoController : MonoBehaviour
         }
     }
 
-
+    void FeedbackClick()
+    {
+        var uiPlaceholder = GameObject.Find("UI Placeholder");
+        if (uiPlaceholder != null)
+        {
+            var FeedbackUI = uiPlaceholder.transform.Find("Feedback").gameObject;
+            var UserInfoUI = uiPlaceholder.transform.Find("User Info").gameObject;
+            FeedbackUI.SetActive(true);
+            UserInfoUI.SetActive(false);
+        }
+    }
 
 
     // 初始化语言和显示设定

+ 5 - 0
Assets/Resources/VoiceAndManu/VoiceController.cs

@@ -126,6 +126,11 @@ public class VoiceController : MonoBehaviour
         foreach (var dog in HomeController.dogsInScene)
         {
             dog.animator.SetBool("isListening", false);
+            // 如果在交互模式,就刷新最后交互时间
+            if (dog.dogState == DogState.INTERACT)
+            {
+                dog.interactLastUpdate = DateTime.Now;
+            }
         }
         StopRecording();
     }

+ 2 - 2
Assets/Resources/Warehouse/ItemUseController.cs

@@ -57,7 +57,7 @@ public class ItemUseController : ScriptableObject
 
                 foreach (var dogInScene in HomeController.dogsInScene)
                 {
-                    dogInScene.StartItemConsume(ItemGroup.food);
+                    dogInScene.StartItemConsume(ItemGroup.FOOD);
                     dogInScene.SetMoveSpeed(UnityEngine.Random.Range(0.3f, 0.6f));
                 }
 
@@ -73,7 +73,7 @@ public class ItemUseController : ScriptableObject
 
                 foreach (var dogInScene in HomeController.dogsInScene)
                 {
-                    dogInScene.StartItemConsume(ItemGroup.water);
+                    dogInScene.StartItemConsume(ItemGroup.WATER);
                     dogInScene.SetMoveSpeed(UnityEngine.Random.Range(0.3f, 0.6f));
                 }
             }

+ 1 - 1
Assets/Scripts/Develop Script/TestSetup.cs

@@ -64,7 +64,7 @@ public class TestSetup : MonoBehaviour
             PlayerPrefs.SetString("LoginTokenTime", oneHourAgo.ToString());
             EnviromentSetting.UUID = "abc";
 
-            // PlayerPrefs.DeleteAll();
+            //PlayerPrefs.DeleteAll();
             // EnviromentSetting.languageCode = "en";
         }
 

+ 5 - 1
Assets/Scripts/EnviromentSetting.cs

@@ -41,7 +41,11 @@ public static class EnviromentSetting
 
     // 最大狗的数量
     public static int maxDogQty = 3;
-    
+
+    // 运行环境 
+    // todo 正式版设定为release 未来从服务器获取
+    public static string runEnv = "Test"; // NA, Test, Release
+
 }
 
 

+ 16 - 1
Assets/Scripts/GameControllers/DogProperty.cs

@@ -46,8 +46,23 @@ public class DogProperty
     public int voiceCall = 0;      // 识别自己名字能力
     public int voiceCommand = 0;       // 识别所有口令能力
     public bool voiceCallEnable = false;
-    public bool voiceCommandEnable = false;
+    public bool voiceCommandEnable = false;     // 暂时弃用参数
     public bool commandSit, commandStand, commandBark, commandLieDown, commandRotate, commandHug, commandDeath, commandTurnL, commandTurnR;        // 具体的口令能力是否开启
+
+    public int CommandTrainingPhase()
+    {
+        int phase = 0;
+        if (commandSit) phase++;
+        if (commandStand) phase++;
+        if (commandBark) phase++;
+        if (commandLieDown) phase++;
+        if (commandRotate) phase++;
+        if (commandHug) phase++;
+        if (commandDeath) phase++;
+        if (commandTurnL) phase++;
+        if (commandTurnR) phase++;
+        return phase;
+    }
 }
 
 public class DogBreed

+ 12 - 0
Assets/Scripts/GameControllers/GameTool.cs

@@ -93,4 +93,16 @@ public static class GameTool
         Time.timeScale = 0;
         //Time.fixedDeltaTime = 0.02f * Time.timeScale;
     }
+
+    public static bool IntBetween(int min, int max, int value)
+    {
+        if (value >= min && value < max)
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
 }

+ 2 - 2
Assets/Scripts/Home/DogInScene.cs

@@ -353,11 +353,11 @@ public class DogInScene //: ScriptableObject
         //this.dogState = "itemConsume";
         this.dogState = DogState.ITEM_CONSUME;
 
-        if (group == ItemGroup.water)
+        if (group == ItemGroup.WATER)
         {
             bowl = GameObject.Find("Bowl_water");       // 开启整个喝水的进程
         }
-        if (group == ItemGroup.food)
+        if (group == ItemGroup.FOOD)
         {
             bowl = GameObject.Find("Bowl_food");        // 开启整个吃食物的进程
         }

+ 88 - 80
Assets/Scripts/Home/HomeController.cs

@@ -9,9 +9,6 @@ using UnityEngine;
 using UnityEngine.InputSystem;
 using UnityEngine.Animations;
 
-//using UnityEngine.Rendering.PostProcessing;
-using UnityEngine.SceneManagement;
-using ZXing.Common;
 
 /* 本代码控制室内场景
  * 控制宠物在Home场景动画
@@ -131,56 +128,64 @@ public class HomeController : MonoBehaviour
                     {
                         trainingContent = "voiceCall";
                     }
-                    else if (dog.dogProperty.voiceCall >= 40 && dog.dogProperty.voiceCallEnable && !GameData.isVoiceTrainingToday)
+                    else if (dog.dogProperty.voiceCallEnable && !GameData.isVoiceTrainingToday)
                     {
-                        // 当狗的voiceCall大于等于40,进入第一阶段指令训练模式
-                        int random = UnityEngine.Random.Range(0, 100);
-                        if (random < 25 && !dog.dogProperty.commandSit)
+                        if (dog.dogProperty.voiceCall >= 40 && dog.dogProperty.CommandTrainingPhase() < 4)
                         {
-                            trainingContent = "commandSit";
-                        }
-                        else if (random < 50 && !dog.dogProperty.commandStand)
-                        {
-                            trainingContent = "commandStand";
-                        }
-                        else if (random < 75 && !dog.dogProperty.commandBark)
-                        {
-                            trainingContent = "commandBark";
-                        }
-                        else if (random < 100 && !dog.dogProperty.commandLieDown)
-                        {
-                            trainingContent = "commandLieDown";
-                        }
-                        // else
-                        // {
-                        //     trainingContent = String.Empty;
-                        // }
-                    }
-                    else if (dog.dogProperty.voiceCommand >= 40 && dog.dogProperty.voiceCommandEnable && !GameData.isVoiceTrainingToday)
-                    {
-                        // 当狗的voiceCommand大于等于40,进入第二阶段指令训练模式
-                        int random = UnityEngine.Random.Range(0, 100);
-                        if (random < 20 && !dog.dogProperty.commandRotate)
-                        {
-                            trainingContent = "commandRotate";
-                        }
-                        else if (random < 40 && !dog.dogProperty.commandHug)
-                        {
-                            trainingContent = "commandHug";
-                        }
-                        else if (random < 60 && !dog.dogProperty.commandDeath)
-                        {
-                            trainingContent = "commandDeath";
-                        }
-                        else if (random < 80 && !dog.dogProperty.commandTurnL)
-                        {
-                            trainingContent = "commandTurnL";
+                            // 当狗的voiceCall大于等于40,进入第一阶段指令训练模式
+                            int random = UnityEngine.Random.Range(0, 100);
+                            if (GameTool.IntBetween(0, 25, random) && !dog.dogProperty.commandSit)
+                            {
+                                trainingContent = "commandSit";
+                            }
+                            else if (GameTool.IntBetween(25, 50, random) && !dog.dogProperty.commandStand)
+                            {
+                                trainingContent = "commandStand";
+                            }
+                            else if (GameTool.IntBetween(50, 75, random) && !dog.dogProperty.commandBark)
+                            {
+                                trainingContent = "commandBark";
+                            }
+                            else if (GameTool.IntBetween(75, 100, random) && !dog.dogProperty.commandLieDown)
+                            {
+                                trainingContent = "commandLieDown";
+                            }
+                            else
+                            {
+                                GameData.isVoiceTrainingToday = true;
+                            }
                         }
-                        else if (random < 100 && !dog.dogProperty.commandTurnR)
+                        else if (dog.dogProperty.voiceCommand >= 40 && dog.dogProperty.CommandTrainingPhase() >= 4)
                         {
-                            trainingContent = "commandTurnR";
+                            // 当狗的voiceCommand大于等于40并且完成第一阶段所有训练,进入第二阶段指令训练模式
+                            int random = UnityEngine.Random.Range(0, 100);
+                            if (GameTool.IntBetween(0, 20, random) && !dog.dogProperty.commandRotate)
+                            {
+                                trainingContent = "commandRotate";
+                            }
+                            else if (GameTool.IntBetween(20, 40, random) && !dog.dogProperty.commandHug)
+                            {
+                                trainingContent = "commandHug";
+                            }
+                            else if (GameTool.IntBetween(40, 60, random) && !dog.dogProperty.commandDeath)
+                            {
+                                trainingContent = "commandDeath";
+                            }
+                            else if (GameTool.IntBetween(60, 80, random) && !dog.dogProperty.commandTurnL)
+                            {
+                                trainingContent = "commandTurnL";
+                            }
+                            else if (GameTool.IntBetween(80, 100, random) && !dog.dogProperty.commandTurnR)
+                            {
+                                trainingContent = "commandTurnR";
+                            }
+                            else
+                            {
+                                GameData.isVoiceTrainingToday = true;
+                            }
                         }
                     }
+
                     else
                     {
                         trainingContent = String.Empty;
@@ -347,8 +352,6 @@ public class HomeController : MonoBehaviour
                 }
             }
             #endregion
-
-
         }
     }
 
@@ -356,13 +359,7 @@ public class HomeController : MonoBehaviour
     {
         Debug.Log("Home scene is destoried.");
     }
-    //void AniOrWalk(DogInScene dog)        // 狗在普通状态下,随机或播放动画,或移动
-    //{
 
-    //}
-
-    // 初始化场景,加载所有的狗,并配置components,添加到dogsInScene List里面去
-    //void InitialScene()
     IEnumerator InitialScene()
     {
         yield return null;      // 跳过三帧,初始化最多三只狗
@@ -495,7 +492,7 @@ public class HomeController : MonoBehaviour
         {
             return Vector3.zero;
         }
-        
+
         Vector3 center = Vector3.zero;
         foreach (var dog in dogsInScene)
         {
@@ -614,15 +611,6 @@ public class HomeController : MonoBehaviour
         }
         else if (sceneMode == SceneMode.TRAINING)
         {
-            // todo 临时代码查上传数据
-            Debug.Log("Voice training Post request");
-            Debug.Log("filepath:" + filePath);
-            Debug.Log("dog_id:" + UserProperty.dogs[GameData.focusDog].d_id);
-            Debug.Log("user_id:" + UserProperty.userId);
-            Debug.Log("trainingContent:" + trainingContent);
-            Debug.Log("current times:" + this.currentTrainingTimes.ToString());
-            Debug.Log("total times:" + totalTrainingTimes.ToString());
-
             //Debug.Log("current times before ++:" + this.currentTrainingTimes.ToString());
             this.currentTrainingTimes++;
             string url = "/api/voice/training/";
@@ -666,12 +654,20 @@ public class HomeController : MonoBehaviour
                     }
                 }
                 dogsInScene[GameData.focusDog].ResetAnimationStatus();        // 重置狗的动画状态
-                if (highestScore >= 60)
+                if (highestScore >= 0.6f)
                 {
                     string animationTrigger = highestScoreCommand.Substring(7);
                     string animationBool = highestScoreCommand + "_status";
                     var animator = dogsInScene[GameData.focusDog].gameObject.GetComponent<Animator>();
-                    animator.SetTrigger(animationTrigger);
+                    if (highestScoreCommand == "commandBark")
+                    {
+                        DogBarkController.Instance.PlayDogBarkWithDelay(3);    // 狗叫相应一下
+                    }
+                    else
+                    {
+                        HomeSoundEffectController.Instance.PlaySoundEffect(5);
+                    }
+                        animator.SetTrigger(animationTrigger);
                     animator.SetBool(animationBool, true);
 
                     // 交互动画执行一段时间后停止
@@ -696,7 +692,7 @@ public class HomeController : MonoBehaviour
                 if (data["message"].ToString().ToLower() == "pass")
                 {
 
-                    // TODO 刷新狗的数据
+                    //  刷新狗的数据,包含dogsInScene
                     string dogJson = data["dogs"].ToString();
                     UserProperty.FreshDogInfo(dogJson);
 
@@ -712,6 +708,10 @@ public class HomeController : MonoBehaviour
                     }
 
                     string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_10", EnviromentSetting.languageCode });
+                    if (msg.Contains("<<dog_name>>"))
+                    {
+                        msg = msg.Replace("<<dog_name>>", interactDog.name);
+                    }
                     GameTool.PauseGameTime();
 
                     MessageBoxController.ShowMessage(msg, ExitTrainingMode);
@@ -729,6 +729,10 @@ public class HomeController : MonoBehaviour
                     HomeSoundEffectController.Instance.PlaySoundEffect(4);
 
                     string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_20", EnviromentSetting.languageCode });
+                    if (msg.Contains("<<dog_name>>"))
+                    {
+                        msg = msg.Replace("<<dog_name>>", interactDog.name);
+                    }
                     GameTool.PauseGameTime();
                     MessageBoxController.ShowMessage(msg, RestartTraining);
                 }
@@ -736,6 +740,19 @@ public class HomeController : MonoBehaviour
             else
             {
                 Debug.Log(data["message"]);
+
+                if (EnviromentSetting.runEnv == "Release")
+                {
+                    HomeSoundEffectController.Instance.PlaySoundEffect(4);
+                    string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", trainingContent + "_20", EnviromentSetting.languageCode });
+                    if (msg.Contains("<<dog_name>>"))
+                    {
+                        msg = msg.Replace("<<dog_name>>", interactDog.name);
+                    }
+                    GameTool.PauseGameTime();
+                    MessageBoxController.ShowMessage(msg, RestartTraining);
+                }
+
             }
         }
     }
@@ -770,14 +787,6 @@ public class HomeController : MonoBehaviour
         {
             FadeBGM(BGM.GetComponent<AudioSource>(), true);
         }
-        // 恢复因为交互,训练模式隐藏的狗
-        // foreach (var dog in dogsInScene)
-        // {
-        //     if (dog.gameObject.activeSelf == false)
-        //     {
-        //         dog.gameObject.SetActive(true);
-        //     }
-        // }
     }
 
     private void RestartTraining()
@@ -836,8 +845,7 @@ public class HomeController : MonoBehaviour
             if (interactTime > 2.5)        // 如果交互时间超过1秒,播放心形粒子效果
             {
                 HeartParticlePlay();
-                var animation = interactDog.GetComponent<Animator>();
-                animation.SetTrigger("Hug");
+                DogBarkController.Instance.PlayDogBarkWithDelay(1);    // 狗叫相应一下
             }
         }
     }
@@ -909,8 +917,8 @@ public class HomeController : MonoBehaviour
 
 public enum ItemGroup
 {
-    food,
-    water
+    FOOD,
+    WATER
 }
 
 public enum SceneMode

+ 2 - 2
Assets/Scripts/Home/UserFeedbackController.cs

@@ -68,9 +68,9 @@ public class UserFeedbackController : MonoBehaviour
         if (uiPlaceholder != null)
         {
             var FeedbackUI = uiPlaceholder.transform.Find("Feedback").gameObject;
-            var UserInfoUI = uiPlaceholder.transform.Find("User Info").gameObject;
+            var VoiceAndMenuUI = uiPlaceholder.transform.Find("VoiceAndMenu").gameObject;
             FeedbackUI.SetActive(false);
-            UserInfoUI.SetActive(false);
+            VoiceAndMenuUI.SetActive(true);
         }
     }