示例#1
0
    public override void WindowGUI()
    {
        if (paused && pauseMenu == null)
        {
            paused              = false;
            Time.timeScale      = 1;
            AudioListener.pause = false;
            Destroy(fade);
        }

        if (pauseMenu != null)
        {
            pauseMenu.BringToFront();
        }

        GUILayout.BeginHorizontal();

        PlayerComponent player = PlayerComponent.instance;

        if (player != null)
        {
            wasAlive = true;
            if (player.health != lastHealth)
            {
                healthChangeTime = Time.time;
                hurt             = player.health < lastHealth;
                lastHealth       = player.health;
            }

            Color baseColor = GUI.color;
            if (Time.time - healthChangeTime < 1.0)
            {
                if (hurt)
                {
                    GUI.color *= Color.Lerp(Color.red, Color.white, Time.time - healthChangeTime);
                }
                else
                {
                    GUI.color *= Color.Lerp(Color.green, Color.white, Time.time - healthChangeTime);
                }
            }
            ActionBarGUI.ActionBarLabel("Health: " + (int)(player.health));
            GUI.color = baseColor;
        }
        else if (wasAlive)
        {
            ActionBarGUI.ActionBarLabel("you died :(");
        }

        //ActionBarGUI.ActionBarLabel((int)(1.0f / Time.smoothDeltaTime) + " FPS");

        GUILayout.FlexibleSpace();
        if (ActionBarGUI.ActionBarButton(GUIIconSet.instance.pause))
        {
            PauseGame();
        }
        GUILayout.EndHorizontal();
    }
示例#2
0
    public override void WindowGUI()
    {
        if (paused && pauseMenu == null)
        {
            paused              = false;
            Time.timeScale      = 1;
            AudioListener.pause = false;
            Destroy(fade);
        }

        if (pauseMenu != null)
        {
            pauseMenu.BringToFront();
        }

        GUILayout.BeginHorizontal();

        PlayerComponent player = PlayerComponent.instance;

        if (player != null)
        {
            wasAlive = true;

            healthCounter.Update((int)player.health);
            scoreCounter.Update(player.score);
        }
        else if (wasAlive)
        {
            ActionBarGUI.ActionBarLabel("you died :(");
            scoreCounter.Display();
        }

        //ActionBarGUI.ActionBarLabel((int)(1.0f / Time.smoothDeltaTime) + " FPS");

        GUILayout.FlexibleSpace();
        if (ActionBarGUI.ActionBarButton(GUIIconSet.instance.pause))
        {
            PauseGame();
        }
        GUILayout.EndHorizontal();
    }