From 2d123da297a0b409485f0cdccb93ea2a613306b2 Mon Sep 17 00:00:00 2001 From: NTG_Lenovo Date: Mon, 14 Jul 2025 15:38:22 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=9E=84=20=ED=94=8C=EB=A1=9C?= =?UTF-8?q?=EC=9A=B0=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_DDD/_Scripts/GameFlow/GameFlowManager.cs | 9 ++----- .../_Scripts/GameFlow/GameFlowReadyHandler.cs | 10 ++++++++ .../GameFlow/GameFlowReadyHandler.cs.meta | 2 ++ .../CreateRestaurantPlayer.cs | 24 +++++++------------ 4 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs create mode 100644 Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs.meta diff --git a/Assets/_DDD/_Scripts/GameFlow/GameFlowManager.cs b/Assets/_DDD/_Scripts/GameFlow/GameFlowManager.cs index a60d6aaf6..109080e86 100644 --- a/Assets/_DDD/_Scripts/GameFlow/GameFlowManager.cs +++ b/Assets/_DDD/_Scripts/GameFlow/GameFlowManager.cs @@ -31,7 +31,6 @@ public async void PostInit() { if (IsGameStarted() == false) { - await Task.Delay(3000); await ChangeFlow(GameFlowState.ReadyForRestaurant); } } @@ -84,13 +83,9 @@ private async Task ReadyNewFlow(GameFlowState newFlowState) { var obj = await AssetManager.LoadAsset(assetRef); - if (obj is GameObject prefab) + if (obj is GameFlowReadyHandler handler) { - Instantiate(prefab); - } - else - { - Debug.LogWarning($"[ReadyNewFlow] Not a GameObject: {assetRef.RuntimeKey}"); + await handler.OnReadyNewFlow(newFlowState); } } } diff --git a/Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs b/Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs new file mode 100644 index 000000000..3f79cd3b7 --- /dev/null +++ b/Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; +using UnityEngine; + +namespace DDD +{ + public abstract class GameFlowReadyHandler : ScriptableObject + { + public abstract Task OnReadyNewFlow(GameFlowState newFlowState); + } +} \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs.meta b/Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs.meta new file mode 100644 index 000000000..af1144a50 --- /dev/null +++ b/Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: b072e73316b7d534b8ec18ffa0b8bfa2 \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/CreateRestaurantPlayer.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/CreateRestaurantPlayer.cs index e1ee7e7bc..81e29ce4e 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/CreateRestaurantPlayer.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/CreateRestaurantPlayer.cs @@ -1,26 +1,20 @@ -using System; +using System.Threading.Tasks; using UnityEngine; namespace DDD { - public class CreateRestaurantPlayer : MonoBehaviour + [CreateAssetMenu(fileName = "CreateRestaurantPlayer", menuName = "GameFlow/CreateRestaurantPlayer")] + public class CreateRestaurantPlayer : GameFlowReadyHandler { [SerializeField] private Vector3 _spawnPosition; - - private async void Start() + + public override async Task OnReadyNewFlow(GameFlowState newFlowState) { - try - { - var playerPrefab = await AssetManager.LoadAsset(CommonConstants.RestaurantPlayer); - var player = Instantiate(playerPrefab, _spawnPosition, playerPrefab.transform.rotation); - player.name = CommonConstants.RestaurantPlayer; - CameraManager.Instance.GetCameraGameObject(CameraType.RestaurantBaseCamera).SetFollowAndLookAtTarget(player.transform); - } - catch (Exception e) - { - Debug.LogError($"Create player failed\n{e.Message}"); - } + var playerPrefab = await AssetManager.LoadAsset(CommonConstants.RestaurantPlayer); + var player = Instantiate(playerPrefab, _spawnPosition, playerPrefab.transform.rotation); + player.name = CommonConstants.RestaurantPlayer; + CameraManager.Instance.GetCameraGameObject(CameraType.RestaurantBaseCamera).SetFollowAndLookAtTarget(player.transform); } } } \ No newline at end of file