Просмотр исходного кода

5/23更新

修复一些领养狗的错误
优化狗在Home场景下的初始位置
Jees 2 недель назад
Родитель
Сommit
25d56b2cf4

+ 1 - 0
.gitignore

@@ -12,3 +12,4 @@
 .csproj
 *.sln
 *.csproj
+Assets/Scripts/Develop Script/TestSetup.cs

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

@@ -953,8 +953,8 @@
         },
         "message": {
             "receive_success": {
-                "en": "Adopt successfully.",
-                "zh-cn": "领养成功。"
+                "en": "Adopt successfully. <<dog_name>> is your good friend.",
+                "zh-cn": "领养成功。<<dog_name>>现在是你的好伙伴了。"
             },
             "receive_fail": {
                 "en": "Adopt failed.",

+ 5 - 5
Assets/Scenes/Home.unity

@@ -362,11 +362,11 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 3082356105365184116, guid: 358eaf0dc05de8c4b925b8d7b41c3df9, type: 3}
       propertyPath: m_LocalPosition.z
-      value: 5.43
+      value: 0
       objectReference: {fileID: 0}
     - target: {fileID: 3082356105365184116, guid: 358eaf0dc05de8c4b925b8d7b41c3df9, type: 3}
       propertyPath: m_LocalRotation.w
-      value: 0.31639415
+      value: -0.79652995
       objectReference: {fileID: 0}
     - target: {fileID: 3082356105365184116, guid: 358eaf0dc05de8c4b925b8d7b41c3df9, type: 3}
       propertyPath: m_LocalRotation.x
@@ -374,11 +374,11 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 3082356105365184116, guid: 358eaf0dc05de8c4b925b8d7b41c3df9, type: 3}
       propertyPath: m_LocalRotation.y
-      value: 0.9486279
+      value: 0.60459906
       objectReference: {fileID: 0}
     - target: {fileID: 3082356105365184116, guid: 358eaf0dc05de8c4b925b8d7b41c3df9, type: 3}
       propertyPath: m_LocalRotation.z
-      value: 0
+      value: -0
       objectReference: {fileID: 0}
     - target: {fileID: 3082356105365184116, guid: 358eaf0dc05de8c4b925b8d7b41c3df9, type: 3}
       propertyPath: m_LocalEulerAnglesHint.x
@@ -386,7 +386,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 3082356105365184116, guid: 358eaf0dc05de8c4b925b8d7b41c3df9, type: 3}
       propertyPath: m_LocalEulerAnglesHint.y
-      value: 143.11
+      value: 285.6
       objectReference: {fileID: 0}
     - target: {fileID: 3082356105365184116, guid: 358eaf0dc05de8c4b925b8d7b41c3df9, type: 3}
       propertyPath: m_LocalEulerAnglesHint.z

+ 1 - 1
Assets/Scenes/Login/InitDogUI.uxml

@@ -3,7 +3,7 @@
     <Style src="project://database/Assets/UI%20Toolkit/Style/rootStyle.uss?fileID=7433441132597879392&amp;guid=b30eb17a0ca8bf64087af4e59d565fdd&amp;type=3#rootStyle" />
     <ui:VisualElement name="root" class="rootStyle" style="background-image: none;">
         <ui:VisualElement name="VisualElement" style="flex-grow: initial; background-color: rgba(253, 251, 251, 0.63); border-top-left-radius: 15px; border-top-right-radius: 15px; border-bottom-right-radius: 15px; border-bottom-left-radius: 15px;">
-            <ui:TextField label="Dog name:" max-length="16" hide-placeholder-on-focus="false" name="name" class="TextField textField" style="height: auto; -unity-text-align: middle-left; -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;); margin-top: 0;" />
+            <ui:TextField label="Dog name:" max-length="16" hide-placeholder-on-focus="false" name="name" class="TextField textField" style="-unity-text-align: middle-left; -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:DropdownField label="Breed" name="breed" class="dropdownField" />
             <ui:DropdownField label="Sex" name="sex" choices="Male,Female" class="dropdownField" />
             <ui:VisualElement style="flex-grow: 1; flex-direction: row; justify-content: space-between;">

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

