Ejemplo n.º 1
0
        void Start()
        {
            background       = GameObject.Find("Background");
            displayCanvas    = GameObject.Find("DisplayCanvas");
            videoPlayer      = GameObject.Find("VideoPlayer/VideoPlayer");
            bgmAudioSource   = GameObject.Find("AudioSource/BgmAudioSource");
            voiceAudioSource = GameObject.Find("AudioSource/VoiceAudioSource");
            startTime        = Time.time;
            bg                = background.transform.Find("Bg").gameObject.GetComponent <SpriteRenderer>();
            titleContainer    = displayCanvas.transform.Find("TitleContainer").gameObject;
            lineContainer     = displayCanvas.transform.Find("LineContainer").gameObject;
            historyField      = displayCanvas.transform.Find("HistoryField").gameObject;
            savedDataField    = displayCanvas.transform.Find("SavedDataField").gameObject;
            settingField      = displayCanvas.transform.Find("SettingField").gameObject;
            menuField         = displayCanvas.transform.Find("MenuField").gameObject;
            popupWindow       = displayCanvas.transform.Find("PopupWindow").gameObject;
            popupNoticeText   = popupWindow.transform.Find("Popup").Find("NoticeText").gameObject.GetComponent <Text>();
            popupCallbackText = popupWindow.transform.Find("Popup").Find("CallbackMethod").gameObject.GetComponent <Text>();
            _video            = videoPlayer.GetComponent <VideoPlayer>();
            _bgmAudio         = bgmAudioSource.GetComponent <AudioSource>();
            _voiceAudio       = voiceAudioSource.GetComponent <AudioSource>();

            // setting field
            PlayMode_Manual             = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "PlayMode:Manual:Toggle");
            PlayMode_Auto               = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "PlayMode:Auto:Toggle");
            PlayMode_Skip               = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "PlayMode:Skip:Toggle");
            Visual_ShowCGInSkipMode     = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "Visual:ShowCGInSkipMode:Toggle");
            Visual_SpecialEffects       = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "Visual:ShowCGInSkipMode:Toggle");
            Visual_TextShadow           = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "Visual:TextShadow:Toggle");
            Visual_Animation            = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "Visual:Animation:Toggle");
            ScreenMode_FullScreen       = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "ScreenMode:FullScreen:Toggle");
            ScreenMode_Windowed         = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "ScreenMode:Windowed:Toggle");
            Other_AppActiveInBackground = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "Other:AppActiveInBackground:Toggle");
            Volume_MuteBGM              = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "Volume:BGM:Toggle");
            Volume_MuteVoices           = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "Volume:Voices:Toggle");
            Volume_MuteSound            = GameObjectUtil.FindComponentByPath <Toggle>(settingField, "Volume:Sound:Toggle");
            Volume_BGM                         = GameObjectUtil.FindComponentByPath <Slider>(settingField, "Volume:BGM:Slider");
            Volume_Voices                      = GameObjectUtil.FindComponentByPath <Slider>(settingField, "Volume:Voices:Slider");
            Volume_Sound                       = GameObjectUtil.FindComponentByPath <Slider>(settingField, "Volume:Sound:Slider");
            MessageSpeed_UnreadText            = GameObjectUtil.FindComponentByPath <Slider>(settingField, "MessageSpeed:UnreadText:Slider");
            MessageSpeed_AutoPlayDelayInterval = GameObjectUtil.FindComponentByPath <Slider>(settingField, "MessageSpeed:AutoPlayDelayInterval:Slider");
            MessageSpeed_SkipInterval          = GameObjectUtil.FindComponentByPath <Slider>(settingField, "MessageSpeed:SkipInterval:Slider");
            ResolutionDropdown                 = GameObjectUtil.FindComponentByPath <Dropdown>(settingField, "ScreenMode:Windowed:Resolution");
            LanguageDropdown                   = GameObjectUtil.FindComponentByPath <Dropdown>(settingField, "Other:Language:Dropdown");

            bool isResInit = false;

            // resolution dropdown list
            foreach (Resolution res in Screen.resolutions)
            {
                if (res.refreshRate == 60)
                {
                    if (!isResInit)
                    {
                        SettingModel.resolution = string.Format("{0}x{1}", res.width, res.height);
                        isResInit = true;
                    }
                    ResolutionDropdown.options.Add(new Dropdown.OptionData(string.Format("{0}x{1}", res.width, res.height)));
                }
            }
            ResolutionDropdown.RefreshShownValue();

            bgmMusic = (AudioClip)Resources.Load("Audio/BGM30", typeof(AudioClip));

            historyQuene = new GameObject[] { null, titleContainer };
            if (null == GlobalGameData.GameValues)
            {
                GlobalGameData.GameValues = new GameValues();
            }

            defaultMenuLocalPos = menuField.transform.localPosition;
            shownMenuLocalPos   = new Vector3(defaultMenuLocalPos.x, defaultMenuLocalPos.y - menuField.GetComponent <RectTransform>().sizeDelta.y, defaultMenuLocalPos.z);

            _bgmAudio.clip = bgmMusic;
            _bgmAudio.loop = true;
            _bgmAudio.Play();

            GlobalGameData.GameValues = DefaultValues.DEFAULT_GAMEVALUES;
            chapterController         = this.GetComponent <ChapterController>();

            InitSettingField();
        }