From 24ab1b213eb9945c413e7b12997497faf62a4e37 Mon Sep 17 00:00:00 2001 From: sylvermyon Date: Fri, 27 Mar 2026 00:43:59 -0700 Subject: [PATCH] five hundred million if statements --- Assets/Scenes/Game.unity | 92 +++++++++++++++++++ Assets/Scripts/Abilities/AbilityManager.cs | 1 + Assets/Scripts/Abilities/AbilityUIHandler.cs | 16 ++-- Assets/Scripts/AbilitySceneTransfer.cs | 73 ++++++++++++++- .../Scripts/Entities/MarisaAbilityHandler.cs | 65 ++++++------- 5 files changed, 203 insertions(+), 44 deletions(-) diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 339879a..0fcef42 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -21447,6 +21447,46 @@ PrefabInstance: propertyPath: secondaryIcon value: objectReference: {fileID: 1509689679} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: abilities.Array.size + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: hotbarIcons.Array.size + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: 'abilities.Array.data[0]' + value: + objectReference: {fileID: 8579369158027197764, guid: d695e39a8ed83e67aa09d75b33cf7bb3, type: 3} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: 'abilities.Array.data[1]' + value: + objectReference: {fileID: 8579369158027197764, guid: fc8f0e7853997c463b72085306621f40, type: 3} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: 'abilities.Array.data[2]' + value: + objectReference: {fileID: 2212103048918046095, guid: 2d849b52879286a90a56fa3955e0adb6, type: 3} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: 'abilities.Array.data[3]' + value: + objectReference: {fileID: 2202756030888818067, guid: 91297fef450704432837e8de1bda05d7, type: 3} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: 'hotbarIcons.Array.data[0]' + value: + objectReference: {fileID: 8557355471054574495} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: 'hotbarIcons.Array.data[1]' + value: + objectReference: {fileID: 1509689679} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: 'hotbarIcons.Array.data[2]' + value: + objectReference: {fileID: 2040234423} + - target: {fileID: 7002501187268097541, guid: 8764555a5fdde3428903d7ac06f8ff7f, type: 3} + propertyPath: 'hotbarIcons.Array.data[3]' + value: + objectReference: {fileID: 2065550206} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -21576,6 +21616,7 @@ Transform: - {fileID: 1972076835} - {fileID: 1483226599} - {fileID: 1432589379} + - {fileID: 1516594163} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &446769396 @@ -25698,6 +25739,11 @@ MonoBehaviour: allUpgrades: - {fileID: 11400000, guid: 6fe34d7ec95c2ce1fac0727c553b5f0b, type: 2} - {fileID: 11400000, guid: 8ba5b877541778773b0434cf7e36cebb, type: 2} + allAbilities: + - {fileID: 8579369158027197764, guid: d695e39a8ed83e67aa09d75b33cf7bb3, type: 3} + - {fileID: 8579369158027197764, guid: fc8f0e7853997c463b72085306621f40, type: 3} + - {fileID: 2212103048918046095, guid: 2d849b52879286a90a56fa3955e0adb6, type: 3} + - {fileID: 2202756030888818067, guid: 91297fef450704432837e8de1bda05d7, type: 3} --- !u!4 &1432589379 Transform: m_ObjectHideFlags: 0 @@ -26187,6 +26233,52 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 18d0774d0a3b11b43858ef778057d6fe, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!1 &1516594162 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1516594163} + - component: {fileID: 1516594164} + m_Layer: 0 + m_Name: SceneTransferHandler + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1516594163 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1516594162} + 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: 439163859} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1516594164 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1516594162} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 344b6d195bedf2119ae2e445a6511a78, type: 3} + m_Name: + m_EditorClassIdentifier: + savedAbilities: [] + abilityHandler: {fileID: 394036756} --- !u!1 &1527669742 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Abilities/AbilityManager.cs b/Assets/Scripts/Abilities/AbilityManager.cs index 7c0b9bb..0bd8d6a 100644 --- a/Assets/Scripts/Abilities/AbilityManager.cs +++ b/Assets/Scripts/Abilities/AbilityManager.cs @@ -26,6 +26,7 @@ public class AbilityManager : MonoBehaviour public Button upgradeButton; [Header("Upgrades")] public AbilityUpgrade[] allUpgrades; + public PlayerAbility[] allAbilities; public Dictionary upgradesInventory = new(); private void Start() { diff --git a/Assets/Scripts/Abilities/AbilityUIHandler.cs b/Assets/Scripts/Abilities/AbilityUIHandler.cs index a177859..c1c423c 100644 --- a/Assets/Scripts/Abilities/AbilityUIHandler.cs +++ b/Assets/Scripts/Abilities/AbilityUIHandler.cs @@ -54,14 +54,14 @@ public class AbilityUIHandler : MonoBehaviour public void UpdateAbilitySelection() { - uiObjects[0].onClick.AddListener(() => ShowAbilityUI(playerAbilityHandler.mainAttackInstance)); - uiObjects[0].GetComponentInChildren().text = playerAbilityHandler.mainAttackInstance.abilityName; - uiObjects[1].onClick.AddListener(() => ShowAbilityUI(playerAbilityHandler.secondaryAttackInstance)); - uiObjects[1].GetComponentInChildren().text = playerAbilityHandler.secondaryAttackInstance.abilityName; - uiObjects[2].onClick.AddListener(() => ShowAbilityUI(playerAbilityHandler.spellAInstance)); - uiObjects[2].GetComponentInChildren().text = playerAbilityHandler.spellAInstance.abilityName; - uiObjects[3].onClick.AddListener(() => ShowAbilityUI(playerAbilityHandler.spellBInstance)); - uiObjects[3].GetComponentInChildren().text = playerAbilityHandler.spellBInstance.abilityName; + int currentUIObject = 0; + foreach (Button uiObject in uiObjects) + { + var o = currentUIObject; + uiObject.onClick.AddListener(() => ShowAbilityUI(playerAbilityHandler.abilityInstances[o])); + uiObject.GetComponentInChildren().text = playerAbilityHandler.abilityInstances[o].abilityName; + currentUIObject++; + } } public void ShowAbilityUI(PlayerAbility ability) diff --git a/Assets/Scripts/AbilitySceneTransfer.cs b/Assets/Scripts/AbilitySceneTransfer.cs index 5823e11..f61bbfc 100644 --- a/Assets/Scripts/AbilitySceneTransfer.cs +++ b/Assets/Scripts/AbilitySceneTransfer.cs @@ -22,15 +22,80 @@ public class AbilitySceneTransfer : MonoBehaviour [System.Serializable] public class SavedAbility { + public enum AbilitySlot {Primary, Secondary, SpellA, SpellB} + public AbilitySlot abilitySlot = AbilitySlot.Primary; public string abilityName; - public Dictionary equippedUpgrades; + public Dictionary equippedUpgrades = new(); } public List savedAbilities; + public MarisaAbilityHandler abilityHandler; + + [ContextMenu("Save")] + public void TestSaving() + { + int testSlot = 0; + foreach (PlayerAbility ability in abilityHandler.abilityInstances) + { + SaveAbility(ability); + savedAbilities[testSlot].abilitySlot = (SavedAbility.AbilitySlot)testSlot; + testSlot++; + } + } + [ContextMenu("Load")] + public void TestLoading() + { + LoadAbilities(); + } public void SaveAbility(PlayerAbility savedAbility) { - savedAbilities.Add(new SavedAbility + SavedAbility newSavedAbility = new(); + newSavedAbility.abilityName = savedAbility.abilityName; + foreach (AbilityUpgrade upgrade in AbilityManager.instance.allUpgrades) { - abilityName = savedAbility.abilityName - }); + int upgradeCount = savedAbility.GetUpgradeCount(upgrade); + if (upgradeCount > 0) + { + newSavedAbility.equippedUpgrades[upgrade.upgradeName] = upgradeCount; + } + } + savedAbilities.Add(newSavedAbility); + } + + public void LoadAbilities() + { + abilityHandler.abilities.Clear(); + foreach (SavedAbility savedAbility in savedAbilities) + { + PlayerAbility foundAbility = null; + foreach (PlayerAbility ability in AbilityManager.instance.allAbilities) + { + if (savedAbility.abilityName == ability.abilityName) //shit code + { + foundAbility = ability; + return; + } + } + + if (!foundAbility) + { + Debug.LogWarning($"{savedAbility.abilityName} was not found."); + } + switch (savedAbility.abilitySlot) + { + case SavedAbility.AbilitySlot.Primary : + abilityHandler.abilities[0] = foundAbility; + break; + case SavedAbility.AbilitySlot.Secondary : + abilityHandler.abilities[1] = foundAbility; + break; + case SavedAbility.AbilitySlot.SpellA : + abilityHandler.abilities[2] = foundAbility; + break; + case SavedAbility.AbilitySlot.SpellB : + abilityHandler.abilities[3] = foundAbility; + break; + } + } + abilityHandler.SetupAbilities(); } } diff --git a/Assets/Scripts/Entities/MarisaAbilityHandler.cs b/Assets/Scripts/Entities/MarisaAbilityHandler.cs index 95ecf4e..01221a1 100644 --- a/Assets/Scripts/Entities/MarisaAbilityHandler.cs +++ b/Assets/Scripts/Entities/MarisaAbilityHandler.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; @@ -6,62 +7,62 @@ public class MarisaAbilityHandler : MonoBehaviour { [SerializeField] private PlayerInput inputHandler; [SerializeField] private Marisa thisPlayer; + [Header("Abilities")] //maybe have to make them public for when you're changing out abilities - [SerializeField] private PlayerAbility mainAttack; - [SerializeField] private PlayerAbility secondaryAttack; - [SerializeField] private PlayerAbility spellA; - [SerializeField] private PlayerAbility spellB; + public List abilities = new(); [Header("Ability Instances")] - public PlayerAbility mainAttackInstance; - public PlayerAbility secondaryAttackInstance; - public PlayerAbility spellAInstance; - public PlayerAbility spellBInstance; + public List abilityInstances = new(); [Header("UI")] - public AbilityHotbarIcon mainIcon; - public AbilityHotbarIcon secondaryIcon; - public AbilityHotbarIcon spellAIcon; - public AbilityHotbarIcon spellBIcon; + public AbilityHotbarIcon[] hotbarIcons; //this is getting ridiculous private void Awake() { - mainAttackInstance = Instantiate(mainAttack, transform); - mainAttackInstance.thisPlayer = thisPlayer; - mainIcon.UpdateAbility(mainAttackInstance); - secondaryAttackInstance = Instantiate(secondaryAttack, transform); - secondaryAttackInstance.thisPlayer = thisPlayer; - secondaryIcon.UpdateAbility(secondaryAttackInstance); - spellAInstance = Instantiate(spellA, transform); - spellAInstance.thisPlayer = thisPlayer; - spellAIcon.UpdateAbility(spellAInstance); - spellBInstance = Instantiate(spellB, transform); - spellBInstance.thisPlayer = thisPlayer; - spellBIcon.UpdateAbility(spellBInstance); + SetupAbilities(); + } + + public void SetupAbilities() + { + foreach (PlayerAbility oldAbility in abilityInstances) + { + Destroy(oldAbility.gameObject); + } + abilityInstances.Clear(); + int currentAbilityCount = 0; + foreach (PlayerAbility ability in abilities) + { + PlayerAbility newAbility = Instantiate(ability, transform); + abilityInstances.Add(newAbility); + newAbility.thisPlayer = thisPlayer; + hotbarIcons[currentAbilityCount].UpdateAbility(newAbility); + currentAbilityCount++; + Debug.Log(ability.abilityName); + } } private void Update() { if (inputHandler.actions["MainAttack"].inProgress) { - mainAttackInstance.TryAbility(); - mainIcon.UpdateCooldown(); + abilityInstances[0].TryAbility(); + hotbarIcons[0].UpdateCooldown(); } else if (inputHandler.actions["SecondaryAttack"].inProgress) { - secondaryAttackInstance.TryAbility(); - secondaryIcon.UpdateCooldown(); + abilityInstances[1].TryAbility(); + hotbarIcons[1].UpdateCooldown(); } else if (inputHandler.actions["SpellA"].inProgress) { - spellAInstance.TryAbility(); - spellAIcon.UpdateCooldown(); + abilityInstances[2].TryAbility(); + hotbarIcons[2].UpdateCooldown(); } else if (inputHandler.actions["SpellB"].inProgress) { - spellBInstance.TryAbility(); - spellBIcon.UpdateCooldown(); + abilityInstances[3].TryAbility(); + hotbarIcons[3].UpdateCooldown(); } } }