using System; using System.Collections.Generic; using UnityEngine; public class MessageWindowMgr : BaseMgr { public void ForceDisableWindow(bool f_bDisable) { this.m_bForceDisable = f_bDisable; if (f_bDisable) { this.CloseMessageWindowPanel(); } } public bool IsVisibleMessageViewer { get { return this.m_goMessageViewer.activeInHierarchy; } } public void Awake() { GameObject gameObject = GameObject.Find("__GameMain__/SystemUI Root"); this.m_goMessageWindowPanel = gameObject.transform.Find("MessageWindowPanel").gameObject; if (this.m_goMessageWindowPanel == null) { Debug.LogError(string.Format("{0}が見つかりませんでした", "MessageWindowPanel")); return; } this.m_goMessageViewer = UTY.GetChildObject(this.m_goMessageWindowPanel, "MessageViewer", false); this.message_bg_ = UTY.GetChildObject(this.m_goMessageWindowPanel, "MessageViewer/MsgParent/MessageBox", false).GetComponent(); Transform transform = gameObject.transform.Find("MessageWindowPanel/MessageViewer/MsgParent/Buttons"); MessageWindowMgr.MessageWindowUnderButton[] array = new MessageWindowMgr.MessageWindowUnderButton[] { MessageWindowMgr.MessageWindowUnderButton.Skip, MessageWindowMgr.MessageWindowUnderButton.Auto, MessageWindowMgr.MessageWindowUnderButton.Voice, MessageWindowMgr.MessageWindowUnderButton.BackLog, MessageWindowMgr.MessageWindowUnderButton.Config }; foreach (MessageWindowMgr.MessageWindowUnderButton key in array) { string text = key.ToString(); GameObject gameObject2 = transform.Find(text).gameObject; if (gameObject2 == null) { NDebug.Assert(text + "が見つかりませんでした", false); return; } this.m_dicButtonGameObject.Add(key, new MessageWindowMgr.SystemButton(gameObject2)); } this.m_messageWindowCtrl = this.m_goMessageWindowPanel.GetComponent(); this.m_messageWindowCtrl.Init(this.m_goMessageWindowPanel); this.m_goMessageWindowPanel.SetActive(false); this.message_ = new MessageClass(this.m_goMessageWindowPanel, this); this.on_click_event_ = new MessageWindowMgr.OnClickEvent(GameMain.Instance.ScriptMgr.adv_kag.OnClickEvent); if (GameMain.Instance.VRMode) { GameObject childObject = UTY.GetChildObject(this.m_goMessageViewer, "MsgParent", false); this.m_vBackMsgParentPos = childObject.transform.localPosition; this.m_vBackMsgParentScale = childObject.transform.localScale; } } public bool IsClickAction() { return this.m_goMessageWindowPanel.activeSelf && !this.m_messageWindowCtrl.IsDisplayBackLog() && !BaseMgr.Instance.IsOpenConfigPanel(); } public void Update() { if (this.m_bForceDisable) { return; } if (this.m_goMessageWindowPanel.activeSelf) { float alpha = (float)(100 - GameMain.Instance.CMSystem.MsgWndAlpha) / 100f; this.message_bg_.alpha = alpha; } this.message_.Update(); if (GameMain.Instance.VRMode && this.m_bVRControllerNew != GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew) { GameObject childObject = UTY.GetChildObject(this.m_goMessageViewer, "MsgParent", false); if (GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew) { childObject.transform.localPosition = new Vector3(0f, 70f, 0f); childObject.transform.localScale = new Vector3(2f, 2f, 1f); } else { childObject.transform.localPosition = this.m_vBackMsgParentPos; childObject.transform.localScale = this.m_vBackMsgParentScale; } this.m_bVRControllerNew = GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew; } this.m_messageWindowCtrl.VRUIModeCheck(); if (this.m_messageWindowCtrl.IsDisplayBackLog() && this.m_goMessageWindowPanel.activeSelf) { if (!BaseMgr.Instance.IsOpenConfigPanel() && NInput.GetMouseButtonUp(1)) { this.CloseBacklog(); } else { Vector3 vector = Input.mouseScrollDelta; this.m_messageWindowCtrl.ScrollDisplayBackLog(vector.y); } } else { bool keyDown = Input.GetKeyDown(KeyCode.Return); if ((NInput.GetMouseButtonUp(0) && UICamera.isFallThrough) || keyDown) { this.ClickMessageBox(keyDown); } } } public void ClickMessageBox(bool is_leftclick_emulate) { if (this.m_bForceDisable) { return; } if (BaseMgr.Instance.IsOpenConfigPanel()) { return; } if (NInput.GetMouseButtonUp(0) || is_leftclick_emulate) { if (this.IsClickAction()) { if (this.m_goMessageViewer.activeSelf) { if (this.on_click_event_ != null) { this.on_click_event_(); } } else { this.SetMessageViewerActive(true); } } } else if (NInput.GetMouseButtonUp(1)) { if (GameMain.Instance.ScriptMgr.adv_kag.GetSettingSkipMode()) { this.CallEvent(MessageWindowMgr.MessageWindowUnderButton.Skip); } else if (this.m_goMessageWindowPanel.activeSelf && this.m_goMessageViewer.activeSelf) { if (this.m_messageWindowCtrl.IsDisplayBackLog()) { this.CloseBacklog(); } else { this.SetMessageViewerActive(false); } } } } public void ClickMessageWindowUnderButton() { MessageWindowMgr.MessageWindowUnderButton type = (MessageWindowMgr.MessageWindowUnderButton)Enum.Parse(typeof(MessageWindowMgr.MessageWindowUnderButton), UIButton.current.name); this.CallEvent(type); } public void CancelSkipAndAuto() { if (GameMain.Instance.ScriptMgr.adv_kag.GetSettingSkipMode()) { this.CallEvent(MessageWindowMgr.MessageWindowUnderButton.Skip); } if (GameMain.Instance.ScriptMgr.adv_kag.auto_mode) { this.CallEvent(MessageWindowMgr.MessageWindowUnderButton.Auto); } } public void CallEvent(MessageWindowMgr.MessageWindowUnderButton type) { if (this.m_messageWindowCtrl.IsSelectButtonPlayingEffect() || BaseMgr.Instance.IsOpenConfigPanel()) { return; } switch (type) { case MessageWindowMgr.MessageWindowUnderButton.Skip: { bool settingSkipMode = GameMain.Instance.ScriptMgr.adv_kag.GetSettingSkipMode(); this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Skip].select = !settingSkipMode; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Auto].enabled = settingSkipMode; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = settingSkipMode; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.BackLog].enabled = settingSkipMode; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Config].enabled = settingSkipMode; GameMain.Instance.ScriptMgr.adv_kag.SetSettingSkipMode(!settingSkipMode); if (this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled) { this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = !string.IsNullOrEmpty(this.current_voice_file_); } break; } case MessageWindowMgr.MessageWindowUnderButton.Auto: { bool auto_mode = GameMain.Instance.ScriptMgr.adv_kag.auto_mode; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Auto].select = !auto_mode; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Skip].enabled = auto_mode; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = auto_mode; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.BackLog].enabled = auto_mode; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Config].enabled = auto_mode; GameMain.Instance.ScriptMgr.adv_kag.auto_mode = !auto_mode; if (this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled) { this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = !string.IsNullOrEmpty(this.current_voice_file_); } break; } case MessageWindowMgr.MessageWindowUnderButton.Voice: if (!string.IsNullOrEmpty(this.current_voice_file_)) { GameMain.Instance.SoundMgr.VoiceStopAll(); GameMain.Instance.SoundMgr.PlayDummyVoice(this.current_voice_file_, 0f, false, false, this.current_voice_pitch_, this.sound_type_); } break; case MessageWindowMgr.MessageWindowUnderButton.BackLog: this.OpenBacklog(); break; case MessageWindowMgr.MessageWindowUnderButton.Config: if (!BaseMgr.Instance.IsOpenConfigPanel()) { BaseMgr.Instance.OpenConfigPanel(); } break; default: Debug.LogError("不適切なボタンがクリックされました。"); break; } } public void ClickBackLogClose() { if (UICamera.currentTouchID != -2) { return; } this.CloseBacklog(); } public void CreateSelectButtons(List>> dicSelectButton, Action onClickCallBack) { this.m_messageWindowCtrl.CreateSelectButtons(dicSelectButton, onClickCallBack); } public void CreateBacklog(List dicBacklog) { this.m_messageWindowCtrl.CreateBacklog(dicBacklog); } public void SetMessageViewerActive(bool value) { if (this.m_bForceDisable) { value = false; } this.m_goMessageViewer.SetActive(value); this.m_messageWindowCtrl.GetSelectButtonCtrl().SetPanelAlpha((float)((!value) ? 0 : 1)); } public void OpenMessageWindowPanel() { if (this.m_bForceDisable) { return; } if (!this.m_goMessageWindowPanel.activeSelf) { this.m_messageWindowCtrl.DisplayBacklog(false); this.m_goMessageWindowPanel.SetActive(true); } } public void CloseMessageWindowPanel() { this.message_.Clear(); this.m_messageWindowCtrl.ClearSelectBtn(); this.m_goMessageWindowPanel.SetActive(false); } private void OpenBacklog() { if (this.m_bForceDisable) { return; } this.backup_camera_control_ = GameMain.Instance.MainCamera.GetControl(); GameMain.Instance.MainCamera.SetControl(false); this.m_messageWindowCtrl.DisplayBacklog(true); this.CreateBacklog(this.m_listBacklogUnit); this.m_goMessageWindowPanel.SetActive(true); } public void CloseBacklog() { GameMain.Instance.MainCamera.SetControl(this.backup_camera_control_); this.m_messageWindowCtrl.DisplayBacklog(false); this.m_goMessageWindowPanel.SetActive(true); } public void AddBackLog(string name, string text, string voice_file, int pitch, AudioSourceMgr.Type type) { this.AddBackLog(name, text, string.Empty, voice_file, pitch, type); } public void AddBackLog(string name, string text, string subtitle_text, string voice_file, int pitch, AudioSourceMgr.Type type) { BacklogCtrl.BacklogUnit backlogUnit = new BacklogCtrl.BacklogUnit(); backlogUnit.m_speakerName = name; backlogUnit.m_msg = text; backlogUnit.m_subtitlemsg = subtitle_text; backlogUnit.m_voiceId = voice_file; backlogUnit.m_voicePitch = pitch; backlogUnit.m_voiceType = type; this.m_listBacklogUnit.Add(backlogUnit); if (30 < this.m_listBacklogUnit.Count) { this.m_listBacklogUnit.RemoveAt(0); } } public void SetText(string name, string text, string voice_file, int voice_pitch, AudioSourceMgr.Type sound_type) { if (this.m_bForceDisable) { return; } this.message_.SetText(name, text, voice_file, voice_pitch, sound_type); this.current_voice_file_ = voice_file; this.current_voice_pitch_ = voice_pitch; this.sound_type_ = sound_type; this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = !string.IsNullOrEmpty(this.current_voice_file_); } public void ClearText() { this.current_voice_file_ = string.Empty; this.current_voice_pitch_ = 50; this.sound_type_ = AudioSourceMgr.Type.Voice; this.message_.Clear(); this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = false; } public void ClearBackLogData() { this.m_listBacklogUnit.Clear(); } public void FinishChAnime() { this.message_.FinishChAnime(); } public int GetExitWaitCount() { return this.message_.GetExitWaitCount(); } public bool IsChAnimeEnabled() { return this.message_.ch_anime_enabled; } public const int kBackLogSaveUnit = 30; public MessageWindowMgr.OnClickEvent on_click_event_; private bool m_bForceDisable; private Dictionary m_dicButtonGameObject = new Dictionary(); private bool m_bVRControllerNew; private Vector3 m_vBackMsgParentPos; private Vector3 m_vBackMsgParentScale; private GameObject m_goMessageViewer; private GameObject m_goMessageWindowPanel; private MessageWindowCtrl m_messageWindowCtrl; private List m_listBacklogUnit = new List(); private UISprite message_bg_; private MessageClass message_; private string current_voice_file_ = string.Empty; private int current_voice_pitch_ = 50; private AudioSourceMgr.Type sound_type_ = AudioSourceMgr.Type.Voice; private bool backup_camera_control_; public delegate void OnClickEvent(); public enum MessageWindowUnderButton { None = -1, Skip, Auto, Voice, BackLog, Config } private class SystemButton { public SystemButton(GameObject obj) { this.game_object_ = obj; this.button_ = this.game_object_.GetComponent(); this.select_color_ = (this.default_color_ = this.button_.defaultColor); this.select_color_.a = 1f; this.is_select_ = false; } public bool enabled { get { return this.button_.isEnabled; } set { this.button_.isEnabled = value; if (!value) { this.select = false; } } } public bool select { get { return this.is_select_; } set { if (this.is_select_ == value) { return; } if (value) { this.button_.isEnabled = true; this.button_.defaultColor = this.select_color_; } else { this.button_.defaultColor = this.default_color_; } this.button_.UpdateColor(false); this.is_select_ = value; } } private GameObject game_object_; private UIButton button_; private bool is_select_; private Color default_color_; private Color select_color_; } }