示例#1
0
    // Drawing
    void OnGUI()
    {
        GUILayout.BeginHorizontal();

        if (m_showLife)
        {
            GUILayout.Box(m_textureLife, m_icon);
            GUILayout.Label(m_lifeCount.ToString(), m_text);
        }

        if (m_showScore)
        {
            GUILayout.Box(m_textureScore, m_icon);
            GUILayout.Label(m_scoreCount.ToString(), m_text);
        }

        if (m_showAmmo)
        {
            // Here we draw all attacks of first switchers if any, then we only highlight selected attack
            if (m_character.m_attacks.m_switchers.Length > 0)
            {
                APAttackSwitcher selector = m_character.m_attacks.m_switchers[0];
                foreach (APAttackTexture attackTexture in m_attackTextures)
                {
                    bool bActive = false;
                    if (string.Compare(attackTexture.m_attackName, selector.GetCurrentAttack().m_name) == 0)
                    {
                        bActive = true;
                    }

                    APAttack charAttack = m_character.GetAttack(attackTexture.m_attackName);
                    if (charAttack != null)
                    {
                        GUI.contentColor = bActive ? Color.white : new Color(1, 1, 1, 0.3f);
                        GUILayout.Box(attackTexture.m_texture, m_icon);
                        GUILayout.Label(charAttack.m_ammoBox ? charAttack.m_ammoBox.GetAmmoString() : "0", m_text);
                        GUI.contentColor = Color.white;
                    }
                }
            }
        }

        GUILayout.EndHorizontal();

        // Handle fade to black
        if (m_fadeToBlack)
        {
            Color color = Color.white;
            color.a   = m_fadeAlpha;
            GUI.color = color;
            GUI.DrawTexture(new Rect(0f, 0f, Screen.width, Screen.height), m_textureFade);
        }
    }