closed #8 유닛 제어 오류 수정

- Unit input system 수정
This commit is contained in:
NTG_Lenovo 2023-09-20 13:54:25 +09:00
parent 462271d683
commit 517dbfde0d
27 changed files with 1385200 additions and 646852 deletions

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ namespace BlueWaterProject
{ {
var gridSize = 0; var gridSize = 0;
switch (pirateUnitStat.SailorCount) switch (pirateUnitStat.PirateAiList.Count)
{ {
case 0: case 0:
gridSize = 1; gridSize = 1;
@ -44,7 +44,7 @@ namespace BlueWaterProject
{ {
var currentPos = i * gridSize + j; var currentPos = i * gridSize + j;
if (currentPos > pirateUnitStat.SailorCount) break; if (currentPos >= pirateUnitStat.PirateAiList.Count) return;
var zOffset = (i - (gridSize - 1) / 2.0f) * UnitManager.Inst.UnitSpacing; var zOffset = (i - (gridSize - 1) / 2.0f) * UnitManager.Inst.UnitSpacing;
var xOffset = (j - (gridSize - 1) / 2.0f) * UnitManager.Inst.UnitSpacing; var xOffset = (j - (gridSize - 1) / 2.0f) * UnitManager.Inst.UnitSpacing;

View File

@ -31,8 +31,9 @@ namespace BlueWaterProject
{ {
var controls = new BlueWater(); var controls = new BlueWater();
controls.Unit.LeftClick.performed += OnLeftClick; controls.Unit.SelectUnit.performed += OnSelectUnit;
controls.Unit.RightClick.performed += OnRightClick; controls.Unit.CancelSelectedUnit.performed += OnCancelSelectedUnit;
controls.Unit.MoveUnit.performed += OnMoveUnit;
controls.Enable(); controls.Enable();
unitLayer = LayerMask.GetMask("Pirate"); unitLayer = LayerMask.GetMask("Pirate");
@ -44,7 +45,7 @@ namespace BlueWaterProject
#region New input system #region New input system
private void OnLeftClick(InputAction.CallbackContext context) private void OnSelectUnit(InputAction.CallbackContext context)
{ {
if (!context.performed || !IsSelectable) return; if (!context.performed || !IsSelectable) return;
@ -111,7 +112,20 @@ namespace BlueWaterProject
} }
} }
private void OnRightClick(InputAction.CallbackContext context) private void OnCancelSelectedUnit(InputAction.CallbackContext context)
{
if (!context.performed || !IsSelectable || SelectedPirateUnit == null) return;
foreach (var pirateAi in SelectedPirateUnit.pirateUnitStat.PirateAiList)
{
pirateAi.ResetHighlight();
}
SelectedPirateUnit = null;
GameManager.Inst.DefaultSpeedMode();
}
private void OnMoveUnit(InputAction.CallbackContext context)
{ {
if (!context.performed || !IsSelectable || SelectedPirateUnit == null) return; if (!context.performed || !IsSelectable || SelectedPirateUnit == null) return;

View File

@ -319,7 +319,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
""id"": ""72deb161-83b9-4d14-8bcf-0bd0c122f76f"", ""id"": ""72deb161-83b9-4d14-8bcf-0bd0c122f76f"",
""actions"": [ ""actions"": [
{ {
""name"": ""LeftClick"", ""name"": ""SelectUnit"",
""type"": ""Button"", ""type"": ""Button"",
""id"": ""2c1978d2-b4be-453a-9413-7b54903dbf38"", ""id"": ""2c1978d2-b4be-453a-9413-7b54903dbf38"",
""expectedControlType"": ""Button"", ""expectedControlType"": ""Button"",
@ -328,7 +328,16 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
""initialStateCheck"": false ""initialStateCheck"": false
}, },
{ {
""name"": ""RightClick"", ""name"": ""CancelSelectedUnit"",
""type"": ""Button"",
""id"": ""952be7b5-8952-47b7-a2db-ced6517d161a"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""MoveUnit"",
""type"": ""Button"", ""type"": ""Button"",
""id"": ""2fe8434e-42e2-4b88-b0b3-0b2b4f8596a8"", ""id"": ""2fe8434e-42e2-4b88-b0b3-0b2b4f8596a8"",
""expectedControlType"": ""Button"", ""expectedControlType"": ""Button"",
@ -344,8 +353,8 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
""path"": ""<Mouse>/leftButton"", ""path"": ""<Mouse>/leftButton"",
""interactions"": """", ""interactions"": """",
""processors"": """", ""processors"": """",
""groups"": """", ""groups"": ""Keyboard&Mouse"",
""action"": ""LeftClick"", ""action"": ""SelectUnit"",
""isComposite"": false, ""isComposite"": false,
""isPartOfComposite"": false ""isPartOfComposite"": false
}, },
@ -355,8 +364,19 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
""path"": ""<Mouse>/rightButton"", ""path"": ""<Mouse>/rightButton"",
""interactions"": """", ""interactions"": """",
""processors"": """", ""processors"": """",
""groups"": """", ""groups"": ""Keyboard&Mouse"",
""action"": ""RightClick"", ""action"": ""MoveUnit"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""e768abd0-e04f-4441-b6b3-09f456041cd8"",
""path"": ""<Keyboard>/escape"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard&Mouse"",
""action"": ""CancelSelectedUnit"",
""isComposite"": false, ""isComposite"": false,
""isPartOfComposite"": false ""isPartOfComposite"": false
} }
@ -410,8 +430,9 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
m_Camera_Rotate = m_Camera.FindAction("Rotate", throwIfNotFound: true); m_Camera_Rotate = m_Camera.FindAction("Rotate", throwIfNotFound: true);
// Unit // Unit
m_Unit = asset.FindActionMap("Unit", throwIfNotFound: true); m_Unit = asset.FindActionMap("Unit", throwIfNotFound: true);
m_Unit_LeftClick = m_Unit.FindAction("LeftClick", throwIfNotFound: true); m_Unit_SelectUnit = m_Unit.FindAction("SelectUnit", throwIfNotFound: true);
m_Unit_RightClick = m_Unit.FindAction("RightClick", throwIfNotFound: true); m_Unit_CancelSelectedUnit = m_Unit.FindAction("CancelSelectedUnit", throwIfNotFound: true);
m_Unit_MoveUnit = m_Unit.FindAction("MoveUnit", throwIfNotFound: true);
} }
public void Dispose() public void Dispose()
@ -637,14 +658,16 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
// Unit // Unit
private readonly InputActionMap m_Unit; private readonly InputActionMap m_Unit;
private List<IUnitActions> m_UnitActionsCallbackInterfaces = new List<IUnitActions>(); private List<IUnitActions> m_UnitActionsCallbackInterfaces = new List<IUnitActions>();
private readonly InputAction m_Unit_LeftClick; private readonly InputAction m_Unit_SelectUnit;
private readonly InputAction m_Unit_RightClick; private readonly InputAction m_Unit_CancelSelectedUnit;
private readonly InputAction m_Unit_MoveUnit;
public struct UnitActions public struct UnitActions
{ {
private @BlueWater m_Wrapper; private @BlueWater m_Wrapper;
public UnitActions(@BlueWater wrapper) { m_Wrapper = wrapper; } public UnitActions(@BlueWater wrapper) { m_Wrapper = wrapper; }
public InputAction @LeftClick => m_Wrapper.m_Unit_LeftClick; public InputAction @SelectUnit => m_Wrapper.m_Unit_SelectUnit;
public InputAction @RightClick => m_Wrapper.m_Unit_RightClick; public InputAction @CancelSelectedUnit => m_Wrapper.m_Unit_CancelSelectedUnit;
public InputAction @MoveUnit => m_Wrapper.m_Unit_MoveUnit;
public InputActionMap Get() { return m_Wrapper.m_Unit; } public InputActionMap Get() { return m_Wrapper.m_Unit; }
public void Enable() { Get().Enable(); } public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); } public void Disable() { Get().Disable(); }
@ -654,22 +677,28 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
{ {
if (instance == null || m_Wrapper.m_UnitActionsCallbackInterfaces.Contains(instance)) return; if (instance == null || m_Wrapper.m_UnitActionsCallbackInterfaces.Contains(instance)) return;
m_Wrapper.m_UnitActionsCallbackInterfaces.Add(instance); m_Wrapper.m_UnitActionsCallbackInterfaces.Add(instance);
@LeftClick.started += instance.OnLeftClick; @SelectUnit.started += instance.OnSelectUnit;
@LeftClick.performed += instance.OnLeftClick; @SelectUnit.performed += instance.OnSelectUnit;
@LeftClick.canceled += instance.OnLeftClick; @SelectUnit.canceled += instance.OnSelectUnit;
@RightClick.started += instance.OnRightClick; @CancelSelectedUnit.started += instance.OnCancelSelectedUnit;
@RightClick.performed += instance.OnRightClick; @CancelSelectedUnit.performed += instance.OnCancelSelectedUnit;
@RightClick.canceled += instance.OnRightClick; @CancelSelectedUnit.canceled += instance.OnCancelSelectedUnit;
@MoveUnit.started += instance.OnMoveUnit;
@MoveUnit.performed += instance.OnMoveUnit;
@MoveUnit.canceled += instance.OnMoveUnit;
} }
private void UnregisterCallbacks(IUnitActions instance) private void UnregisterCallbacks(IUnitActions instance)
{ {
@LeftClick.started -= instance.OnLeftClick; @SelectUnit.started -= instance.OnSelectUnit;
@LeftClick.performed -= instance.OnLeftClick; @SelectUnit.performed -= instance.OnSelectUnit;
@LeftClick.canceled -= instance.OnLeftClick; @SelectUnit.canceled -= instance.OnSelectUnit;
@RightClick.started -= instance.OnRightClick; @CancelSelectedUnit.started -= instance.OnCancelSelectedUnit;
@RightClick.performed -= instance.OnRightClick; @CancelSelectedUnit.performed -= instance.OnCancelSelectedUnit;
@RightClick.canceled -= instance.OnRightClick; @CancelSelectedUnit.canceled -= instance.OnCancelSelectedUnit;
@MoveUnit.started -= instance.OnMoveUnit;
@MoveUnit.performed -= instance.OnMoveUnit;
@MoveUnit.canceled -= instance.OnMoveUnit;
} }
public void RemoveCallbacks(IUnitActions instance) public void RemoveCallbacks(IUnitActions instance)
@ -724,7 +753,8 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
} }
public interface IUnitActions public interface IUnitActions
{ {
void OnLeftClick(InputAction.CallbackContext context); void OnSelectUnit(InputAction.CallbackContext context);
void OnRightClick(InputAction.CallbackContext context); void OnCancelSelectedUnit(InputAction.CallbackContext context);
void OnMoveUnit(InputAction.CallbackContext context);
} }
} }

View File

@ -297,7 +297,7 @@
"id": "72deb161-83b9-4d14-8bcf-0bd0c122f76f", "id": "72deb161-83b9-4d14-8bcf-0bd0c122f76f",
"actions": [ "actions": [
{ {
"name": "LeftClick", "name": "SelectUnit",
"type": "Button", "type": "Button",
"id": "2c1978d2-b4be-453a-9413-7b54903dbf38", "id": "2c1978d2-b4be-453a-9413-7b54903dbf38",
"expectedControlType": "Button", "expectedControlType": "Button",
@ -306,7 +306,16 @@
"initialStateCheck": false "initialStateCheck": false
}, },
{ {
"name": "RightClick", "name": "CancelSelectedUnit",
"type": "Button",
"id": "952be7b5-8952-47b7-a2db-ced6517d161a",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "MoveUnit",
"type": "Button", "type": "Button",
"id": "2fe8434e-42e2-4b88-b0b3-0b2b4f8596a8", "id": "2fe8434e-42e2-4b88-b0b3-0b2b4f8596a8",
"expectedControlType": "Button", "expectedControlType": "Button",
@ -322,8 +331,8 @@
"path": "<Mouse>/leftButton", "path": "<Mouse>/leftButton",
"interactions": "", "interactions": "",
"processors": "", "processors": "",
"groups": "", "groups": "Keyboard&Mouse",
"action": "LeftClick", "action": "SelectUnit",
"isComposite": false, "isComposite": false,
"isPartOfComposite": false "isPartOfComposite": false
}, },
@ -333,8 +342,19 @@
"path": "<Mouse>/rightButton", "path": "<Mouse>/rightButton",
"interactions": "", "interactions": "",
"processors": "", "processors": "",
"groups": "", "groups": "Keyboard&Mouse",
"action": "RightClick", "action": "MoveUnit",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "e768abd0-e04f-4441-b6b3-09f456041cd8",
"path": "<Keyboard>/escape",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "CancelSelectedUnit",
"isComposite": false, "isComposite": false,
"isPartOfComposite": false "isPartOfComposite": false
} }

View File

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

View File

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

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 4ff1f29eab234cf4490d9bb383892c44
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 3643c0d76ec153646b1203880bfb64ed
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 3d7c4217783978e4abe6496ac71eee94
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 697b6e7dea1fde146b7e3e5cf3ed9e9f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 078b8f13a17171b49892ad10426d5af0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 9aacf6f3043624194bb6f6fe9a580786
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 41e59f562b69648719f2424c438758f3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

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

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 5f3f53ee059b45a4d9a5b9fc75e8aea9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 4368c9be31b3c174dbfd80f2caf98889
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 617b3f1032a08c14ebfedfa340767cdf
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 48e08dc33330d11e9d4a1b246c52e4f6
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

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