Ejemplo n.º 1
0
    //绘制UI
    private void OnGUI()
    {
        if (screenH != Screen.height || screenW != Screen.width)
        {
            screenW = Screen.width;
            screenH = Screen.height;
            Resize(screenW, screenH);
        }

        if (DebugConsole.Open)
        {
            if (!showConsole)
            {//console button
#if UNITY_EDITOR || UNITY_STANDALONE
                GUI.Box(debugButton, "Open Console", "button");
                if (isDebug)
                {
                    showConsole = true;
                    isDebug     = false;
                }
#endif
            }
            else
            {//console ui
                GUI.Box(area, "DebugConsole");
                GUI.Box(display, "");
                view = new Rect(display.x, display.y, display.width, DebugConsole.lineHeight * DebugConsole.perCharPixel_h);
                //自动滚屏
                if (autoScrollToEnd && !isPauseAutoScroll && DebugConsole.LogSwitch())
                {
                    scrollToEnd();
                }

                //显示信息
                GUI.BeginScrollView(display, scrollPos, view, false, false);
                GUI.Label(view, DebugConsole.ConsoleLogInfo.ToString(), fontStyle);
                GUI.EndScrollView();

                //close
                GUI.Box(closeButton, "Close", "button");
                if (isClose)
                {
                    isClose     = false;
                    showConsole = false;
                }

                GUI.Box(clearButton, "Clear", "button");
                if (isClear)
                {
                    isClear = false;
                    DebugConsole.Clear();
                }

                GUI.Box(upButton, "Up", "button");
                GUI.Box(downButton, "Down", "button");
            }
        }
    }
Ejemplo n.º 2
0
        /** OnEnable
         */
        private void OnEnable()
        {
            UnityEngine.Debug.Log("Window.OnEnable");

            //ヘッド。
            {
                UnityEngine.UIElements.Box t_head_box = new UnityEngine.UIElements.Box();
                {
                    //クリア。
                    {
                        UnityEngine.UIElements.Button t_button = new UnityEngine.UIElements.Button(() => {
                            DebugConsole.Clear();
                        });
                        t_button.text          = "Clear";
                        this.head_clear_button = t_button;
                        t_head_box.Add(t_button);
                    }

                    //テスト1。
                    {
                        UnityEngine.UIElements.Button t_button = new UnityEngine.UIElements.Button(() => {
                            DebugConsole.Log("Assets/ThirdParty/Open/Fee/Script/DebugConsole/ListItemEvent.cs(51):テスト");
                        });
                        t_button.text          = "LogReCreate";
                        this.head_test1_button = t_button;
                        t_head_box.Add(t_button);
                    }

                    //テスト2。
                    {
                        UnityEngine.UIElements.Button t_button = new UnityEngine.UIElements.Button(() => {
                            DebugConsole.Log("Assets/ThirdParty/Open/Fee/Script/DebugConsole/ListItemEvent.cs(51)");
                        });
                        t_button.text          = "LogAdd";
                        this.head_test2_button = t_button;
                        t_head_box.Add(t_button);
                    }
                }
                this.head_box = t_head_box;
                this.rootVisualElement.Add(t_head_box);
            }

            //リスト。
            {
                UnityEngine.UIElements.ListView t_listview = new UnityEngine.UIElements.ListView(Data.GetList(), 64, s_func_makeitem, s_func_binditem);
                {
                    t_listview.style.flexGrow = 1.0f;
                    t_listview.selectionType  = UnityEngine.UIElements.SelectionType.Single;
                }
                this.rootVisualElement.Add(t_listview);
            }
        }
Ejemplo n.º 3
0
    IEnumerator WaitToStop()
    {
        DebugConsole.Log("Stopping Music", "error");
        yield return(new WaitForSeconds(fadeOutDuration));

        bed.Stop();
        melody.Stop();
        perc.Stop();
        fx.Stop();
        musicPlaying = false;
        DebugConsole.Clear();
        DebugConsole.Log("Music Stopped", "error");
        StopAllCoroutines();
    }
Ejemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     UpdateManager();
     if (isSceneUpdate)
     {
         isSceneUpdate = false;
         EnterPlaying();
     }
     if (EasyTouch.current != null)
     {
         Debug.Log(EasyTouch.current.type);
     }
     if (Input.GetKeyDown(KeyCode.Space))
     {
         DebugConsole.Clear();
     }
 }
        protected override void Update()
        {
            base.Update();

            // ESC
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Debug.Log("press key ESC : Application Quit");
                DebugConsole.Log("press key ESC : Application Quit");

                if (Application.platform != RuntimePlatform.WindowsEditor)
                {
                    Application.Quit();
                }
            }

            // D
            if (Input.GetKeyDown(KeyCode.D))
            {
                Debug.Log("press key D : Visible Debug View");
                DebugConsole.Log("press key D : Visible Debug View");

                DebugManager debugManager = AppMain.Instance.debugManager;
                debugManager.isDebug = !debugManager.isDebug;
                debugManager.ToggleShowDebugView();
            }

            // C
            if (Input.GetKeyDown(KeyCode.C))
            {
                Debug.Log("press key C : Clear DebugConsole");
                DebugConsole.Log("press key C : Clear DebugConsole");

                DebugConsole.Clear();
            }

            // G
            if (Input.GetKeyDown(KeyCode.G))
            {
                Debug.Log("press key G : System GC Collect");
                DebugConsole.Log("press key G : System GC Collect");

                System.GC.Collect();
            }

            // R
            if (Input.GetKeyDown(KeyCode.R))
            {
                Debug.Log("press key R : Reload ApplicationSetting");
                DebugConsole.Log("press key R : Reload ApplicationSetting");

                // Reload settings
                ApplicationSetting.Instance.LoadXML();
            }

            // Space
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Debug.Log("press key Space : Change State");
                DebugConsole.Log("press key Space : Change State");

                // SE
                AppMain.Instance.soundManager.Play("SE", "CLICK");

                // change State or Timer start
                PlayState state = AppMain.Instance.sceneStateManager.CurrentState.StateObj as PlayState;
                if (state != null)
                {
                    state.StartTimer(); // PLAY state
                }
                else
                {
                    ISequentialState seqState = AppMain.Instance.sceneStateManager.CurrentState.StateObj as ISequentialState;
                    if (seqState != null)
                    {
                        seqState.ToNextState(); // WAIT or RESULT state
                    }
                }
            }
        }
