Skip to content

Commit

Permalink
player
Browse files Browse the repository at this point in the history
's actions converted
  • Loading branch information
fernando-cortez committed Jan 11, 2025
1 parent f253378 commit cfe13da
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 67 deletions.
89 changes: 80 additions & 9 deletions Assets/InputSystem/PlayerActions.inputactions
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"name": "Attack",
"type": "Button",
"id": "6c2ab1b8-8984-453a-af3d-a3c78ae1679a",
"expectedControlType": "Button",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
Expand All @@ -36,7 +36,7 @@
"name": "Interact",
"type": "Button",
"id": "852140f2-7766-474d-8707-702459ba45f3",
"expectedControlType": "Button",
"expectedControlType": "",
"processors": "",
"interactions": "Hold",
"initialStateCheck": false
Expand All @@ -45,7 +45,7 @@
"name": "Crouch",
"type": "Button",
"id": "27c5f898-bc57-4ee1-8800-db469aca5fe3",
"expectedControlType": "Button",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
Expand All @@ -54,7 +54,7 @@
"name": "Jump",
"type": "Button",
"id": "f1ba0d36-48eb-4cd5-b651-1c94a6531f70",
"expectedControlType": "Button",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
Expand All @@ -63,7 +63,7 @@
"name": "Previous",
"type": "Button",
"id": "2776c80d-3c14-4091-8c56-d04ced07a2b0",
"expectedControlType": "Button",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
Expand All @@ -72,7 +72,7 @@
"name": "Next",
"type": "Button",
"id": "b7230bb6-fc9b-4f52-8b25-f5e19cb2c2ba",
"expectedControlType": "Button",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
Expand All @@ -81,7 +81,7 @@
"name": "Sprint",
"type": "Button",
"id": "641cd816-40e6-41b4-8c3d-04687c349290",
"expectedControlType": "Button",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
Expand Down Expand Up @@ -193,6 +193,33 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Target",
"type": "Button",
"id": "43b99b7b-ca7a-4ef6-9d13-2751c2d2b3aa",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Skill1",
"type": "Button",
"id": "b97db0db-4f74-415d-99bf-8b754bfa6827",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Point",
"type": "PassThrough",
"id": "577651e7-bedb-409c-bba8-513e74e03e3b",
"expectedControlType": "Vector2",
"processors": "",
"interactions": "",
"initialStateCheck": true
}
],
"bindings": [
Expand Down Expand Up @@ -734,6 +761,50 @@
"action": "ToggleCheats",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "571fb49b-094d-4788-b76c-68863ac01164",
"path": "<Mouse>/leftButton",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "Target",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "8817849f-00f0-4640-a383-abfd3a812ade",
"path": "<Touchscreen>/primaryTouch/tap",
"interactions": "",
"processors": "",
"groups": ";Touch",
"action": "Target",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "03468fd1-8d67-488b-ba05-2dd82ef9c830",
"path": "<Mouse>/rightButton",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "Skill1",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "de7a02bc-5cc4-4d3e-b7f7-3b6ea4e56a69",
"path": "<Mouse>/position",
"interactions": "",
"processors": "",
"groups": "",
"action": "Point",
"isComposite": false,
"isPartOfComposite": false
}
]
},
Expand All @@ -754,7 +825,7 @@
"name": "Submit",
"type": "Button",
"id": "7607c7b6-cd76-4816-beef-bd0341cfe950",
"expectedControlType": "Button",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
Expand All @@ -763,7 +834,7 @@
"name": "Cancel",
"type": "Button",
"id": "15cef263-9014-4fd5-94d9-4e4a6234a6ef",
"expectedControlType": "Button",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
Expand Down
19 changes: 16 additions & 3 deletions Assets/Prefabs/Actions/ClientAoeInput.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2317072454108786653}
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:
- {fileID: 519043390440476}
- {fileID: 7786310081837396287}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8447158110562487606
MonoBehaviour:
Expand All @@ -47,6 +48,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_InRangeVisualization: {fileID: 4372974839826446078}
m_OutOfRangeVisualization: {fileID: 3023808054957408081}
m_PointAction: {fileID: -1959881153152325168, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_TargetAction: {fileID: -2762237389118783121, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
--- !u!1 &3023808054957408081
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -72,12 +75,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3023808054957408081}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.025, z: 0}
m_LocalScale: {x: 0.125, y: 0.125, z: 0.125}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6459207307567452869}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2938808106645325272
MeshFilter:
Expand All @@ -98,11 +102,15 @@ MeshRenderer:
m_CastShadows: 0
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
Expand Down Expand Up @@ -153,12 +161,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4372974839826446078}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.025, z: 0}
m_LocalScale: {x: 0.125, y: 0.125, z: 0.125}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6459207307567452869}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &5292373250812076600
MeshFilter:
Expand All @@ -179,11 +188,15 @@ MeshRenderer:
m_CastShadows: 0
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
Expand Down
4 changes: 3 additions & 1 deletion Assets/Prefabs/Character/PlayerAvatar.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
ShowTopMostFoldoutHeaderGroup: 1
m_ServerCharacter: {fileID: 741733315856861890}
m_TargetAction: {fileID: -2762237389118783121, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_Skill1Action: {fileID: 2701198716142841280, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_PointAction: {fileID: -1959881153152325168, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_Action1: {fileID: 916937064669491580, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_Action2: {fileID: 2288820758043559878, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_Action3: {fileID: 6071755229503605740, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_Action4: {fileID: -4952775069611586389, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_Action5: {fileID: -1289729065238941167, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_Action6: {fileID: -1072022056946843674, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
m_Action7: {fileID: 5111210855846757706, guid: add476edce0d24d26bcdaf1681449ecf, type: 3}
Expand Down
15 changes: 11 additions & 4 deletions Assets/Scripts/Gameplay/Action/Input/AoeActionInput.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Unity.BossRoom.Gameplay.GameplayObjects;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;

namespace Unity.BossRoom.Gameplay.Actions
{
Expand All @@ -18,6 +19,12 @@ public class AoeActionInput : BaseActionInput

[SerializeField]
GameObject m_OutOfRangeVisualization;

[SerializeField]
InputActionReference m_PointAction;

[SerializeField]
InputActionReference m_TargetAction;

Camera m_Camera;

Expand Down Expand Up @@ -45,24 +52,24 @@ void Start()
void Update()
{
// TODO: convert to mouse position using new input system
/*if (PlaneRaycast(k_Plane, m_Camera.ScreenPointToRay(Input.mousePosition), out Vector3 pointOnPlane) &&
if (PlaneRaycast(k_Plane, m_Camera.ScreenPointToRay(m_PointAction.action.ReadValue<Vector2>()), out Vector3 pointOnPlane) &&
NavMesh.SamplePosition(pointOnPlane, out m_NavMeshHit, 2f, NavMesh.AllAreas))
{
transform.position = m_NavMeshHit.position;
}*/
}

float range = GameDataSource.Instance.GetActionPrototypeByID(m_ActionPrototypeID).Config.Range;
bool isInRange = (m_Origin - transform.position).sqrMagnitude <= range * range;
m_InRangeVisualization.SetActive(isInRange);
m_OutOfRangeVisualization.SetActive(!isInRange);

// wait for the player to click down and then release the mouse button before actually taking the input
if (Input.GetMouseButtonDown(0))
if (m_TargetAction.action.WasPressedThisFrame())
{
m_ReceivedMouseDownEvent = true;
}

if (Input.GetMouseButtonUp(0) && m_ReceivedMouseDownEvent)
if (m_TargetAction.action.WasReleasedThisFrame() && m_ReceivedMouseDownEvent)
{
if (isInRange)
{
Expand Down
Loading

0 comments on commit cfe13da

Please sign in to comment.