yeah you're going straight to hell
This commit is contained in:
parent
11d1cbb543
commit
e30de274c8
15 changed files with 3061 additions and 913 deletions
66
Assets/Scripts/AbilityManager.cs
Normal file
66
Assets/Scripts/AbilityManager.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue