コード例 #1
0
        public GUI(RenderContext rc)
        {
            //Basic Init

            _fontSmall = rc.LoadFont("Assets/Cabin.ttf", 12);
            _fontMedium = rc.LoadFont("Assets/Cabin.ttf", 18);
            _fontBig = rc.LoadFont("Assets/Cabin.ttf", 40);

            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(rc);

            //Start Pannel Init
            _guiPanel = new GUIPanel("PhysicsTest", _fontMedium, 10, 10, 330, 250);

            _info1 = new GUIText("Über die Tasten des Nummernblocks  " , _fontMedium, 30, 170, _color2);
            _info2 = new GUIText("(1-4) kann zwischen 4 verschiedenen ", _fontMedium, 30, 190, _color2);
            _info3 = new GUIText("Szenen gewechselt werden", _fontMedium, 30, 210, _color2);
            _fps = new GUIText("FPS", _fontMedium, 30, 55, _color2);
            _numberRb = new GUIText("Rigidbodies: ", _fontMedium, 30, 85, _color2);
            _shapeType = new GUIText("Collision Shapes: ", _fontMedium, 30, 115, _color2);
            _shapes = new GUIText("", _fontMedium, 50, 135, _color2);

            _guiPanel.ChildElements.Add(_info1);
            _guiPanel.ChildElements.Add(_info2);
            _guiPanel.ChildElements.Add(_info3);
            _guiPanel.ChildElements.Add(_fps);
            _guiPanel.ChildElements.Add(_numberRb);
            _guiPanel.ChildElements.Add(_shapeType);
            _guiPanel.ChildElements.Add(_shapes);

            ShowGUI();
        }
コード例 #2
0
        public GUI(RenderContext rc, GameWorld gw)
        {
            //Basic Init
            _gw = gw;

            _fontSmall = rc.LoadFont("Assets/Cabin.ttf", 12);
            _fontMedium = rc.LoadFont("Assets/Cabin.ttf", 18);
            _fontBig = rc.LoadFont("Assets/Cabin.ttf", 40);

            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(rc);

            //Start Pannel Init
            _startPanel1 = new GUIPanel("RocketGame", _fontMedium, 10, 10, 150, 110);
            _startPanelButtonStart = new GUIButton("Start", _fontSmall, 10, 30, 130, 30);
            _startPanelButtonStart.OnGUIButtonDown += OnGUIButtonDown;
            _startPanelButtonStart.OnGUIButtonUp += OnGUIButtonUp;
            _startPanelButtonStart.OnGUIButtonEnter += OnGUIButtonEnter;
            _startPanelButtonStart.OnGUIButtonLeave += OnGUIButtonLeave;
            _startPanelButtonStuff = new GUIButton("Stuff", _fontSmall, 10, 70, 130, 30);
            _startPanelButtonStuff.OnGUIButtonDown += OnGUIButtonDown;
            _startPanelButtonStuff.OnGUIButtonUp += OnGUIButtonUp;
            _startPanelButtonStuff.OnGUIButtonEnter += OnGUIButtonEnter;
            _startPanelButtonStuff.OnGUIButtonLeave += OnGUIButtonLeave;
            _startPanel1.ChildElements.Add(_startPanelButtonStart);
            _startPanel1.ChildElements.Add(_startPanelButtonStuff);

            _startPanel2 = new GUIPanel("Find and activate all the red cubes!", _fontMedium, 170, 20, 300, 30);

            _playPanel = new GUIPanel("Goals found:", _fontMedium, 10, 10, 150, 60);
            _playScore = new GUIText("", _fontMedium, 48, 45, new float4(1, 0, 0, 1));
            _playPanel.ChildElements.Add(_playScore);

            _overText = new GUIText("Game Over, you Win!", _fontBig, 200, 100, new float4(0, 1, 0, 1));

            ShowStartGUI();
        }
