using System; using System.Collections; using System.Collections.Generic; using PrivateMaidMode; using UnityEngine; using wf; public class PrivateMaidTouchManager : MonoBehaviour { public int currentExcitement { get; private set; } public int currentMood { get; private set; } public Maid maid { get; private set; } public TouchDataBase.Data playTouchData { get; private set; } private void Awake() { PrivateMaidTouchManager.instance = this; this.subtitleDisplay.visible = false; if (!Product.supportMultiLanguage) { this.subtitleDisplay.autoDisplayTypeChange = false; } this.subtitleDisplay.displayType = SubtitleDisplayManager.DisplayType.Original; this.uiPanel.alpha = 0f; } private void Start() { if (ScenePrivateEventModeAwake.callEventId != -1) { this.CallTouchMode(GameMain.Instance.CharacterMgr.GetMaid(0), ScenePrivateEventModeAwake.callEventId); } } protected IEnumerator Setup() { this.setupCompleted = false; this.pointDatas = this.playTouchData.GetAllPointData(); this.maid.AllProcPropSeqStart(); this.maid.Visible = true; while (this.maid.IsBusy) { yield return null; } MaidPartsCollider partsCollider = MaidPartsCollider.AddPartCollider(this.maid); this.colliderList = partsCollider.AddCollider(); for (int i = 0; i < this.colliderList.Count; i++) { int num = i; this.colliderList[num].canTouch = this.playTouchData.EnabledPoint(this.colliderList[num].point); ColliderEvent colliderEvent = this.colliderList[i].gameObject.AddComponent(); colliderEvent.onMouseDown = delegate() { if (UICamera.Raycast(Input.mousePosition)) { return; } if (this.playTouchData.EnabledPoint(this.colliderList[num].point)) { this.OnTouchPoint(this.colliderList[num].point); } }; } yield return null; yield return null; if (this.playTouchData.phaseType == 0) { this.currentExcitement = 0; this.currentMood = 300; } else { this.currentExcitement = PrivateMaidTouchManager.backupExcitement; this.currentMood = PrivateMaidTouchManager.backuptMood; } this.statusGauge.SetCurrentExcite(this.currentExcitement, false); this.statusGauge.SetCurrentMood(this.currentMood, false); GameMain.Instance.ScriptMgr.is_motion_blend = false; this.kagManager.LoadScript(null, this.playTouchData.ftFile, string.Empty); GameMain.Instance.ScriptMgr.is_motion_blend = true; this.rcVoiceList.Clear(); this.kagManager.LoadScript(this.maid, this.playTouchData.rcRegisterFile, this.playTouchData.rcRegisterLabel); this.TouchPointViewer.Setup(this.playTouchData); this.setupCompleted = true; this.uiPanel.alpha = 1f; GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color)); yield break; } public void CallTouchMode(Maid maid, int id) { GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color)); GameMain.Instance.MainLight.Reset(); GameMain.Instance.CharacterMgr.ResetCharaPosAll(); GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true); GameMain.Instance.SoundMgr.VoiceStopAll(); this.playTouchData = ((!TouchDataBase.Contains(id)) ? null : TouchDataBase.GetData(id)); if (this.playTouchData == null) { Debug.LogError("タッチモードを始められませんでした。要求id" + id.ToString()); return; } this.maid = maid; base.StartCoroutine(this.Setup()); } public void OnTouchPoint(TouchDataBase.TouchPoint point) { if (this.playTouchData == null || !this.playTouchData.EnabledPoint(point)) { return; } this.repeatVoiceTriggerTime = (this.subtitleOffTime = 0f); this.subtitleDisplay.visible = false; TouchDataBase.PointData pointData = this.playTouchData.GetPointData(point); int num = 0; int num2 = 0; int num3 = (this.playTouchData.phaseType != 0) ? 100 : 0; while (num3 < 300 && num == 0) { num3 += 40; if (this.currentExcitement < num3) { num = num3; } else { num2++; } } this.currentExcitement = wf.Math.RoundMinMax(this.currentExcitement + pointData.addExcitement, 0, (this.playTouchData.phaseType != 0) ? 300 : 100); this.currentMood = wf.Math.RoundMinMax(this.currentMood + pointData.addMood, 0, 300); this.statusGauge.SetCurrentExcite(this.currentExcitement, true); this.statusGauge.SetCurrentMood(this.currentMood, true); if (this.currentMood <= 0) { GameMain.Instance.MainCamera.FadeOut(0.5f, false, delegate { this.OnFinish(false); }, true, default(Color)); } else if ((this.playTouchData.phaseType == 0 && this.currentExcitement >= 100) || (this.playTouchData.phaseType == 1 && this.currentExcitement >= 300)) { PrivateMaidTouchManager.backupExcitement = this.currentExcitement; PrivateMaidTouchManager.backuptMood = this.currentMood; GameMain.Instance.MainCamera.FadeOut(0.5f, false, delegate { this.OnFinish(true); }, true, default(Color)); } else { this.kagManager.ClearExecWait(); this.kagManager.LoadScript(this.maid, this.playTouchData.touchScriptFile, pointData.scriptLabelName); float reserveRepeatVoice; if (num <= this.currentExcitement && num2 < this.rcVoiceList.Count) { reserveRepeatVoice = this.PlayVoice(this.rcVoiceList[num2]); } else { reserveRepeatVoice = this.PlayVoice(this.singleVoiceData); } this.SetReserveRepeatVoice(reserveRepeatVoice); } } public void OnFinish(bool isSuccess) { if (this.playTouchData == null) { return; } string text = (!isSuccess) ? this.playTouchData.failureFile : this.playTouchData.successFile; string str = (!isSuccess) ? this.playTouchData.failureLabel : this.playTouchData.successLabel; if (this.maid != null && this.maid.GetComponent() != null) { this.maid.GetComponent().RemoveCollider(); UnityEngine.Object.Destroy(this.maid.GetComponent()); } if (string.IsNullOrEmpty(text)) { Debug.LogError("移動先の指定はありませんでした"); return; } text = ((!(this.maid == null)) ? ScriptManager.ReplacePersonal(this.maid, text) : text); this.uiPanel.alpha = 0f; GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color)); PartColliderData.SetDefaultCursor(); ScriptManager scriptMgr = GameMain.Instance.ScriptMgr; scriptMgr.EvalScript("global.__private_maid_mode_adv_file = '" + text + "';"); scriptMgr.EvalScript("global.__private_maid_mode_adv_label = '" + str + "';"); scriptMgr.LoadAdvScenarioScript("private_maid_mode_adv_call.ks", "*ADVスタート"); scriptMgr.adv_kag.Exec(); } public void SetSingleVoice(PrivateMaidTouchManager.VoiceData voiceData) { this.singleVoiceData = voiceData; } public void SetRepeatVoice(PrivateMaidTouchManager.VoiceData voiceData) { this.repeatVoiceData = voiceData; } public void AddRcVoiceData(PrivateMaidTouchManager.VoiceData voiceData) { this.rcVoiceList.Add(voiceData); } private void SetReserveRepeatVoice(float playingVoiceTime) { this.repeatVoiceTriggerTime = Time.time + playingVoiceTime + UnityEngine.Random.Range(3f, 7f); } private float PlayVoice(PrivateMaidTouchManager.VoiceData voiceData) { if (voiceData == null) { return 0f; } Maid maid = null; for (int i = 0; i < GameMain.Instance.CharacterMgr.GetMaidCount(); i++) { Maid maid2 = GameMain.Instance.CharacterMgr.GetMaid(i); if (maid2 != null && maid2.status.guid == voiceData.maidGuid) { maid = maid2; break; } } float num = 0f; if (maid != null && maid.Visible) { maid.AudioMan.LoadPlay(voiceData.voiceFileName, 0f, false, false); if (maid.AudioMan.audiosource.clip != null) { num = maid.AudioMan.audiosource.clip.length; } } else { int voice_pitch = 50; AudioSourceMgr.Type soundType = AudioSourceMgr.Type.Voice; if (maid != null) { voice_pitch = maid.VoicePitch; soundType = maid.AudioMan.SoundType; } GameMain.Instance.SoundMgr.PlayDummyVoice(voiceData.voiceFileName, 0f, false, false, voice_pitch, soundType); if (GameMain.Instance.SoundMgr.m_AudioDummyVoice.audiosource.clip != null) { num = GameMain.Instance.SoundMgr.m_AudioDummyVoice.audiosource.clip.length; } } if (0f < num) { this.subtitleDisplay.SetTextFromScriptStyle(voiceData.text); this.subtitleDisplay.visible = true; this.subtitleOffTime = Time.time + num; } return num; } private void Update() { if (this.subtitleDisplay.visible && this.subtitleDisplay.messageBgAlpha != SubtitleDisplayManager.configMessageAlpha) { this.subtitleDisplay.messageBgAlpha = SubtitleDisplayManager.configMessageAlpha; } if (0f < this.subtitleOffTime && this.subtitleOffTime <= Time.time) { this.subtitleOffTime = 0f; this.subtitleDisplay.visible = false; } if (0f < this.repeatVoiceTriggerTime && this.repeatVoiceTriggerTime <= Time.time) { float reserveRepeatVoice = this.PlayVoice(this.repeatVoiceData); this.SetReserveRepeatVoice(reserveRepeatVoice); } } private PrivateMaidTouchKagManager kagManager { get { return GameMain.Instance.ScriptMgr.privatemode_touch_kag; } } private static int backupExcitement; private static int backuptMood; [SerializeField] private UIPanel uiPanel; [SerializeField] private PrivateMaidTouchParamBasicBar statusGauge; [SerializeField] private SubtitleDisplayManager subtitleDisplay; [SerializeField] private PrivateMaidTouchTouchPointViewer TouchPointViewer; public static PrivateMaidTouchManager instance; private List colliderList; private List pointDatas; private bool setupCompleted; private List rcVoiceList = new List(); private PrivateMaidTouchManager.VoiceData singleVoiceData; private PrivateMaidTouchManager.VoiceData repeatVoiceData; private float repeatVoiceTriggerTime; private float subtitleOffTime; public class VoiceData { public string maidGuid; public string voiceFileName; public string text; } }