From 606b349c921ea31f44067502f5f93aab48769629 Mon Sep 17 00:00:00 2001 From: Yann Dupont 01 Date: Fri, 1 Apr 2022 23:52:36 -0400 Subject: [PATCH] Minion bar cont'd --- Assets/Prefabs/Minion Icon.prefab | 4 +- Assets/Scenes/YannTest.unity | 210 +++++++++--------- Assets/Scripts/UI/MinionBar.cs | 24 +- .../Settings/ConjureLudumDare50.inputactions | 75 +++++++ 4 files changed, 203 insertions(+), 110 deletions(-) diff --git a/Assets/Prefabs/Minion Icon.prefab b/Assets/Prefabs/Minion Icon.prefab index 17ed4b4..03ced9a 100644 --- a/Assets/Prefabs/Minion Icon.prefab +++ b/Assets/Prefabs/Minion Icon.prefab @@ -52,8 +52,8 @@ MonoBehaviour: m_EditorClassIdentifier: icon: {fileID: 1979632679604795359} indexInMinionList: 0 - selectedColor: {r: 1, g: 1, b: 1, a: 0} - unSelectedColor: {r: 0.6792453, g: 0.6792453, b: 0.6792453, a: 0} + selectedColor: {r: 1, g: 1, b: 1, a: 1} + unSelectedColor: {r: 0.6792453, g: 0.6792453, b: 0.6792453, a: 1} --- !u!1 &1979632679258755678 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/YannTest.unity b/Assets/Scenes/YannTest.unity index 972caa8..0e0fe87 100644 --- a/Assets/Scenes/YannTest.unity +++ b/Assets/Scenes/YannTest.unity @@ -209,6 +209,7 @@ GameObject: - component: {fileID: 1302468887} - component: {fileID: 1302468889} - component: {fileID: 1302468888} + - component: {fileID: 1302468890} m_Layer: 5 m_Name: Minion Bar m_TagString: Untagged @@ -226,8 +227,7 @@ RectTransform: 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_Children: - - {fileID: 1739165038} + m_Children: [] m_Father: {fileID: 2126071660} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -274,8 +274,110 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 81a29b049c6380f4abb3c18ed121efcd, type: 3} m_Name: m_EditorClassIdentifier: - minionTypes: [] + minionTypes: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} minionIconPrefab: {fileID: 1979632678310270257, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} +--- !u!114 &1302468890 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1302468886} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Actions: {fileID: -944628639613478452, guid: 3f999e92409efaa4fa202b3263fc7ba4, type: 3} + m_NotificationBehavior: 2 + 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_PersistentCalls: + m_Calls: [] + m_ActionId: 1071c237-0382-46b6-9750-c39a686354f8 + m_ActionName: Player/Move[/Keyboard/w,/Keyboard/upArrow,/Keyboard/s,/Keyboard/downArrow,/Keyboard/a,/Keyboard/leftArrow,/Keyboard/d,/Keyboard/rightArrow] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: eefb12f1-0980-4e79-a169-5b8d9c5f8909 + m_ActionName: Player/Jump[/Keyboard/space] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: bd3662a8-0f8c-46c3-a035-be5ce123a673 + m_ActionName: Player/Suck[/Keyboard/e] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: bba4f6e1-6e22-4374-b248-2e5bc19a3705 + m_ActionName: UI/Navigate[/Keyboard/w,/Keyboard/upArrow,/Keyboard/s,/Keyboard/downArrow,/Keyboard/a,/Keyboard/leftArrow,/Keyboard/d,/Keyboard/rightArrow] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: f0db3b44-2fa0-4228-9bca-9c384c0d12c6 + m_ActionName: UI/Submit[/Keyboard/enter] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: baf9b26e-f035-4332-98a0-35730b6f70c8 + m_ActionName: UI/Cancel[/Keyboard/escape] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: 17b66829-f839-44f5-9544-2693e69f7dea + m_ActionName: UI/Point[/Mouse/position] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: 1ebf91c2-c166-4c56-84b5-b441c4bc0788 + m_ActionName: UI/Click[/Mouse/leftButton] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: e6c07a73-7275-4cad-b986-88f211037618 + m_ActionName: UI/ScrollWheel[/Mouse/scroll] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: 2664e5d8-ab63-41f4-b614-5aaa91e73447 + m_ActionName: UI/MiddleClick[/Mouse/middleButton] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: 056609de-e1b8-4db5-be6d-089e2e870adf + m_ActionName: UI/RightClick[/Mouse/rightButton] + - m_PersistentCalls: + m_Calls: [] + m_ActionId: e6b3fe0b-f8c4-43f6-8c25-939569ff5b0e + m_ActionName: UI/TrackedDevicePosition + - m_PersistentCalls: + m_Calls: [] + m_ActionId: 6e7e8be9-9198-4490-bb0c-a25fa63601b6 + m_ActionName: UI/TrackedDeviceOrientation + - m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1302468889} + m_TargetAssemblyTypeName: MinionBar, Assembly-CSharp + m_MethodName: ChangeSelectedIcon + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_ActionId: d0405457-c534-4103-a0b6-cf113432b467 + m_ActionName: Player/SwitchMinion[/Keyboard/q,/Keyboard/e,/XInputControllerWindows/leftShoulder,/XInputControllerWindows/rightShoulder] + m_NeverAutoSwitchControlSchemes: 0 + m_DefaultControlScheme: + m_DefaultActionMap: Player + m_SplitScreenIndex: -1 + m_Camera: {fileID: 0} --- !u!1 &1612282031 GameObject: m_ObjectHideFlags: 0 @@ -359,11 +461,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!224 &1739165038 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - m_PrefabInstance: {fileID: 1979632678971496540} - m_PrefabAsset: {fileID: 0} --- !u!1 &2126071656 GameObject: m_ObjectHideFlags: 0 @@ -464,100 +561,3 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} ---- !u!1001 &1979632678971496540 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 1302468887} - m_Modifications: - - target: {fileID: 1979632678310270257, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_Name - value: Minion Icon - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_Pivot.x - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_Pivot.y - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_RootOrder - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_AnchorMax.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_AnchorMin.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_SizeDelta.x - value: 60 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_SizeDelta.y - value: 60 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1979632678310270258, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 2fee1ea5c97c5a04bb2c5f1f685fc92e, type: 3} diff --git a/Assets/Scripts/UI/MinionBar.cs b/Assets/Scripts/UI/MinionBar.cs index 69886a7..48d5b84 100644 --- a/Assets/Scripts/UI/MinionBar.cs +++ b/Assets/Scripts/UI/MinionBar.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.InputSystem; public class MinionBar : MonoBehaviour { @@ -17,15 +18,32 @@ public class MinionBar : MonoBehaviour { minionIcons[i] = newIconObj.GetComponent(); // minionIcons[i].icon = minionTypes.icon; // TODO minionIcons[i].indexInMinionList = i; - minionIcons[currentIndex].UnSelect(); + minionIcons[i].UnSelect(); } minionIcons[currentIndex].Select(); } - public void ChangeSelectedIcon(int delta) { + public void ChangeSelectedIcon(InputAction.CallbackContext context) { + + float floatDelta = context.ReadValue(); + int delta = 0; + if(floatDelta > 0.5f) { + delta = 1; + } else if(floatDelta < -0.5f) { + delta = -1; + } + minionIcons[currentIndex].UnSelect(); - currentIndex = (currentIndex + delta) % minionTypes.Length; + + currentIndex += delta; + if(currentIndex >= minionIcons.Length) { + currentIndex = 0; + } else if(currentIndex < 0) { + currentIndex = minionIcons.Length - 1; + } + minionIcons[currentIndex].Select(); + // print("new selected minion type : " + currentIndex.ToString()); } public Object GetCurrentMinion() { diff --git a/Assets/Settings/ConjureLudumDare50.inputactions b/Assets/Settings/ConjureLudumDare50.inputactions index 83d2d17..92bc982 100644 --- a/Assets/Settings/ConjureLudumDare50.inputactions +++ b/Assets/Settings/ConjureLudumDare50.inputactions @@ -31,6 +31,15 @@ "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "SwitchMinion", + "type": "PassThrough", + "id": "d0405457-c534-4103-a0b6-cf113432b467", + "expectedControlType": "Axis", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -209,6 +218,72 @@ "action": "Suck", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "QE", + "id": "7f731b6b-09d5-4df1-88b2-d5f24f5fdd8f", + "path": "1DAxis", + "interactions": "", + "processors": "", + "groups": "", + "action": "SwitchMinion", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "negative", + "id": "92a7acbf-263d-4b34-9b92-b4fd097ac639", + "path": "/q", + "interactions": "", + "processors": "", + "groups": "", + "action": "SwitchMinion", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "positive", + "id": "c12b1f77-64b3-4626-8f69-02f43f77a73a", + "path": "/e", + "interactions": "", + "processors": "", + "groups": "", + "action": "SwitchMinion", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "Bumpers", + "id": "c2a550ee-5ab5-4368-8e31-d29870aa7be0", + "path": "1DAxis", + "interactions": "", + "processors": "", + "groups": "", + "action": "SwitchMinion", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "negative", + "id": "1a0d3183-498e-4a7f-bf51-8b9dd889e653", + "path": "/leftShoulder", + "interactions": "", + "processors": "", + "groups": "", + "action": "SwitchMinion", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "positive", + "id": "c1f320ef-6e29-4026-a29d-74e1fea256cb", + "path": "/rightShoulder", + "interactions": "", + "processors": "", + "groups": "", + "action": "SwitchMinion", + "isComposite": false, + "isPartOfComposite": true } ] },