fix upgrades
This commit is contained in:
parent
d8c49317a3
commit
5dcbd3c313
17 changed files with 477 additions and 83 deletions
|
|
@ -15,7 +15,7 @@ public class PlayerAbility : MonoBehaviour
|
|||
[Header("Stats")]
|
||||
public float power;
|
||||
public float projectileCount;
|
||||
public HashSet<AbilityUpgrade> attachedUpgrades = new();
|
||||
public Dictionary<AbilityUpgrade, int> attachedUpgrades = new();
|
||||
|
||||
public void TryAbility()
|
||||
{
|
||||
|
|
@ -37,4 +37,37 @@ public class PlayerAbility : MonoBehaviour
|
|||
currentCooldown -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddUpgrade(AbilityUpgrade upgrade)
|
||||
{
|
||||
if (!attachedUpgrades.ContainsKey(upgrade))
|
||||
{
|
||||
attachedUpgrades[upgrade] = 0;
|
||||
}
|
||||
attachedUpgrades[upgrade]++;
|
||||
upgrade.ApplyUpgrade(this);
|
||||
}
|
||||
|
||||
public bool RemoveUpgrade(AbilityUpgrade upgrade)
|
||||
{
|
||||
if (attachedUpgrades.ContainsKey(upgrade))
|
||||
{
|
||||
attachedUpgrades[upgrade]--;
|
||||
if (attachedUpgrades[upgrade] >= 0)
|
||||
{
|
||||
attachedUpgrades.Remove(upgrade);
|
||||
}
|
||||
upgrade.ApplyRemoval(this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public int GetUpgradeCount(AbilityUpgrade upgrade)
|
||||
{
|
||||
if (!attachedUpgrades.ContainsKey(upgrade))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return attachedUpgrades[upgrade];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue