using UnityEngine;
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Character.Abilities.Items;
public class TPCInventoryManager : MonoBehaviour {
[SerializeField] protected GameObject m_Player;
[SerializeField] protected UltimateCharacterLocomotion m_CharacterLocomotion;
void Awake() {
if(m_Player != null) {
// Get a reference to UltimateCharacterLocomotion component and register the SwitchWeaponsKeyPressed event
m_CharacterLocomotion = m_Player.GetComponent<UltimateCharacterLocomotion> ();
EventHandler.RegisterEvent ("SwitchWeaponsKeyPressed", SwitchToNextWeapon);
} else {
// Or die...
Debug.Log ("m_Player in TPCInventoryManager on: " + gameObject.name + ", has not been set, disabling...");
this.enabled = false;
}
}
public void SwitchToNextWeapon()
{
Debug.Log ("Called SwitchToNextWeapon function in TPCInventoryManager");
// Roll that beautiful CharacterLocomotion footage!
if(m_CharacterLocomotion != null) {
var equipNext = m_CharacterLocomotion.GetAbility <EquipNext>();
if(equipNext != null) {
m_CharacterLocomotion.TryStartAbility (equipNext);
}
}
}
}