Ejemplo n.º 1
0
    void OnGUI()
    {
        if (showObjectPannel)
        {
            // Menü  an der Seite...
            Object[] SIDEmenuOptions = Unit.SellectableObjects;
            float    btnHeight       = (60 * ScaleY);
            //   float zwischenbuttonraum = (20 * ScaleY);
            Rect guiposition;
            sideMenuHeight = ((btnHeight) * (SIDEmenuOptions.Length + 2));
            //   guiposition = new Rect(1718 * ScaleX, (210 * ScaleY) - 3 * guiStyle.fontSize, 202 * ScaleX, sideMenuHeight );
            guiposition = new Rect(1695 * ScaleX, (210 * ScaleY) - 3 * guiStyle.fontSize, 225 * ScaleX, sideMenuHeight);
            GUI.BeginGroup(guiposition, "", guiSIDEstyle); // Unit.name+"'s Activities:"
            for (int i = 0; i < SIDEmenuOptions.Length; i++)
            {
                //     if (GUI.Button(new Rect(0, 3 * guiStyle.fontSize + i * (btnHeight + zwischenbuttonraum), (180 * ScaleX), btnHeight), SIDEmenuOptions[i].name))
                if (GUI.Button(new Rect(0, 3 * guiStyle.fontSize + i * (btnHeight), (224 * ScaleX), btnHeight), SIDEmenuOptions[i].name, buttonSIDEstyle))
                {
                    Unit.Sellect(SIDEmenuOptions[i]);
                }
            }
            if (GUI.Button(new Rect(0, 3 * guiStyle.fontSize + SIDEmenuOptions.Length * (btnHeight), (224 * ScaleX), btnHeight), "Cancel", buttonSIDEstyle))
            {
                if (!Focus.IsLocked)
                {
                    Component.Destroy(Focus.masterGameObject.GetComponent <Focus>());
                }
            }
            GUI.EndGroup();
        }
        else
        {
            // Side-Menu
            Object[] SIDEmenuOptions = this.buildingBuilder.BuildableBuildings;
            float    btnHeight       = (60 * ScaleY);
            //    float zwischenbuttonraum = (20 * ScaleY);
            Rect guiposition;
            sideMenuHeight = ((btnHeight) * (SIDEmenuOptions.Length + 1));
            //   guiposition = new Rect(1718 * ScaleX, (210 * ScaleY) - 3 * guiStyle.fontSize, 202 * ScaleX, 360 * ScaleY);
            guiposition = new Rect(1695 * ScaleX, (210 * ScaleY) - 3 * guiStyle.fontSize, 224 * ScaleX, sideMenuHeight);
            GUI.BeginGroup(guiposition, guiSIDEstyle);
            for (int i = 0; i < SIDEmenuOptions.Length; i++)
            {
                if (GUI.Button(new Rect(0, 3 * guiStyle.fontSize + i * (btnHeight), (224 * ScaleX), btnHeight), SIDEmenuOptions[i].name, buttonSIDEstyle))
                {
                    // Code for Build-Action

                    // TODO Upgrade Building / Unit

                    this.buildingBuilder.CreatePrefab(i);
                }
            }
            GUI.EndGroup();
        }

        if (showCommandPannel)
        {
            // If Unit of RightClickMenu was destroyed -> hide Menu
            if (Unit == null)
            {
                showCommandPannel = false;
                return;
            }

            /* [Rightclick] PopUp Menu */
            float btnHeight = (40 * ScaleY);

            //string[] menuOptions = Unit.RightClickMenuOptions;
            //EnumProvider.ORDERSLIST[] selected = new EnumProvider.ORDERSLIST[1];
            EnumProvider.ORDERSLIST[] options = Unit.RightClickMenuOptionStates;
            // Rect guiposition = new Rect(1695 * ScaleX, 590 * ScaleY, 223 * ScaleX, (options.Length + 1) * btnHeight + guiStyle.fontSize);
            Rect guiposition = new Rect(1695 * ScaleX, sideMenuHeight + ((210 * ScaleY) - 2 * guiStyle.fontSize), 223 * ScaleX, (options.Length + 1) * btnHeight + guiStyle.fontSize);
            //  Rect guiposition = new Rect(UnitPosition.x, view.height - UnitPosition.y, Pannel.texture.width * ScaleX, (options.Length + 1) * btnHeight + guiStyle.fontSize);
            GUI.BeginGroup(guiposition, "Orders:", guiStyle);
            for (int i = 0; i < options.Length; i++)
            {
                if (GUI.Button(new Rect(22 * ScaleX, guiStyle.fontSize + i * btnHeight, 180 * ScaleX, btnHeight), options[i].ToString(), buttonStyle))
                {
                    Unit.Options.GiveOrder(options[i]);
                    //Debug.Log("order given to unit!");
                    showCommandPannel = false;
                }
            }
            if (GUI.Button(new Rect(22 * ScaleX, guiStyle.fontSize + options.Length * btnHeight, 180 * ScaleX, btnHeight), "Cancel...", buttonStyle))
            {
                showCommandPannel = false;
            }
            GUI.EndGroup();
        }
    }