camera_system #5
@ -31,7 +31,6 @@ public async void PostInit()
|
|||||||
{
|
{
|
||||||
if (IsGameStarted() == false)
|
if (IsGameStarted() == false)
|
||||||
{
|
{
|
||||||
await Task.Delay(3000);
|
|
||||||
await ChangeFlow(GameFlowState.ReadyForRestaurant);
|
await ChangeFlow(GameFlowState.ReadyForRestaurant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,13 +83,9 @@ private async Task ReadyNewFlow(GameFlowState newFlowState)
|
|||||||
{
|
{
|
||||||
var obj = await AssetManager.LoadAsset<UnityEngine.Object>(assetRef);
|
var obj = await AssetManager.LoadAsset<UnityEngine.Object>(assetRef);
|
||||||
|
|
||||||
if (obj is GameObject prefab)
|
if (obj is GameFlowReadyHandler handler)
|
||||||
{
|
{
|
||||||
Instantiate(prefab);
|
await handler.OnReadyNewFlow(newFlowState);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"[ReadyNewFlow] Not a GameObject: {assetRef.RuntimeKey}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DDD
|
namespace DDD
|
||||||
{
|
{
|
||||||
public class CreateRestaurantPlayer : MonoBehaviour
|
[CreateAssetMenu(fileName = "CreateRestaurantPlayer", menuName = "GameFlow/CreateRestaurantPlayer")]
|
||||||
|
public class CreateRestaurantPlayer : GameFlowReadyHandler
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Vector3 _spawnPosition;
|
private Vector3 _spawnPosition;
|
||||||
|
|
||||||
private async void Start()
|
public override async Task OnReadyNewFlow(GameFlowState newFlowState)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var playerPrefab = await AssetManager.LoadAsset<GameObject>(CommonConstants.RestaurantPlayer);
|
var playerPrefab = await AssetManager.LoadAsset<GameObject>(CommonConstants.RestaurantPlayer);
|
||||||
var player = Instantiate(playerPrefab, _spawnPosition, playerPrefab.transform.rotation);
|
var player = Instantiate(playerPrefab, _spawnPosition, playerPrefab.transform.rotation);
|
||||||
player.name = CommonConstants.RestaurantPlayer;
|
player.name = CommonConstants.RestaurantPlayer;
|
||||||
CameraManager.Instance.GetCameraGameObject(CameraType.RestaurantBaseCamera).SetFollowAndLookAtTarget(player.transform);
|
CameraManager.Instance.GetCameraGameObject(CameraType.RestaurantBaseCamera).SetFollowAndLookAtTarget(player.transform);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError($"Create player failed\n{e.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user