Beispiel #1
0
        public SidePanel()
        {
            // Init
            m_index = 0;
            m_prefabButtons = new List<PrefabButton>();
            m_buildingCount = -1;
            m_display = Type.Building;
            m_progressTex = (Texture2D)UnityEngine.Resources.Load("Textures/angular");
            m_progressMat = new Material(Shader.Find("ButtonProgress"));
            m_progressMat.color = new Color(1f, 1f, 0f, 0.5f);

            m_positions = new Rect[8];
            m_origPositions = new Rect[8];
            m_origPositions[0] = new Rect(1920 - 224, 452, 100, 100);
            m_origPositions[1] = new Rect(1920 - 116, 452, 100, 100);
            m_origPositions[2] = new Rect(1920 - 224, 561, 100, 100);
            m_origPositions[3] = new Rect(1920 - 116, 561, 100, 100);
            m_origPositions[4] = new Rect(1920 - 224, 670, 100, 100);
            m_origPositions[5] = new Rect(1920 - 116, 670, 100, 100);
            m_origPositions[6] = new Rect(1920 - 224, 779, 100, 100);
            m_origPositions[7] = new Rect(1920 - 116, 779, 100, 100);

            // Text GUI Style
            m_textStyle = new GUIStyle();
            m_textStyle.font = (Font)UnityEngine.Resources.Load("Fonts/gil");
            m_textStyle.fontSize = 24;
            m_textStyle.alignment = TextAnchor.MiddleCenter;
            m_textStyle.normal.textColor = Color.white;

            // Panel Textures
            m_guiMat = new Material(Shader.Find("Billboard"));
            m_guiPanel = (Texture2D)UnityEngine.Resources.Load("Textures/panel");

            // Left Button
            Texture2D leftUp = (Texture2D)UnityEngine.Resources.Load("Textures/panel_left");
            Texture2D leftDown = (Texture2D)UnityEngine.Resources.Load("Textures/panel_left_down");
            m_buttonLeft = new Button(leftUp, leftDown, UserInterface.ResizeGUI(new Rect(1920 - 234, 898, 26, 63)));

            // Right Button
            Texture2D rightUp = (Texture2D)UnityEngine.Resources.Load("Textures/panel_right");
            Texture2D rightDown = (Texture2D)UnityEngine.Resources.Load("Textures/panel_right_down");
            m_buttonRight = new Button(rightUp, rightDown, UserInterface.ResizeGUI(new Rect(1920 - 34, 898, 26, 63)));

            // Main Buttons
            Texture2D buttonUp = (Texture2D)UnityEngine.Resources.Load("Textures/panel_button");
            Texture2D buttonDown = (Texture2D)UnityEngine.Resources.Load("Textures/panel_button_down");
            m_buttons = new List<Button>();
            for (int i = 0; i < 8; ++i)
            {
                Rect rect = new Rect(m_origPositions[i].x - 4, m_origPositions[i].y - 4, m_origPositions[i].width + 4, m_origPositions[i].height + 4);
                Button button = new Button(buttonUp, buttonDown, rect);
                m_buttons.Add(button);
            }

            // Minimap
            m_minimap = new Minimap();

            // Initial bounds update
            UpdateBounds();
        }