Ejemplo n.º 6
0
    protected override void Update()
    {
        base.Update();

        // ESC
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("press key ESC : Application Quit");
            DebugConsole.Log("press key ESC : Application Quit");

            if (Application.platform != RuntimePlatform.WindowsEditor)
            {
                // アプリケーション終了
                Application.Quit();
            }
        }

        // D
        if (Input.GetKeyDown(KeyCode.D))
        {
            Debug.Log("press key D : Visible Debug View");
            DebugConsole.Log("press key D : Visible Debug View");

            // デバッグ表示のトグル
            DebugManager debugManager = AppMain.Instance.debugManager;
            debugManager.IsDebug = !debugManager.IsDebug;
            debugManager.ToggleShowDebugView();
        }

        // C
        if (Input.GetKeyDown(KeyCode.C))
        {
            Debug.Log("press key C : Clear DebugConsole");
            DebugConsole.Log("press key C : Clear DebugConsole");

            // デバッグコンソールのクリア
            DebugConsole.Clear();
        }

        // W
        if (Input.GetKeyDown(KeyCode.W))
        {
            Debug.Log("press key W : Change DebugConsole Mode");
            DebugConsole.Log("press key W : Change DebugConsole Mode");

            // デバッグコンソールのモードを切り替える
            if (DebugConsole.IsOpen)
            {
                if (DebugConsole.Instance.mode == DebugConsole.Mode.Log)
                {
                    DebugConsole.Instance.mode = DebugConsole.Mode.WatchVars;
                }
                else
                {
                    DebugConsole.Instance.mode = DebugConsole.Mode.Log;
                }
            }
        }

        // G
        if (Input.GetKeyDown(KeyCode.G))
        {
            Debug.Log("press key G : System GC Collect");
            DebugConsole.Log("press key G : System GC Collect");

            // 強制CG
            System.GC.Collect();
        }

        // R
        if (Input.GetKeyDown(KeyCode.R))
        {
            Debug.Log("press key R : Reload ApplicationSetting");
            DebugConsole.Log("press key R : Reload ApplicationSetting");

            // 設定ファイルの再読み込み
            ApplicationSetting.Instance.LoadXML();
        }

        // Space
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("press key Space : Change Stage");
            DebugConsole.Log("press key Space : Change Stage");

            // ステージの変更
            SceneStateManager sceneStateManager = AppMain.Instance.sceneStateManager;
            TimeManager       timeManager       = AppMain.Instance.timeManager;
            if (sceneStateManager.CurrentState == SceneStateManager.SceneState.STARTUP)
            {
                sceneStateManager.ChangeState(SceneStateManager.SceneState.WAIT);
            }
            else if (sceneStateManager.CurrentState == SceneStateManager.SceneState.WAIT)
            {
                sceneStateManager.ChangeState(SceneStateManager.SceneState.PLAY);
            }
            else if (sceneStateManager.CurrentState == SceneStateManager.SceneState.PLAY)
            {
                timeManager.timerEvents[0].StartTimer(ApplicationSetting.Instance.GetInt("GameTime"));
            }
            else if (sceneStateManager.CurrentState == SceneStateManager.SceneState.RESULT)
            {
                sceneStateManager.ChangeAsyncState(SceneStateManager.SceneState.WAIT);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Pause)
        {
            return;
        }

        //Time is stored as hours with decimals rather than seconds. At a speed of 1, a full cycle will take 24 hours.
        //Sun and Moon have different timers
        SunTime += (Time.deltaTime / 3600) * CurrentSpeed;
        while (SunTime > 24f)
        {
            SunTime -= 24f;
        }
        MoonTime += (Time.deltaTime / 3600) * CurrentSpeed;
        while (MoonTime > 24f)
        {
            MoonTime -= 24f;
        }

        if (PreviousHour < Mathf.Floor(SunTime) ||
            PreviousHour > Mathf.Floor(SunTime) ||
            (PreviousHour == Mathf.Floor(SunTime) && Minute == PreviousMinutes + 15))
        {
            if (PreviousHour != Mathf.Floor(SunTime))
            {
                PreviousMinutes = 0;
            }
            else
            {
                PreviousMinutes = Minute;
            }
            PreviousHour = (int)SunTime;

            //			Debug.Log("Announcing: " + PreviousHour + ":" + PreviousMinutes);

            if (HourChanged != null)
            {
                HourChanged(this, Hour, Minute);
            }
        }

        if (ShowTime)
        {
            DebugConsole.Clear();
            DebugConsole.Log(string.Format("{0:00}:{1:00}", Hour, Minute));
        }

        if (DayInMinutes == 0 || !MoveSun)
        {
            return;
        }

        //--- Sun Cycle ---//
        // If the time is before sunrise, rotate the sun between straight down, and the east horizon
        if (SunTime < SunCycle[0] && this.MoveSun)
        {
            Sun.transform.rotation = Quaternion.Euler(90 * (SunTime - SunCycle[0]) / SunCycle[0], 0, 0);
        }
        // If the time is after sunset, rotate the sun between the west horizon, and straight down
        if (SunTime > SunCycle[3] && this.MoveSun)
        {
            Sun.transform.rotation = Quaternion.Euler(180 + 90 * (SunTime - SunCycle[3]) / (24 - SunCycle[3]), 0, 0);
            // TransitionTime is used to smoothly change the speed of time at sunrise and sunset, over the course of one realtime second
            // Check if the day-to-night transition has already completed, and move it along if it hasn't
            if (TransitionTime <= 1f)
            {
                TransitionTime += Time.deltaTime;
                if (TransitionTime > 1f)
                {
                    TransitionTime = 1f;
                }
            }
        }
        // If the sun is about to rise, then we start shifting the speed of time back to the speed during daylight hours
        else if (SunTime > SunCycle[0] - SunriseOffset && TransitionTime > 0f)
        {
            TransitionTime -= Time.deltaTime;
            if (TransitionTime < 0f)
            {
                TransitionTime = 0f;
            }
        }

        // Calculate the speed of time, based on what time of day it is, and what part of the transition we're in
        CurrentSpeed = (DaySpeed + ((NightSpeed - DaySpeed) * TransitionTime)) * Multiplier;

        // Check if we are between sunrise and sunset. The last bit is so we have one update after sunset, to turn everything off

        if (SunTime > SunCycle[0] && SunTime < SunCycle[3] + ((Time.deltaTime / 3600) * CurrentSpeed))
        {
            // If the sun isn't turned on, turn it on
            if (!Sun.GetComponent <Light>().enabled)
            {
                Sun.GetComponent <Light>().enabled = true;
                // If anyone is listening, trigger the "SunRise" event
                if (SunRise != null)
                {
                    StartCoroutine(SunRise(this, SunTime));
                }
                DebugConsole.Log("Sun is rising");
            }

            // Rotate the sun from one horizon to the other over the daytime period
            Sun.transform.rotation = Quaternion.Euler(180 * (SunTime - SunCycle[0]) / (SunCycle[3] - SunCycle[0]), 0, 0);

            // Check if the sun is rising
            if (SunTime < SunCycle[1] + ((Time.deltaTime / 3600) * CurrentSpeed))
            {
                //Slowly phase the sun in, and change its colour
                Sun.GetComponent <Light>().intensity      = 0.5f * ((SunTime - SunCycle[0]) / (SunCycle[1] - SunCycle[0]));
                Sun.GetComponent <Light>().shadowStrength = 1f * ((SunTime - SunCycle[0]) / (SunCycle[1] - SunCycle[0]));
                Sun.GetComponent <Light>().color          = Color.Lerp(SunRiseColour, SunColour, ((SunTime - SunCycle[0]) / (SunCycle[1] - SunCycle[0])));

                float time = ((SunTime - SunCycle[0]) / (SunCycle[1] - SunCycle[0]));
                float dusk = 2 * (0.5f - Math.Abs(0.5f - time));

                DayNightSkybox.SetFloat("_BlendDusk", dusk);
                DayNightSkybox.SetFloat("_BlendNight", Mathf.Clamp(1 - (2 * time), 0f, 1f));
            }

            // Otherwise, check if the sun is setting
            else if (SunTime > SunCycle [2] + ((Time.deltaTime / 3600) * CurrentSpeed))
            {
                // Slowly phase the sun out, and change its colour
                Sun.GetComponent <Light>().intensity      = 0.5f - 0.5f * ((SunTime - SunCycle[2]) / (SunCycle[3] - SunCycle[2]));
                Sun.GetComponent <Light>().shadowStrength = Mathf.Clamp(1f - 1f * ((SunTime - SunCycle[2]) / (SunCycle[3] - SunCycle[2])), 0, 1);
                Sun.GetComponent <Light>().color          = Color.Lerp(SunColour, SunRiseColour, ((SunTime - SunCycle[2]) / (SunCycle[3] - SunCycle[2])));

                float time = ((SunTime - SunCycle[2]) / (SunCycle[3] - SunCycle[2]));
                float dusk = 2 * (0.5f - Math.Abs(0.5f - time));

                DayNightSkybox.SetFloat("_BlendDusk", dusk);
                DayNightSkybox.SetFloat("_BlendNight", Mathf.Clamp(2 * (time - 0.5f), 0f, 1f));
            }
        }
        // If the sun isn't used, turn off the light
        else
        {
            if (Sun.GetComponent <Light>().enabled)
            {
                Sun.GetComponent <Light>().enabled = false;
                // If anyone is listening, trigger the "SunSet" event
                if (SunSet != null)
                {
                    StartCoroutine(SunSet(this, SunTime));
                }
                DebugConsole.Log("Sun is Setting");
            }
        }

        //--- Moon Cycle ---//
        // If the time is before moonrise, rotate the moon between straight down, and the east horizon
        if (MoonTime < MoonCycle[0] && this.MoveSun)
        {
            Moon.transform.rotation = Quaternion.Euler(90 * (MoonTime - MoonCycle[0]) / MoonCycle[0], 0, 0);
        }

        // If the time is after moonset, rotate the moon between the west horizon, and straight down
        if (MoonTime > MoonCycle[3] && this.MoveSun)
        {
            Moon.transform.rotation = Quaternion.Euler(180 + 90 * (MoonTime - MoonCycle[3]) / (24 - MoonCycle[3]), 0, 0);
        }

        // Check if we are between moonrise and moonset. The last bit is so we have one update after moonset, to turn everything off
        if (MoonTime > MoonCycle[0] && MoonTime < MoonCycle[3] + ((Time.deltaTime / 3600) * CurrentSpeed))
        {
            Moon.GetComponent <Light>().enabled = true;

            //Rotate the moon from one horizon to the other over the nighttime period
            if (this.MoveSun)
            {
                Moon.transform.rotation = Quaternion.Euler(180 * (MoonTime - MoonCycle[0]) / (MoonCycle[3] - MoonCycle[0]), 0, 0);
            }

            //Check if the moon is rising
            if (MoonTime < MoonCycle[1] + ((Time.deltaTime / 3600) * CurrentSpeed))
            {
                //Slowly phase the moon in, and change its colour
                Moon.GetComponent <Light>().intensity      = 0.1f * ((MoonTime - MoonCycle[0]) / (MoonCycle[1] - MoonCycle[0]));
                Moon.GetComponent <Light>().shadowStrength = 0.2f * ((MoonTime - MoonCycle[0]) / (MoonCycle[1] - MoonCycle[0]));
                Moon.GetComponent <Light>().color          = Color.Lerp(MoonRiseColour, MoonColour, ((MoonTime - MoonCycle[0]) / (MoonCycle[1] - MoonCycle[0])));
            }

            //Otherwise, check if the moon is setting
            else if (MoonTime > MoonCycle [2] + ((Time.deltaTime / 3600) * CurrentSpeed))
            {
                //Slowly phase the moon out, and change its colour
                Moon.GetComponent <Light>().intensity      = 0.1f - 0.1f * ((MoonTime - MoonCycle[2]) / (MoonCycle[3] - MoonCycle[2]));
                Moon.GetComponent <Light>().shadowStrength = 0.2f - 0.2f * ((MoonTime - MoonCycle[2]) / (MoonCycle[3] - MoonCycle[2]));
                Moon.GetComponent <Light>().color          = Color.Lerp(MoonColour, MoonRiseColour, ((MoonTime - MoonCycle[2]) / (MoonCycle[3] - MoonCycle[2])));
            }
        }
        //If the moon isn't used, turn off the light
        else
        {
            Moon.GetComponent <Light>().enabled = false;
        }

        // If we have reached a new hour, or quarter of an hour, and anyone is listening, trigger the HourChanged event
