Procházet zdrojové kódy

3/22更行

2025/3/17 修改用户第1次注册游戏初始化狗之后的逻辑错误
2025/3/18 效改回单例,跨场景会销毁。
增加Home场景下检测是否完全加载功能。修正睡眠状态。
2025/3/19 添加玩飞盘后道具使用提交
添加Home场景下道具使用后提交
2025/3/20 添加狗状态页面下创建多只狗界面。添加部分代码。
Jees před 2 měsíci
rodič
revize
d53492c204

+ 1 - 0
.gitignore

@@ -5,6 +5,7 @@
 /Usersettings/
 /.vs/
 /.vscode/
+/.utmp/
 /.vsconfig
 /.Assembly-CSharp.csproj
 /.Assembly-CSharp-Editor.csproj

+ 89 - 4
Assets/Packages/2D Casual UI/Sprite/GUI.png.meta

@@ -1,5 +1,12 @@
 fileFormatVersion: 2
 guid: 1eaee135ce037439d925cee5e41ce026
+AssetOrigin:
+  serializedVersion: 1
+  productId: 82080
+  packageName: 2D Casual UI HD
+  packageVersion: 1.0
+  assetPath: Assets/Packages/2D Casual UI/Sprite/GUI.png
+  uploadId: 159936
 TextureImporter:
   internalIDToNameTable:
   - first:
@@ -253,7 +260,7 @@ TextureImporter:
   swizzle: 50462976
   cookieLightType: 1
   platformSettings:
-  - serializedVersion: 3
+  - serializedVersion: 4
     buildTarget: DefaultTexturePlatform
     maxTextureSize: 2048
     resizeAlgorithm: 0
@@ -266,7 +273,7 @@ TextureImporter:
     ignorePlatformSupport: 0
     androidETC2FallbackOverride: 0
     forceMaximumCompressionQuality_BC6H_BC7: 0
-  - serializedVersion: 3
+  - serializedVersion: 4
     buildTarget: Standalone
     maxTextureSize: 2048
     resizeAlgorithm: 0
@@ -279,8 +286,21 @@ TextureImporter:
     ignorePlatformSupport: 0
     androidETC2FallbackOverride: 0
     forceMaximumCompressionQuality_BC6H_BC7: 0
-  - serializedVersion: 3
-    buildTarget: WebGL
+  - serializedVersion: 4
+    buildTarget: Android
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 0
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    ignorePlatformSupport: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 4
+    buildTarget: iOS
     maxTextureSize: 2048
     resizeAlgorithm: 0
     textureFormat: -1
@@ -306,6 +326,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -327,6 +348,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -348,6 +370,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -369,6 +392,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -390,6 +414,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -411,6 +436,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -432,6 +458,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -453,6 +480,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -474,6 +502,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -495,6 +524,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 70, y: 0, z: 70, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -516,6 +546,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 50, y: 50, z: 50, w: 50}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -537,6 +568,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 50, y: 50, z: 50, w: 50}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -558,6 +590,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 30, y: 20, z: 30, w: 20}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -579,6 +612,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 30, y: 20, z: 30, w: 20}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -600,6 +634,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -621,6 +656,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -642,6 +678,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -663,6 +700,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 0, y: 50, z: 0, w: 50}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -684,6 +722,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 0, y: 50, z: 0, w: 50}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -705,6 +744,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 40, y: 0, z: 40, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -726,6 +766,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -747,6 +788,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -768,6 +810,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -789,6 +832,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 40, y: 0, z: 40, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -810,6 +854,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -831,6 +876,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -852,6 +898,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -873,6 +920,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -894,6 +942,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 70, y: 70, z: 70, w: 70}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -915,6 +964,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -936,6 +986,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -957,6 +1008,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -978,6 +1030,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -999,6 +1052,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1020,6 +1074,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1041,6 +1096,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1062,6 +1118,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1083,6 +1140,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1104,6 +1162,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1125,6 +1184,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1146,6 +1206,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1167,6 +1228,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1188,6 +1250,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1209,6 +1272,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1230,6 +1294,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1251,6 +1316,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 80, y: 80, z: 80, w: 80}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1272,6 +1338,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 80, y: 80, z: 80, w: 80}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1293,6 +1360,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1314,6 +1382,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1335,6 +1404,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1356,6 +1426,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1377,6 +1448,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1398,6 +1470,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1419,6 +1492,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1440,6 +1514,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1461,6 +1536,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1482,6 +1558,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1503,6 +1580,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1524,6 +1602,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1545,6 +1624,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1566,6 +1646,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0, y: 0}
       border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1587,6 +1668,7 @@ TextureImporter:
       alignment: 0
       pivot: {x: 0.5, y: 0.5}
       border: {x: 200, y: 0, z: 200, w: 0}
+      customData: 
       outline: []
       physicsShape: []
       tessellationDetail: 0
@@ -1598,6 +1680,7 @@ TextureImporter:
       edges: []
       weights: []
     outline: []
+    customData: 
     physicsShape: []
     bones: []
     spriteID: 
@@ -1607,6 +1690,8 @@ TextureImporter:
     edges: []
     weights: []
     secondaryTextures: []
+    spriteCustomMetadata:
+      entries: []
     nameFileIdTable:
       GUI_0: 21300000
       GUI_1: 21300002

+ 7 - 0
Assets/Packages/2D Casual UI/readme.rtf.meta

@@ -6,3 +6,10 @@ DefaultImporter:
   userData: 
   assetBundleName: 
   assetBundleVariant: 
+AssetOrigin:
+  serializedVersion: 1
+  productId: 82080
+  packageName: 2D Casual UI HD
+  packageVersion: 1.0
+  assetPath: Assets/Packages/2D Casual UI/readme.rtf
+  uploadId: 159936