@@ -380,8 +380,8 @@ public class HomeController : MonoBehaviour
         {
             DogInScene dogInScene = new DogInScene(dog);
             float x = UnityEngine.Random.Range(-1f, 1f);        // 随机生成位置,考虑到手机评估宽度限制宽度
-            float z = UnityEngine.Random.Range(-5f, 5f);
-            float y = UnityEngine.Random.Range(0, 360f);
+            float z = UnityEngine.Random.Range(0f, 5f);         // 随机生成位置,考虑且保持和用户距离
+            float y = UnityEngine.Random.Range(90f, 270f);      // 随机生成朝向,且面向用户
             var initPosition = new Vector3(x, 0, z);
             StartCoroutine(DogComponentInstaller(dog));       // 加载狗的其他组件
             var dogGameObject = GameObject.Find(dog.dog_name);

+ 13 - 10
Assets/Scripts/Login/CreateOrAdopt.cs

@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using Newtonsoft.Json;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.UIElements;
@@ -48,10 +49,10 @@ public class CreateOrAdopt : MonoBehaviour
         cameraContent = createAdoptCanvas.transform.Find("Camera Content").gameObject;
         cameraContent.SetActive(false);
 
-        if (UserProperty.dogs.Count > 0)
-        {
-            SwitchToCreate();
-        }
+        // if (UserProperty.dogs.Count > 0)
+        // {
+        //     SwitchToCreate();
+        // }
     }
 
     // Update is called once per frame
@@ -121,13 +122,13 @@ public class CreateOrAdopt : MonoBehaviour
             cameraTexture.texture = webCamTexture;
             webCamTexture.Play();
             barcodeReader = new BarcodeReader();
-            
+
             cameraContent.SetActive(true);
             messageLabel.visible = false;
             // messageLabel.style.display = DisplayStyle.None;
             createBtn.style.display = DisplayStyle.None;
             adoptBtn.style.display = DisplayStyle.None;
-            cancelBtn.style.display = DisplayStyle.Flex;    
+            cancelBtn.style.display = DisplayStyle.Flex;
         }
         else
         {
@@ -150,7 +151,7 @@ public class CreateOrAdopt : MonoBehaviour
                     // 处理二维码内容
                     string transferCode = qrCode.Substring(17);
                     Debug.Log("转移代码:" + transferCode);
-                    SubmitQRCodeRequest(result.Text); // 提交二维码请求 
+                    SubmitQRCodeRequest(transferCode); // 提交二维码请求 
                     isScanning = false;
                     webCamTexture.Stop();
                 }
@@ -176,14 +177,16 @@ public class CreateOrAdopt : MonoBehaviour
         StartCoroutine(WebController.PostRequest(url, form, callback: SubmitQRCodeCallback));
     }
 
-    private void SubmitQRCodeCallback(string response)
+    private void SubmitQRCodeCallback(string json)
     {
-        Debug.Log("QuickStartCallback: " + response);
+        Debug.Log("QuickStartCallback: " + json);
+        var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
         // 处理返回的结果
-        if (response.Contains("success"))
+        if (data != null && data["status"].ToString() == "success")
         {
             // 成功处理逻辑
             string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "InitDogUI", "message", "receive_success", EnviromentSetting.languageCode });
+            msg = msg.Replace("<<dog_name>>", data["dog_name"].ToString());
             MessageBoxController.ShowMessage(msg, () => GameTool.ReloadCurrentScene());
         }
         else

+ 5 - 2
Assets/Scripts/Login/InitDogUIController.cs

@@ -255,8 +255,11 @@ public class InitDogUIController : MonoBehaviour
     // 绑定取消按键
     void CancelClick()
     {
-        var RegCanvas = GameObject.Find("Init Dog Canvas");
-        RegCanvas.SetActive(false);
+        var regCanvas = GameObject.Find("Init Dog Canvas");
+        regCanvas.SetActive(false);
+        var canvasPlaceholder = GameObject.Find("Canvas Placeholder");
+        var createOrAdoptCanvas = canvasPlaceholder.transform.Find("Create Or Adopt Canvas").gameObject;
+        createOrAdoptCanvas.SetActive(true);
     }
 
     // 初始化语言和显示设定

