Merge pull request 'feature/restaurant_state' (#11) from feature/restaurant_state into develop

Reviewed-on: #11
This commit is contained in:
iwnc2020 2025-07-21 03:01:39 +00:00
commit 944a83a896
21 changed files with 180 additions and 119 deletions

View File

@ -0,0 +1,47 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4494202516554020285
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 19655205931395604}
- component: {fileID: 8500549904376788358}
m_Layer: 0
m_Name: RestaurantController
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &19655205931395604
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4494202516554020285}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.0732, y: 0, z: 18.71973}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8500549904376788358
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4494202516554020285}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e51cd804b1464fb282ba2729ddffae69, type: 3}
m_Name:
m_EditorClassIdentifier:
_persistent: 0

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d81cf4649bf54485a8b0da7a235f3817
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -56,71 +56,7 @@ MonoBehaviour:
Data: 1
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data:
- Name: $k
Entry: 3
Data: 1
- Name: $v
Entry: 7
Data: 3|System.Collections.Generic.List`1[[UnityEngine.AddressableAssets.AssetReference,
Unity.Addressables]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 4|UnityEngine.AddressableAssets.AssetReference, Unity.Addressables
- Name: m_AssetGUID
Entry: 1
Data: 47e757b9a170ab649af14c4d7b80ac41
- Name: m_SubObjectName
Entry: 6
Data:
- Name: m_SubObjectType
Entry: 6
Data:
- Name: m_SubObjectGUID
Entry: 1
Data:
- Name: m_EditorAssetChanged
Entry: 5
Data: true
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 5|UnityEngine.AddressableAssets.AssetReference, Unity.Addressables
- Name: m_AssetGUID
Entry: 1
Data: 0912c3de85fd61848a41575faa2794ed
- Name: m_SubObjectName
Entry: 6
Data:
- Name: m_SubObjectType
Entry: 6
Data:
- Name: m_SubObjectGUID
Entry: 1
Data:
- Name: m_EditorAssetChanged
Entry: 5
Data: true
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
Data: 0
- Name:
Entry: 13
Data:

View File

@ -17,8 +17,8 @@ public enum GameFlowState
public class GameFlowManager : Singleton<GameFlowManager>, IManager
{
public GameFlowDataSo GameFlowDataSo;
public GameFlowAssetsSo GameFlowAssetsSo;
public GameFlowSceneMappingSo GameFlowSceneMappingSo;
public List<IGameFlowHandler> FlowHandlers = new List<IGameFlowHandler>();
public void Init()
{
@ -69,27 +69,6 @@ private async Task ReadyNewFlow(GameFlowState newFlowState)
{
GameFlowDataSo.CurrentGameState = newFlowState;
if (GameFlowAssetsSo.FlowItems.TryGetValue(newFlowState, out var stringKeys))
{
foreach (var key in stringKeys)
{
await AssetManager.LoadAsset<UnityEngine.Object>(key);
}
}
if (GameFlowAssetsSo.FlowAssets.TryGetValue(newFlowState, out var assetRefs))
{
foreach (var assetRef in assetRefs)
{
var obj = await AssetManager.LoadAsset<UnityEngine.Object>(assetRef);
if (obj is GameFlowReadyHandler handler)
{
await handler.OnReadyNewFlow(newFlowState);
}
}
}
OpenFlowScene(newFlowState);
StartFlow();

View File

@ -3,7 +3,7 @@
namespace DDD
{
public abstract class GameFlowReadyHandler : ScriptableObject
public abstract class GameFlowTask : ScriptableObject
{
public abstract Task OnReadyNewFlow(GameFlowState newFlowState);
}

View File

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace DDD
{
public interface IGameFlowHandler
{
public Task OnReadyNewFlow(GameFlowState newFlowState);
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 57907d840def417997b2511445a85da5
timeCreated: 1752732011

View File

@ -4,7 +4,7 @@
namespace DDD
{
[CreateAssetMenu(fileName = "CreateRestaurantPlayer", menuName = "GameFlow/CreateRestaurantPlayer")]
public class CreateRestaurantPlayer : GameFlowReadyHandler
public class CreateRestaurantPlayer : GameFlowTask
{
[SerializeField]
private Vector3 _spawnPosition;

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f3de96aa3cc24115ac3b7531effd5040
timeCreated: 1752730369

View File

@ -0,0 +1,76 @@
using System.Threading.Tasks;
using UnityEngine;
namespace DDD
{
public class RestaurantController : Singleton<RestaurantController>, IManager, IGameFlowHandler
{
private RestaurantEnvironmentState _restaurantEnvironmentState;
public RestaurantEnvironmentState RestaurantEnvironmentState => _restaurantEnvironmentState;
// TODO : GameManager에 등록되게 So에 추가해주세요.
public void Init()
{
LoadOrCreateRestaurantState();
RegisterFlowHandler();
}
public void PostInit()
{
GenerateDummyEnvironmentProps();// XXX : DUMMY! REMOVE THIS
}
private void RegisterFlowHandler()
{
GameFlowManager.Instance.FlowHandlers.Add(this);
}
private void LoadOrCreateRestaurantState()
{
// TODO : Load states from saved files. if none, create them.
_restaurantEnvironmentState = new RestaurantEnvironmentState();
}
private void GenerateDummyEnvironmentProps()
{
// Make dummy placement data
foreach (EnvironmentData prop in DataManager.Instance.EnvironmentDataSo.GetDataList())
{
if (prop.EnvironmentType != EnvironmentType.Prop)
{
continue;
}
for (int i = 0; i < 10; i++)
{
// Make random position
Vector2 randomPos = new Vector2(
Random.Range(-10f, 10f),
Random.Range(10f, 20f)
);
RestaurantEnvironmentData randomPropData = new RestaurantEnvironmentData();
randomPropData.Position = randomPos;
randomPropData.Id = prop.Id;
_restaurantEnvironmentState.RestaurantEnvironmentProps.Add(randomPropData);
}
}
}
public Task OnReadyNewFlow(GameFlowState newFlowState)
{
if (newFlowState == GameFlowState.ReadyForRestaurant)
{
CreateRestaurantPlayer createRestaurantPlayerJob = new CreateRestaurantPlayer();
CreateEnvironment createEnvironmentJob = new CreateEnvironment();
var playerHandle = createRestaurantPlayerJob.OnReadyNewFlow(newFlowState);
var propHandle = createEnvironmentJob.OnReadyNewFlow(newFlowState);
// Combine handles and return it
return Task.WhenAll(playerHandle, propHandle);
}
return Task.CompletedTask;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e51cd804b1464fb282ba2729ddffae69
timeCreated: 1752730386

View File

@ -4,34 +4,18 @@
namespace DDD
{
[CreateAssetMenu(fileName = "CreateEnvironment", menuName = "GameFlow/CreateEnvironment")]
public class CreateEnvironment : GameFlowReadyHandler
public class CreateEnvironment : GameFlowTask
{
public override async Task OnReadyNewFlow(GameFlowState newFlowState)
{
var baseRestaurantEnvironmentPrefab = await AssetManager.LoadAsset<GameObject>(CommonConstants.BaseRestaurantEnvironment);
for (int i = 0; i < 10; i++)
var props = RestaurantController.Instance.RestaurantEnvironmentState.RestaurantEnvironmentProps;
foreach (var prop in props)
{
var restaurantEnvironment = Instantiate(baseRestaurantEnvironmentPrefab).GetComponent<RestaurantEnvironment>();
restaurantEnvironment.Initialize("Item_Environment_001");
}
for (int i = 0; i < 10; i++)
{
var restaurantEnvironment = Instantiate(baseRestaurantEnvironmentPrefab).GetComponent<RestaurantEnvironment>();
restaurantEnvironment.Initialize("Item_Environment_002");
}
for (int i = 0; i < 10; i++)
{
var restaurantEnvironment = Instantiate(baseRestaurantEnvironmentPrefab).GetComponent<RestaurantEnvironment>();
restaurantEnvironment.Initialize("Item_Environment_003");
}
for (int i = 0; i < 10; i++)
{
var restaurantEnvironment = Instantiate(baseRestaurantEnvironmentPrefab).GetComponent<RestaurantEnvironment>();
restaurantEnvironment.Initialize("Item_Environment_004");
var restaurantEnvironment =
Instantiate(baseRestaurantEnvironmentPrefab).GetComponent<RestaurantEnvironment>();
restaurantEnvironment.Initialize(prop);
}
}
}

View File

@ -12,11 +12,11 @@ public class RestaurantEnvironment : MonoBehaviour
private Transform _visualLook;
private Renderer _renderer;
public async void Initialize(string id)
public async void Initialize(RestaurantEnvironmentData data)
{
await DataManager.Instance.WaitUntilInitialized();
EnvironmentData environmentData = DataManager.Instance.EnvironmentDataSo.GetDataById(id);
EnvironmentData environmentData = DataManager.Instance.EnvironmentDataSo.GetDataById(data.Id);
_collider = GetComponent<Collider>();
_visualLook = transform.Find(CommonConstants.VisualLook);
@ -48,12 +48,7 @@ public async void Initialize(string id)
_collider.isTrigger = environmentData.IsTrigger == 1;
Vector2 randomPos = new Vector2(
Random.Range(-10f, 10f),
Random.Range(10f, 20f)
);
transform.position = new Vector3(randomPos.x, 0f, randomPos.y);
transform.position = new Vector3(data.Position.x, 0f, data.Position.y);
transform.localScale = Vector3.one * environmentData.Size;
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d3f6e4fcc2934f36970e3a1077fb3c70
timeCreated: 1752729763

View File

@ -0,0 +1,13 @@
using System.Collections.Generic;
using UnityEngine;
namespace DDD
{
// [CreateAssetMenu(fileName = "FILENAME", menuName = "MENUNAME", order = 0)]
public class RestaurantEnvironmentState : ScriptableObject
{
// TODO : Public???
public List<RestaurantEnvironmentData> RestaurantEnvironmentProps = new List<RestaurantEnvironmentData>();
public List<RestaurantEnvironmentData> RestaurantEnvironmentObjects = new List<RestaurantEnvironmentData>();
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0c87c6773ca54d81ab1d8c2e218081c4
timeCreated: 1752729814