+ 16 - 0
Assets/Resources/Data/languages.json

@@ -194,6 +194,22 @@
             "en": "The dog is very clean now, take it home.",
             "zh-cn": "狗狗现在很干净了,带它回家吧。"
         },
+        "add_dog_prompt":{
+            "en": "Are you going to adopt a new dog?",
+            "zh-cn": "确认再领养一只新的狗吗?"
+        },
+        "add_dog_fail_no_more":{
+            "en": "You can't adopt a new dog anymore. Unless you transfer your dog to someone else or foster it",
+            "zh-cn": "你不能再领养新的狗了。除非把现有的狗赠送给别人或者寄养。"
+        },
+        "add_dog_fail_account_level":{
+            "en": "If you want to adopt more dogs, please upgrade to be a Pro user.",
+            "zh-cn": "想领养更多狗,请升级成为Pro用户。"
+        },
+        "foster_dog_prompt":{
+            "en": "Will you send<<dog name>>to foster care? It will cost 200 coins.",
+            "zh-cn": "把<<dog name>>送去寄养吗?将花费200金币。"
+        },
         "from here not used. no_more_food": {
             "en": "<dog_name> is full. It doesn't want to eat anymore.",
             "zh-cn": "<dog_name>吃饱了。它不想再吃了。"

+ 1 - 1
Assets/Resources/MessageBox/MessageBoxController.cs

@@ -73,7 +73,7 @@ public class MessageBoxController : MonoBehaviour
 
     public static void DestoryMessageBox()
     {
-        Debug.Log("destrory message func start");
+        //Debug.Log("destrory message func start");
         GameObject messageBox = GameObject.Find("MessageBox(Clone)");
         Destroy(messageBox);
     }

+ 4 - 1
Assets/Resources/Status/Status.prefab

@@ -53,6 +53,9 @@ MonoBehaviour:
   m_ParentUI: {fileID: 0}
   sourceAsset: {fileID: 9197481963319205126, guid: f834ac681a2cf1e4ab4ac1a3b5ce6680, type: 3}
   m_SortingOrder: 0
+  m_WorldSpaceSizeMode: 1
+  m_WorldSpaceWidth: 1920
+  m_WorldSpaceHeight: 1080
 --- !u!114 &6906035488236654832
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -83,7 +86,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!224 &8435704930564478781
 RectTransform:
   m_ObjectHideFlags: 0

+ 66 - 3
Assets/Resources/Status/StatusController.cs

@@ -2,17 +2,21 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using UnityEngine.SceneManagement;
 using UnityEngine.UIElements;
 
 /* 这个controller 是用于控制 Status UI菜单的
+ * 包含显示狗的最新状态
+ * 添加狗,把狗送给朋友,删除狗
  */
 public class StatusController : MonoBehaviour
 {
-    public Button backButton;
-    public Label nameLabel, genderLabel, breedLabel, hostLabel, hostnameLabel, ageLabel, ageValueLabel, statusLabel, statusValueLabel;
+    private Button backButton;
+    private Label nameLabel, genderLabel, breedLabel, hostLabel, hostnameLabel, ageLabel, ageValueLabel, statusLabel, statusValueLabel;
     private Label leftArrow, rightArrow;
+    private Label addLabel, transfer, remove, callback;
     DogProperty puppy;
-    public VisualElement selectElement;
+    private VisualElement selectElement;
     // Start is called before the first frame update
     void OnEnable()
     {
@@ -30,11 +34,18 @@ public class StatusController : MonoBehaviour
         selectElement = root.Q("selectElement");
         leftArrow = root.Q<Label>("leftArrow");
         rightArrow = root.Q<Label>("rightArrow");
+        addLabel = root.Q<Label>("add");
+        transfer = root.Q<Label>("transfer");
+        remove = root.Q<Label>("remove");
+        callback = root.Q<Label>("callback");
 
         // 绑定事件
         backButton.clicked += BackBtnClick;
         leftArrow.RegisterCallback<ClickEvent>(e => LeftArrowClicked(e));
         rightArrow.RegisterCallback<ClickEvent>(e => RightArrowClicked(e));
+        addLabel.RegisterCallback<ClickEvent>(e => AddClick(e));
+        remove.RegisterCallback< ClickEvent >(e => RemoveClick(e));
+        transfer.RegisterCallback<ClickEvent >(e => TransferClick(e));
 
         // 箭头是否显示
         if (UserProperty.dogs.Count > 1)
@@ -249,5 +260,57 @@ public class StatusController : MonoBehaviour
         }
     }
 
+    void AddClick(ClickEvent e)
+    {
+        if (UserProperty.level == "basic")
+        {
+            string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "add_dog_fail_account_level", EnviromentSetting.languageCode });
+            MessageBoxController.ShowMessage(msg);
+        }
+        else if (UserProperty.dogs.Count == EnviromentSetting.maxDogQty)
+        {
+            string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "add_dog_fail_no_more", EnviromentSetting.languageCode });
+            MessageBoxController.ShowMessage(msg);
+        }
+        else
+        {
+            string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "add_dog_prompt", EnviromentSetting.languageCode });
+            MessageBoxController.YorN_Message(msg, SwitchAddNewDog);
+        }
+        
+    }
+
+    // 跳转login 场景添加新的狗
+    void SwitchAddNewDog()
+    {
+        GameData.subScene = "Login_InitDog";
+        SceneManager.LoadScene("Home");
+    }
+
+    void RemoveClick(ClickEvent e) {
+        string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "foster_dog_prompt", EnviromentSetting.languageCode });
+        msg = msg.Replace("<<dog name>>", UserProperty.dogs[GameData.focusDog].dog_name);
+        MessageBoxController.YorN_Message(msg, FosterDog);
+    }
+    
+    // 点击确认remove后调用寄养的程序
+    void FosterDog()
+    {
+        // 检测用户是否有200金币
+        if (UserProperty.coin >= 200)
+        {
+            // todo 寄养某一只狗,并扣除金币
+        }
+    }
+
+    // 找回寄养的狗
+    void CallbackDogClick(ClickEvent e){
+
+    }
+
+    void TransferClick(ClickEvent e)
+    {
+        // TODO 添加代码增加面对面赠送狗的功能
+    }
 }
 

