From 11d68b850b7be78fd9bd140f49bb300ed54ef97f Mon Sep 17 00:00:00 2001 From: NTG_Lenovo Date: Thu, 5 Oct 2023 13:11:46 +0900 Subject: [PATCH] =?UTF-8?q?InIslandPlayer=20=EB=B0=B0=EC=B9=98=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BlueWater/Assets/01.Scenes/02.Main_TG.unity | 188 +++++++++++++++++- BlueWater/Assets/02.Scripts/BlueWater.cs | 155 +++++++++++++++ .../Assets/02.Scripts/BlueWater.inputactions | 92 +++++++++ .../02.Scripts/Character/Player/Player.cs | 7 +- .../Character/Player/Type/InIslandPlayer.cs | 49 ++++- BlueWater/Assets/02.Scripts/GameManager.cs | 32 +++ .../Characters/Players/Viking.prefab | 32 +++ 7 files changed, 545 insertions(+), 10 deletions(-) diff --git a/BlueWater/Assets/01.Scenes/02.Main_TG.unity b/BlueWater/Assets/01.Scenes/02.Main_TG.unity index 8c4b2e485..3d01a6116 100644 --- a/BlueWater/Assets/01.Scenes/02.Main_TG.unity +++ b/BlueWater/Assets/01.Scenes/02.Main_TG.unity @@ -143266,7 +143266,7 @@ Transform: m_GameObject: {fileID: 193056413} serializedVersion: 2 m_LocalRotation: {x: 0.68862504, y: 0.030224524, z: -0.028751038, w: 0.7239167} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: -1.1368684e-13, y: 0, z: -0.0000009536744} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -222809,8 +222809,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 310929530} serializedVersion: 2 - m_LocalRotation: {x: 0.6618744, y: 0.031249192, z: -0.027634379, w: 0.7484532} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: 0.6618745, y: 0.031248953, z: -0.02763417, w: 0.7484532} + m_LocalPosition: {x: -1.1368684e-13, y: 0, z: -0.0000009536744} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -635213,6 +635213,7 @@ Transform: - {fileID: 1140805708} - {fileID: 178962826} - {fileID: 982629706} + - {fileID: 1037586754} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &888439617 @@ -701704,7 +701705,7 @@ Transform: m_GameObject: {fileID: 978318587} serializedVersion: 2 m_LocalRotation: {x: 0.6753436, y: 0.03074276, z: -0.028196778, w: 0.7363227} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: -1.1368684e-13, y: 0, z: -0.0000009536744} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -744109,6 +744110,37 @@ SkinnedMeshRenderer: m_Center: {x: -2.6278043, y: -0.0457796, z: -0.0107373} m_Extent: {x: 2.9271088, y: 0.21452628, z: 1.4139687} m_DirtyAABB: 0 +--- !u!1 &1037586753 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1037586754} + m_Layer: 0 + m_Name: SpawnPostion + m_TagString: Untagged + m_Icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1037586754 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1037586753} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 28.71, y: 2.853, z: -26.55} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 888439616} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1037610699 GameObject: m_ObjectHideFlags: 0 @@ -1062665,6 +1062697,150 @@ SkinnedMeshRenderer: m_Center: {x: -3.037315, y: -0.16242945, z: 0.0017783642} m_Extent: {x: 1.6850129, y: 0.013213582, z: 0.91438246} m_DirtyAABB: 0 +--- !u!1001 &1489125362 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_SizeDelta.x + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_SizeDelta.y + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalScale.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalScale.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalScale.z + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalPosition.z + value: -47.621864 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_AnchoredPosition.x + value: -8.368828 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 2.76 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 895707786071648807, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_ConstrainProportionsScale + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4681418249284042988, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + propertyPath: m_Name + value: Viking + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 5d3f02c24a243a044bbddafc1652ee67, type: 3} +--- !u!1 &1489125363 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 4681418249284042988, guid: 5d3f02c24a243a044bbddafc1652ee67, + type: 3} + m_PrefabInstance: {fileID: 1489125362} + m_PrefabAsset: {fileID: 0} --- !u!1 &1489261967 GameObject: m_ObjectHideFlags: 0 @@ -1100387,6 +1100563,9 @@ MonoBehaviour: _persistent: 0 shipPlayer: {fileID: 0} boats: [] + playerAction: {fileID: -944628639613478452, guid: 0acb404847404484198cbf94e6929af2, + type: 3} + inIslandPlayer: {fileID: 1489125363} slowSpeed: 0.1 --- !u!4 &1540310984 Transform: @@ -1550689,3 +1550868,4 @@ SceneRoots: - {fileID: 342641572} - {fileID: 1574668128} - {fileID: 1376199811} + - {fileID: 1489125362} diff --git a/BlueWater/Assets/02.Scripts/BlueWater.cs b/BlueWater/Assets/02.Scripts/BlueWater.cs index 940ed9372..1e5ec8f84 100644 --- a/BlueWater/Assets/02.Scripts/BlueWater.cs +++ b/BlueWater/Assets/02.Scripts/BlueWater.cs @@ -107,6 +107,15 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable ""processors"": """", ""interactions"": ""Hold(duration=1)"", ""initialStateCheck"": false + }, + { + ""name"": ""SpawnInIsladnPlayer"", + ""type"": ""Button"", + ""id"": ""1558b861-5937-46f7-8887-3f322044049b"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false } ], ""bindings"": [ @@ -252,6 +261,17 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable ""action"": ""TargetingHold"", ""isComposite"": false, ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""95f474a1-8d98-4b85-8fd9-fa128951f69f"", + ""path"": ""/t"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""Keyboard&Mouse"", + ""action"": ""SpawnInIsladnPlayer"", + ""isComposite"": false, + ""isPartOfComposite"": false } ] }, @@ -381,6 +401,78 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable ""isPartOfComposite"": false } ] + }, + { + ""name"": ""InIslandPlayer"", + ""id"": ""ecd1ce71-0143-4a0d-b768-d3f1a7fe33b9"", + ""actions"": [ + { + ""name"": ""Move"", + ""type"": ""Value"", + ""id"": ""8bcf669e-cce8-4177-a248-711e234a39be"", + ""expectedControlType"": ""Vector2"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": true + } + ], + ""bindings"": [ + { + ""name"": ""WASD"", + ""id"": ""32f0e967-e5de-4f01-aa1e-a607a0304c52"", + ""path"": ""2DVector"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Move"", + ""isComposite"": true, + ""isPartOfComposite"": false + }, + { + ""name"": ""up"", + ""id"": ""d2c8ac50-a12f-4f41-aacf-42310db8dee5"", + ""path"": ""/w"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""Keyboard&Mouse"", + ""action"": ""Move"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""down"", + ""id"": ""68dbc390-f395-4d17-8c23-1526b11f2363"", + ""path"": ""/s"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""Keyboard&Mouse"", + ""action"": ""Move"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""left"", + ""id"": ""2a8275a8-ada7-48c0-ab42-3030013101b0"", + ""path"": ""/a"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""Keyboard&Mouse"", + ""action"": ""Move"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""right"", + ""id"": ""fd4aca22-d5e4-4c5c-8d49-4aff6b308a83"", + ""path"": ""/d"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""Keyboard&Mouse"", + ""action"": ""Move"", + ""isComposite"": false, + ""isPartOfComposite"": true + } + ] } ], ""controlSchemes"": [ @@ -424,6 +516,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable m_Player_InteractionE = m_Player.FindAction("InteractionE", throwIfNotFound: true); m_Player_Targeting = m_Player.FindAction("Targeting", throwIfNotFound: true); m_Player_TargetingHold = m_Player.FindAction("TargetingHold", throwIfNotFound: true); + m_Player_SpawnInIsladnPlayer = m_Player.FindAction("SpawnInIsladnPlayer", throwIfNotFound: true); // Camera m_Camera = asset.FindActionMap("Camera", throwIfNotFound: true); m_Camera_Zoom = m_Camera.FindAction("Zoom", throwIfNotFound: true); @@ -433,6 +526,9 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable m_Unit_SelectUnit = m_Unit.FindAction("SelectUnit", throwIfNotFound: true); m_Unit_CancelSelectedUnit = m_Unit.FindAction("CancelSelectedUnit", throwIfNotFound: true); m_Unit_MoveUnit = m_Unit.FindAction("MoveUnit", throwIfNotFound: true); + // InIslandPlayer + m_InIslandPlayer = asset.FindActionMap("InIslandPlayer", throwIfNotFound: true); + m_InIslandPlayer_Move = m_InIslandPlayer.FindAction("Move", throwIfNotFound: true); } public void Dispose() @@ -503,6 +599,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable private readonly InputAction m_Player_InteractionE; private readonly InputAction m_Player_Targeting; private readonly InputAction m_Player_TargetingHold; + private readonly InputAction m_Player_SpawnInIsladnPlayer; public struct PlayerActions { private @BlueWater m_Wrapper; @@ -516,6 +613,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable public InputAction @InteractionE => m_Wrapper.m_Player_InteractionE; public InputAction @Targeting => m_Wrapper.m_Player_Targeting; public InputAction @TargetingHold => m_Wrapper.m_Player_TargetingHold; + public InputAction @SpawnInIsladnPlayer => m_Wrapper.m_Player_SpawnInIsladnPlayer; public InputActionMap Get() { return m_Wrapper.m_Player; } public void Enable() { Get().Enable(); } public void Disable() { Get().Disable(); } @@ -552,6 +650,9 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable @TargetingHold.started += instance.OnTargetingHold; @TargetingHold.performed += instance.OnTargetingHold; @TargetingHold.canceled += instance.OnTargetingHold; + @SpawnInIsladnPlayer.started += instance.OnSpawnInIsladnPlayer; + @SpawnInIsladnPlayer.performed += instance.OnSpawnInIsladnPlayer; + @SpawnInIsladnPlayer.canceled += instance.OnSpawnInIsladnPlayer; } private void UnregisterCallbacks(IPlayerActions instance) @@ -583,6 +684,9 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable @TargetingHold.started -= instance.OnTargetingHold; @TargetingHold.performed -= instance.OnTargetingHold; @TargetingHold.canceled -= instance.OnTargetingHold; + @SpawnInIsladnPlayer.started -= instance.OnSpawnInIsladnPlayer; + @SpawnInIsladnPlayer.performed -= instance.OnSpawnInIsladnPlayer; + @SpawnInIsladnPlayer.canceled -= instance.OnSpawnInIsladnPlayer; } public void RemoveCallbacks(IPlayerActions instance) @@ -716,6 +820,52 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable } } public UnitActions @Unit => new UnitActions(this); + + // InIslandPlayer + private readonly InputActionMap m_InIslandPlayer; + private List m_InIslandPlayerActionsCallbackInterfaces = new List(); + private readonly InputAction m_InIslandPlayer_Move; + public struct InIslandPlayerActions + { + private @BlueWater m_Wrapper; + public InIslandPlayerActions(@BlueWater wrapper) { m_Wrapper = wrapper; } + public InputAction @Move => m_Wrapper.m_InIslandPlayer_Move; + public InputActionMap Get() { return m_Wrapper.m_InIslandPlayer; } + public void Enable() { Get().Enable(); } + public void Disable() { Get().Disable(); } + public bool enabled => Get().enabled; + public static implicit operator InputActionMap(InIslandPlayerActions set) { return set.Get(); } + public void AddCallbacks(IInIslandPlayerActions instance) + { + if (instance == null || m_Wrapper.m_InIslandPlayerActionsCallbackInterfaces.Contains(instance)) return; + m_Wrapper.m_InIslandPlayerActionsCallbackInterfaces.Add(instance); + @Move.started += instance.OnMove; + @Move.performed += instance.OnMove; + @Move.canceled += instance.OnMove; + } + + private void UnregisterCallbacks(IInIslandPlayerActions instance) + { + @Move.started -= instance.OnMove; + @Move.performed -= instance.OnMove; + @Move.canceled -= instance.OnMove; + } + + public void RemoveCallbacks(IInIslandPlayerActions instance) + { + if (m_Wrapper.m_InIslandPlayerActionsCallbackInterfaces.Remove(instance)) + UnregisterCallbacks(instance); + } + + public void SetCallbacks(IInIslandPlayerActions instance) + { + foreach (var item in m_Wrapper.m_InIslandPlayerActionsCallbackInterfaces) + UnregisterCallbacks(item); + m_Wrapper.m_InIslandPlayerActionsCallbackInterfaces.Clear(); + AddCallbacks(instance); + } + } + public InIslandPlayerActions @InIslandPlayer => new InIslandPlayerActions(this); private int m_KeyboardMouseSchemeIndex = -1; public InputControlScheme KeyboardMouseScheme { @@ -745,6 +895,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable void OnInteractionE(InputAction.CallbackContext context); void OnTargeting(InputAction.CallbackContext context); void OnTargetingHold(InputAction.CallbackContext context); + void OnSpawnInIsladnPlayer(InputAction.CallbackContext context); } public interface ICameraActions { @@ -757,4 +908,8 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable void OnCancelSelectedUnit(InputAction.CallbackContext context); void OnMoveUnit(InputAction.CallbackContext context); } + public interface IInIslandPlayerActions + { + void OnMove(InputAction.CallbackContext context); + } } diff --git a/BlueWater/Assets/02.Scripts/BlueWater.inputactions b/BlueWater/Assets/02.Scripts/BlueWater.inputactions index 2d5e75c30..a753bec80 100644 --- a/BlueWater/Assets/02.Scripts/BlueWater.inputactions +++ b/BlueWater/Assets/02.Scripts/BlueWater.inputactions @@ -85,6 +85,15 @@ "processors": "", "interactions": "Hold(duration=1)", "initialStateCheck": false + }, + { + "name": "SpawnInIsladnPlayer", + "type": "Button", + "id": "1558b861-5937-46f7-8887-3f322044049b", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -230,6 +239,17 @@ "action": "TargetingHold", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "95f474a1-8d98-4b85-8fd9-fa128951f69f", + "path": "/t", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "SpawnInIsladnPlayer", + "isComposite": false, + "isPartOfComposite": false } ] }, @@ -359,6 +379,78 @@ "isPartOfComposite": false } ] + }, + { + "name": "InIslandPlayer", + "id": "ecd1ce71-0143-4a0d-b768-d3f1a7fe33b9", + "actions": [ + { + "name": "Move", + "type": "Value", + "id": "8bcf669e-cce8-4177-a248-711e234a39be", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": true + } + ], + "bindings": [ + { + "name": "WASD", + "id": "32f0e967-e5de-4f01-aa1e-a607a0304c52", + "path": "2DVector", + "interactions": "", + "processors": "", + "groups": "", + "action": "Move", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "up", + "id": "d2c8ac50-a12f-4f41-aacf-42310db8dee5", + "path": "/w", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "68dbc390-f395-4d17-8c23-1526b11f2363", + "path": "/s", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "2a8275a8-ada7-48c0-ab42-3030013101b0", + "path": "/a", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "fd4aca22-d5e4-4c5c-8d49-4aff6b308a83", + "path": "/d", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + } + ] } ], "controlSchemes": [ diff --git a/BlueWater/Assets/02.Scripts/Character/Player/Player.cs b/BlueWater/Assets/02.Scripts/Character/Player/Player.cs index 120326fea..6992cd769 100644 --- a/BlueWater/Assets/02.Scripts/Character/Player/Player.cs +++ b/BlueWater/Assets/02.Scripts/Character/Player/Player.cs @@ -3,11 +3,8 @@ using UnityEngine; // ReSharper disable once CheckNamespace namespace BlueWaterProject { - public class Player : BaseCharacter, IDamageable + public class Player : BaseCharacter { - public void TakeDamage(float attackerPower, float attackerShieldPenetrationRate = default, Vector3? attackPos = null) - { - throw new System.NotImplementedException(); - } + } } \ No newline at end of file diff --git a/BlueWater/Assets/02.Scripts/Character/Player/Type/InIslandPlayer.cs b/BlueWater/Assets/02.Scripts/Character/Player/Type/InIslandPlayer.cs index ce9ede6b9..2abcb36d9 100644 --- a/BlueWater/Assets/02.Scripts/Character/Player/Type/InIslandPlayer.cs +++ b/BlueWater/Assets/02.Scripts/Character/Player/Type/InIslandPlayer.cs @@ -1,10 +1,57 @@ +using Sirenix.OdinInspector; using UnityEngine; +using UnityEngine.InputSystem; // ReSharper disable once CheckNamespace namespace BlueWaterProject { - public class InIslandPlayer : Player + public class InIslandPlayer : Player, IDamageable { + #region Properties and variables + + [Title("Player Input System")] + [SerializeField] private float moveSpeed; + private Vector2 movementInput; + + #endregion + + #region Unity built-in methods + + protected override void Update() + { + var movement = new Vector3(movementInput.x, 0, movementInput.y) * (moveSpeed * Time.deltaTime); + transform.Translate(movement); + } + + #endregion + + #region Interface + + public void TakeDamage(float attackerPower, float attackerShieldPenetrationRate = default, Vector3? attackPos = null) + { + throw new System.NotImplementedException(); + } + + #endregion + + #region Player input system + + private void OnMove(InputValue value) + { + movementInput = value.Get(); + + // 2D 스프라이트 뒤집기 + var localScale = transform.localScale; + localScale.x = movementInput.x >= 0 ? Mathf.Abs(localScale.x) : -Mathf.Abs(localScale.x); + transform.localScale = localScale; + } + + #endregion + + #region Custom methods + + + #endregion } } \ No newline at end of file diff --git a/BlueWater/Assets/02.Scripts/GameManager.cs b/BlueWater/Assets/02.Scripts/GameManager.cs index 0c685d2d1..f9157ea62 100644 --- a/BlueWater/Assets/02.Scripts/GameManager.cs +++ b/BlueWater/Assets/02.Scripts/GameManager.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using BlueWaterProject; using Sirenix.OdinInspector; using UnityEngine; +using UnityEngine.InputSystem; // ReSharper disable once CheckNamespace namespace BlueWaterProject @@ -13,9 +14,15 @@ namespace BlueWaterProject public CameraController CameraController { get; private set; } public ShipPlayer shipPlayer; public List boats = new List(10); + [Required("BlueWater Player Input Action을 넣어주세요.")] + [SerializeField] private InputActionAsset playerAction; + [Required("Viking Prefab을 넣어주세요.")] + [SerializeField] private GameObject inIslandPlayer; [Range(0f, 1f)] [SerializeField] private float slowSpeed = 0.1f; + + private const string IN_ISLAND_PLAYER_NAME = "InIslandPlayer"; private void Init() { @@ -32,6 +39,31 @@ namespace BlueWaterProject Cursor.lockState = CursorLockMode.Confined; } + public void SpawnInIslandPlayer(Vector3 spawnPosition) + { + var islandPlayer = Instantiate(inIslandPlayer, spawnPosition, Quaternion.identity); + islandPlayer.name = IN_ISLAND_PLAYER_NAME; + + var playerInput = islandPlayer.GetComponent(); + if (playerInput == null) + { + playerInput = islandPlayer.AddComponent(); + } + playerInput.actions = playerAction; + + var desiredActionMap = playerInput.actions.FindActionMap(IN_ISLAND_PLAYER_NAME); + if (desiredActionMap == null) + { + print($"Action map named '{IN_ISLAND_PLAYER_NAME}' not found in player actions!"); + return; + } + + playerInput.defaultActionMap = IN_ISLAND_PLAYER_NAME; + playerInput.SwitchCurrentActionMap(IN_ISLAND_PLAYER_NAME); + + islandPlayer.AddComponent(); + } + public void testPrint() { print("Boat가 목표에 도착해서 이 함수를 호출합니다"); diff --git a/BlueWater/Assets/05.Prefabs/Characters/Players/Viking.prefab b/BlueWater/Assets/05.Prefabs/Characters/Players/Viking.prefab index 896406960..9b4832e27 100644 --- a/BlueWater/Assets/05.Prefabs/Characters/Players/Viking.prefab +++ b/BlueWater/Assets/05.Prefabs/Characters/Players/Viking.prefab @@ -1685,6 +1685,7 @@ GameObject: m_Component: - component: {fileID: 895707786071648807} - component: {fileID: 2790053813834214194} + - component: {fileID: 5961428674722413686} m_Layer: 5 m_Name: Viking m_TagString: Untagged @@ -1734,6 +1735,37 @@ MonoBehaviour: UnitTypeChanged: m_PersistentCalls: m_Calls: [] +--- !u!114 &5961428674722413686 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4681418249284042988} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Actions: {fileID: -944628639613478452, guid: 0acb404847404484198cbf94e6929af2, + type: 3} + m_NotificationBehavior: 0 + m_UIInputModule: {fileID: 0} + m_DeviceLostEvent: + m_PersistentCalls: + m_Calls: [] + m_DeviceRegainedEvent: + m_PersistentCalls: + m_Calls: [] + m_ControlsChangedEvent: + m_PersistentCalls: + m_Calls: [] + m_ActionEvents: [] + m_NeverAutoSwitchControlSchemes: 0 + m_DefaultControlScheme: + m_DefaultActionMap: ecd1ce71-0143-4a0d-b768-d3f1a7fe33b9 + m_SplitScreenIndex: -1 + m_Camera: {fileID: 0} --- !u!1 &4698308777242127462 GameObject: m_ObjectHideFlags: 0