68 lines
2 KiB
C#
68 lines
2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class MarisaAbilityHandler : MonoBehaviour
|
|
{
|
|
[SerializeField] private PlayerInput inputHandler;
|
|
public Marisa thisPlayer;
|
|
|
|
[Header("Abilities")] //maybe have to make them public for when you're changing out abilities
|
|
public List<PlayerAbility> abilities = new();
|
|
|
|
[Header("Ability Instances")]
|
|
public List<PlayerAbility> abilityInstances = new();
|
|
public Dictionary<String, PlayerAbility> instantiatedAbilityLookup = new();
|
|
[Header("UI")]
|
|
public AbilityHotbarIcon[] hotbarIcons;
|
|
//this is getting ridiculous
|
|
|
|
private void Start()
|
|
{
|
|
if (hotbarIcons[0] != null) //bad
|
|
{
|
|
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);
|
|
instantiatedAbilityLookup[ability.abilityName] = ability;
|
|
currentAbilityCount++;
|
|
Debug.Log(ability.abilityName);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (inputHandler.actions["MainAttack"].inProgress)
|
|
{
|
|
abilityInstances[0].TryAbility();
|
|
}
|
|
else if (inputHandler.actions["SecondaryAttack"].inProgress)
|
|
{
|
|
abilityInstances[1].TryAbility();
|
|
}
|
|
else if (inputHandler.actions["SpellA"].inProgress)
|
|
{
|
|
abilityInstances[2].TryAbility();
|
|
}
|
|
else if (inputHandler.actions["SpellB"].inProgress)
|
|
{
|
|
abilityInstances[3].TryAbility();
|
|
}
|
|
}
|
|
}
|