+ 14 - 0
Assets/Resources/Status/StatusStyle.uss

@@ -43,6 +43,20 @@
     -unity-font-definition: url("project://database/Assets/Font/MaoKenZhuYuanTi-MaokenZhuyuanTi-2.ttf?fileID=12800000&guid=50a63638b44907e46a3fa871d63b7d39&type=3#MaoKenZhuYuanTi-MaokenZhuyuanTi-2");
 }
 
+.subMenu {
+    background-image: url("project://database/Assets/Packages/2D%20Casual%20UI/Sprite/GUI.png?fileID=21300106&guid=1eaee135ce037439d925cee5e41ce026&type=3#GUI_60");
+    -unity-background-image-tint-color: rgba(255, 252, 90, 0.78);
+    width: 30px;
+    height: 30px;
+    background-size: 100% 100%;
+    flex-shrink: initial;
+    flex-grow: initial;
+    align-items: center;
+    align-self: center;
+    max-width: initial;
+    max-height: initial;
+}
+
 .background {
     flex-grow: 1;
     width: auto;

+ 6 - 1
Assets/Resources/Status/StatusUI.uxml

@@ -12,7 +12,12 @@
         <ui:Label tabindex="-1" text="状态" parse-escape-sequences="true" display-tooltip-when-elided="true" name="status" class="Labels" style="position: absolute; top: 180px; left: 30px; height: 40px; width: auto; 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: 30px; padding-bottom: 0; padding-right: 0; padding-top: 0; padding-left: 0; color: rgb(255, 162, 11);" />
         <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: 220px; left: 30px; height: auto; width: auto; -unity-text-align: upper-left; right: 93px; border-top-width: 0; border-right-width: 0; border-bottom-width: 0; border-left-width: 0; margin-right: 10px; margin-left: auto; margin-top: auto; margin-bottom: auto;" />
         <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="selectElement" style="flex-grow: 1; position: absolute; height: 20px; top: 450px; width: auto; background-color: rgba(116, 116, 116, 0.47); border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; align-items: center; align-self: auto; justify-content: flex-start; flex-direction: row;" />
+        <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: 12%; 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;);" />
+            <ui:Label name="Label" class="subMenu" style="background-image: url(&quot;project://database/Assets/Packages/2D%20Casual%20UI/Sprite/GUI.png?fileID=21300070&amp;guid=1eaee135ce037439d925cee5e41ce026&amp;type=3#GUI_35&quot;);" />
+        </ui:VisualElement>
         <ui:VisualElement name="arrowArea" style="flex-grow: 1; height: auto; min-height: auto; flex-direction: row; justify-content: space-between; align-self: auto; align-content: flex-start; align-items: center; position: absolute; bottom: 20%; width: 90%; visibility: visible; display: flex;">
             <ui:Label text="⬅" name="leftArrow" class="arrow" style="visibility: visible; -unity-text-outline-color: rgba(22, 131, 245, 0.78); -unity-text-outline-width: 1px;" />
             <ui:Label text="➡" emoji-fallback-support="false" name="rightArrow" class="arrow" style="visibility: visible; -unity-text-outline-color: rgba(22, 131, 245, 0.78); -unity-text-outline-width: 1px;" />

+ 1 - 1
Assets/Resources/VoiceAndManu/VoiceController.cs