//		Debug.Log (minutes);
    }
    void Update()
    {
        //ESC
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("press key ESC : Application Quit");
            DebugConsole.Log("press key ESC : Application Quit");

            if (Application.platform != RuntimePlatform.WindowsEditor)
            {
                //アプリケーション終了
                Application.Quit();
            }
        }

        //D
        if (Input.GetKeyDown(KeyCode.D))
        {
            Debug.Log("press key D : Visible Debug View");
            DebugConsole.Log("press key D : Visible Debug View");

            //デバッグ表示のトグル
            DebugManager.Instance.IsDebug = !DebugManager.Instance.IsDebug;
            DebugManager.Instance.ToggleShowDebugView();
        }

        //C
        if (Input.GetKeyDown(KeyCode.C))
        {
            Debug.Log("press key C : Clear DebugConsole");
            DebugConsole.Log("press key C : Clear DebugConsole");

            //デバッグコンソールのクリア
            DebugConsole.Clear();
        }

        //W
        if (Input.GetKeyDown(KeyCode.W))
        {
            Debug.Log("press key W : Change DebugConsole Mode");
            DebugConsole.Log("press key W : Change DebugConsole Mode");

            //デバッグコンソールのモードを切り替える
            if (DebugConsole.IsOpen)
            {
                if (DebugConsole.Instance.mode == DebugConsole.Mode.Log)
                {
                    DebugConsole.Instance.mode = DebugConsole.Mode.WatchVars;
                }
                else
                {
                    DebugConsole.Instance.mode = DebugConsole.Mode.Log;
                }
            }
        }

        //G
        if (Input.GetKeyDown(KeyCode.G))
        {
            Debug.Log("press key G : System GC Collect");
            DebugConsole.Log("press key G : System GC Collect");

            //強制CG
            System.GC.Collect();
        }

        //R
        if (Input.GetKeyDown(KeyCode.R))
        {
            Debug.Log("press key R : Reload ApplicationSetting");
            DebugConsole.Log("press key R : Reload ApplicationSetting");

            //設定ファイルの再読み込み
            ApplicationSetting.Instance.LoadXML();
        }

        //Space
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("press key Space : Change Stage");
            DebugConsole.Log("press key Space : Change Stage");

            //ステージの変更
            if (StageManager.Instance.CurrentStage == StageManager.StageState.STARTUP)
            {
                StageManager.Instance.ChangeStage(StageManager.StageState.WAIT);
            }
            else if (StageManager.Instance.CurrentStage == StageManager.StageState.WAIT)
            {
                StageManager.Instance.ChangeStage(StageManager.StageState.PLAY);
            }
            else if (StageManager.Instance.CurrentStage == StageManager.StageState.PLAY)
            {
                TimeManager.Instance.GameTimer_Start();
            }
            else if (StageManager.Instance.CurrentStage == StageManager.StageState.RESULT)
            {
                StageManager.Instance.ChangeStage(StageManager.StageState.WAIT);
            }
        }
    }