From 186dec2175c15f7ce4e79f00bb94a174ea467a1e Mon Sep 17 00:00:00 2001 From: ujisuke <86547644+ujisuke@users.noreply.github.com> Date: Fri, 30 Aug 2024 00:33:07 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Player=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=A4?= =?UTF-8?q?=E3=81=8F=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/App/Scenes/SampleScene.unity | 300 +++++++++++++++++- .../App/Scripts/Battle/BattleLifetimeScope.cs | 2 + Assets/App/Scripts/Battle/Data/Player.cs | 16 + Assets/App/Scripts/Battle/Data/Player.cs.meta | 11 + .../Datastores/BattlePlayerDatastores.cs | 55 ++++ .../Datastores/BattlePlayerDatastores.cs.meta | 11 + .../Datastores/IBattlePlayerDatastore.cs | 14 + .../Datastores/IBattlePlayerDatastore.cs.meta | 11 + .../UseCases/IBattlePlayerUseCase.cs | 7 + .../UseCases/IBattlePlayerUseCase.cs.meta | 11 + .../Battle/Usecases/BattlePlayerUsecase.cs | 28 ++ .../Usecases/BattlePlayerUsecase.cs.meta | 11 + .../Data/MasterData/PlayerMasterData.asset | 22 ++ .../MasterData/PlayerMasterData.asset.meta | 8 + .../Data/MasterData/PlayerMasterData.cs | 29 ++ .../Data/MasterData/PlayerMasterData.cs.meta | 11 + .../MasterData/PlayerMasterDataBase.asset | 15 + .../PlayerMasterDataBase.asset.meta | 8 + .../Data/MasterData/PlayerMasterDataBase.cs | 12 + .../MasterData/PlayerMasterDataBase.cs.meta | 11 + .../Debug/Battle/BattleDebugLifetimeScope.cs | 3 + .../Presenters/IBattleDebugPlayerPresenter.cs | 10 + .../IBattleDebugPlayerPresenter.cs.meta | 11 + .../Presenters/BattleDebugPlayerPresenter.cs | 31 ++ .../BattleDebugPlayerPresenter.cs.meta | 11 + .../UseCases/BattleDebugPlayerUseCase.cs | 39 +++ .../UseCases/BattleDebugPlayerUseCase.cs.meta | 11 + 27 files changed, 707 insertions(+), 2 deletions(-) create mode 100644 Assets/App/Scripts/Battle/Data/Player.cs create mode 100644 Assets/App/Scripts/Battle/Data/Player.cs.meta create mode 100644 Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs create mode 100644 Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs.meta create mode 100644 Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs create mode 100644 Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs.meta create mode 100644 Assets/App/Scripts/Battle/Interfaces/UseCases/IBattlePlayerUseCase.cs create mode 100644 Assets/App/Scripts/Battle/Interfaces/UseCases/IBattlePlayerUseCase.cs.meta create mode 100644 Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs create mode 100644 Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs.meta create mode 100644 Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.asset create mode 100644 Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.asset.meta create mode 100644 Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.cs create mode 100644 Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.cs.meta create mode 100644 Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.asset create mode 100644 Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.asset.meta create mode 100644 Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.cs create mode 100644 Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.cs.meta create mode 100644 Assets/App/Scripts/Debug/Battle/Interfaces/Presenters/IBattleDebugPlayerPresenter.cs create mode 100644 Assets/App/Scripts/Debug/Battle/Interfaces/Presenters/IBattleDebugPlayerPresenter.cs.meta create mode 100644 Assets/App/Scripts/Debug/Battle/Presenters/BattleDebugPlayerPresenter.cs create mode 100644 Assets/App/Scripts/Debug/Battle/Presenters/BattleDebugPlayerPresenter.cs.meta create mode 100644 Assets/App/Scripts/Debug/Battle/UseCases/BattleDebugPlayerUseCase.cs create mode 100644 Assets/App/Scripts/Debug/Battle/UseCases/BattleDebugPlayerUseCase.cs.meta diff --git a/Assets/App/Scenes/SampleScene.unity b/Assets/App/Scenes/SampleScene.unity index 54f199e..aa82587 100644 --- a/Assets/App/Scenes/SampleScene.unity +++ b/Assets/App/Scenes/SampleScene.unity @@ -167,6 +167,127 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &344372761 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 344372762} + - component: {fileID: 344372765} + - component: {fileID: 344372764} + - component: {fileID: 344372763} + m_Layer: 5 + m_Name: GeneratePlayerButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &344372762 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 344372761} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1267245699} + m_Father: {fileID: 568042970} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: -40} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &344372763 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 344372761} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 344372764} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &344372764 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 344372761} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &344372765 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 344372761} + m_CullTransparentMesh: 1 --- !u!1 &404842156 GameObject: m_ObjectHideFlags: 0 @@ -180,7 +301,7 @@ GameObject: - component: {fileID: 404842159} - component: {fileID: 404842158} m_Layer: 5 - m_Name: GenerateButton + m_Name: GenerateEnemyButton m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -197,7 +318,8 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 1083513898} m_Father: {fileID: 568042970} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} @@ -708,6 +830,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 404842157} + - {fileID: 344372762} - {fileID: 842995929} - {fileID: 416316748} - {fileID: 1110636000} @@ -1008,6 +1131,7 @@ MonoBehaviour: autoRun: 1 autoInjectGameObjects: [] _BattleDebugEnemyPresenter: {fileID: 2048206442} + _BattleDebugPlayerPresenter: {fileID: 2048206444} _BattleDebugStatePresenter: {fileID: 2048206443} --- !u!1 &842995928 GameObject: @@ -1130,6 +1254,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 842995928} m_CullTransparentMesh: 1 +--- !u!1 &1083513897 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1083513898} + - component: {fileID: 1083513900} + - component: {fileID: 1083513899} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1083513898 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1083513897} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.9999506, y: 0.9999506, z: 0.9999506} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 404842157} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 150, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1083513899 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1083513897} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 1 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: GenerateEnemy +--- !u!222 &1083513900 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1083513897} + m_CullTransparentMesh: 1 --- !u!1 &1110635999 GameObject: m_ObjectHideFlags: 0 @@ -1330,6 +1533,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1222253567} m_CullTransparentMesh: 1 +--- !u!1 &1267245698 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1267245699} + - component: {fileID: 1267245701} + - component: {fileID: 1267245700} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1267245699 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1267245698} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.9999506, y: 0.9999506, z: 0.9999506} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 344372762} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 150, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1267245700 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1267245698} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 1 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: GeneratePlayer +--- !u!222 &1267245701 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1267245698} + m_CullTransparentMesh: 1 --- !u!1 &1387411687 GameObject: m_ObjectHideFlags: 0 @@ -1588,6 +1870,7 @@ GameObject: m_Component: - component: {fileID: 2048206441} - component: {fileID: 2048206442} + - component: {fileID: 2048206444} - component: {fileID: 2048206443} m_Layer: 0 m_Name: BattleDebugPresenter @@ -1640,6 +1923,19 @@ MonoBehaviour: _cancelStateButton: {fileID: 416316749} _increaseStateIndexButton: {fileID: 1110636001} _decreaseStateIndexButton: {fileID: 1387411689} +--- !u!114 &2048206444 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2048206440} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1b940b6e2eb4947408843bf72f095cd3, type: 3} + m_Name: + m_EditorClassIdentifier: + _generatePlayerButton: {fileID: 344372763} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 diff --git a/Assets/App/Scripts/Battle/BattleLifetimeScope.cs b/Assets/App/Scripts/Battle/BattleLifetimeScope.cs index 3f60f95..3dfd07f 100644 --- a/Assets/App/Scripts/Battle/BattleLifetimeScope.cs +++ b/Assets/App/Scripts/Battle/BattleLifetimeScope.cs @@ -13,6 +13,8 @@ protected override void Configure(IContainerBuilder builder) { builder.Register(Lifetime.Singleton).AsImplementedInterfaces(); builder.Register(Lifetime.Singleton).AsImplementedInterfaces(); + builder.Register(Lifetime.Singleton).AsImplementedInterfaces(); + builder.Register(Lifetime.Singleton).AsImplementedInterfaces(); builder.Register(Lifetime.Singleton).AsImplementedInterfaces(); builder.Register(Lifetime.Singleton).AsImplementedInterfaces(); } diff --git a/Assets/App/Scripts/Battle/Data/Player.cs b/Assets/App/Scripts/Battle/Data/Player.cs new file mode 100644 index 0000000..f400cab --- /dev/null +++ b/Assets/App/Scripts/Battle/Data/Player.cs @@ -0,0 +1,16 @@ +using App.Common.Data; + +namespace App.Battle.Data +{ + public class Player + { + public string Id { get; } + public CharacterParameter characterParameter { get; } + + public Player(string id, CharacterParameter characterParameter) + { + Id = id; + this.characterParameter = characterParameter; + } + } +} \ No newline at end of file diff --git a/Assets/App/Scripts/Battle/Data/Player.cs.meta b/Assets/App/Scripts/Battle/Data/Player.cs.meta new file mode 100644 index 0000000..f983ec8 --- /dev/null +++ b/Assets/App/Scripts/Battle/Data/Player.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a501b8169a3ab5e40925c2bfadea18b1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs b/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs new file mode 100644 index 0000000..85e06a6 --- /dev/null +++ b/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs @@ -0,0 +1,55 @@ +using App.Battle.Data; +using App.Common.Data; +using App.Battle.Interfaces.Datastores; +using System; +using System.Linq; +using System.Collections.Generic; +using UniRx; + +namespace App.Battle.Datastores +{ + public class BattlePlayerDatastore : IBattlePlayerDatastore, IDisposable + { + private Dictionary _players = new(); + public IEnumerable Players => _players.Values.ToArray(); + + public void AddPlayer(string id, CharacterParameter characterParameter) + { + if(characterParameter == null) + { + throw new NullReferenceException($"{nameof(CharacterParameter)} is null"); + } + + var player = new Player(id, characterParameter); + UnityEngine.Debug.Log($"{player} added"); + + _players.Add(id, player); + } + + public void RemovePlayer(string id) + { + if(!_players.ContainsKey(id)) + { + return; + } + _players.Remove(id); + } + + public Player GetPlayerBy(string id) + { + if(!_players.ContainsKey(id)) + { + return null; + } + + var player = _players[id]; + UnityEngine.Debug.Log($"{player} got"); + return player; + } + + public void Dispose() + { + _players.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs.meta b/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs.meta new file mode 100644 index 0000000..7908aa3 --- /dev/null +++ b/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fd80d18e4e0eb2c4eaafd5f06410e0c5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs b/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs new file mode 100644 index 0000000..cccc092 --- /dev/null +++ b/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs @@ -0,0 +1,14 @@ +using App.Battle.Data; +using App.Common.Data; +using System.Collections.Generic; + +namespace App.Battle.Interfaces.Datastores +{ + public interface IBattlePlayerDatastore + { + IEnumerable Players { get; } + void AddPlayer(string id, CharacterParameter characterParameter); + void RemovePlayer(string id); + Player GetPlayerBy(string id); + } +} \ No newline at end of file diff --git a/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs.meta b/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs.meta new file mode 100644 index 0000000..c5af1bb --- /dev/null +++ b/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9a6cda6c11cf827418547b8fcbc61950 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Battle/Interfaces/UseCases/IBattlePlayerUseCase.cs b/Assets/App/Scripts/Battle/Interfaces/UseCases/IBattlePlayerUseCase.cs new file mode 100644 index 0000000..d003a74 --- /dev/null +++ b/Assets/App/Scripts/Battle/Interfaces/UseCases/IBattlePlayerUseCase.cs @@ -0,0 +1,7 @@ +namespace App.Battle.Interfaces.UseCases +{ + public interface IBattlePlayerUseCase + { + void GeneratePlayer(); + } +} diff --git a/Assets/App/Scripts/Battle/Interfaces/UseCases/IBattlePlayerUseCase.cs.meta b/Assets/App/Scripts/Battle/Interfaces/UseCases/IBattlePlayerUseCase.cs.meta new file mode 100644 index 0000000..6beafb5 --- /dev/null +++ b/Assets/App/Scripts/Battle/Interfaces/UseCases/IBattlePlayerUseCase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4c4cbd3f8b7bb5d44a070b9a69bb2e42 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs b/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs new file mode 100644 index 0000000..a8b0c62 --- /dev/null +++ b/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs @@ -0,0 +1,28 @@ +using App.Common.Data; +using App.Battle.Interfaces.UseCases; +using App.Battle.Interfaces.Datastores; +using App.Battle.Datastores; +using VContainer; +using VContainer.Unity; + +namespace App.Battle.UseCases +{ + public class BattlePlayerUseCase : IBattlePlayerUseCase + { + private readonly IBattlePlayerDatastore _BattlePlayerDatastore; + + [Inject] + public BattlePlayerUseCase( + IBattlePlayerDatastore battlePlayerDatastore + ) + { + _BattlePlayerDatastore = battlePlayerDatastore; + } + + public void GeneratePlayer() + { + _BattlePlayerDatastore.AddPlayer("1", new CharacterParameter()); + UnityEngine.Debug.Log($"{"1"} generated"); + } + } +} diff --git a/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs.meta b/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs.meta new file mode 100644 index 0000000..471a8d4 --- /dev/null +++ b/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: efd40c4b1879b9a42ab34e5de40b03e1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.asset b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.asset new file mode 100644 index 0000000..113b0a9 --- /dev/null +++ b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.asset @@ -0,0 +1,22 @@ +%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: 11500000, guid: d979c6c5b2c17d94bac07e872d132b59, type: 3} + m_Name: PlayerMasterData + m_EditorClassIdentifier: + k__BackingField: 0 + k__BackingField: + k__BackingField: 0 + k__BackingField: 0 + k__BackingField: 0 + k__BackingField: 0 + k__BackingField: 0 + k__BackingField: 0 diff --git a/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.asset.meta b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.asset.meta new file mode 100644 index 0000000..f6bea60 --- /dev/null +++ b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 628455a84a73c29438d8aec21b395011 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.cs b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.cs new file mode 100644 index 0000000..1cc80a6 --- /dev/null +++ b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using App.Common.Data; +using System; +using Unity.VisualScripting; + + +namespace App.Common.Data.MasterData +{ + [CreateAssetMenu(fileName = "PlayerMasterData", menuName = "MasterData/PlayerMasterData")] + public class PlayerMasterData : ScriptableObject, ISerializationCallbackReceiver + { + [field: SerializeField] public int Id { get; private set; } + [field: SerializeField] public string Name { get; private set; } + [field: SerializeField] public int Hp { get; private set; } + [field: SerializeField] public int Mp { get; private set; } + [field: SerializeField] public int Atk { get; private set; } + [field: SerializeField] public int Mat { get; private set; } + [field: SerializeField] public int Def { get; private set; } + [field: SerializeField] public int Mde { get; private set; } + + [field: NonSerialized] public CharacterParameter CharacterParameter { get; private set; } + + public void OnBeforeSerialize() { } + public void OnAfterDeserialize() + { + CharacterParameter = new CharacterParameter(Name, Hp, Mp, Atk, Mat, Def, Mde); + } + } +} diff --git a/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.cs.meta b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.cs.meta new file mode 100644 index 0000000..3aa12e4 --- /dev/null +++ b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d979c6c5b2c17d94bac07e872d132b59 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.asset b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.asset new file mode 100644 index 0000000..3d60702 --- /dev/null +++ b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.asset @@ -0,0 +1,15 @@ +%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: 11500000, guid: 29dd81de54614f04fb4e1a12853336c0, type: 3} + m_Name: PlayerMasterDataBase + m_EditorClassIdentifier: + k__BackingField: [] diff --git a/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.asset.meta b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.asset.meta new file mode 100644 index 0000000..82c0498 --- /dev/null +++ b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 57924289f99d5d447a43e56100c25335 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.cs b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.cs new file mode 100644 index 0000000..bb62b70 --- /dev/null +++ b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.cs @@ -0,0 +1,12 @@ +using UnityEngine; +using App.Common.Data.MasterData; + +namespace App.Common.Data.MasterData +{ + [CreateAssetMenu(fileName = "PlayerMasterDataBase", menuName = "MasterData/PlayerMasterDataBase")] + + public class PlayerMasterDataBase : ScriptableObject + { + [field: SerializeField] public PlayerMasterData[] PlayerMasterData { get; private set; } + } +} diff --git a/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.cs.meta b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.cs.meta new file mode 100644 index 0000000..d50ccd9 --- /dev/null +++ b/Assets/App/Scripts/Common/Data/MasterData/PlayerMasterDataBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29dd81de54614f04fb4e1a12853336c0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Debug/Battle/BattleDebugLifetimeScope.cs b/Assets/App/Scripts/Debug/Battle/BattleDebugLifetimeScope.cs index 93f85cb..e4526c0 100644 --- a/Assets/App/Scripts/Debug/Battle/BattleDebugLifetimeScope.cs +++ b/Assets/App/Scripts/Debug/Battle/BattleDebugLifetimeScope.cs @@ -9,12 +9,15 @@ namespace App.Debug.Battle public class BattleDebugLifetimeScope : LifetimeScope { [SerializeField] private BattleDebugEnemyPresenter _BattleDebugEnemyPresenter; + [SerializeField] private BattleDebugPlayerPresenter _BattleDebugPlayerPresenter; [SerializeField] private BattleDebugStatePresenter _BattleDebugStatePresenter; protected override void Configure(IContainerBuilder builder) { builder.RegisterComponent(_BattleDebugEnemyPresenter).AsImplementedInterfaces(); builder.RegisterEntryPoint(); + builder.RegisterComponent(_BattleDebugPlayerPresenter).AsImplementedInterfaces(); + builder.RegisterEntryPoint(); builder.RegisterComponent(_BattleDebugStatePresenter).AsImplementedInterfaces(); builder.RegisterEntryPoint(); } diff --git a/Assets/App/Scripts/Debug/Battle/Interfaces/Presenters/IBattleDebugPlayerPresenter.cs b/Assets/App/Scripts/Debug/Battle/Interfaces/Presenters/IBattleDebugPlayerPresenter.cs new file mode 100644 index 0000000..a67189d --- /dev/null +++ b/Assets/App/Scripts/Debug/Battle/Interfaces/Presenters/IBattleDebugPlayerPresenter.cs @@ -0,0 +1,10 @@ +using System; +using UniRx; + +namespace App.Debug.Battle.Interfaces.Presenters +{ + public interface IBattleDebugPlayerPresenter + { + IObservable OnGeneratePlayer { get; } + } +} diff --git a/Assets/App/Scripts/Debug/Battle/Interfaces/Presenters/IBattleDebugPlayerPresenter.cs.meta b/Assets/App/Scripts/Debug/Battle/Interfaces/Presenters/IBattleDebugPlayerPresenter.cs.meta new file mode 100644 index 0000000..774fa5a --- /dev/null +++ b/Assets/App/Scripts/Debug/Battle/Interfaces/Presenters/IBattleDebugPlayerPresenter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c493951fc42bf1d428d16f7a4f3d094f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Debug/Battle/Presenters/BattleDebugPlayerPresenter.cs b/Assets/App/Scripts/Debug/Battle/Presenters/BattleDebugPlayerPresenter.cs new file mode 100644 index 0000000..a91afdf --- /dev/null +++ b/Assets/App/Scripts/Debug/Battle/Presenters/BattleDebugPlayerPresenter.cs @@ -0,0 +1,31 @@ +using App.Debug.Battle.Interfaces.Presenters; +using System; +using UniRx; +using UnityEngine; +using UnityEngine.UI; +using VContainer.Unity; + +namespace App.Debug.Battle.Presenters +{ + public class BattleDebugPlayerPresenter : MonoBehaviour, IBattleDebugPlayerPresenter, IInitializable, IDisposable + { + [Header("Player")] + [SerializeField] private Button _generatePlayerButton; + + private readonly Subject _onGeneratePlayer = new(); + public IObservable OnGeneratePlayer => _onGeneratePlayer; + + private readonly CompositeDisposable _disposables = new(); + public void Initialize() + { + _generatePlayerButton.OnClickAsObservable() + .Subscribe(_ => _onGeneratePlayer.OnNext(Unit.Default)) + .AddTo(_disposables); + } + + public void Dispose() + { + _disposables.Dispose(); + } + } +} diff --git a/Assets/App/Scripts/Debug/Battle/Presenters/BattleDebugPlayerPresenter.cs.meta b/Assets/App/Scripts/Debug/Battle/Presenters/BattleDebugPlayerPresenter.cs.meta new file mode 100644 index 0000000..e2cfeaf --- /dev/null +++ b/Assets/App/Scripts/Debug/Battle/Presenters/BattleDebugPlayerPresenter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1b940b6e2eb4947408843bf72f095cd3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/App/Scripts/Debug/Battle/UseCases/BattleDebugPlayerUseCase.cs b/Assets/App/Scripts/Debug/Battle/UseCases/BattleDebugPlayerUseCase.cs new file mode 100644 index 0000000..5e8ce72 --- /dev/null +++ b/Assets/App/Scripts/Debug/Battle/UseCases/BattleDebugPlayerUseCase.cs @@ -0,0 +1,39 @@ +using App.Battle.Interfaces.UseCases; +using App.Debug.Battle.Interfaces.Presenters; +using System; +using UniRx; +using VContainer; +using VContainer.Unity; + +namespace App.Debug.Battle.UseCases +{ + public class BattleDebugPlayerUseCase : IInitializable, IDisposable + { + private readonly IBattleDebugPlayerPresenter _BattleDebugPlayerPresenter; + private readonly IBattlePlayerUseCase _BattlePlayerUseCase; + + private readonly CompositeDisposable _disposables = new(); + + [Inject] + public BattleDebugPlayerUseCase( + IBattlePlayerUseCase battlePlayerUseCase, + IBattleDebugPlayerPresenter battleDebugPlayerPresenter + ) + { + _BattlePlayerUseCase = battlePlayerUseCase; + _BattleDebugPlayerPresenter = battleDebugPlayerPresenter; + } + + public void Initialize() + { + _BattleDebugPlayerPresenter.OnGeneratePlayer + .Subscribe(x => _BattlePlayerUseCase.GeneratePlayer()) + .AddTo(_disposables); + } + + public void Dispose() + { + _disposables.Dispose(); + } + } +} diff --git a/Assets/App/Scripts/Debug/Battle/UseCases/BattleDebugPlayerUseCase.cs.meta b/Assets/App/Scripts/Debug/Battle/UseCases/BattleDebugPlayerUseCase.cs.meta new file mode 100644 index 0000000..52de31b --- /dev/null +++ b/Assets/App/Scripts/Debug/Battle/UseCases/BattleDebugPlayerUseCase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b24e1efceaad3714aa7d692065ee9175 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 38755406dc7514f83f268d0002a8af52f78eb7e8 Mon Sep 17 00:00:00 2001 From: ujisuke <86547644+ujisuke@users.noreply.github.com> Date: Fri, 30 Aug 2024 00:49:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E7=B5=8C=E9=A8=93=E5=80=A4=E3=82=AF?= =?UTF-8?q?=E3=83=A9=E3=82=B9=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/App/Scripts/Battle/Data/Player.cs | 4 +++- .../App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs | 4 ++-- .../Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs | 2 +- Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Assets/App/Scripts/Battle/Data/Player.cs b/Assets/App/Scripts/Battle/Data/Player.cs index f400cab..d7721cd 100644 --- a/Assets/App/Scripts/Battle/Data/Player.cs +++ b/Assets/App/Scripts/Battle/Data/Player.cs @@ -6,11 +6,13 @@ public class Player { public string Id { get; } public CharacterParameter characterParameter { get; } + public ExperiencePoint experiencePoint { get; } - public Player(string id, CharacterParameter characterParameter) + public Player(string id, CharacterParameter characterParameter, ExperiencePoint experiencePoint) { Id = id; this.characterParameter = characterParameter; + this.experiencePoint = experiencePoint; } } } \ No newline at end of file diff --git a/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs b/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs index 85e06a6..0966591 100644 --- a/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs +++ b/Assets/App/Scripts/Battle/Datastores/BattlePlayerDatastores.cs @@ -13,14 +13,14 @@ public class BattlePlayerDatastore : IBattlePlayerDatastore, IDisposable private Dictionary _players = new(); public IEnumerable Players => _players.Values.ToArray(); - public void AddPlayer(string id, CharacterParameter characterParameter) + public void AddPlayer(string id, CharacterParameter characterParameter, ExperiencePoint experiencePoint) { if(characterParameter == null) { throw new NullReferenceException($"{nameof(CharacterParameter)} is null"); } - var player = new Player(id, characterParameter); + var player = new Player(id, characterParameter, experiencePoint); UnityEngine.Debug.Log($"{player} added"); _players.Add(id, player); diff --git a/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs b/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs index cccc092..2196602 100644 --- a/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs +++ b/Assets/App/Scripts/Battle/Interfaces/Datastores/IBattlePlayerDatastore.cs @@ -7,7 +7,7 @@ namespace App.Battle.Interfaces.Datastores public interface IBattlePlayerDatastore { IEnumerable Players { get; } - void AddPlayer(string id, CharacterParameter characterParameter); + void AddPlayer(string id, CharacterParameter characterParameter, ExperiencePoint experiencePoint); void RemovePlayer(string id); Player GetPlayerBy(string id); } diff --git a/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs b/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs index a8b0c62..3b16c07 100644 --- a/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs +++ b/Assets/App/Scripts/Battle/Usecases/BattlePlayerUsecase.cs @@ -21,7 +21,7 @@ IBattlePlayerDatastore battlePlayerDatastore public void GeneratePlayer() { - _BattlePlayerDatastore.AddPlayer("1", new CharacterParameter()); + _BattlePlayerDatastore.AddPlayer("1", new CharacterParameter(), new ExperiencePoint(0,10)); UnityEngine.Debug.Log($"{"1"} generated"); } }