58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class WeaponVisualHandler : MonoBehaviour
|
|
{
|
|
public List<WeaponVisualSlot> visualWeaponSlots = new List<WeaponVisualSlot>();
|
|
|
|
Taggable owner;
|
|
CastingStateController stateController;
|
|
|
|
private void Awake()
|
|
{
|
|
owner = GetComponentInParent<Taggable>();
|
|
stateController = owner.GetComponentInChildren<CastingStateController>();
|
|
|
|
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
stateController.OnAbilityQueued.AddListener(ToggleCorrectWeapon);
|
|
}
|
|
|
|
private void ToggleCorrectWeapon(BaseAbility ability)
|
|
{
|
|
|
|
for (int i = 0; i < visualWeaponSlots.Count; i++)
|
|
{
|
|
if (visualWeaponSlots[i].animationTypes.Contains(ability.animationType))
|
|
{
|
|
RPC_ToggleCorrectWeapon(i);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void RPC_ToggleCorrectWeapon(int index)
|
|
{
|
|
for (int i = 0; i < visualWeaponSlots.Count; i++)
|
|
{
|
|
for (int j = 0; j < visualWeaponSlots[i].weapons.Count; j++)
|
|
{
|
|
visualWeaponSlots[i].weapons[j].SetActive(i == index);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
[System.Serializable]
|
|
public class WeaponVisualSlot
|
|
{
|
|
public List<AbilityAnimationType> animationTypes = new List<AbilityAnimationType>();
|
|
public List<GameObject> weapons = new List<GameObject>();
|
|
} |