게임 플로우 로직 변경
This commit is contained in:
parent
c66c9a201e
commit
2d123da297
@ -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<UnityEngine.Object>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs
Normal file
10
Assets/_DDD/_Scripts/GameFlow/GameFlowReadyHandler.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DDD
|
||||
{
|
||||
public abstract class GameFlowReadyHandler : ScriptableObject
|
||||
{
|
||||
public abstract Task OnReadyNewFlow(GameFlowState newFlowState);
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b072e73316b7d534b8ec18ffa0b8bfa2
|
@ -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<GameObject>(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<GameObject>(CommonConstants.RestaurantPlayer);
|
||||
var player = Instantiate(playerPrefab, _spawnPosition, playerPrefab.transform.rotation);
|
||||
player.name = CommonConstants.RestaurantPlayer;
|
||||
CameraManager.Instance.GetCameraGameObject(CameraType.RestaurantBaseCamera).SetFollowAndLookAtTarget(player.transform);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user