// EXECUTABLE: ---------------------------------------------------------------------------- public override IEnumerator Execute(GameObject target, IAction[] actions, int index) { Transform targetTransform = this.target.GetTransform(target); if (targetTransform != null) { if (this.audioClip != null) { AudioMixerGroup voiceMixer = DatabaseGeneral.Load().voiceAudioMixer; AudioManager.Instance.PlayVoice(this.audioClip, 0f, 1f, voiceMixer); } FloatingMessageManager.Show( this.message.GetText(), this.color, targetTransform, this.offset, this.time ); float waitTime = Time.time + this.time; WaitUntil waitUntil = new WaitUntil(() => Time.time > waitTime || this.forceStop); yield return(waitUntil); if (this.audioClip != null) { AudioManager.Instance.StopVoice(this.audioClip); } } yield return(0); }
// EXECUTABLE: ---------------------------------------------------------------------------- public override IEnumerator Execute(GameObject target, IAction[] actions, int index) { this.forceStop = false; if (this.audioClip != null) { AudioMixerGroup voiceMixer = DatabaseGeneral.Load().voiceAudioMixer; AudioManager.Instance.PlayVoice(this.audioClip, 0f, 1f, voiceMixer); } tooltippanel = tooltipPanel.GetComponent <Image>(); tooltipText = tooltipPanel.GetComponentInChildren <Text>(); if (this.tooltippanel != null) { tooltippanel.color = this.panelcolor; } if (this.tooltipText != null) { tooltipText.text = this.message.GetText(); tooltipText.color = this.textcolor; if (this.font != null) { tooltipText.font = font; } else { tooltipText.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); } } tooltipPanel.transform.position = new Vector3( target.transform.position.x + this.offset.x, target.transform.position.y + this.offset.y, target.transform.position.z + this.offset.z ); tooltipPanel.SetActive(true); float waitTime = Time.time + this.time; WaitUntil waitUntil = new WaitUntil(() => Time.time > waitTime || this.forceStop); yield return(waitUntil); if (this.audioClip != null) { AudioManager.Instance.StopVoice(this.audioClip); } tooltipPanel.SetActive(false); yield return(0); }
// INITIALIZE: ---------------------------------------------------------------------------- private static void RequireInit() { if (INITIALIZED) { return; } EventSystemManager.Instance.Wakeup(); ANIMATOR_HASH_CLOSE = Animator.StringToHash("Close"); DatabaseGeneral general = DatabaseGeneral.Load(); PREFAB = general.prefabFloatingMessage; if (PREFAB == null) { PREFAB = Resources.Load <GameObject>(CANVAS_ASSET_PATH); } }
// INITIALIZERS: -------------------------------------------------------------------------- protected override void Awake() { if (!Application.isPlaying) { return; } this.CharacterAwake(); this.initSaveData = new SaveData() { position = transform.position, rotation = transform.rotation, }; if (this.save) { SaveLoadManager.Instance.Initialize( this, (int)SaveLoadManager.Priority.Normal, true ); } HookPlayer hookPlayer = gameObject.GetComponent <HookPlayer>(); if (hookPlayer == null) { gameObject.AddComponent <HookPlayer>(); } if (ON_LOAD_SCENE_DATA != null && ON_LOAD_SCENE_DATA.active) { transform.position = ON_LOAD_SCENE_DATA.position; transform.rotation = ON_LOAD_SCENE_DATA.rotation; ON_LOAD_SCENE_DATA.Consume(); } #if UNITY_EDITOR DatabaseGeneral general = DatabaseGeneral.Load(); if (general.forceDisplayInEditor) { this.forceDisplayTouchstick = general.forceDisplayInEditor; } #endif }
// INITIALIZE: ------------------------------------------------------------------------------------------------- protected override void OnCreate() { EventSystemManager.Instance.Wakeup(); ANIMATOR_HASH_SHOW = Animator.StringToHash("Show"); ANIMATOR_HASH_HIDE = Animator.StringToHash("Hide"); ANIMATOR_HASH_OPEN = Animator.StringToHash("IsOpen"); DatabaseGeneral general = DatabaseGeneral.Load(); GameObject prefab = general.prefabMessage; if (prefab == null) { prefab = Resources.Load <GameObject>(CANVAS_ASSET_PATH); } GameObject instance = Instantiate <GameObject>(prefab, transform); this.messageAnimator = instance.GetComponentInChildren <Animator>(); this.text = instance.GetComponentInChildren <Text>(); }
public void PlayAudio(AudioClip audioClip) { if (audioClip == null) { return; } Vector3 position = transform.position; if (this.muzzle != null) { position = this.muzzle.transform.position; } float pitch = UnityEngine.Random.Range(MIN_RAND_PITCH, MAX_RAND_PITCH); AudioMixerGroup soundMixer = DatabaseGeneral.Load().soundAudioMixer; AudioManager.Instance.PlaySound3D( audioClip, 0f, position, 1f, pitch, 1.0f, soundMixer ); }
// PUBLIC METHODS: ------------------------------------------------------------------------ public void Gibber(int visibleCharacters) { if (Time.time < this.lastGibberTime + MIN_SPACE) { return; } if (this.lastVisibleCharacters == visibleCharacters) { return; } this.RequireAudio(); float volume = AudioManager.Instance.GetGlobalVoiceVolume(); AudioMixerGroup voiceMixer = DatabaseGeneral.Load().voiceAudioMixer; BUFFERS[BUFFER_INDEX].SetPitch(this.pitch + Random.Range(0.0f, this.variation)); BUFFERS[BUFFER_INDEX].Play(this.audioClip, 0f, volume, voiceMixer); BUFFER_INDEX = (++BUFFER_INDEX >= MAX_BUFFERS ? 0 : BUFFER_INDEX); this.lastGibberTime = Time.time; this.lastVisibleCharacters = visibleCharacters; }