@@ -21,7 +21,7 @@ public class VoiceController : MonoBehaviour
 
     void OnEnable()
     {
-        Debug.Log("voice controller start");
+        //Debug.Log("voice controller start");
         var root = GetComponent<UIDocument>().rootVisualElement;
         var voiceArea = root.Q<VisualElement>("voiceArea");
         waveForm = voiceArea.Q<VisualElement>("waveForm");

+ 35 - 29
Assets/Resources/Warehouse/ItemUseController.cs

@@ -29,7 +29,7 @@ public class ItemUseController : ScriptableObject
     {
         "toy_00001"     // 飞盘
     };
-    private static List<string> Showers = new()
+    private static List<string> showers = new()
     {
         "other_00001"     // 打开洗澡页面的用品
     };
@@ -41,39 +41,46 @@ public class ItemUseController : ScriptableObject
 
     public static void ItemUsed(string itemId)
     {
-        // 消费食物类
-        if (foodBowlItems.Contains(itemId))
+        // 在Home场景使用道具调用_itemUseId来启动道具使用
+        if (SceneManager.GetActiveScene().name == "Home")
         {
-            var bowls = GameObject.Find("Bowls");
-            var targetBowl = bowls.transform.Find("Bowl_food").gameObject;
-            targetBowl.transform.localPosition = CalcBowlShowLoc();
-            var food = targetBowl.transform.Find("Food").gameObject;
-            food.SetActive(true);
-
-            foreach (var dogInScene in HomeController.dogsInScene)
+            // 消费食物类
+            if (foodBowlItems.Contains(itemId))
             {
-                dogInScene.StartItemConsume(ItemGroup.food);
-                dogInScene.SetMoveSpeed(UnityEngine.Random.Range(0.3f, 0.6f));
-            }
-            
-        }
+                var bowls = GameObject.Find("Bowls");
+                var targetBowl = bowls.transform.Find("Bowl_food").gameObject;
+                targetBowl.transform.localPosition = CalcBowlShowLoc();
+                var food = targetBowl.transform.Find("Food").gameObject;
+                food.SetActive(true);
 
-        // 消费水牛奶等
-        if (waterBowlItems.Contains(itemId))
-        {
-            var bowls = GameObject.Find("Bowls");
-            var targetBowl = bowls.transform.Find("Bowl_water").gameObject;
-            targetBowl.transform.localPosition = CalcBowlShowLoc();
-            var water = targetBowl.transform.Find("Water").gameObject;
-            water.SetActive(true);
+                foreach (var dogInScene in HomeController.dogsInScene)
+                {
+                    dogInScene.StartItemConsume(ItemGroup.food);
+                    dogInScene.SetMoveSpeed(UnityEngine.Random.Range(0.3f, 0.6f));
+                }
 
-            foreach (var dogInScene in HomeController.dogsInScene)
+            }
+
+            // 消费水牛奶等
+            if (waterBowlItems.Contains(itemId))
             {
-                dogInScene.StartItemConsume(ItemGroup.water);
-                dogInScene.SetMoveSpeed(UnityEngine.Random.Range(0.3f, 0.6f));
+                var bowls = GameObject.Find("Bowls");
+                var targetBowl = bowls.transform.Find("Bowl_water").gameObject;
+                targetBowl.transform.localPosition = CalcBowlShowLoc();
+                var water = targetBowl.transform.Find("Water").gameObject;
+                water.SetActive(true);
+
+                foreach (var dogInScene in HomeController.dogsInScene)
+                {
+                    dogInScene.StartItemConsume(ItemGroup.water);
+                    dogInScene.SetMoveSpeed(UnityEngine.Random.Range(0.3f, 0.6f));
+                }
             }
 
+            // 通过将_itemUseId 设置为非空后,启动网络通讯
+            ItemUseController._itemUseId = itemId;
         }
+        
 
         // 使用飞盘类道具
         if (frisbees.Contains(itemId))
@@ -83,13 +90,12 @@ public class ItemUseController : ScriptableObject
         }
 
         // 使用洗澡页面道具
-        if (Showers.Contains(itemId))
+        if (showers.Contains(itemId))
         {
             GameData.bathItemId = itemId;        // 存储使用哪一个玩具
             SceneManager.LoadScene("Bathroom", LoadSceneMode.Single);
         }
-        // TODO 以后打开 网络通讯后刷新数据
-        ItemUseController._itemUseId = itemId;
+        
     }
 
     #region 食物和喝水控制代码

+ 3 - 3
Assets/Resources/Warehouse/WarehouseController.cs

@@ -93,7 +93,7 @@ public class WarehouseController : MonoBehaviour
         var root = GetComponent<UIDocument>().rootVisualElement;
         itemListView.Clear();
         VisualTreeAsset itemResource = Resources.Load<VisualTreeAsset>("Shopping/Item");
-        Dictionary<string, int> items;
+        Dictionary<string, int> items = new();
         if (type == "food")
         {
             items = UserProperty.food;
@@ -101,7 +101,7 @@ public class WarehouseController : MonoBehaviour
         {
             items = UserProperty.toy;
         }
-        else
+        else if (type == "other")
         {
             items = UserProperty.other;
         }
@@ -178,7 +178,7 @@ public class WarehouseController : MonoBehaviour
     // todo 以后在这里添加调出确认页面,确认后将道具使用请求给服务器
     void MsgYesClick()
     {
-        Debug.Log("msg yes clicked");
+        //Debug.Log("msg yes clicked");
         msgRoot.visible = false;
         //ItemUseController itemUseController = new ItemUseController();
         ItemUseController.ItemUsed(selectedItemId);

+ 0 - 4
Assets/Scenes/Home.unity

@@ -3784,10 +3784,6 @@ PrefabInstance:
       propertyPath: m_Name
       value: Status
       objectReference: {fileID: 0}
-    - target: {fileID: 5997909836355842307, guid: 00b97733408f83840b44ba387e9ae31b, type: 3}
-      propertyPath: m_IsActive
-      value: 0
-      objectReference: {fileID: 0}
     - target: {fileID: 8435704930564478781, guid: 00b97733408f83840b44ba387e9ae31b, type: 3}
       propertyPath: m_Pivot.x
       value: 0

+ 0 - 1
Assets/Scripts/Bathroom/BathroomController.cs

@@ -214,7 +214,6 @@ public class BathroomController : MonoBehaviour
         List<string> dogs = new List<string>();
         dogs.Add(UserProperty.dogs[GameData.focusDog].d_id);
         string dogsJson = JsonConvert.SerializeObject(dogs);
-
         string url = "/api/item/use/";
         WWWForm form = new();
         form.AddField("user_id", UserProperty.userId);

+ 20 - 19
Assets/Scripts/Develop Script/TestSetup.cs

@@ -15,7 +15,7 @@ public class TestSetup : MonoBehaviour
             UserProperty.dogs.Clear();
             UserProperty.dogs.Add(puppy);
             UserProperty.userId = "JTYNZP9O";
-            EnviromentSetting.accessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiSlRZTlpQOU8iLCJleHAiOjE3NDIyMDEwMzV9.0OjtHi5usRTNJ9hOidAk-tVLGdyHPLNVnDIZS2l4RbE";
+            EnviromentSetting.accessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiSlRZTlpQOU8iLCJleHAiOjE3NDI0Nzg5OTB9._br_Yd7xn6m2Nc078MEn3T7r-B7IYEjhVJY-H46Ob5E";
             EnviromentSetting.accessTokenReceivedTime = DateTime.Now;
             GameData.bathItemId = "other_00001";
         }
@@ -27,29 +27,30 @@ public class TestSetup : MonoBehaviour
             //UserProperty.dogs.Add(puppy);
             UserProperty.food.Clear();
             UserProperty.toy.Clear();
+            UserProperty.other.Clear();
             UserProperty.food.Add("food_00001", 10);
             UserProperty.food.Add("food_00002", 20);
             UserProperty.food.Add("food_00003", 30);
             UserProperty.toy.Add("toy_00001", 1);
             UserProperty.food.Add("water_00001", 999);
             UserProperty.food.Add("water_00002", 33);
-            UserProperty.food.Add("other_00001", 3);
+            UserProperty.other.Add("other_00001", 3);
         }
 
         if (SceneManager.GetActiveScene().name == "Playground")
         {
             // 初始化狗数据用于测试
-            DogProperty puppy = new DogProperty();
-            UserProperty.dogs.Clear();
-            UserProperty.dogs.Add(puppy);
-            UserProperty.food.Clear();
-            UserProperty.toy.Clear();
-            UserProperty.food.Add("food_00001", 10);
-            UserProperty.food.Add("food_00002", 20);
-            UserProperty.food.Add("food_00003", 30);
-            UserProperty.toy.Add("toy_00001", 1);
-            UserProperty.food.Add("water_00001", 999);
-            UserProperty.food.Add("water_00002", 33);
+            //DogProperty puppy = new DogProperty();
+            //UserProperty.dogs.Clear();
+            //UserProperty.dogs.Add(puppy);
+            //UserProperty.food.Clear();
+            //UserProperty.toy.Clear();
+            //UserProperty.food.Add("food_00001", 10);
+            //UserProperty.food.Add("food_00002", 20);
+            //UserProperty.food.Add("food_00003", 30);
+            //UserProperty.toy.Add("toy_00001", 1);
+            //UserProperty.food.Add("water_00001", 999);
+            //UserProperty.food.Add("water_00002", 33);
 
         }
 
