yeah you're going straight to hell

This commit is contained in:
reisenlol 2026-02-07 11:21:21 -08:00
parent 11d1cbb543
commit e30de274c8
No known key found for this signature in database
15 changed files with 3061 additions and 913 deletions

View file

@ -0,0 +1,66 @@
using System;
using UnityEngine;
using UnityEngine.UI;
public class AbilityManager : MonoBehaviour
{
#region Statication
public static AbilityManager instance;
private void Awake()
{
if (instance != null && instance != this)
{
Destroy(gameObject);
return;
}
instance = this;
}
#endregion
public MarisaAbilityHandler player;
public AbilityUpgrade upgradeToAdd;
public Button upgradeButton;
private void Start()
{
upgradeButton.onClick.AddListener((() => AddUpgrade(upgradeToAdd, player.mainAttackInstance)));
}
public void AddUpgrade(AbilityUpgrade upgrade, PlayerAbility ability)
{
if (!ability.attachedUpgrades.Contains(upgrade))
{
AbilityUpgrade newUpgrade = Instantiate(upgrade, ability.transform);
ability.attachedUpgrades.Add(newUpgrade);
newUpgrade.thisPlayerAbility = ability;
newUpgrade.ApplyUpgrade();
}
else
{
ability.attachedUpgrades.TryGetValue(upgrade, out AbilityUpgrade foundUpgrade);
if (foundUpgrade)
{
foundUpgrade.count++;
foundUpgrade.ApplyUpgrade();
}
}
}
public void RemoveUpgrade(AbilityUpgrade upgrade, PlayerAbility ability)
{
if (ability.attachedUpgrades.TryGetValue(upgrade, out AbilityUpgrade foundUpgrade))
{
if (foundUpgrade.count > 1)
{
foundUpgrade.ApplyRemoval();
foundUpgrade.count--;
}
else
{
foundUpgrade.ApplyRemoval();
ability.attachedUpgrades.Remove(foundUpgrade);
}
}
}
}