2020-11-07 21:20:30 +00:00
|
|
|
|
using QSB.Animation;
|
2020-11-09 21:05:50 +00:00
|
|
|
|
using QSB.EventsCore;
|
2020-11-01 12:26:09 +00:00
|
|
|
|
using QSB.Instruments.QSBCamera;
|
2020-11-03 21:33:48 +00:00
|
|
|
|
using QSB.Player;
|
2020-10-27 22:59:19 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Instruments
|
|
|
|
|
{
|
|
|
|
|
public class InstrumentsManager : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public static InstrumentsManager Instance;
|
2020-11-08 19:32:04 +00:00
|
|
|
|
private AnimationType _savedType;
|
2020-10-27 22:59:19 +00:00
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
Instance = this;
|
|
|
|
|
gameObject.AddComponent<CameraManager>();
|
2020-11-11 08:31:20 +00:00
|
|
|
|
|
|
|
|
|
QSBInputManager.ChertTaunt += () => StartInstrument(AnimationType.Chert);
|
|
|
|
|
QSBInputManager.EskerTaunt += () => StartInstrument(AnimationType.Esker);
|
|
|
|
|
QSBInputManager.FeldsparTaunt += () => StartInstrument(AnimationType.Feldspar);
|
|
|
|
|
QSBInputManager.GabbroTaunt += () => StartInstrument(AnimationType.Gabbro);
|
|
|
|
|
QSBInputManager.RiebeckTaunt += () => StartInstrument(AnimationType.Riebeck);
|
|
|
|
|
QSBInputManager.SolanumTaunt += () => StartInstrument(AnimationType.Solanum);
|
2020-11-11 08:56:03 +00:00
|
|
|
|
QSBInputManager.ExitTaunt += () => ReturnToPlayer();
|
2020-11-11 08:31:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
QSBInputManager.ChertTaunt -= () => StartInstrument(AnimationType.Chert);
|
|
|
|
|
QSBInputManager.EskerTaunt -= () => StartInstrument(AnimationType.Esker);
|
|
|
|
|
QSBInputManager.FeldsparTaunt -= () => StartInstrument(AnimationType.Feldspar);
|
|
|
|
|
QSBInputManager.GabbroTaunt -= () => StartInstrument(AnimationType.Gabbro);
|
|
|
|
|
QSBInputManager.RiebeckTaunt -= () => StartInstrument(AnimationType.Riebeck);
|
|
|
|
|
QSBInputManager.SolanumTaunt -= () => StartInstrument(AnimationType.Solanum);
|
2020-11-11 08:56:03 +00:00
|
|
|
|
QSBInputManager.ExitTaunt -= () => ReturnToPlayer();
|
2020-11-11 08:31:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void StartInstrument(AnimationType type)
|
|
|
|
|
{
|
|
|
|
|
if (QSBPlayerManager.LocalPlayer.PlayingInstrument)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_savedType = QSBPlayerManager.LocalPlayer.Animator.CurrentType;
|
|
|
|
|
CameraManager.Instance.SwitchTo3rdPerson();
|
|
|
|
|
SwitchToType(type);
|
2020-10-27 22:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-11 08:31:20 +00:00
|
|
|
|
public void ReturnToPlayer()
|
2020-10-27 22:59:19 +00:00
|
|
|
|
{
|
2020-11-11 08:31:20 +00:00
|
|
|
|
if (!QSBPlayerManager.LocalPlayer.PlayingInstrument)
|
2020-10-27 22:59:19 +00:00
|
|
|
|
{
|
2020-11-11 08:31:20 +00:00
|
|
|
|
return;
|
2020-10-27 22:59:19 +00:00
|
|
|
|
}
|
2020-11-11 08:31:20 +00:00
|
|
|
|
CameraManager.Instance.SwitchTo1stPerson();
|
|
|
|
|
SwitchToType(_savedType);
|
2020-10-27 22:59:19 +00:00
|
|
|
|
}
|
2020-11-01 15:56:48 +00:00
|
|
|
|
|
2020-11-08 19:32:04 +00:00
|
|
|
|
public void SwitchToType(AnimationType type)
|
2020-11-01 15:56:48 +00:00
|
|
|
|
{
|
2020-11-09 21:05:50 +00:00
|
|
|
|
GlobalMessenger<uint, AnimationType>.FireEvent(EventNames.QSBChangeAnimType, QSBPlayerManager.LocalPlayerId, type);
|
2020-11-08 19:32:04 +00:00
|
|
|
|
QSBPlayerManager.LocalPlayer.Animator.SetAnimationType(type);
|
2020-11-01 15:56:48 +00:00
|
|
|
|
}
|
2020-10-27 22:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|