@@ -65,15 +66,15 @@ public class TestSetup : MonoBehaviour
     {
         if (SceneManager.GetActiveScene().name == "Login")
         {
-            //PlayerPrefs.SetString("LoginToken", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiSlRZTlpQOU8iLCJleHAiOjE3NTY1NDUxNzd9.oQgjY_6ZHJVYaYxh2b_LMIkUaCJ9FX8UpxpHOt_yLg8");
-            //DateTime now = DateTime.Now;
-            //DateTime oneHourAgo = now.AddHours(-1);
-            //PlayerPrefs.SetString("LoginTokenTime", oneHourAgo.ToString());
+            PlayerPrefs.SetString("LoginToken", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiSlRZTlpQOU8iLCJleHAiOjE3NTY1NDUxNzd9.oQgjY_6ZHJVYaYxh2b_LMIkUaCJ9FX8UpxpHOt_yLg8");
+            DateTime now = DateTime.Now;
+            DateTime oneHourAgo = now.AddHours(-1);
+            PlayerPrefs.SetString("LoginTokenTime", oneHourAgo.ToString());
 
-            PlayerPrefs.DeleteAll();
+            // PlayerPrefs.DeleteAll();
         }
 
-        Debug.Log("Login token" + PlayerPrefs.GetString("LoginToken"));
+        //Debug.Log("Login token" + PlayerPrefs.GetString("LoginToken"));
     }
 
     

+ 10 - 9
Assets/Scripts/Functions/WebController.cs

@@ -2,6 +2,7 @@
 using System.Collections;
 using System.Collections.Generic;
 using System.IO;
+using System.Linq;
 using UnityEngine;
 using UnityEngine.Networking;
 using UnityEngine.SceneManagement;
@@ -31,17 +32,17 @@ public class WebController : MonoBehaviour {
 
         // 检测是否需要添加access_token
         bool accessTokenReq = true;
-        foreach (string whiteUrl in EnviromentSetting.accessTokenWhiteList)
+        if (EnviromentSetting.accessTokenWhiteList.Contains<string>(url))
         {
-            if (url == whiteUrl)
-            {
-                accessTokenReq = false;
-            }
-            else
-            {
-                accessTokenReq = true;
-            }
+            accessTokenReq = false;
         }
+        //foreach (string whiteUrl in EnviromentSetting.accessTokenWhiteList)
+        //{
+        //    if (url == whiteUrl)
+        //    {
+        //        accessTokenReq = false;
+        //    }
+        //}
 
         // 添加access token
         if (accessTokenReq) 

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

@@ -19,6 +19,7 @@ public class DogProperty
     public int sex = 1;
     public string breed = "shibaInu";       // 狗的默认模型
     public string skin = "black";     // 狗的默认贴图
+    public string adoption = "home";
     public DateTime brithday = new(2023, 1, 1, 12, 0, 0);
     public int satiety = 15;
     public int happiness = 50;

+ 0 - 3
Assets/Scripts/Home/AudioManager.cs

@@ -1,3 +0,0 @@
-internal class AudioManager
-{
-}

+ 0 - 2
Assets/Scripts/Home/AudioManager.cs.meta

@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: cd4317539099efa4f8b51b9a09ad4be7

+ 102 - 62
Assets/Scripts/Home/HomeController.cs

@@ -8,6 +8,7 @@ using UnityEngine;
 using UnityEngine.Animations;
 
 using UnityEngine.Rendering.PostProcessing;
+using UnityEngine.SceneManagement;
 
 /* 本代码控制室内场景
  * 控制宠物在Home场景动画
@@ -21,105 +22,119 @@ public class HomeController : MonoBehaviour
 
     public static List<DogInScene> dogsInScene = new List<DogInScene>();
     public static bool listenBreak = false;       // 当按下说话按键后,所有狗停止行动,立刻切换到监听状态。
-    private bool isInitialDone = false;
     public static CinemachineVirtualCamera playerCam, dogCam;
     public static DateTime lastCameraChange;
+    private bool isSleepChecked = false;        // 用于检测第一次睡眠检测是否执行完成
     // Start is called once before the first execution of Update after the MonoBehaviour is created
     void Start()
     {
-
+        dogsInScene.Clear();        // dogsInScene 是静态,每次启动要清空
         lastCameraChange = DateTime.Now;
         playerCam = GameObject.Find("VCam Player").GetComponent<CinemachineVirtualCamera>();
         dogCam = GameObject.Find("VCam Dog").GetComponent<CinemachineVirtualCamera>();
 
         //InitialScene();
         StartCoroutine(InitialScene());
-
-        // 判断是否在睡觉时间
-        DateTime dateTime = DateTime.Now;
-
-        foreach (var dog in dogsInScene)
-        {
-            if (dateTime.Hour >= 22 || dateTime.Hour <= 5)      // 深夜模式,狗默认在睡觉状态
-            {
-                dog.Sleep();
-            }else if(dog.dogProperty.stamina <= 10) { dog.Sleep(); }        // 狗体力太低了,进入睡觉模式
-            else
-            {
-                dog.StartAnimation();
-            }
-        }
-        isInitialDone = true;
     }
 
     // Update is called once per frame
     void FixedUpdate()
     {
-
-        #region 场景动画主循环
-        // 检测狗是否被撞翻,如果是,立刻翻回来
-        foreach (var dog in dogsInScene)
+        if (SceneInitialCheck())      // 确保狗读取成功后执行代码
         {
-            Quaternion curRotation = dog.gameObject.transform.rotation;
-            if (curRotation.x !=0)
-            {
-                curRotation.x = 0;
-            }
-            if (curRotation.z != 0)
+            // 每次启动检测一次是否进入睡眠
+            if (!isSleepChecked)
             {
-                curRotation.z = 0;
-            }
-            dog.gameObject.transform.rotation = curRotation;
-        }
+                // 判断是否在睡觉时间
+                DateTime dateTime = DateTime.Now;
 
-            // 生成一个数据数用于随机开启动画,如果和狗的randomFactor相同就开启动画
-            int randomCheck = UnityEngine.Random.Range(0, 51);
-        foreach (var dog in dogsInScene)
-        {
-            // 如果在eat drink进程结束前不执行随机场景代码
-            if (dog.eatProgress || dog.itemConsumeProgress)
-            {
-                if (dog.isMovingToBowl)
+                foreach (var dog in dogsInScene)
                 {
-                    dog.MovetoBowl();
+                    if (dateTime.Hour >= 22 || dateTime.Hour <= 5)      // 深夜模式,狗默认在睡觉状态
+                    {
+                        dog.Sleep();
+                    }
+                    else if (dog.dogProperty.stamina <= 10) { dog.Sleep(); }        // 狗体力太低了,进入睡觉模式
+                    else
+                    {
+                        dog.StartAnimation();
+                    }
                 }
+                isSleepChecked = true;
             }
-            else
-            {    // 随机动作控制控制   
-                // 随机镜头切换代码
-                RandomCameraChange();
 
-                if (listenBreak)        // 如果用户按下说话按键,立刻切换到监听状态
+            #region 场景动画主循环
+            // 检测狗是否被撞翻,如果是,立刻翻回来
+            foreach (var dog in dogsInScene)
+            {
+                Quaternion curRotation = dog.gameObject.transform.rotation;
+                if (curRotation.x != 0)
                 {
-                    dog.Listen();
+                    curRotation.x = 0;
                 }
-                else if (dog.isMoving)
+                if (curRotation.z != 0)
                 {
-                    dog.Move();
+                    curRotation.z = 0;
                 }
-                else if (randomCheck == dog.randomFactor)        // 当狗自身的随机数和系统随机数相同时候触发。约100秒触发一次。
+                dog.gameObject.transform.rotation = curRotation;
+            }
+
+            // 生成一个数据数用于随机开启动画,如果和狗的randomFactor相同就开启动画
+            int randomCheck = UnityEngine.Random.Range(0, 51);
+
+            foreach (var dog in dogsInScene)
+            {
+                // 如果在eat drink进程结束前不执行随机场景代码
+                if (dog.eatProgress || dog.itemConsumeProgress)
                 {
-                    TimeSpan ts = DateTime.Now - dog.animationStartTime;
-                    if (ts.Seconds >= 30)        // 如果距离上一个动作超过30秒就可以开始新的动作
+                    if (dog.isMovingToBowl)
                     {
-                        float r = UnityEngine.Random.Range(0, 1f);
-                        if (r > 0.6)       // 随机选择开始动画,或者移动
-                        {
-                            dog.StartAnimation();
-                        }
-                        else        // 狗狗开始步行移动
+                        dog.MovetoBowl();
+                    }
+                }
+                else
+                {    // 随机动作控制控制   
+                     // 随机镜头切换代码
+                    RandomCameraChange();
+
+                    if (listenBreak)        // 如果用户按下说话按键,立刻切换到监听状态
+                    {
+                        dog.Listen();
+                    }
+                    else if (dog.isMoving)
+                    {
+                        dog.Move();
+                    }
+
+                    else if (randomCheck == dog.randomFactor && !dog.isSleeping)        // 当狗自身的随机数和系统随机数相同时候触发。约100秒触发一次。
+                    {
+                        TimeSpan ts = DateTime.Now - dog.animationStartTime;
+                        if (ts.Seconds >= 30)        // 如果距离上一个动作超过30秒就可以开始新的动作
                         {
-                            dog.SetMoveSpeed(0);
-                            dog.moveSpeed = 0;
-                            dog.Move();
+                            float r = UnityEngine.Random.Range(0, 1f);
+                            if (r > 0.6)       // 随机选择开始动画,或者移动
+                            {
+                                dog.StartAnimation();
+                            }
+                            else        // 狗狗开始步行移动
+                            {
+                                dog.SetMoveSpeed(0);
+                                dog.moveSpeed = 0;
+                                dog.Move();
+                            }
                         }
                     }
                 }
             }
+            #endregion
         }
-        #endregion
+
     }
 
+    private void OnDestroy()
+    {
+        Debug.Log("Home scene is destoried.");
+    }
     //void AniOrWalk(DogInScene dog)        // 狗在普通状态下,随机或播放动画,或移动
     //{
 
@@ -212,6 +227,28 @@ public class HomeController : MonoBehaviour
         }
         lastCameraChange = DateTime.Now;
     }
+
+    // 检测场景是否初始化完成
+    bool SceneInitialCheck()
+    {
+        bool initDone = true;
+        if (dogsInScene.Count == UserProperty.dogs.Count)       // 检测是否所有狗都被加载
+        {
+            foreach (var dog in dogsInScene)
+            {
+                if(dog.gameObject.GetComponent<Animator>().runtimeAnimatorController == null)
+                {
+                    initDone = false;
+                }
+            }
+        }
+        else
+        {
+            initDone=false;
+        }
+        //Debug.Log("Home scene initial status:"+initDone);
+        return initDone;
+    }
 }
 
 // 本类用于管理场景中所有狗的状态包括动画状态,随机数分配等
@@ -235,6 +272,7 @@ public class DogInScene
     public DateTime animationStartTime;     // 记录上一个动画开始时间的,每个随机动作间隔至少30秒
     private int activeIndex;      // 动物的活动指数
     public bool isMoving;       // 动物正在移动,避免其他随机动作发生
+    public bool isSleeping;       // 动物正在正在睡觉,避免触发其他动画
 
     // 固定参数
     private float moveSpeedAdj = 0.025f;
@@ -319,6 +357,7 @@ public class DogInScene
     {
         this.animator.SetTrigger("sleep");
         this.animator.SetBool("isSleeping", true);  
+        this.isSleeping = true;
     }
 
     public void Listen()
@@ -329,6 +368,7 @@ public class DogInScene
         this.animator.SetBool("isMoving", false) ;
         this.animator.SetBool("isBarking", false);
         this.animator.SetBool("isSleeping", false);
+        this.isSleeping= false;     // 主人呼叫可以唤醒狗
         this.gameObject.transform.LookAt(new Vector3(0, 0, -6));
         HomeController.playerCam.Priority = 10;
         HomeController.dogCam.Priority = 1;

+ 1 - 1
Assets/Scripts/Home/HomeSoundEffectController.cs

@@ -17,7 +17,7 @@ public class HomeSoundEffectController: MonoBehaviour
         if (Instance == null)
         {
             Instance = this;
-            DontDestroyOnLoad(gameObject);
+            //DontDestroyOnLoad(gameObject);        // 必须关掉否则会导致原场景destroy不能执行
         }
         else
         {

+ 14 - 13
Assets/Scripts/Home/ItemUseWebCommController.cs

@@ -1,4 +1,5 @@
 using Newtonsoft.Json;
+using NUnit.Framework;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -7,6 +8,7 @@ using UnityEngine.SceneManagement;
 
 /* 本代码主要是因为Unity限制Monobehavior不能new()。
  * 因此在本类中监控ItemUseController._itemUseId 一旦不是null就触发网络通讯
+ * 本代码用于Home场景,挂载在Player组件下
  */
 public class ItemUseWebCommController : MonoBehaviour
 {
@@ -21,27 +23,34 @@ public class ItemUseWebCommController : MonoBehaviour
     {
         if (ItemUseController._itemUseId != null)
         {
-            StartCoroutine(ItemUsePost(ItemUseController._itemUseId));
+            ItemUsePost(ItemUseController._itemUseId);
             ItemUseController._itemUseId = null;
         }
     }
 
     // Post道具使用时网络通讯 
-    IEnumerator ItemUsePost(string itemId)
+    void ItemUsePost(string itemId)
     {
         Debug.Log("Item use Post request");
 
+        List<string> dogsList = new List<string>();
+        foreach (var dog in UserProperty.dogs)
+        {
+            dogsList.Add(dog.d_id);
+        }
+        string dogsJson = JsonConvert.SerializeObject(dogsList);
+
         // 提交POST
         string url = "/api/item/use/";
 
+
         WWWForm form = new();
         form.AddField("user_id", UserProperty.userId);
         form.AddField("item_id", itemId);
-        form.AddField("dog_names", UserProperty.dogNames());
-        form.AddField("date_time", DateTime.Now.ToString());
+        form.AddField("dog_list", dogsJson);
+        form.AddField("date_time", DateTime.Now.ToString());        // 可选项,以服务器时间为准
 
         StartCoroutine(WebController.PostRequest(url, form, callback: ItemUseCallback));
-        yield break;
     }
 
     // Post道具使用网络通讯后Callback
@@ -66,14 +75,6 @@ public class ItemUseWebCommController : MonoBehaviour
             {
                 UserProperty.dogs.Add(dog);
             }
-
-            // 判断用户狗的数量,如果为0就跳转用户创建狗。
-            if (UserProperty.dogs.Count < 1)
-            {
-                GameData.subScene = "Login_InitDog";
-                SceneManager.LoadScene("Login");
-            }
-
         }
         else
         {

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

@@ -186,11 +186,45 @@ public class InitDogUIController : MonoBehaviour
         if (data != null && data["status"].ToString() == "success")
         {
             string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "dog_create_success", EnviromentSetting.languageCode });
-            msg.Replace("<<dog_name>>", dogProperty.dog_name);
-            MessageBoxController.ShowMessage(msg, ()=> SceneManager.LoadScene("Home"));
+            msg=msg.Replace("<<dog_name>>", dogProperty.dog_name);
+            MessageBoxController.ShowMessage(msg, FreshUserData);
         }
     }
 
