- Added placeholder videos for all In Jail animations. - ACME Crimenet Computer now uses more synced values and less network events.
232 lines
5.5 KiB
C#
232 lines
5.5 KiB
C#
|
|
using System.Runtime.InteropServices;
|
|
using System.Runtime.Remoting;
|
|
using TMPro;
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
using VRC.SDK3.Image;
|
|
using VRC.SDK3.UdonNetworkCalling;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon;
|
|
using VRC.Udon.Common.Interfaces;
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class ACMECrimenetComputer : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] private GameManagerRound1 _GameManager;
|
|
[SerializeField] private AudioManager _AudioManager;
|
|
|
|
[Space]
|
|
[SerializeField] private GameObject _ComputerBase;
|
|
[SerializeField] private MeshRenderer _ClueImageCard;
|
|
|
|
[Space]
|
|
|
|
[SerializeField] private Transform _UntranslatedCard;
|
|
[SerializeField] private Transform _UntranslatedCardSpawn;
|
|
[SerializeField] private Transform _UntranslatedCardAnimator;
|
|
[SerializeField] private TextMeshProUGUI _UntranslatedTextGUI;
|
|
|
|
[Space]
|
|
|
|
[SerializeField] private Transform _TranslatedCard;
|
|
[SerializeField] private Transform _TranslatedCardAnimator;
|
|
[SerializeField] private TextMeshProUGUI _TranslatedTextGUI;
|
|
|
|
[Space]
|
|
[SerializeField] private GameObject[] _Interactables;
|
|
|
|
|
|
[UdonSynced, FieldChangeCallback(nameof(Activate))] private bool _Activate = false;
|
|
[UdonSynced, FieldChangeCallback(nameof(UntranslatedText))] private string _UntranslatedText = "";
|
|
[UdonSynced, FieldChangeCallback(nameof(TranslatedText))] private string _TranslatedText = "";
|
|
|
|
[UdonSynced, FieldChangeCallback(nameof(ClueImage))] private int _ClueImage = -1;
|
|
[UdonSynced, FieldChangeCallback(nameof(ClueImageScale))] private float _ClueImageScale = 1.0f;
|
|
|
|
|
|
private VRCImageDownloader _ClueImageDownloader;
|
|
private Texture2D _ClueImageDownload;
|
|
private Animator _Animator;
|
|
|
|
|
|
private void Start()
|
|
{
|
|
_ClueImageDownloader = new VRCImageDownloader();
|
|
_Animator = GetComponent<Animator>();
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
_ClueImageDownloader.Dispose();
|
|
}
|
|
|
|
|
|
private void SetUntranslatedText(string Untranslated)
|
|
{
|
|
_UntranslatedText = Untranslated;
|
|
_UntranslatedTextGUI.text = _UntranslatedText;
|
|
RequestSerialization();
|
|
}
|
|
|
|
private void SetTranslatedText(string Translated)
|
|
{
|
|
_TranslatedText = Translated;
|
|
_TranslatedTextGUI.text = _TranslatedText;
|
|
RequestSerialization();
|
|
}
|
|
|
|
|
|
private void SwooceRightIn()
|
|
{
|
|
_Animator.SetBool("Swooce Right In", true);
|
|
foreach (GameObject Interactable in _Interactables)
|
|
{
|
|
Interactable.SetActive(true);
|
|
}
|
|
|
|
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All, "PlayMusicLoop", MusicEventType.ACMECrimenetComputerIdle);
|
|
|
|
}
|
|
|
|
private void SwooceRightBackOutAgain()
|
|
{
|
|
foreach (GameObject Interactable in _Interactables)
|
|
{
|
|
Interactable.SetActive(false);
|
|
}
|
|
|
|
ClueImageScale = 1.0f;
|
|
|
|
_Animator.SetBool("Swooce Right In", false);
|
|
_Animator.SetBool("Open Compartment", false);
|
|
_Animator.SetBool("Throw Clue Into The Air", false);
|
|
_Animator.SetBool("Run Translator", false);
|
|
|
|
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All, "FadeOutMusic");
|
|
|
|
_ClueImageCard.transform.localPosition = Vector3.zero;
|
|
_ClueImageCard.transform.localRotation = Quaternion.identity;
|
|
|
|
_UntranslatedCard.SetParent(_UntranslatedCardSpawn);
|
|
_UntranslatedCard.localPosition = Vector3.zero;
|
|
_UntranslatedCard.localRotation = Quaternion.identity;
|
|
|
|
_TranslatedCard.SetParent(_TranslatedCardAnimator);
|
|
_TranslatedCard.localPosition = Vector3.zero;
|
|
_TranslatedCard.localRotation = Quaternion.identity;
|
|
}
|
|
|
|
|
|
private void LoadClueImage()
|
|
{
|
|
TextureInfo AdditionalTextureInfo = new TextureInfo();
|
|
AdditionalTextureInfo.WrapModeU = TextureWrapMode.Clamp;
|
|
AdditionalTextureInfo.WrapModeV = TextureWrapMode.Clamp;
|
|
AdditionalTextureInfo.GenerateMipMaps = true;
|
|
_ClueImageDownloader.DownloadImage(
|
|
_GameManager.GetClueImageURL(_ClueImage), null,
|
|
(IUdonEventReceiver)this, AdditionalTextureInfo);
|
|
}
|
|
public override void OnImageLoadSuccess(IVRCImageDownload Result)
|
|
{
|
|
_ClueImageCard.material.SetTexture("_MainTex", Result.Result);
|
|
base.OnImageLoadSuccess(Result);
|
|
}
|
|
|
|
|
|
[NetworkCallable]
|
|
public void OpenCompartment()
|
|
{
|
|
_AudioManager.PlaySFX(SFXEventType.LeverCartoon);
|
|
_Animator.SetBool("Open Compartment", true);
|
|
}
|
|
|
|
[NetworkCallable]
|
|
public void ThrowClueIntoTheAir()
|
|
{
|
|
_AudioManager.PlaySFX(SFXEventType.Boing);
|
|
_Animator.SetBool("Throw Clue Into The Air", true);
|
|
}
|
|
|
|
[NetworkCallable]
|
|
public void RunTranslator()
|
|
{
|
|
_AudioManager.PlaySFX(SFXEventType.Printer);
|
|
|
|
_UntranslatedCard.SetParent(_UntranslatedCardAnimator);
|
|
_UntranslatedCard.localPosition = Vector3.zero;
|
|
_UntranslatedCard.localRotation = Quaternion.identity;
|
|
|
|
_TranslatedCard.SetParent(_TranslatedCardAnimator);
|
|
_TranslatedCard.localPosition = Vector3.zero;
|
|
_TranslatedCard.localRotation = Quaternion.identity;
|
|
|
|
_Animator.SetBool("Run Translator", true);
|
|
}
|
|
|
|
|
|
public bool Activate
|
|
{
|
|
set
|
|
{
|
|
_Activate = value;
|
|
if (_Activate)
|
|
{
|
|
SwooceRightIn();
|
|
}
|
|
else
|
|
{
|
|
SwooceRightBackOutAgain();
|
|
}
|
|
RequestSerialization();
|
|
}
|
|
get => _Activate;
|
|
}
|
|
|
|
public string UntranslatedText
|
|
{
|
|
set
|
|
{
|
|
SetUntranslatedText(value);
|
|
}
|
|
get => _UntranslatedText;
|
|
}
|
|
|
|
public string TranslatedText
|
|
{
|
|
set
|
|
{
|
|
SetTranslatedText(value);
|
|
}
|
|
get => _TranslatedText;
|
|
}
|
|
|
|
public int ClueImage
|
|
{
|
|
set
|
|
{
|
|
if (_ClueImage != value)
|
|
{
|
|
_ClueImage = value;
|
|
LoadClueImage();
|
|
RequestSerialization();
|
|
}
|
|
}
|
|
get => _ClueImage;
|
|
}
|
|
|
|
public float ClueImageScale
|
|
{
|
|
set
|
|
{
|
|
_ClueImageScale = value;
|
|
_ClueImageCard.transform.localScale = new Vector3(_ClueImageScale, _ClueImageScale, _ClueImageScale);
|
|
RequestSerialization();
|
|
}
|
|
get => _ClueImageScale;
|
|
}
|
|
}
|