Added pawn system, player system, and rough player spawning
This commit is contained in:
parent
eb67082d71
commit
74c6f81f3f
8
Assets/Data/Units.meta
Normal file
8
Assets/Data/Units.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 50a525946abd59a488fa4d860246a471
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
16
Assets/Data/Units/BLOODJOE.asset
Normal file
16
Assets/Data/Units/BLOODJOE.asset
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
%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: 6b3a9e9e76344affbc76fb463d95fe74, type: 3}
|
||||||
|
m_Name: BLOODJOE
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::Data.UnitData
|
||||||
|
UnitName: BLOOD JOE
|
||||||
|
MoveSpeed: 0.1
|
||||||
8
Assets/Data/Units/BLOODJOE.asset.meta
Normal file
8
Assets/Data/Units/BLOODJOE.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 002caf708abb1144c99ca1048c00afcc
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -172,6 +172,15 @@ public partial class @InputControls: IInputActionCollection2, IDisposable
|
|||||||
""processors"": """",
|
""processors"": """",
|
||||||
""interactions"": """",
|
""interactions"": """",
|
||||||
""initialStateCheck"": false
|
""initialStateCheck"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Pause"",
|
||||||
|
""type"": ""Button"",
|
||||||
|
""id"": ""ce6f0bdb-8150-43d4-8aeb-134e15b5c867"",
|
||||||
|
""expectedControlType"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
""bindings"": [
|
""bindings"": [
|
||||||
@ -559,6 +568,17 @@ public partial class @InputControls: IInputActionCollection2, IDisposable
|
|||||||
""action"": ""Crouch"",
|
""action"": ""Crouch"",
|
||||||
""isComposite"": false,
|
""isComposite"": false,
|
||||||
""isPartOfComposite"": false
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": """",
|
||||||
|
""id"": ""e65235e0-3265-472c-b736-66dbd6363247"",
|
||||||
|
""path"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Pause"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1153,6 +1173,7 @@ public partial class @InputControls: IInputActionCollection2, IDisposable
|
|||||||
m_Player_Previous = m_Player.FindAction("Previous", throwIfNotFound: true);
|
m_Player_Previous = m_Player.FindAction("Previous", throwIfNotFound: true);
|
||||||
m_Player_Next = m_Player.FindAction("Next", throwIfNotFound: true);
|
m_Player_Next = m_Player.FindAction("Next", throwIfNotFound: true);
|
||||||
m_Player_Sprint = m_Player.FindAction("Sprint", throwIfNotFound: true);
|
m_Player_Sprint = m_Player.FindAction("Sprint", throwIfNotFound: true);
|
||||||
|
m_Player_Pause = m_Player.FindAction("Pause", throwIfNotFound: true);
|
||||||
// UI
|
// UI
|
||||||
m_UI = asset.FindActionMap("UI", throwIfNotFound: true);
|
m_UI = asset.FindActionMap("UI", throwIfNotFound: true);
|
||||||
m_UI_Navigate = m_UI.FindAction("Navigate", throwIfNotFound: true);
|
m_UI_Navigate = m_UI.FindAction("Navigate", throwIfNotFound: true);
|
||||||
@ -1255,6 +1276,7 @@ public partial class @InputControls: IInputActionCollection2, IDisposable
|
|||||||
private readonly InputAction m_Player_Previous;
|
private readonly InputAction m_Player_Previous;
|
||||||
private readonly InputAction m_Player_Next;
|
private readonly InputAction m_Player_Next;
|
||||||
private readonly InputAction m_Player_Sprint;
|
private readonly InputAction m_Player_Sprint;
|
||||||
|
private readonly InputAction m_Player_Pause;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides access to input actions defined in input action map "Player".
|
/// Provides access to input actions defined in input action map "Player".
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1303,6 +1325,10 @@ public partial class @InputControls: IInputActionCollection2, IDisposable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public InputAction @Sprint => m_Wrapper.m_Player_Sprint;
|
public InputAction @Sprint => m_Wrapper.m_Player_Sprint;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Provides access to the underlying input action "Player/Pause".
|
||||||
|
/// </summary>
|
||||||
|
public InputAction @Pause => m_Wrapper.m_Player_Pause;
|
||||||
|
/// <summary>
|
||||||
/// Provides access to the underlying input action map instance.
|
/// Provides access to the underlying input action map instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
||||||
@ -1355,6 +1381,9 @@ public partial class @InputControls: IInputActionCollection2, IDisposable
|
|||||||
@Sprint.started += instance.OnSprint;
|
@Sprint.started += instance.OnSprint;
|
||||||
@Sprint.performed += instance.OnSprint;
|
@Sprint.performed += instance.OnSprint;
|
||||||
@Sprint.canceled += instance.OnSprint;
|
@Sprint.canceled += instance.OnSprint;
|
||||||
|
@Pause.started += instance.OnPause;
|
||||||
|
@Pause.performed += instance.OnPause;
|
||||||
|
@Pause.canceled += instance.OnPause;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1393,6 +1422,9 @@ public partial class @InputControls: IInputActionCollection2, IDisposable
|
|||||||
@Sprint.started -= instance.OnSprint;
|
@Sprint.started -= instance.OnSprint;
|
||||||
@Sprint.performed -= instance.OnSprint;
|
@Sprint.performed -= instance.OnSprint;
|
||||||
@Sprint.canceled -= instance.OnSprint;
|
@Sprint.canceled -= instance.OnSprint;
|
||||||
|
@Pause.started -= instance.OnPause;
|
||||||
|
@Pause.performed -= instance.OnPause;
|
||||||
|
@Pause.canceled -= instance.OnPause;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1756,6 +1788,13 @@ public partial class @InputControls: IInputActionCollection2, IDisposable
|
|||||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||||
void OnSprint(InputAction.CallbackContext context);
|
void OnSprint(InputAction.CallbackContext context);
|
||||||
|
/// <summary>
|
||||||
|
/// Method invoked when associated input action "Pause" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||||
|
void OnPause(InputAction.CallbackContext context);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "UI" which allows adding and removing callbacks.
|
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "UI" which allows adding and removing callbacks.
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"version": 1,
|
||||||
"name": "InputSystem_Actions",
|
"name": "InputSystem_Actions",
|
||||||
"maps": [
|
"maps": [
|
||||||
{
|
{
|
||||||
@ -85,6 +86,15 @@
|
|||||||
"processors": "",
|
"processors": "",
|
||||||
"interactions": "",
|
"interactions": "",
|
||||||
"initialStateCheck": false
|
"initialStateCheck": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Pause",
|
||||||
|
"type": "Button",
|
||||||
|
"id": "ce6f0bdb-8150-43d4-8aeb-134e15b5c867",
|
||||||
|
"expectedControlType": "",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bindings": [
|
"bindings": [
|
||||||
@ -472,6 +482,17 @@
|
|||||||
"action": "Crouch",
|
"action": "Crouch",
|
||||||
"isComposite": false,
|
"isComposite": false,
|
||||||
"isPartOfComposite": false
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "e65235e0-3265-472c-b736-66dbd6363247",
|
||||||
|
"path": "",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Pause",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@ -9,7 +9,7 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 3636029506242817898}
|
- component: {fileID: 3636029506242817898}
|
||||||
- component: {fileID: 2117588860408389559}
|
- component: {fileID: 4543037591913187645}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: BLOODJOE
|
m_Name: BLOODJOE
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -33,7 +33,7 @@ Transform:
|
|||||||
- {fileID: 3717987685648007551}
|
- {fileID: 3717987685648007551}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &2117588860408389559
|
--- !u!114 &4543037591913187645
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
@ -42,10 +42,10 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 5178305101487608751}
|
m_GameObject: {fileID: 5178305101487608751}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 4cefd9a2a7d2ae448bc9bbe40286234e, type: 3}
|
m_Script: {fileID: 11500000, guid: 9f09fee310742e740b0853ad4366d1b0, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::PlayerMovement
|
m_EditorClassIdentifier: Assembly-CSharp::Pawn
|
||||||
speed: 0.05
|
unitData: {fileID: 11400000, guid: 002caf708abb1144c99ca1048c00afcc, type: 2}
|
||||||
--- !u!1 &7443273741764524837
|
--- !u!1 &7443273741764524837
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -74,8 +74,8 @@ Transform:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1.2, y: 1.2, z: 1.2}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 1
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 3636029506242817898}
|
m_Father: {fileID: 3636029506242817898}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|||||||
103
Assets/Prefab/Player.prefab
Normal file
103
Assets/Prefab/Player.prefab
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &2801350755836739254
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 259388946424143483}
|
||||||
|
- component: {fileID: 5374725762074941630}
|
||||||
|
- component: {fileID: 5930325806846324897}
|
||||||
|
- component: {fileID: 6300030663040521374}
|
||||||
|
- component: {fileID: 1058551726234483551}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Player
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &259388946424143483
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2801350755836739254}
|
||||||
|
serializedVersion: 2
|
||||||
|
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: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &5374725762074941630
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2801350755836739254}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Unity.InputSystem::UnityEngine.InputSystem.PlayerInput
|
||||||
|
m_Actions: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, 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: Player
|
||||||
|
m_SplitScreenIndex: -1
|
||||||
|
m_Camera: {fileID: 0}
|
||||||
|
--- !u!114 &5930325806846324897
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2801350755836739254}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 090adb8c34526d44c8084293b7835dfc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::Player
|
||||||
|
--- !u!114 &6300030663040521374
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2801350755836739254}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: f4c7a6df1ceb4769b865dd0e31fb927c, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::Managers.PlayerInputRouter
|
||||||
|
--- !u!114 &1058551726234483551
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2801350755836739254}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 12c97df4296b47b5be9ee4ac8df0f08f, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::State.PlayerStateMachine.PlayerStateMachine
|
||||||
7
Assets/Prefab/Player.prefab.meta
Normal file
7
Assets/Prefab/Player.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 15b524c7b47092648af91b9f0163c227
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -262,6 +262,161 @@ AudioSource:
|
|||||||
m_PreInfinity: 2
|
m_PreInfinity: 2
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
|
--- !u!1 &1135129241
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1135129243}
|
||||||
|
- component: {fileID: 1135129242}
|
||||||
|
- component: {fileID: 1135129244}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: PlayerInputManager
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1135129242
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1135129241}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 621567455fd1c4ceb811cc8a00b6a1a5, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Unity.InputSystem::UnityEngine.InputSystem.PlayerInputManager
|
||||||
|
m_NotificationBehavior: 3
|
||||||
|
m_MaxPlayerCount: 2
|
||||||
|
m_AllowJoining: 1
|
||||||
|
m_JoinBehavior: 1
|
||||||
|
m_PlayerJoinedEvent:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_PlayerLeftEvent:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_JoinAction:
|
||||||
|
m_UseReference: 0
|
||||||
|
m_Action:
|
||||||
|
m_Name: Join
|
||||||
|
m_Type: 0
|
||||||
|
m_ExpectedControlType:
|
||||||
|
m_Id: 6743169d-f1a9-4e07-bd51-c04f6aad9684
|
||||||
|
m_Processors:
|
||||||
|
m_Interactions:
|
||||||
|
m_SingletonActionBindings:
|
||||||
|
- m_Name:
|
||||||
|
m_Id: 27014fd1-8bd7-482b-b75a-c80560b224f8
|
||||||
|
m_Path: <Keyboard>/enter
|
||||||
|
m_Interactions:
|
||||||
|
m_Processors:
|
||||||
|
m_Groups:
|
||||||
|
m_Action: Join
|
||||||
|
m_Flags: 0
|
||||||
|
- m_Name:
|
||||||
|
m_Id: 78b5b965-1aeb-4a9b-b233-d598d35b7902
|
||||||
|
m_Path: <Gamepad>/start
|
||||||
|
m_Interactions:
|
||||||
|
m_Processors:
|
||||||
|
m_Groups:
|
||||||
|
m_Action: Join
|
||||||
|
m_Flags: 0
|
||||||
|
m_Flags: 0
|
||||||
|
m_Reference: {fileID: 0}
|
||||||
|
m_PlayerPrefab: {fileID: 2801350755836739254, guid: 15b524c7b47092648af91b9f0163c227, type: 3}
|
||||||
|
m_SplitScreen: 0
|
||||||
|
m_MaintainAspectRatioInSplitScreen: 0
|
||||||
|
m_FixedNumberOfSplitScreens: -1
|
||||||
|
m_SplitScreenRect:
|
||||||
|
serializedVersion: 2
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
width: 1
|
||||||
|
height: 1
|
||||||
|
--- !u!4 &1135129243
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1135129241}
|
||||||
|
serializedVersion: 2
|
||||||
|
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: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &1135129244
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1135129241}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 6c77688db5ee421faec9592570fa3db8, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::Managers.InputManager
|
||||||
|
stateMachine: {fileID: 1567913722}
|
||||||
|
playerInputManager: {fileID: 1135129242}
|
||||||
|
uiModule: {fileID: 0}
|
||||||
|
characterPrefabs:
|
||||||
|
- {fileID: 5178305101487608751, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
||||||
|
- {fileID: 5178305101487608751, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
||||||
|
--- !u!1 &1567913721
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1567913723}
|
||||||
|
- component: {fileID: 1567913722}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: GameStateMachine
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1567913722
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1567913721}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 9fba63db359b4b479a0f0a57ab8ea23b, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::State.GameStateMachine.GameStateMachine
|
||||||
|
--- !u!4 &1567913723
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1567913721}
|
||||||
|
serializedVersion: 2
|
||||||
|
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: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1695492502
|
--- !u!1 &1695492502
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -291,7 +446,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 8a3740ea238ed9c4a86891b0fecf1c2f, type: 3}
|
m_Script: {fileID: 11500000, guid: 8a3740ea238ed9c4a86891b0fecf1c2f, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
sceneManager: {fileID: 0}
|
playerJoiner: {fileID: 0}
|
||||||
bgm: {fileID: 1072830981}
|
bgm: {fileID: 1072830981}
|
||||||
--- !u!4 &1695492504
|
--- !u!4 &1695492504
|
||||||
Transform:
|
Transform:
|
||||||
@ -314,3 +469,5 @@ SceneRoots:
|
|||||||
m_Roots:
|
m_Roots:
|
||||||
- {fileID: 1072830980}
|
- {fileID: 1072830980}
|
||||||
- {fileID: 1695492504}
|
- {fileID: 1695492504}
|
||||||
|
- {fileID: 1135129243}
|
||||||
|
- {fileID: 1567913723}
|
||||||
|
|||||||
@ -479,79 +479,6 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!1001 &222485703
|
|
||||||
PrefabInstance:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Modification:
|
|
||||||
serializedVersion: 3
|
|
||||||
m_TransformParent: {fileID: 0}
|
|
||||||
m_Modifications:
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.x
|
|
||||||
value: -4.424926
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.y
|
|
||||||
value: -1.37
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.w
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3636029506242817898, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3717987685648007551, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalScale.x
|
|
||||||
value: 1.2
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3717987685648007551, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalScale.y
|
|
||||||
value: 1.2
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3717987685648007551, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_LocalScale.z
|
|
||||||
value: 1.2
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 3717987685648007551, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_ConstrainProportionsScale
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 5178305101487608751, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
propertyPath: m_Name
|
|
||||||
value: BLOODJOE
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
m_RemovedComponents: []
|
|
||||||
m_RemovedGameObjects: []
|
|
||||||
m_AddedGameObjects: []
|
|
||||||
m_AddedComponents: []
|
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 990b0cce140f5964eabc74ee4b0fde11, type: 3}
|
|
||||||
--- !u!1 &232652745
|
--- !u!1 &232652745
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -5394,4 +5321,3 @@ SceneRoots:
|
|||||||
- {fileID: 2141805247}
|
- {fileID: 2141805247}
|
||||||
- {fileID: 1252944905}
|
- {fileID: 1252944905}
|
||||||
- {fileID: 1553743613}
|
- {fileID: 1553743613}
|
||||||
- {fileID: 222485703}
|
|
||||||
|
|||||||
8
Assets/Scripts/Data.meta
Normal file
8
Assets/Scripts/Data.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 380f2e10c9e9c9a4996f41a832c41f8b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
14
Assets/Scripts/Data/Level.cs
Normal file
14
Assets/Scripts/Data/Level.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Data
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(menuName = "Level")]
|
||||||
|
public class Level : ScriptableObject
|
||||||
|
{
|
||||||
|
public AudioClip BGM => bgm;
|
||||||
|
public string SceneName => sceneName;
|
||||||
|
|
||||||
|
[SerializeField] private AudioClip bgm;
|
||||||
|
[SerializeField] private string sceneName;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Data/UnitData.cs
Normal file
11
Assets/Scripts/Data/UnitData.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Data
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(menuName = "UnitData")]
|
||||||
|
public class UnitData : ScriptableObject
|
||||||
|
{
|
||||||
|
public string UnitName;
|
||||||
|
public float MoveSpeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Data/UnitData.cs.meta
Normal file
3
Assets/Scripts/Data/UnitData.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6b3a9e9e76344affbc76fb463d95fe74
|
||||||
|
timeCreated: 1755290497
|
||||||
@ -1,11 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
[CreateAssetMenu(menuName = "Level")]
|
|
||||||
public class Level : ScriptableObject
|
|
||||||
{
|
|
||||||
public AudioClip BGM => bgm;
|
|
||||||
public string SceneName => sceneName;
|
|
||||||
|
|
||||||
[SerializeField] private AudioClip bgm;
|
|
||||||
[SerializeField] private string sceneName;
|
|
||||||
}
|
|
||||||
66
Assets/Scripts/Managers/PlayerInputRouter.cs
Normal file
66
Assets/Scripts/Managers/PlayerInputRouter.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using State;
|
||||||
|
using State.PlayerStateMachine;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
namespace Managers
|
||||||
|
{
|
||||||
|
[RequireComponent(typeof(PlayerInput))]
|
||||||
|
public class PlayerInputRouter : MonoBehaviour
|
||||||
|
{
|
||||||
|
private PlayerInput _playerInput;
|
||||||
|
private PlayerStateMachine _playerStateMachine;
|
||||||
|
private InputActionMap _map;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_playerInput = GetComponent<PlayerInput>();
|
||||||
|
_playerStateMachine = GetComponent<PlayerStateMachine>();
|
||||||
|
_map = _playerInput.actions.FindActionMap("Player", throwIfNotFound: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
_map["Move"].performed += OnMovePerformed;
|
||||||
|
_map["Move"].canceled += OnMoveCanceled;
|
||||||
|
_map["Attack"].performed += OnAttackPerformed;
|
||||||
|
_map["Jump"].performed += OnJumpPerformed;
|
||||||
|
_map["Pause"].performed += OnPausePerformed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
_map["Move"].performed -= OnMovePerformed;
|
||||||
|
_map["Move"].canceled -= OnMoveCanceled;
|
||||||
|
_map["Attack"].performed -= OnAttackPerformed;
|
||||||
|
_map["Jump"].performed -= OnJumpPerformed;
|
||||||
|
_map["Pause"].performed -= OnPausePerformed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnJumpPerformed(InputAction.CallbackContext obj)
|
||||||
|
{
|
||||||
|
_playerStateMachine.Issue(GameState.Command.Jump);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPausePerformed(InputAction.CallbackContext obj)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAttackPerformed(InputAction.CallbackContext obj)
|
||||||
|
{
|
||||||
|
_playerStateMachine.Issue(GameState.Command.Attack);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMoveCanceled(InputAction.CallbackContext obj)
|
||||||
|
{
|
||||||
|
_playerStateMachine.SetMove(Vector2.zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMovePerformed(InputAction.CallbackContext obj)
|
||||||
|
{
|
||||||
|
_playerStateMachine.SetMove(obj.ReadValue<Vector2>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Managers/PlayerInputRouter.cs.meta
Normal file
3
Assets/Scripts/Managers/PlayerInputRouter.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f4c7a6df1ceb4769b865dd0e31fb927c
|
||||||
|
timeCreated: 1755284785
|
||||||
121
Assets/Scripts/Managers/PlayerJoiner.cs
Normal file
121
Assets/Scripts/Managers/PlayerJoiner.cs
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using State;
|
||||||
|
using State.GameStateMachine;
|
||||||
|
using State.PlayerStateMachine;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
using UnityEngine.InputSystem.UI;
|
||||||
|
|
||||||
|
namespace Managers
|
||||||
|
{
|
||||||
|
public class PlayerJoiner : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private GameStateMachine stateMachine;
|
||||||
|
[SerializeField] private PlayerInputManager playerInputManager;
|
||||||
|
[SerializeField] private InputSystemUIInputModule uiModule;
|
||||||
|
[SerializeField] private GameObject[] characterPrefabs = new GameObject[2];
|
||||||
|
|
||||||
|
|
||||||
|
private readonly List<PlayerInput> _players = new();
|
||||||
|
private PlayerInput _currentUIOwner;
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
playerInputManager.onPlayerJoined += HandlePlayerJoined;
|
||||||
|
playerInputManager.onPlayerLeft += HandlePlayerLeft;
|
||||||
|
stateMachine.OnStateChange += HandleStateChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
playerInputManager.onPlayerJoined -= HandlePlayerJoined;
|
||||||
|
playerInputManager.onPlayerLeft -= HandlePlayerLeft;
|
||||||
|
stateMachine.OnStateChange -= HandleStateChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleStateChanged(GameState newState)
|
||||||
|
{
|
||||||
|
switch (newState)
|
||||||
|
{
|
||||||
|
case MainMenu:
|
||||||
|
EnableUIFor(null);
|
||||||
|
break;
|
||||||
|
case PlayLevel:
|
||||||
|
EnableActionMaps(true);
|
||||||
|
break;
|
||||||
|
case Paused:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandlePlayerJoined(PlayerInput playerInput)
|
||||||
|
{
|
||||||
|
Debug.Log("Player joined!");
|
||||||
|
_players.Add(playerInput);
|
||||||
|
|
||||||
|
// TODO: Move all of this to a player spawner
|
||||||
|
var character = Instantiate(characterPrefabs[_players.Count - 1]);
|
||||||
|
var playerStateMachine = playerInput.gameObject.GetComponent<PlayerStateMachine>();
|
||||||
|
playerStateMachine.controlledPawn = character.GetComponent<Pawn>();
|
||||||
|
playerInput.actions.Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandlePlayerLeft(PlayerInput playerInput)
|
||||||
|
{
|
||||||
|
_players.Remove(playerInput);
|
||||||
|
if(_currentUIOwner == playerInput) _currentUIOwner = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnableUIFor(PlayerInput owner)
|
||||||
|
{
|
||||||
|
_currentUIOwner = owner;
|
||||||
|
var asset = uiModule.actionsAsset;
|
||||||
|
if (owner == null)
|
||||||
|
{
|
||||||
|
asset.devices = null; // any device can drive UI (boot)
|
||||||
|
asset.bindingMask = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
asset.devices = owner.devices; // owner's paired devices only
|
||||||
|
asset.bindingMask = InputBinding.MaskByGroup(owner.currentControlScheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure UI actions are enabled
|
||||||
|
asset.FindActionMap("UI", true).Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnableActionMaps(bool gameplayEnabled)
|
||||||
|
{
|
||||||
|
foreach (var p in _players)
|
||||||
|
{
|
||||||
|
if (gameplayEnabled)
|
||||||
|
{
|
||||||
|
p.ActivateInput();
|
||||||
|
if (p.currentActionMap?.name != "Player")
|
||||||
|
p.SwitchCurrentActionMap("Player");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p.DeactivateInput(); // disables player actions, keeps device pairing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReleaseUIFocus()
|
||||||
|
{
|
||||||
|
var asset = uiModule.actionsAsset;
|
||||||
|
asset.devices = null;
|
||||||
|
asset.bindingMask = null;
|
||||||
|
_currentUIOwner = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called by UI Button (Resume) or router "Back" when paused.
|
||||||
|
public void ResumeFromPause()
|
||||||
|
{
|
||||||
|
stateMachine.ChangeState(new PlayLevel());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Managers/PlayerJoiner.cs.meta
Normal file
3
Assets/Scripts/Managers/PlayerJoiner.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6c77688db5ee421faec9592570fa3db8
|
||||||
|
timeCreated: 1755234020
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Managers
|
|
||||||
{
|
|
||||||
public class SceneManager : MonoBehaviour
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 544fd6c0f88f7f647bd2ed389d8e3747
|
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
namespace Managers
|
namespace Managers
|
||||||
{
|
{
|
||||||
@ -6,10 +7,10 @@ namespace Managers
|
|||||||
{
|
{
|
||||||
public static Services Instance { get; private set; }
|
public static Services Instance { get; private set; }
|
||||||
|
|
||||||
public SceneManager SceneManager => sceneManager;
|
public PlayerJoiner PlayerJoiner => playerJoiner;
|
||||||
public BGM BGM => bgm;
|
public BGM BGM => bgm;
|
||||||
|
|
||||||
[SerializeField] private SceneManager sceneManager;
|
[FormerlySerializedAs("inputCoordinator")] [FormerlySerializedAs("inputManager")] [FormerlySerializedAs("inputRouter")] [SerializeField] private PlayerJoiner playerJoiner;
|
||||||
[SerializeField] private BGM bgm;
|
[SerializeField] private BGM bgm;
|
||||||
|
|
||||||
public void Awake()
|
public void Awake()
|
||||||
|
|||||||
19
Assets/Scripts/Pawn.cs
Normal file
19
Assets/Scripts/Pawn.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using Data;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Pawn : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private UnitData unitData;
|
||||||
|
private Vector2 _moveInput;
|
||||||
|
|
||||||
|
public virtual void HandleMove(Vector2 input)
|
||||||
|
{
|
||||||
|
_moveInput = input;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
transform.Translate(_moveInput * unitData.MoveSpeed);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Pawn.cs.meta
Normal file
2
Assets/Scripts/Pawn.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9f09fee310742e740b0853ad4366d1b0
|
||||||
12
Assets/Scripts/Player.cs
Normal file
12
Assets/Scripts/Player.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(PlayerInput))]
|
||||||
|
public class Player : MonoBehaviour
|
||||||
|
{
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
DontDestroyOnLoad(gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Player.cs.meta
Normal file
2
Assets/Scripts/Player.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 090adb8c34526d44c8084293b7835dfc
|
||||||
@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class PlayerMovement : MonoBehaviour
|
|
||||||
{
|
|
||||||
private InputControls _controls;
|
|
||||||
private Vector2 _input;
|
|
||||||
|
|
||||||
[SerializeField] private float speed;
|
|
||||||
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
_controls = new InputControls();
|
|
||||||
_controls.Enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
_input = _controls.Player.Move.ReadValue<Vector2>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FixedUpdate()
|
|
||||||
{
|
|
||||||
transform.Translate(_input.normalized * speed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 4cefd9a2a7d2ae448bc9bbe40286234e
|
|
||||||
3
Assets/Scripts/State.meta
Normal file
3
Assets/Scripts/State.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b780695be93947ac9b3651fa1fa5b9a2
|
||||||
|
timeCreated: 1755232332
|
||||||
22
Assets/Scripts/State/GameState.cs
Normal file
22
Assets/Scripts/State/GameState.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace State
|
||||||
|
{
|
||||||
|
public abstract class GameState
|
||||||
|
{
|
||||||
|
public enum Command { Attack, Jump, Pause }
|
||||||
|
protected StateMachine StateMachine;
|
||||||
|
public virtual void OnEnter(StateMachine machine)
|
||||||
|
{
|
||||||
|
StateMachine = machine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnExit() { }
|
||||||
|
|
||||||
|
public virtual void Update() { }
|
||||||
|
|
||||||
|
public virtual void Handle(Command command) { }
|
||||||
|
|
||||||
|
public virtual void Handle(Vector2 input) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/State/GameState.cs.meta
Normal file
3
Assets/Scripts/State/GameState.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 035addff692543a3909f214ea76461c0
|
||||||
|
timeCreated: 1755232317
|
||||||
3
Assets/Scripts/State/GameStateMachine.meta
Normal file
3
Assets/Scripts/State/GameStateMachine.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 94796da2a3a245ffb93288868610223e
|
||||||
|
timeCreated: 1755232596
|
||||||
15
Assets/Scripts/State/GameStateMachine/Cutscene.cs
Normal file
15
Assets/Scripts/State/GameStateMachine/Cutscene.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace State.GameStateMachine
|
||||||
|
{
|
||||||
|
public class Cutscene : GameState
|
||||||
|
{
|
||||||
|
public override void OnExit()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/State/GameStateMachine/Cutscene.cs.meta
Normal file
3
Assets/Scripts/State/GameStateMachine/Cutscene.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5d6e5eb837674ccbb4391603ca4fecce
|
||||||
|
timeCreated: 1755233147
|
||||||
12
Assets/Scripts/State/GameStateMachine/GameStateMachine.cs
Normal file
12
Assets/Scripts/State/GameStateMachine/GameStateMachine.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace State.GameStateMachine
|
||||||
|
{
|
||||||
|
public class GameStateMachine : StateMachine
|
||||||
|
{
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9fba63db359b4b479a0f0a57ab8ea23b
|
||||||
|
timeCreated: 1755232794
|
||||||
15
Assets/Scripts/State/GameStateMachine/MainMenu.cs
Normal file
15
Assets/Scripts/State/GameStateMachine/MainMenu.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace State.GameStateMachine
|
||||||
|
{
|
||||||
|
public class MainMenu : GameState
|
||||||
|
{
|
||||||
|
public override void OnExit()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/State/GameStateMachine/MainMenu.cs.meta
Normal file
3
Assets/Scripts/State/GameStateMachine/MainMenu.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9325a9be1a54d94affa8809cab91493
|
||||||
|
timeCreated: 1755283250
|
||||||
15
Assets/Scripts/State/GameStateMachine/Paused.cs
Normal file
15
Assets/Scripts/State/GameStateMachine/Paused.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace State.GameStateMachine
|
||||||
|
{
|
||||||
|
public class Paused : GameState
|
||||||
|
{
|
||||||
|
public override void OnExit()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/State/GameStateMachine/Paused.cs.meta
Normal file
3
Assets/Scripts/State/GameStateMachine/Paused.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9beb186523341e5a902cbb6532fc0dd
|
||||||
|
timeCreated: 1755283304
|
||||||
20
Assets/Scripts/State/GameStateMachine/PlayLevel.cs
Normal file
20
Assets/Scripts/State/GameStateMachine/PlayLevel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
namespace State.GameStateMachine
|
||||||
|
{
|
||||||
|
public class PlayLevel : GameState
|
||||||
|
{
|
||||||
|
public override void OnEnter(StateMachine machine)
|
||||||
|
{
|
||||||
|
base.OnEnter(machine);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnExit()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/State/GameStateMachine/PlayLevel.cs.meta
Normal file
3
Assets/Scripts/State/GameStateMachine/PlayLevel.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3b2aa235764e43fe9dc7b8065d3e6711
|
||||||
|
timeCreated: 1755232664
|
||||||
3
Assets/Scripts/State/PlayerStateMachine.meta
Normal file
3
Assets/Scripts/State/PlayerStateMachine.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e3129febb48e4260a4a30eea4cd4e11f
|
||||||
|
timeCreated: 1755285675
|
||||||
13
Assets/Scripts/State/PlayerStateMachine/Idle.cs
Normal file
13
Assets/Scripts/State/PlayerStateMachine/Idle.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace State.PlayerStateMachine
|
||||||
|
{
|
||||||
|
public class Idle : GameState
|
||||||
|
{
|
||||||
|
public override void Handle(Vector2 input)
|
||||||
|
{
|
||||||
|
base.Handle(input);
|
||||||
|
((PlayerStateMachine)StateMachine).controlledPawn.HandleMove(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/State/PlayerStateMachine/Idle.cs.meta
Normal file
3
Assets/Scripts/State/PlayerStateMachine/Idle.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b19fd86c3d7742ba96901825856abc47
|
||||||
|
timeCreated: 1755290059
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace State.PlayerStateMachine
|
||||||
|
{
|
||||||
|
public class PlayerStateMachine : StateMachine
|
||||||
|
{
|
||||||
|
public Pawn controlledPawn;
|
||||||
|
public void Issue(GameState.Command command) => CurrentState?.Handle(command);
|
||||||
|
public void SetMove(Vector2 input)
|
||||||
|
{
|
||||||
|
Debug.Log(input);
|
||||||
|
CurrentState?.Handle(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
ChangeState(new Idle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 12c97df4296b47b5be9ee4ac8df0f08f
|
||||||
|
timeCreated: 1755285683
|
||||||
24
Assets/Scripts/State/StateMachine.cs
Normal file
24
Assets/Scripts/State/StateMachine.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace State
|
||||||
|
{
|
||||||
|
public class StateMachine : MonoBehaviour
|
||||||
|
{
|
||||||
|
public event Action<GameState> OnStateChange;
|
||||||
|
protected GameState CurrentState;
|
||||||
|
|
||||||
|
public void ChangeState(GameState newState)
|
||||||
|
{
|
||||||
|
CurrentState?.OnExit();
|
||||||
|
CurrentState = newState;
|
||||||
|
CurrentState?.OnEnter(this);
|
||||||
|
OnStateChange?.Invoke(CurrentState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
CurrentState?.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/State/StateMachine.cs.meta
Normal file
2
Assets/Scripts/State/StateMachine.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 95ec47d6e54a58f47990e8b4d49ad277
|
||||||
@ -8,6 +8,5 @@ EditorBuildSettings:
|
|||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/Scenes/MainMenu.unity
|
path: Assets/Scenes/MainMenu.unity
|
||||||
guid: 8c9cfa26abfee488c85f1582747f6a02
|
guid: 8c9cfa26abfee488c85f1582747f6a02
|
||||||
m_configObjects:
|
m_configObjects: {}
|
||||||
com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
|
||||||
m_UseUCBPForAssetBundles: 0
|
m_UseUCBPForAssetBundles: 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user