+    // 刷新用户狗的数据
+    void FreshUserData()
+    {
+        Debug.Log("fresh user data in inil Dog UI. request");
+        // 提交POST
+        string url = "/api/user/info/";
+        WWWForm form = new();
+        form.AddField("user_id", UserProperty.userId);
+        StartCoroutine(WebController.PostRequest(url, form, callback: FreshUserDataCallback));
+    }
+
+    void FreshUserDataCallback(string json)
+    {
+        var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
+        if (data != null && data["status"].ToString() == "success")
+        {
+            UserProperty.dogs.Clear();
+
+            // 保存狗的数据
+            DogProperty[] dogProperties = JsonConvert.DeserializeObject<DogProperty[]>(data["dogs"].ToString());
+            foreach (var dog in dogProperties)
+            {
+                UserProperty.dogs.Add(dog);
+            }
+            SceneManager.LoadScene("Home");
+        }
+        else
+        {
+            Debug.Log(data["message"]);
+        }
+
+    }
+
+
     // 绑定取消按键
     void CancelClick()
     {

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

@@ -173,6 +173,7 @@ public class LoginController : MonoBehaviour
             UserProperty.mobile = user_info["mobile"];
             UserProperty.email = user_info["email"];
             UserProperty.level = user_info["level"];
+            if (UserProperty.level == "pro"){ EnviromentSetting.maxDogQty = 3; }
             UserProperty.isRegUser = bool.Parse(user_info["isRegUser"]);
             Debug.Log("login in user id: " + UserProperty.userId);
 

+ 3 - 3
Assets/Scripts/Login/RegisterUIController.cs

@@ -100,7 +100,7 @@ public class RegisterUIController : MonoBehaviour
             string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "register_success", EnviromentSetting.languageCode });
             MessageBoxController.ShowMessage(msg, () => SceneManager.LoadScene("Home"));
         }