コード例 #3
0
ファイル: GUIRender.cs プロジェクト: juradosa/BeeTheGame
        // Konstruktor
        public GUIRender(RenderContext rc, BeeTheGame thisGame)
        {
            RC = rc;
            _game = thisGame;
            //GUIHandler an den Kontext anhaengen
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(rc);

            //Bilder einbinden
            _guiImageDummy = new GUIImage("Assets/dummy.png", 0, 0, 0, 5, 5);
            _guiImageBarText = new GUIImage("Assets/nectarCollected.png", 10, 10, -1, 153, 23);

            _guiImageStartBack = new GUIImage("Assets/background.png", 0, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2);
            _guiImageGameHelp = new GUIImage("Assets/gameHelp.png", 0, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2);
            _guiImageStartBee = new GUIImage("Assets/beePlaceholder.png", 200, 30, 1, 130, 118);
            _guiImageStartPlay = new GUIImage("Assets/play.png", (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width/2 - 300/2), 0, 2, 300, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2);

            _guiImageHelpButton = new GUIImage("Assets/helpButton.png", 10, 10, 2, 41, 50);
            _guiImageHelpOne = new GUIImage("Assets/helpOne.png", 100, 10, 1, 300, 129);
            _guiImageHelpTwo = new GUIImage("Assets/helpTwo.png", 950, 20, 1, 300, 130);

            //Text
            _guiFontArial24 = RC.LoadFont("Assets/arial.ttf", 16);
            _guiArial24 = new GUIText("Score: ", _guiFontArial24, 1200, 25);
            _guiArial24.TextColor = new float4(1, 1, 1, 1);

            //Button
            _guiButtonPlay = new GUIButton((System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width/2 - 300/2), 0, 3, 300, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2);

            _guiButtonPlay.ButtonColor = new float4(0, 0, 0, 0);
            _guiButtonPlay.BorderColor = new float4(0, 0, 0, 1);
            _guiButtonPlay.BorderWidth = 0;

            _guiButtonHelp = new GUIButton(10, 10, 1, 50, 50);
            //Buttonfarbe setzen
            _guiButtonHelp.ButtonColor = new float4(0, 0, 0, 0);
            _guiButtonHelp.BorderColor = new float4(0, 0, 0, 1);
            _guiButtonHelp.BorderWidth = 0;

            //an den Handler anhaengen
            _guiHandler.Add(_guiImageDummy);
            _guiHandler.Add(_guiImageBarText);

            _guiImagePause = new GUIImage("Assets/gamePaused.png", 350, 40, 0, 500, 100);
        }
