- bugfix build manager on starter builds not correctly assigning keybinders with defaults - added 2h ranged shoot animation - added shoot animation type for abilities - new weapon visual handler swaps visual weapons based on ability queues
62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
using Photon.Pun;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class WeaponVisualHandler : MonoBehaviour
|
|
{
|
|
public List<WeaponVisualSlot> visualWeaponSlots = new List<WeaponVisualSlot>();
|
|
|
|
PhotonView owner;
|
|
CastingStateController stateController;
|
|
|
|
private void Awake()
|
|
{
|
|
owner = GetComponentInParent<PhotonView>();
|
|
stateController = owner.GetComponentInChildren<CastingStateController>();
|
|
|
|
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
if(owner.IsMine)
|
|
stateController.OnAbilityQueued.AddListener(ToggleCorrectWeapon);
|
|
|
|
}
|
|
|
|
private void ToggleCorrectWeapon(BaseAbility ability)
|
|
{
|
|
|
|
for (int i = 0; i < visualWeaponSlots.Count; i++)
|
|
{
|
|
if(visualWeaponSlots[i].animationTypes.Contains(ability.animationType))
|
|
{
|
|
owner.RPC(nameof(RPC_ToggleCorrectWeapon), RpcTarget.All, i);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
[PunRPC]
|
|
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>();
|
|
} |