-        else if (data != null && data["status"] == "register fail")
+        else if (data != null && data["status"] == "error")
         {
             // TODO 注册失败动作
 
@@ -111,9 +111,9 @@ public class RegisterUIController : MonoBehaviour
                 errorText += errorMessageDict["duplicated_mobile"];
                 errorText += "<br>";
             }
-            if (data["message"] == "duplicated mobile phone")
+            if (data["message"] == "duplicated email")
             {
-                errorText += errorMessageDict["duplicated_mobile"];
+                errorText += errorMessageDict["duplicated_email"];
                 errorText += "<br>";
             }
 

+ 44 - 2
Assets/Scripts/Playground/PlayToyController.cs

@@ -1,5 +1,7 @@
 using Cinemachine;
+using Newtonsoft.Json;
 using System;
+using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.InputSystem;
 using UnityEngine.SceneManagement;
@@ -268,10 +270,50 @@ public class PlayToyController : MonoBehaviour
         SceneManager.LoadScene(currentSceneName);
     }
 
-    // UI 点击确认后,返回到Home界面
+    // UI 点击确认后,提交道具使用信息返回到Home界面
     void ConfirmBtnClick()
     {
-        SceneManager.LoadScene("Home");
+        PlayFinishRequest();
+    }
+
+    // 提交道具使用和受影响狗的列表
+    void PlayFinishRequest()
+    {
+        Debug.Log("Play Frisbee finish request");
+
+        List<string> dogs = new List<string>();
+        dogs.Add(UserProperty.dogs[GameData.focusDog].d_id);
+        string dogsJson = JsonConvert.SerializeObject(dogs);
+        string url = "/api/item/use/";
+        WWWForm form = new();
+        form.AddField("user_id", UserProperty.userId);
+        form.AddField("item_id", GameData.playedToy);
+        form.AddField("dog_list", dogsJson);
+        form.AddField("date_time", DateTime.Now.ToString());        // 可选项,以服务器时间为准
+        StartCoroutine(WebController.PostRequest(url, form, callback: PlayFrisbeeReqCallback));
+    }
+
+    void PlayFrisbeeReqCallback(string json)
+    {
+        var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
+        if (data != null && data["status"].ToString() == "success")
+        {
+            // TODO 清除然后重新写入用户道具数据
+
+            // 清除然后重新写入狗的数据
+            DogProperty[] dogProperties = JsonConvert.DeserializeObject<DogProperty[]>(data["dogs"].ToString());
+            UserProperty.dogs.Clear();
+            foreach (var dog in dogProperties)
+            {
+                UserProperty.dogs.Add(dog);
+            }
+            SceneManager.LoadScene("Home");
+        }
+        else
+        {
+            Debug.Log(data["message"]);
+        }
+
     }
 }
 

+ 4 - 0
ProjectSettings/EditorBuildSettings.asset

@@ -17,4 +17,8 @@ EditorBuildSettings:
   - enabled: 1
     path: Assets/Scenes/Playground.unity
     guid: bd3485dd96a9e624e81096642e7d6530
+  - enabled: 1
+    path: Assets/Scenes/Bathroom.unity
+    guid: 928c5be61ebde2b4ea4268318553ad79
   m_configObjects: {}
+  m_UseUCBPForAssetBundles: 0