コード例 #4
0
        //da initialisieren wir alles für den GuiHandler
        public Gui(RenderContext RC, RenderCanvas rCanvas, GameHandler gameHandler)
        {
            #region Variablen
            _rCanvas = rCanvas;
            var height = _rCanvas.Height;
            var width = _rCanvas.Width;

            _gameHandler = gameHandler;
            _guiHandler = new GUIHandler(RC);
            _mainmenuHandler = new GUIHandler(RC);
            _inGameHandler = new GUIHandler(RC);
            _highScoreHandler = new GUIHandler(RC);

            _guiDiffs = new GUIButton[4];
            _guiImageTomato = new GUIImage[10];
            _guiImages = new GUIImage[9];
            _highscoreBretter = new GUIImage[5];

            float textwidth;
            float texthight;
            _highscore = false;
            _neustart = true;
            _pause = true;
            _level = 1;

              #endregion

            #region Bilder
            //Hintergrund Startscreen
            _guiImages[(int)_btnimages.Startbild] = new GUIImage("Assets/startbild.png", 0, 0,-3, width, height);

            //Hintergrund Endscreen
            _guiImages[(int)_btnimages.Endbild] = new GUIImage("Assets/endbild.png", 0, 0, -3, width, height);

            //Maus-Nutzerinfo in Mainmenü einblenden
            _guiImages[(int)_btnimages.btniMouse] = new GUIImage("Assets/Mouse.png", width / 4, 0, -1, (int)(height / 1.322), height);

            //Fadenkreuz flexibel (Falls es zwecks Schwierigkeitsstufe kleiner werden soll)
            _aimimage = 80;
            _guiImages[(int)_btnimages.btniFadenkreuz] = new GUIImage("Assets/Fadenkreuz.png", width / 2 - _aimimage / 2, height / 2 - _aimimage / 2, -2, _aimimage, _aimimage);

            // Credits Klohaus
            _guiImages[(int)_btnimages.btniCreditsA] = new GUIImage("Assets/kloClosed.png", width - height, 0, -1, height, height);
            _guiImages[(int)_btnimages.btniCreditsB] = new GUIImage("Assets/kloOpen.png", width - height, 0, -1, height, height);

            #endregion

            #region Beschriftungen
            //Schriften
            _guiFontCabin12 = RC.LoadFont("Assets/Cabin.ttf", 12);
            _guiFontCabin14 = RC.LoadFont("Assets/Cabin.ttf", 14);
            _guiFontCabin18 = RC.LoadFont("Assets/Cabin.ttf", 18);
            _guiFontCabin100 = RC.LoadFont("Assets/Cabin.ttf", 100);
            _guiFontWESTERN30 = RC.LoadFont("Assets/WESTERN.ttf", 30);

            //Credits
            texthight = GUIText.GetTextHeight("So hoch.", _guiFontCabin18);
            textwidth = GUIText.GetTextWidth("Sooooooooo laaaaaang", _guiFontCabin14);
            _guiTextCredits1 = new GUIText("Ramazan Gündogdu", _guiFontCabin14, (width) - (int)(textwidth), (height / 3)+ (int)(texthight/2), new float4(1, 1, 1, 1));
            _guiTextCredits2 = new GUIText("Kathleen Hübel", _guiFontCabin14, (width) - (int)(textwidth), (int)(_guiTextCredits1.PosY + texthight), new float4(1, 1, 1, 1));
            _guiTextCredits3 = new GUIText("Linda Schey", _guiFontCabin14, (width) - (int)(textwidth), (int)(_guiTextCredits2.PosY + texthight), new float4(1, 1, 1, 1));
            _guiTextCredits4 = new GUIText("Susanne Schmidt", _guiFontCabin14, (width) - (int)(textwidth), (int)(_guiTextCredits3.PosY + texthight), new float4(1, 1, 1, 1));
            _guiTextCredits5 = new GUIText("Tobias Winterhalder ", _guiFontCabin14, (width) - (int)(textwidth), (int)(_guiTextCredits4.PosY + texthight), new float4(1, 1, 1, 1));

            //Eingabetext Name für Highscore
            texthight = GUIText.GetTextHeight("Lorem ipsum", _guiFontCabin18);
            textwidth = GUIText.GetTextWidth("Write name: ", _guiFontCabin18);
            _name = new GUIText("Write name: ", _guiFontCabin18, (width / 2) - (int)(textwidth), (height / 2), new float4(0, 0, 0, 1));
            nameInput = new GUIText("", _guiFontCabin18, (width / 2), (height / 2), new float4(1, 1, 1, 1));

            //Text Mainmenü: Scha(r)fschießen
            textwidth = GUIText.GetTextWidth("Scha(r)fschießen", _guiFontWESTERN30);
            _guiTextTitel = new GUIText("Scha(r)fschießen", _guiFontWESTERN30, (width/2) - (int) (textwidth/2), (height/3));
            _guiTextTitel.TextColor = new float4(0, 0, 0, 1);

            // Text InGame
            textwidth = GUIText.GetTextWidth("Time: ", _guiFontCabin18);
            texthight = GUIText.GetTextHeight("Time: ", _guiFontCabin18);
            _guiText1 = new GUIText("Time: " + _countdown, _guiFontCabin18, (int)textwidth, (int)(texthight*2));
            _guiText1.TextColor = new float4(0, 0, 0, 1);
            textwidth = GUIText.GetTextWidth("Time: ", _guiFontCabin18);
            _guiText2 = new GUIText("Points: " + _points, _guiFontCabin18, width - (int)(textwidth * 3), (int)(texthight*2));
            _guiText2.TextColor = new float4(0, 0, 0, 1);

            //Text LevelUp
            textwidth = GUIText.GetTextWidth("Level Up!", _guiFontCabin100);
            _guiText7 = new GUIText("Level Up!", _guiFontCabin100, (width / 2) - (int)(textwidth/2), (height / 2));
            _guiText7.TextColor = new float4(1, 0, 0, 0.5f);

            #endregion

            #region Buttons
            // Button MainMenü: Starten
            textwidth = GUIText.GetTextWidth("Start", _guiFontWESTERN30);
            texthight = GUIText.GetTextHeight("Start", _guiFontWESTERN30);
            _guiText3 = new GUIText("Start", _guiFontWESTERN30, width / 2 - (int)(textwidth / 2), (int)(height / 1.5));
            _guiText3.TextColor = new float4(1, 1, 1, 1);
            _guiDiffs[(int)_buttons.btnStart] = new GUIButton(_guiText3.PosX - (int)(texthight / 2), _guiText3.PosY - (int)texthight, -2,
                (int)(textwidth * 1.5), (int)(texthight * 1.5));
            _guiImages[(int)_btnimages.btniStart] = new GUIImage("Assets/holz.png", _guiText3.PosX - (int)textwidth / 2,
                _guiText3.PosY - (int)(texthight * 1.5), -1, (int)textwidth * 2, (int)texthight * 2);

            // Button HighscoreMenü: Nochmal spielen
            textwidth = GUIText.GetTextWidth("Play again", _guiFontCabin18);
            _guiText5 = new GUIText("Play again", _guiFontCabin18, (width / 2) - (int)(textwidth * 1.5),
                (height / 2 + height / 3));
            _guiText5.TextColor = new float4(1, 1, 1, 1);
            texthight = GUIText.GetTextHeight("Play again", _guiFontCabin18);
            _guiDiffs[(int) _buttons.btnNochmal] = new GUIButton(_guiText5.PosX, _guiText5.PosY - (int) texthight, -2,
                (int) textwidth, (int) texthight);
            _guiImages[(int) _btnimages.btniNochmal] = new GUIImage("Assets/holz.png",
                _guiText5.PosX - (int) textwidth/2, _guiText5.PosY - (int) (texthight*1.5), -1, (int) textwidth*2,
                (int) texthight*2);

            // Button HighscoreMenü: Highscore
            textwidth = GUIText.GetTextWidth("Enter in Highscore", _guiFontCabin18);
            _guiText6 = new GUIText("Enter in Highscore", _guiFontCabin18, (width / 2) + (int)(textwidth / 5), (height / 2 + height / 3));
            _guiText6.TextColor = new float4(1, 1, 1, 1);
            texthight = GUIText.GetTextHeight("Enter in Highscore", _guiFontCabin18);
            _guiDiffs[(int) _buttons.btnHighscore] = new GUIButton(_guiText6.PosX, _guiText6.PosY - (int) texthight, -2, (int) textwidth, (int) texthight);
            _guiImages[(int) _btnimages.btniHighscore] = new GUIImage("Assets/holz.png",_guiText6.PosX - (int)textwidth / 8, _guiText6.PosY - (int)(texthight * 1.5), -1, (int)(textwidth * 1.2), (int) texthight*2);

            //Button Credits
            textwidth = GUIText.GetTextWidth("Credits", _guiFontCabin18);
            texthight = GUIText.GetTextWidth("Credits", _guiFontCabin18);
            _guiCredits = new GUIText("Credits", _guiFontCabin18, width - (int)(textwidth*1.5), (height / 2), new float4(1, 1, 1, 1));
            _guiDiffs[(int)_buttons.btnCredits] = new GUIButton(_guiCredits.PosX, _guiCredits.PosY - (int)texthight, -2,
               (int)textwidth, (int)texthight);
            #endregion
        }