2020-11-01 12:26:09 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Instruments.QSBCamera;
|
2020-10-27 22:59:19 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Instruments
|
|
|
|
|
{
|
|
|
|
|
public class InstrumentsManager : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public static InstrumentsManager Instance;
|
2020-11-02 22:15:46 +00:00
|
|
|
|
private RuntimeAnimatorController RiebeckController;
|
|
|
|
|
private RuntimeAnimatorController ChertController;
|
|
|
|
|
private RuntimeAnimatorController GabbroController;
|
|
|
|
|
private RuntimeAnimatorController FeldsparController;
|
2020-10-27 22:59:19 +00:00
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
Instance = this;
|
|
|
|
|
gameObject.AddComponent<CameraManager>();
|
2020-11-02 22:15:46 +00:00
|
|
|
|
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSceneLoaded(OWScene scene, bool inUniverse)
|
|
|
|
|
{
|
|
|
|
|
var reibeckRoot = GameObject.Find("Traveller_HEA_Riebeck_ANIM_Talking");
|
|
|
|
|
RiebeckController = reibeckRoot.GetComponent<Animator>().runtimeAnimatorController;
|
|
|
|
|
var chertRoot = GameObject.Find("Traveller_HEA_Chert_ANIM_Chatter_Chipper");
|
|
|
|
|
ChertController = chertRoot.GetComponent<Animator>().runtimeAnimatorController;
|
|
|
|
|
var gabbroRoot = GameObject.Find("Traveller_HEA_Gabbro_ANIM_IdleFlute");
|
|
|
|
|
GabbroController = gabbroRoot.GetComponent<Animator>().runtimeAnimatorController;
|
|
|
|
|
var feldsparRoot = GameObject.Find("Traveller_HEA_Feldspar_ANIM_Talking");
|
|
|
|
|
FeldsparController = feldsparRoot.GetComponent<Animator>().runtimeAnimatorController;
|
2020-10-27 22:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.Keypad9))
|
|
|
|
|
{
|
2020-11-01 12:26:09 +00:00
|
|
|
|
if (!PlayerRegistry.LocalPlayer.PlayingInstrument)
|
|
|
|
|
{
|
|
|
|
|
CameraManager.Instance.SwitchTo3rdPerson();
|
2020-11-02 22:15:46 +00:00
|
|
|
|
SwitchToInstrument(InstrumentType.RIEBECK);
|
|
|
|
|
var animator = Locator.GetPlayerTransform().Find("Traveller_HEA_Player_v2").GetComponent<Animator>();
|
|
|
|
|
animator.runtimeAnimatorController = ChertController;
|
|
|
|
|
animator.SetTrigger("Playing");
|
2020-11-01 12:26:09 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CameraManager.Instance.SwitchTo1stPerson();
|
2020-11-01 15:56:48 +00:00
|
|
|
|
SwitchToInstrument(InstrumentType.NONE);
|
2020-11-01 12:26:09 +00:00
|
|
|
|
}
|
2020-10-27 22:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-01 15:56:48 +00:00
|
|
|
|
|
|
|
|
|
public void SwitchToInstrument(InstrumentType type)
|
|
|
|
|
{
|
|
|
|
|
PlayerRegistry.LocalPlayer.CurrentInstrument = type;
|
|
|
|
|
GlobalMessenger<InstrumentType>.FireEvent(EventNames.QSBPlayInstrument, type);
|
|
|
|
|
}
|
2020-10-27 22:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|