From f2d308aae4b44a4b8344f6f85e11398ed5fcec92 Mon Sep 17 00:00:00 2001 From: YL Date: Wed, 23 Apr 2025 14:15:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E8=B4=AA=E5=90=83=E8=9B=87?= =?UTF-8?q?=E5=92=8CARGame=E6=B8=B8=E6=88=8F=E8=84=9A=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E8=BF=9C=E7=A8=8B=E4=BB=93=E5=BA=93=E7=A1=AC?= =?UTF-8?q?=E7=9B=98=E5=87=BA=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=9B=9E=E9=80=80=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EintooAR/Assets/AssetRaw/Scenes/ARGame.meta | 8 +++ .../Scenes/ARGame}/Snack.unity | 0 .../Scenes/ARGame}/Snack.unity.meta | 0 .../CustomInterface/ARGameSnackInterface.cs | 14 +++++ .../ARGameSnackInterface.cs.meta | 2 + .../HotFix/GameLogic/YL/SnackGame/Snack.cs | 31 ++++++----- .../YL/UI/UIARGameWindow/UIARGameWindow.cs | 21 ++++---- .../YL/UI/UISnackWindow/UISnackWindow.cs | 29 +++++++++-- EintooAR/Assets/Settings.meta | 8 +++ EintooAR/Assets/Settings/Build Profiles.meta | 8 +++ .../Build Profiles/New Windows Profile.asset | 52 +++++++++++++++++++ .../New Windows Profile.asset.meta | 8 +++ .../ProjectSettings/EditorBuildSettings.asset | 3 ++ .../UserSettings/EditorUserSettings.asset | 12 ++--- 14 files changed, 161 insertions(+), 35 deletions(-) create mode 100644 EintooAR/Assets/AssetRaw/Scenes/ARGame.meta rename EintooAR/Assets/{Scenes => AssetRaw/Scenes/ARGame}/Snack.unity (100%) rename EintooAR/Assets/{Scenes => AssetRaw/Scenes/ARGame}/Snack.unity.meta (100%) create mode 100644 EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/Event/CustomInterface/ARGameSnackInterface.cs create mode 100644 EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/Event/CustomInterface/ARGameSnackInterface.cs.meta create mode 100644 EintooAR/Assets/Settings.meta create mode 100644 EintooAR/Assets/Settings/Build Profiles.meta create mode 100644 EintooAR/Assets/Settings/Build Profiles/New Windows Profile.asset create mode 100644 EintooAR/Assets/Settings/Build Profiles/New Windows Profile.asset.meta diff --git a/EintooAR/Assets/AssetRaw/Scenes/ARGame.meta b/EintooAR/Assets/AssetRaw/Scenes/ARGame.meta new file mode 100644 index 00000000..0db1081d --- /dev/null +++ b/EintooAR/Assets/AssetRaw/Scenes/ARGame.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0fa02d898f7e57d4f89aa30111b7b50f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EintooAR/Assets/Scenes/Snack.unity b/EintooAR/Assets/AssetRaw/Scenes/ARGame/Snack.unity similarity index 100% rename from EintooAR/Assets/Scenes/Snack.unity rename to EintooAR/Assets/AssetRaw/Scenes/ARGame/Snack.unity diff --git a/EintooAR/Assets/Scenes/Snack.unity.meta b/EintooAR/Assets/AssetRaw/Scenes/ARGame/Snack.unity.meta similarity index 100% rename from EintooAR/Assets/Scenes/Snack.unity.meta rename to EintooAR/Assets/AssetRaw/Scenes/ARGame/Snack.unity.meta diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/Event/CustomInterface/ARGameSnackInterface.cs b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/Event/CustomInterface/ARGameSnackInterface.cs new file mode 100644 index 00000000..9759ddb7 --- /dev/null +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/Event/CustomInterface/ARGameSnackInterface.cs @@ -0,0 +1,14 @@ +using TEngine; + +namespace GameLogic +{ + [EventInterface(EEventGroup.GroupUI)] + public interface ARGameSnackInterface + { + public void IsStart(bool isStarted); + + public void IsGrow(bool isGrowing); + + public void ControlRotion(float angle); + } +} diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/Event/CustomInterface/ARGameSnackInterface.cs.meta b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/Event/CustomInterface/ARGameSnackInterface.cs.meta new file mode 100644 index 00000000..bd96be59 --- /dev/null +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/Event/CustomInterface/ARGameSnackInterface.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 879c707e916669849b13c71a20459f7e \ No newline at end of file diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/SnackGame/Snack.cs b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/SnackGame/Snack.cs index df861275..f4c8018d 100644 --- a/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/SnackGame/Snack.cs +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/SnackGame/Snack.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using TEngine; using UnityEngine; namespace GameLogic @@ -25,29 +26,29 @@ namespace GameLogic { rb = GetComponent(); - InvokeRepeating("Move", 0.0f, 1f); - - SpawnFood(); + GameEvent.AddEventListener(ARGameSnackInterface_Event.IsStart,IsStart); + + GameEvent.AddEventListener(ARGameSnackInterface_Event.ControlRotion,ControlRotion); } - // Update is called once per frame - void Update() + public void IsStart(bool isStarted) { - if (Input.GetKeyDown(KeyCode.Alpha1)) + if (isStarted) { - RotationCube(90); + InvokeRepeating("Move", 0.0f, 1f); + + SpawnFood(); } - if (Input.GetKeyDown(KeyCode.Alpha2)) + else { - RotationCube(-90); - } - if (Input.GetKeyDown(KeyCode.Alpha3)) - { - Grow(); + CancelInvoke("Move"); + + // 清空食物list + FoodList.Clear(); } } - private void RotationCube(float angle) + public void ControlRotion(float angle) { transform.Rotate(Vector3.up, angle); @@ -87,6 +88,8 @@ namespace GameLogic } BodyList.Add(body.transform); + + GameEvent.Get().IsGrow(true); } private void SpawnFood() diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/UI/UIARGameWindow/UIARGameWindow.cs b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/UI/UIARGameWindow/UIARGameWindow.cs index 969fa1ae..0652966c 100644 --- a/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/UI/UIARGameWindow/UIARGameWindow.cs +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/UI/UIARGameWindow/UIARGameWindow.cs @@ -2,10 +2,7 @@ using Cysharp.Threading.Tasks; using UnityEngine; using UnityEngine.UI; using TEngine; -using static PetResponseScriptableObject; using System.Threading.Tasks; -using System.Xml.Linq; -using VoxelBusters.CoreLibrary; namespace GameLogic { @@ -33,7 +30,7 @@ namespace GameLogic { await UniTask.Yield(); - LoadGameScene(curgamename); + LoadGameScene(this.curgamename); } #endregion @@ -41,12 +38,7 @@ namespace GameLogic { base.RegisterEvent(); - GameEvent.AddEventListener( - "UIARGameInterface", - (gamename) => - { - this.curgamename = gamename; - }); + GameEvent.AddEventListener(UIARGameInterface_Event.GetCurGameName, GetCurGameName); } protected override void OnCreate() @@ -58,6 +50,11 @@ namespace GameLogic RegisterEvent(); } + public void GetCurGameName(string gameName) + { + this.curgamename = gameName; + } + private async void LoadARGameData() { aRGame = GameModule.Resource.LoadAsset(GAME_DATA_PATH); @@ -101,8 +98,12 @@ namespace GameLogic { case "贪吃蛇": GameModule.UI.ShowUI(); + GameModule.Scene.LoadScene("Snack"); GameModule.UI.CloseUI(); break; + default: + Debug.Log("_curgamename为空"); + break; } } diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/UI/UISnackWindow/UISnackWindow.cs b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/UI/UISnackWindow/UISnackWindow.cs index f9a41e89..b810d15c 100644 --- a/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/UI/UISnackWindow/UISnackWindow.cs +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/YL/UI/UISnackWindow/UISnackWindow.cs @@ -2,8 +2,6 @@ using Cysharp.Threading.Tasks; using UnityEngine; using UnityEngine.UI; using TEngine; -using VoxelBusters.CoreLibrary; -using UnityEngine.SocialPlatforms.Impl; namespace GameLogic { @@ -40,7 +38,8 @@ namespace GameLogic m_btnPlay.gameObject.SetActive(false); m_textPlay.gameObject.SetActive(false); - Debug.Log("贪吃蛇游戏开始"); + + GameEvent.Get().IsStart(true); } private async UniTaskVoid OnClickLeftBtn() { @@ -61,15 +60,34 @@ namespace GameLogic base.OnCreate(); score = 0; + RegisterEvent(); + } + + protected override void RegisterEvent() + { + base.RegisterEvent(); + + GameEvent.AddEventListener(ARGameSnackInterface_Event.IsGrow,IsGrow); + } + + public void IsGrow(bool isGrowing) + { + if (isGrowing) + { + CreateScoreWidget(); + } } private void CreateScoreWidget() { - if (score >= 10) + if (score >= 9) { m_textWin.gameObject.SetActive(true); + + GameEvent.Get().IsStart(false); return; } + CreateWidgetByPath(m_goScoreICon.transform, "UISnackWidget"); score++; @@ -77,11 +95,12 @@ namespace GameLogic private void LeftFunc() { - + GameEvent.Get().ControlRotion(-90); } private void RightFunc() { + GameEvent.Get().ControlRotion(90); } } } \ No newline at end of file diff --git a/EintooAR/Assets/Settings.meta b/EintooAR/Assets/Settings.meta new file mode 100644 index 00000000..41d9bfb0 --- /dev/null +++ b/EintooAR/Assets/Settings.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 250ed5a2e8769e140a102a11abade44d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EintooAR/Assets/Settings/Build Profiles.meta b/EintooAR/Assets/Settings/Build Profiles.meta new file mode 100644 index 00000000..3385ed2c --- /dev/null +++ b/EintooAR/Assets/Settings/Build Profiles.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 402b066996251f74faa5002a58a42935 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EintooAR/Assets/Settings/Build Profiles/New Windows Profile.asset b/EintooAR/Assets/Settings/Build Profiles/New Windows Profile.asset new file mode 100644 index 00000000..fa5f4c24 --- /dev/null +++ b/EintooAR/Assets/Settings/Build Profiles/New Windows Profile.asset @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 15003, guid: 0000000000000000e000000000000000, type: 0} + m_Name: New Windows Profile + m_EditorClassIdentifier: + m_AssetVersion: 1 + m_BuildTarget: 19 + m_Subtarget: 2 + m_PlatformId: 4e3c793746204150860bf175a9a41a05 + m_PlatformBuildProfile: + rid: 8495471767982702592 + m_OverrideGlobalSceneList: 0 + m_Scenes: + - m_enabled: 1 + m_path: Assets/Scenes/main.unity + - m_enabled: 1 + m_path: Assets/AssetRaw/Scenes/scene_arTest.unity + m_ScriptingDefines: [] + m_PlayerSettingsYaml: + m_Settings: [] + references: + version: 2 + RefIds: + - rid: 8495471767982702592 + type: {class: WindowsPlatformSettings, ns: UnityEditor.WindowsStandalone, asm: UnityEditor.WindowsStandalone.Extensions} + data: + m_Development: 0 + m_ConnectProfiler: 0 + m_BuildWithDeepProfilingSupport: 0 + m_AllowDebugging: 0 + m_WaitForManagedDebugger: 0 + m_ManagedDebuggerFixedPort: 0 + m_ExplicitNullChecks: 0 + m_ExplicitDivideByZeroChecks: 0 + m_ExplicitArrayBoundsChecks: 0 + m_CompressionType: 0 + m_InstallInBuildFolder: 0 + m_WindowsBuildAndRunDeployTarget: 0 + m_Architecture: 0 + m_CreateSolution: 0 + m_CopyPDBFiles: 0 + m_WindowsDevicePortalAddress: + m_WindowsDevicePortalUsername: diff --git a/EintooAR/Assets/Settings/Build Profiles/New Windows Profile.asset.meta b/EintooAR/Assets/Settings/Build Profiles/New Windows Profile.asset.meta new file mode 100644 index 00000000..1640cd77 --- /dev/null +++ b/EintooAR/Assets/Settings/Build Profiles/New Windows Profile.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5d686ef185f5cd2429fdfb84681d0713 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/EintooAR/ProjectSettings/EditorBuildSettings.asset b/EintooAR/ProjectSettings/EditorBuildSettings.asset index 186d6fe0..1b42d4bd 100644 --- a/EintooAR/ProjectSettings/EditorBuildSettings.asset +++ b/EintooAR/ProjectSettings/EditorBuildSettings.asset @@ -11,6 +11,9 @@ EditorBuildSettings: - enabled: 1 path: Assets/AssetRaw/Scenes/scene_arTest.unity guid: 666dbea7feb88644c8b8ae858ca278ae + - enabled: 1 + path: Assets/AssetRaw/Scenes/ARGame/Snack.unity + guid: 429eee27bf9fcd14d82b7b95f9668fb2 m_configObjects: AR Foundation RemoteARFoundationRemoteLoaderSettings: {fileID: 11400000, guid: f14fc17ac2a466f4e96561ec973674db, type: 2} AR Foundation RemoteARFoundationRemoteSessionRecordsData: {fileID: 11400000, guid: 223d99c2357a28b47aae9876795f4641, type: 2} diff --git a/EintooAR/UserSettings/EditorUserSettings.asset b/EintooAR/UserSettings/EditorUserSettings.asset index d5f7714f..da12a8eb 100644 --- a/EintooAR/UserSettings/EditorUserSettings.asset +++ b/EintooAR/UserSettings/EditorUserSettings.asset @@ -21,20 +21,20 @@ EditorUserSettings: value: 0705000004570c59555b097112770d40144f41722f7d7e652f7c1f66e6b5646a flags: 0 RecentlyUsedSceneGuid-4: - value: 57030d0300505b0c0f08552413270e44124f4a287b2a7f652b704b65bae6366a - flags: 0 - RecentlyUsedSceneGuid-5: value: 0606035f5c515b0d0e0a5a7213265d44414e1d2c2f782734782b4432b3e66d3b flags: 0 - RecentlyUsedSceneGuid-6: + RecentlyUsedSceneGuid-5: value: 5604515e00500c0c5b5b582116765a44414f1e7c757025357b2d1b6bbab8373d flags: 0 - RecentlyUsedSceneGuid-7: + RecentlyUsedSceneGuid-6: value: 0003505352045a0855595b27122759444015487f2f7177327f2a4461b4b76469 flags: 0 - RecentlyUsedSceneGuid-8: + RecentlyUsedSceneGuid-7: value: 07045553540d0c025c590a2113250c44434e1b292d7971627e284b6be1b9616b flags: 0 + RecentlyUsedSceneGuid-8: + value: 57030d0300505b0c0f08552413270e44124f4a287b2a7f652b704b65bae6366a + flags: 0 RecentlyUsedSceneGuid-9: value: 02500105010d500359565b7616225a44474e4c7d7b2c27337b7f4d31b1b8666f flags: 0