示例#1
0
    private void OnGUI()
    {
        if (!_model.isVisible || GameManager.GetCamera() == null)
        {
            return;
        }

        Vector3 pos = GameManager.GetCamera().WorldToScreenPoint(transform.position + new Vector3(0f, 2.8f, 0f));

        if (!GameManager.Instance.GameStarted || Local.IsHunter)
        {
            GUI.contentColor = Color.white;
            float width = GUI.skin.label.CalcSize(new GUIContent(Name)).x;
            GUI.DrawTexture(new Rect(pos.x - width / 2f, Screen.height - pos.y - 8f, width, 16f), _nameGradient);
            GUI.contentColor = IsHunter ? (Color) new Color32(255, 128, 128, 255) : Color.white;
            GUI.Label(new Rect(pos.x - width / 2f, Screen.height - pos.y - 8f, width, 20f), Name);
            GUI.contentColor = Color.white;
        }

        if (isLocalPlayer)
        {
            if (IsHunter)
            {
                float cd = Mathf.Ceil(LastAction + Cooldown - (float)NetworkTime.time);
                if (cd > 0f)
                {
                    GUI.contentColor = Color.black;
                    GUI.Label(new Rect(pos.x - 8f, Screen.height - pos.y + 12f, 16f, 18f),
                              cd.ToString(CultureInfo.InvariantCulture));
                    GUI.contentColor = new Color32(200, 128, 200, 255);
                    GUI.Label(new Rect(pos.x - 9f, Screen.height - pos.y + 11f, 16f, 18f),
                              cd.ToString(CultureInfo.InvariantCulture));
                    GUI.contentColor = Color.white;
                }

                List <Color> usedColors = GameManager.Instance.GetUsedColors();
                GUI.Box(new Rect(8f, Screen.height - 8f - (usedColors.Count * 32f) - 8f, 128f, usedColors.Count * 32f + 8f), "");
                for (var i = 0; i < usedColors.Count; i++)
                {
                    Texture2D clr = AssetLoader.GetColor(usedColors[i]);
                    GUI.skin.button.normal.background = clr;
                    GUI.skin.button.hover.background  = clr;
                    GUI.skin.button.active.background = clr;
                    if (GUI.Button(new Rect(12f, Screen.height - 8f - (i * 32f) - 32f, 120f, 24f), ""))
                    {
                        SetColor(usedColors[i]);
                    }
                }

                GUI.skin.button.normal.background = GameAssets.DefaultUnityNormalBackground;
                GUI.skin.button.hover.background  = GameAssets.DefaultUnityHoverBackground;
                GUI.skin.button.active.background = GameAssets.DefaultUnityActiveBackground;

                if (GUI.Button(new Rect(136f, Screen.height - 8f - 20f, 64f, 20f), SlowMode ? "Fast" : "Slow"))
                {
                    CmdTriggerSlowMode();
                }
            }

            if (CurrentTask != null)
            {
                CurrentTask.OnTaskGUI();
            }
        }
    }