Beispiel #1
0
        private static void StepLightAndPlay()
        {
            if (intensityState && reflectCount < 60)
            {
                switch (KK_FBIOpenUp.nowGameMode)
                {
                case KK_FBIOpenUp.GameMode.Studio:
                    studioLightInfo.intensity += (intensityTo - intensityFrom) / 60;
                    studioLightCalc.Invoke("Reflect");
                    break;

                case KK_FBIOpenUp.GameMode.FreeH:
                    freeHLight.intensity += (intensityTo - intensityFrom) / 60;
                    break;

                case KK_FBIOpenUp.GameMode.Maker:
                    makerLight.intensity += (intensityTo - intensityFrom) / 60;
                    break;
                }
                reflectCount++;
            }
            else
            {
                Logger.LogDebug($"At Step: {step}");
                switch (step)
                {
                case 0:
                    //消滅圖片
                    if (null != shiftPicture.Transform.parent.gameObject)
                    {
                        GameObject.Destroy(shiftPicture.Transform.parent.gameObject);
                        shiftPicture.image = null;
                        shiftPicture.video = null;
                        shiftPicture       = null;
                    }
                    break;

                case 1:
                    //由中間移動到左邊
                    shiftPicture.targetPosition = new Vector3(0 - (shiftPicture.Width / 2), Screen.height / 2);
                    stepSet(0);
                    break;

                case 2:
                    //由中間移動到右邊
                    shiftPicture.targetPosition = new Vector3(Screen.width + shiftPicture.Width / 2, Screen.height / 2);
                    stepSet(0);
                    break;

                case 10:
                    //將角色全部替換
                    //加亮角色光
                    reflectCount = 0;
                    ToggleFlashLight(true);
                    stepAdd();
                    break;

                case 11:
                    intensityState = false;
                    Patches.ChangeAllCharacters(false);
                    reflectCount = 0;
                    ToggleFlashLight(false);
                    stepAdd();
                    break;

                case 12:
                    intensityState = false;
                    if (!ChangeWithoutShiftPicture)
                    {
                        stepSet(1);
                    }
                    else
                    {
                        ChangeWithoutShiftPicture = false;
                        stepSet(0);
                    }
                    break;

                case 20:
                    //將角色換回
                    //加亮角色光
                    reflectCount = 0;
                    ToggleFlashLight(true);
                    stepAdd();
                    break;

                case 21:
                    intensityState = false;
                    Patches.ChangeAllCharacters(true);
                    reflectCount = 0;
                    ToggleFlashLight(false);
                    stepAdd();
                    break;

                case 22:
                    intensityState = false;
                    if (!ChangeWithoutShiftPicture)
                    {
                        stepSet(2);
                    }
                    else
                    {
                        ChangeWithoutShiftPicture = false;
                        stepSet(0);
                    }
                    break;
                }
                void stepAdd()
                {
                    step++;
                }

                void stepSet(int st)
                {
                    step = st;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 繪製轉場圖片
        /// </summary>
        /// <param name="_step">繪製完後要進入的腳本位置</param>
        /// <param name="sceneName">Scene名稱</param>
        private static void DrawSlidePic(int _step)
        {
            GameObject parent;

            switch (KK_FBIOpenUp.nowGameMode)
            {
            case KK_FBIOpenUp.GameMode.Studio:
                parent = GameObject.Find("StudioScene/Canvas Main Menu");
                break;

            case KK_FBIOpenUp.GameMode.MainGame:
                parent = GameObject.Find("ActionScene/UI/ActionMenuCanvas/ModeAnimation");
                break;

            case KK_FBIOpenUp.GameMode.Maker:
                parent = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsCoordinateType/redBagBtn");
                break;

            //FreeH死都不成功,放棄
            //case KK_FBIOpenUp.GameMode.FreeH:
            //    parent = GameObject.Find("CommonSpace");
            //    break;
            default:
                parent = GameObject.FindObjectsOfType <GameObject>()[0];    //Not tested
                break;
            }
            GameObject gameObject = new GameObject();

            gameObject.transform.SetParent(parent.transform, false);
            gameObject.SetActive(false);
            if (null != shiftPicture)
            {
                GameObject.Destroy(shiftPicture.Transform.parent.gameObject);
                shiftPicture.image = null;
                shiftPicture.video = null;
                shiftPicture       = null;
            }
            shiftPicture = new ShiftPicture();

            //如果影片不存在,用熊吉代替
            bool noVideoFallback = _step == 20 && null == KK_FBIOpenUp.videoPath;

            if (noVideoFallback)
            {
                _step = 2;
            }

            switch (_step)
            {
            case 1:
                //小學生真是太棒了
                shiftPicture.type  = ShiftPicture.Type.picture;
                shiftPicture.image = UIUtility.CreateImage("", gameObject.transform, Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.saikodaze.jpg", 800, 657));
                shiftPicture.image.rectTransform.sizeDelta = new Vector2(Screen.height / 1.5f * 800 / 657, Screen.height / 1.5f);
                Right2Center();
                break;

            case 2:
                //熊吉逮捕
                shiftPicture.type  = ShiftPicture.Type.picture;
                shiftPicture.image = UIUtility.CreateImage("", gameObject.transform, Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.Kumakichi.jpg", 640, 480));
                shiftPicture.image.rectTransform.sizeDelta = new Vector2(Screen.height / 1.5f * 640 / 480, Screen.height / 1.5f);
                Left2Center();
                break;

            case 10:
                //幼女退光線
                shiftPicture.type  = ShiftPicture.Type.picture;
                shiftPicture.image = UIUtility.CreateImage("", gameObject.transform, Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.beam.png", 700, 700));
                shiftPicture.image.rectTransform.sizeDelta = new Vector2(Screen.height / 1.25f, Screen.height / 1.25f);
                Right2Center();
                break;

            case 20:
                //FBI Open Up影片
                shiftPicture.type = ShiftPicture.Type.video;

                shiftPicture.video = UIUtility.CreateRawImage("", gameObject.transform);
                shiftPicture.video.rectTransform.sizeDelta = new Vector2(Screen.height / 1.5f, Screen.height / 1.5f);

                UnityEngine.Video.VideoPlayer videoPlayer = gameObject.AddComponent <UnityEngine.Video.VideoPlayer>();
                AudioSource audioSource = gameObject.AddComponent <AudioSource>();
                videoPlayer.playOnAwake = false;
                audioSource.playOnAwake = false;
                videoPlayer.renderMode  = UnityEngine.Video.VideoRenderMode.APIOnly;

                //videoPlayer.url= "../UserData/audio/FBI.mp4";
                videoPlayer.url = KK_FBIOpenUp.videoPath;

                //Set Audio Output to AudioSource
                videoPlayer.audioOutputMode = UnityEngine.Video.VideoAudioOutputMode.AudioSource;

                //Assign the Audio from Video to AudioSource to be played
                videoPlayer.EnableAudioTrack(0, true);
                videoPlayer.SetTargetAudioSource(0, audioSource);

                Logger.LogDebug($"{videoPlayer.url}");
                videoPlayer.isLooping = true;

                //先把他移到螢幕外啟用,否則未啟用無法Prepare,而直接啟用會出現白色畫面
                shiftPicture.Transform.position = new Vector3(-2 * Screen.width, Screen.height / 2);
                gameObject.SetActive(true);

                videoPlayer.Prepare();
                videoPlayer.prepareCompleted += (source) => {
                    ///TODO 這實際上沒有辦法真的catch到錯誤,待修
                    if (videoPlayer.texture == null)
                    {
                        Logger.LogError("Video not found");
                        GameObject.Destroy(shiftPicture.Transform.parent.gameObject);
                        shiftPicture.video = null;
                        shiftPicture       = null;
                        _step = 0;
                        return;
                    }

                    shiftPicture.video.texture = videoPlayer.texture;
                    videoTimer = 2;
                    videoPlayer.Play();
                    audioSource.Play();

                    //影片太大聲QQ
                    audioSource.volume = KK_FBIOpenUp.videoVolume;

                    Left2Center();
                };
                break;
            }

            //如果影片不存在,用熊吉代替
            if (noVideoFallback)
            {
                _step = 20;
            }

            step = _step;
            Logger.LogDebug("Draw Slide Pic");

            void Right2Center()
            {
                //Right To Center
                shiftPicture.Transform.position = new Vector3(Screen.width + shiftPicture.Width / 2, Screen.height / 2);
                shiftPicture.targetPosition     = new Vector3(Screen.width / 2, Screen.height / 2);
                gameObject.SetActive(true);
            }

            void Left2Center()
            {
                //Left To Center
                shiftPicture.Transform.position = new Vector3(-1 * (Screen.width + shiftPicture.Width / 2), Screen.height / 2);
                shiftPicture.targetPosition     = new Vector3(Screen.width / 2, Screen.height / 2);
                gameObject.SetActive(true);
            }
        }