123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- 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>();
- 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<MaidPartsCollider>() != null)
- {
- this.maid.GetComponent<MaidPartsCollider>().RemoveCollider();
- UnityEngine.Object.Destroy(this.maid.GetComponent<MaidPartsCollider>());
- }
- 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<PartColliderData> colliderList;
- private List<TouchDataBase.PointData> pointDatas;
- private bool setupCompleted;
- private List<PrivateMaidTouchManager.VoiceData> rcVoiceList = new List<PrivateMaidTouchManager.VoiceData>();
- 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;
- }
- }
|