+ 1 - 0
Assets/Scripts/Login/LoginController.cs

@@ -265,6 +265,7 @@ public class LoginController : MonoBehaviour
     // 切换到生成狗的子场景
     void SwitchToInitDogScene()
     {
+        
         createAdoptCanvas.SetActive(true);
         loginCanvas.SetActive(false);
         regCanvas.SetActive(false);

+ 8 - 10
Assets/Scripts/WalkDogs/SoundGameController.cs

@@ -2,6 +2,14 @@
 using UnityEngine;
 using UnityEngine.InputSystem;
 
+/* * WalkDogs 场景挂载在2D Player上
+ * SoundGameController.cs
+ * Author: 2023-10-12
+    * Description: 音乐游戏控制器
+    * 1. 读取音轨数据
+    * 2. 创建音符
+    * 3. 检测音符点击
+ */
 public class SoundGameController : MonoBehaviour
 {
     SoundTrackManager soundTrackManager = new();
@@ -188,16 +196,6 @@ public class SoundGameController : MonoBehaviour
         {
             foreach (var note in soundTrackManager.soundAction)
             {
-                // float TapTimeDeadline = note.time + gameStartTime + 0.35f; // 计算点击事件超时
-                // if (note.isActive && !note.isTapped && Time.time > TapTimeDeadline)
-                // {
-                //     note.isTapped = true;
-                //     MissCount++;
-                //     Debug.Log("Miss!" + Time.time + " Tap time deadline: " + TapTimeDeadline + " total miss:" + MissCount);
-                //     Debug.Log("index of note:" + soundTrackManager.soundAction.IndexOf(note));
-                //     break;
-                // }
-
                 float TapTimeDelta = Mathf.Abs(touchResponse.time - (note.time + gameStartTime));       // 计算点击时间和音符时间的差值
                 if (note.isActive && !note.isTapped && TapTimeDelta < 0.3f)
                 {

+ 10 - 6
Assets/UI Toolkit/Style/rootStyle.uss

@@ -22,7 +22,7 @@
 
 .textField > .unity-base-field__input {
     width: auto;
-    height: 20px;
+    height: 35px;
     -unity-font-definition: url("project://database/Assets/Font/MaoKenZhuYuanTi-MaokenZhuyuanTi-2.ttf?fileID=12800000&guid=50a63638b44907e46a3fa871d63b7d39&type=3#MaoKenZhuYuanTi-MaokenZhuyuanTi-2");
     font-size: 13px;
     background-color: rgba(255, 255, 255, 0.63);
@@ -34,16 +34,19 @@
     padding-right: 1px;
     padding-bottom: 1px;
     padding-left: 1px;
-    margin-top: 0;
-    margin-right: 0;
-    margin-bottom: 0;
-    margin-left: 0;
+    margin-top: 10px;
+    margin-right: 10px;
+    margin-bottom: 10px;
+    margin-left: 10px;
     max-width: 100%;
     -unity-text-align: middle-center;
 }
 
 .textField {
     align-items: center;
+    flex-shrink: initial;
+    flex-grow: initial;
+    margin-top: 4px;
 }
 
 .textField__multiline {
@@ -130,7 +133,7 @@
 
 .dropdownField > .unity-base-field__input {
     width: auto;
-    height: auto;
+    height: 35px;
     -unity-font-definition: url("project://database/Assets/Font/MaoKenZhuYuanTi-MaokenZhuyuanTi-2.ttf?fileID=12800000&guid=50a63638b44907e46a3fa871d63b7d39&type=3#MaoKenZhuYuanTi-MaokenZhuyuanTi-2");
     font-size: 13px;
     background-color: rgba(255, 255, 255, 0.63);
@@ -147,6 +150,7 @@
     margin-bottom: 10px;
     margin-left: 10px;
     max-width: 100%;
+    -unity-text-align: middle-center;
 }
 
 .dropdownField > .unity-base-field__input > .unity-base-popup-field__text {