public GameState(ref Gui g, GameHandler gameHandler)
 {
     Gui = g;
     GameHandler = gameHandler;
     _currentState = State.MainMenu;
     LastState = CurrentState;
     Gui.SetGui(_currentState);
 }
Exemplo n.º 2
0
        // is called on startup
        public override void Init()
        {
            //Position des fensters wir erst bei zweitem aufruf von Setwindow gesezt...
            SetWindowSize(Screen.PrimaryScreen.Bounds.Width, (Screen.PrimaryScreen.Bounds.Height / 9)*2, true, 0, 0);
            SetWindowSize(Screen.PrimaryScreen.Bounds.Width, (Screen.PrimaryScreen.Bounds.Height / 9)*2, true, 0, 0);
            RC.ClearColor = new float4(0.2f, 0.5f, 0.9f, 1);

            GameHandler = new GameHandler(RC, this);
            Resize();
        }
Exemplo n.º 3
0
        public Game(GameHandler gh,RenderContext rc)
        {
            _gameHandler = gh;
            RC = rc;

            //alle 3D Assets laden
            SceneLoader = new SceneLoader();
            srTomato = SceneLoader.LoadTomato();
            srSheep = SceneLoader.LoadSheep();
            srTrees = SceneLoader.LoadTrees();
            srCows = SceneLoader.LoadCows();
            srLandschaft = SceneLoader.LoadEnvironment();
            srBuildings = SceneLoader.LoadBuildings();
            CreateEnvironment();

            //Hürde die zum Austieg zum nächsten level erreicht werden muss
            _nextLevel = 500;
            Points = 0;
            LoadLevel();
            _skybox = new Skybox(RC);
        }
Exemplo n.º 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
        }