alotta upgrade stuff but no upgrades
This commit is contained in:
parent
b9fb490dce
commit
3b60583c76
35 changed files with 2937 additions and 61 deletions
40
Assets/Scripts/Abilities/AbilityHotbarIcon.cs
Normal file
40
Assets/Scripts/Abilities/AbilityHotbarIcon.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class AbilityHotbarIcon : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject overlay;
|
||||
[SerializeField] private TextMeshProUGUI cooldownText;
|
||||
[SerializeField] private TextMeshProUGUI text;
|
||||
private bool onCooldown;
|
||||
private PlayerAbility thisAbility;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (onCooldown)
|
||||
{
|
||||
cooldownText.text = thisAbility.currentCooldown.ToString("F2");
|
||||
if (thisAbility.currentCooldown <= 0)
|
||||
{
|
||||
onCooldown = false;
|
||||
overlay.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCooldown()
|
||||
{
|
||||
if (thisAbility.currentCooldown > 0)
|
||||
{
|
||||
onCooldown = true;
|
||||
overlay.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAbility(PlayerAbility ability)
|
||||
{
|
||||
thisAbility = ability;
|
||||
text.text = thisAbility.abilityName;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Abilities/AbilityHotbarIcon.cs.meta
Normal file
2
Assets/Scripts/Abilities/AbilityHotbarIcon.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 18d0774d0a3b11b43858ef778057d6fe
|
||||
|
|
@ -31,10 +31,33 @@ public class AbilityManager : MonoBehaviour
|
|||
public Button upgradeButton;
|
||||
|
||||
[Header("Upgrades")]
|
||||
public List<StoredUpgrade> upgradesInventory;
|
||||
public HashSet<StoredUpgrade> upgradesInventory = new();
|
||||
private void Start()
|
||||
{
|
||||
upgradeButton.onClick.AddListener((() => AddUpgrade(upgradeToAdd, player.mainAttackInstance)));
|
||||
// upgradeButton.onClick.AddListener((() => AddUpgrade(upgradeToAdd, player.mainAttackInstance)));
|
||||
}
|
||||
|
||||
public void StoreUpgrade(AbilityUpgrade upgradeToStore)
|
||||
{
|
||||
foreach (StoredUpgrade storedUpgrade in upgradesInventory)
|
||||
{
|
||||
if (storedUpgrade.upgrade == upgradeToStore)
|
||||
{
|
||||
storedUpgrade.count++;
|
||||
Debug.Log($"Added upgrade {storedUpgrade.upgrade.upgradeName}. Current count: {storedUpgrade.count}");
|
||||
AbilityUIHandler.instance.UpdateInventory();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
StoredUpgrade newUpgrade = new()
|
||||
{
|
||||
upgrade = upgradeToStore,
|
||||
count = 1
|
||||
};
|
||||
upgradesInventory.Add(newUpgrade);
|
||||
Debug.Log($"Added upgrade {newUpgrade.upgrade.upgradeName}. Current count: {newUpgrade.count}");
|
||||
AbilityUIHandler.instance.UpdateInventory();
|
||||
}
|
||||
|
||||
public void AddUpgrade(AbilityUpgrade upgrade, PlayerAbility ability)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,29 @@ using UnityEngine;
|
|||
|
||||
public class AbilityUIHandler : MonoBehaviour
|
||||
{
|
||||
public List<AbilityUIObject> uiObjects = new();
|
||||
#region Statication
|
||||
|
||||
public static AbilityUIHandler instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance != null && instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
[Header("Abilities")]
|
||||
public List<AbilityUIObject> uiObjects = new();
|
||||
[SerializeField] private MarisaAbilityHandler playerAbilityHandler;
|
||||
|
||||
[Header("Upgrades")]
|
||||
[SerializeField] private Transform upgradeGrid;
|
||||
[SerializeField] private StoredAbilityUpgradeUI templateStoredUpgradeUI;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
uiObjects[0].thisAbility = playerAbilityHandler.mainAttackInstance;
|
||||
|
|
@ -19,4 +38,17 @@ public class AbilityUIHandler : MonoBehaviour
|
|||
uiObject.UpdateUI();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateInventory()
|
||||
{
|
||||
foreach (Transform child in upgradeGrid) //awful but we'll go with it for now
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
foreach (AbilityManager.StoredUpgrade storedUpgrade in AbilityManager.instance.upgradesInventory)
|
||||
{
|
||||
StoredAbilityUpgradeUI newUI = Instantiate(templateStoredUpgradeUI, upgradeGrid);
|
||||
newUI.SetUpgrade(storedUpgrade.upgrade, storedUpgrade.count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class Laser : PlayerAbility
|
|||
{
|
||||
canCooldown = false;
|
||||
currentDuration = duration;
|
||||
currentCooldown = cooldown;
|
||||
currentDebounce = damageDebounceTime;
|
||||
beamObjectInstance.gameObject.SetActive(true);
|
||||
transform.Lookat2D(thisPlayer.mouseWorldPos);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public class NondirectionalLaser : Laser
|
|||
{
|
||||
canCooldown = false;
|
||||
currentDuration = duration;
|
||||
currentCooldown = cooldown;
|
||||
currentDebounce = damageDebounceTime;
|
||||
beamRoot.gameObject.SetActive(true);
|
||||
}
|
||||
|
|
@ -40,6 +41,7 @@ public class NondirectionalLaser : Laser
|
|||
}
|
||||
currentDebounce = damageDebounceTime;
|
||||
}
|
||||
currentDuration -= Time.deltaTime;
|
||||
}
|
||||
if (currentDuration <= 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class PlayerAbility : MonoBehaviour
|
|||
[Header("Cooldown")]
|
||||
public bool canCooldown = true;
|
||||
public float cooldown;
|
||||
protected float currentCooldown;
|
||||
public float currentCooldown;
|
||||
[Header("Stats")]
|
||||
public float power;
|
||||
public float projectileCount;
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class UpgradePickup : ItemPickup
|
||||
{
|
||||
public AbilityUpgrade upgradeDropped;
|
||||
protected override void PickupEffects()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 414126e6ddc5f8085af89e294a8deb38
|
||||
Loading…
Add table
Add a link
Reference in a new issue