Example #1
0
        public override CurrentMenu Update(GameTime gametime, Inputhandler inputhandler)
        {
            CurrentMenu menu = CurrentMenu.Options;
            base.DoUpDownMovement(gametime, inputhandler);
            if (inputhandler.GetNewPressedMenuKeys.Contains(MenuKeys.Left) || inputhandler.GetNewPressedMenuKeys.Contains(MenuKeys.Right))
            {
                int relative = inputhandler.GetNewPressedMenuKeys.Contains(MenuKeys.Left) ? -1 : 1;
                switch (current_position)
                {
                    case (int)OptionsMenuPositions.Resolution:
                        tempRes = Resolution.GetAvailableResolutions.GetRelativeElement(currentResPos, relative);
                        try
                        {
                            currentResPos = Resolution.GetAvailableResolutions.IndexOf(tempRes);
                        }
                        catch (Exception)
                        {
                            currentResPos = 0;
                        }
                        break;
                    case (int)OptionsMenuPositions.Shader_Quality:
                        options.QualitySettings[OptionsID.ShaderQuality] = options.QualitySettings[OptionsID.ShaderQuality].GetRelativeElement(relative);
                        break;
                    case (int)OptionsMenuPositions.Post_Process_Quality:
                        options.QualitySettings[OptionsID.PostProcessQuality] = options.QualitySettings[OptionsID.PostProcessQuality].GetRelativeElement(relative);
                        break;
                    case (int)OptionsMenuPositions.Particle_Quality:
                        options.QualitySettings[OptionsID.ParticleQuality] = options.QualitySettings[OptionsID.ParticleQuality].GetRelativeElement(relative);
                        break;
                    case (int)OptionsMenuPositions.Controller:
                        options.Controller = options.Controller.GetRelativeElement(relative);
                        break;
                    case (int)OptionsMenuPositions.Display_Mode:
                        tempDisplayMode = options.DisplayMode.GetRelativeElement(relative);
                        break;
                    case (int)OptionsMenuPositions.Music_Volume:
                        options.MusicVolume = options.MusicVolume + relative * 5;
                        break;
                }
                RecreateStrings();
            }
            if (inputhandler.GetNewPressedMenuKeys.Contains(MenuKeys.Back))
                menu = CurrentMenu.MainMenu;
            if (inputhandler.GetNewPressedMenuKeys.Contains(MenuKeys.Enter))
            {
                switch (current_position)
                {
                    case (int)OptionsMenuPositions.Back:
                        menu = CurrentMenu.MainMenu;
                        break;
                    case (int)OptionsMenuPositions.Apply:
                        options.DisplayMode = tempDisplayMode;
                        options.Resolution = tempRes;
                        RecreateStrings();
                        break;
                }
            }

            return menu;
        }
Example #2
0
        public override CurrentMenu Update(GameTime gametime, Inputhandler inputhandler)
        {
            CurrentMenu currentmenu;
            base.Update(gametime,inputhandler);
            currentmenu = checkactions(inputhandler.GetMenuKeys, inputhandler.GetOldMenuKeys);

            return currentmenu;
        }
Example #3
0
 public GameManager(EGameState state,IServiceProvider ServiceProvider)
 {
     cur_state = state;
     options = new Options();
     options.DisplayModeChanged += new DisplayModeChangedEventHandler(options_DisplayModeChanged);
     options.ResolutionChanged += new ResolutionChangedEventHandler(options_ResolutionChanged);
     game = new SGame(ServiceProvider);
     inputhandler = new Inputhandler(Vector2.Zero,options);
     menu = new SMenu(ServiceProvider);
     serviceprovider = ServiceProvider;
     content = new ContentManager(serviceprovider, "Data");
     music = new Music();
     credits = new SCredits(serviceprovider);
     pthreadManager = new ParticleThreadManager();
     gameTimes = new TimeSpan[numberOfTimes];
     for (int i = 0; i < numberOfTimes; i++)
     {
         gameTimes[i] = new TimeSpan(0, 0, 0, 0, 16);
     }
 }
Example #4
0
 private void CheckGameStateChange(EGameState tempState)
 {
     if (tempState != cur_state)
     {
         oldState = cur_state;
         cur_state = tempState;
         drawnOldState = false;
         oldStateRectangle = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight);
         curStateRectangle = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight);
         curStateScale = .7f;
         oldStateScale = 1f;
         if (cur_state == EGameState.Game)
         {
             music.GraphXPackChanged(game.Level.LevelVariables.Dictionary[Game.Level.LV.GraphXPack]);
             music.StartCategoryTransition(true);
             inputhandler = new Inputhandler(game.Player.Pos, options);
         }
         else if (cur_state == EGameState.Menu && oldState == EGameState.Game)
         {
             music.StartCategoryTransition(false);
         }
         else if (cur_state == EGameState.Credits)
         {
             credits.ResetCredits(options.Resolution);
         }
     }
 }
Example #5
0
        public void Initialize(GraphicsDeviceManager graphics)
        {
            options = Options.FromSettingsFile();
            options.DisplayModeChanged += new DisplayModeChangedEventHandler(options_DisplayModeChanged);
            options.ResolutionChanged += new ResolutionChangedEventHandler(options_ResolutionChanged);
            inputhandler = new Inputhandler(Vector2.Zero, options);
            graphicsDeviceManager = graphics;
            spritebatch = new SpriteBatch(graphics.GraphicsDevice);
            /*options.ScreenHeight = graphics.GraphicsDevice.Viewport.Height;
            options.ScreenWidth = graphics.GraphicsDevice.Viewport.Width;*/
            graphics.PreferredBackBufferHeight = options.ScreenHeight;
            graphics.PreferredBackBufferWidth = options.ScreenWidth;
            graphicsDeviceManager.IsFullScreen = options.IsFullScreen;
            graphics.ApplyChanges();
            options.ScreenWidth = graphics.GraphicsDevice.PresentationParameters.BackBufferWidth;
            options.ScreenHeight = graphics.GraphicsDevice.PresentationParameters.BackBufferHeight;
            options.InitObjectHolder.graphics = graphics.GraphicsDevice;

            options.InitObjectHolder.serviceProvider = serviceprovider;
            menu.Initialize(options);
            game.Initialize(options);
            loadingscreen = new SLoadingScreen(serviceprovider, options);
            loadingscreen.Initialize(options, graphics.GraphicsDevice);
            credits.Initialize(options);
            GraphicsManager.AddItem(credits);
            GraphicsManager.AddItem(game);
            GraphicsManager.AddItem(menu);
            GraphicsManager.AddItem(loadingscreen);
            graphics.DeviceDisposing += new EventHandler<EventArgs>(graphics_DeviceDisposing);
            graphics.DeviceCreated += new EventHandler<EventArgs>(graphics_DeviceCreated);
            graphics.Disposed += new EventHandler<EventArgs>(graphics_Disposed);
            PresentationParameters pp = graphics.GraphicsDevice.PresentationParameters;

            currentTarget = new RenderTarget2D(
                graphics.GraphicsDevice,
                pp.BackBufferWidth, pp.BackBufferHeight, false,
                SurfaceFormat.Color, DepthFormat.None, pp.MultiSampleCount, RenderTargetUsage.PreserveContents);
            oldStateTarget = new RenderTarget2D(
                graphics.GraphicsDevice,
                pp.BackBufferWidth, pp.BackBufferHeight, false,
                SurfaceFormat.Color, DepthFormat.None, pp.MultiSampleCount, RenderTargetUsage.PreserveContents);
            oldStateRectangle = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight);
            curStateRectangle = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight);
            curStateScale = .7f;
            oldStateScale = 1f;
            music.Initialize(serviceprovider,options);
        }
Example #6
0
        public EGameState Update(Microsoft.Xna.Framework.GameTime gameTime,Input.Inputhandler inputhandler,Options options)
        {
            List<Star.Game.CollisionType> collission = new List<Star.Game.CollisionType>();
            List<EventAction> actions;
            Inputhandler input;
            actions = gamelogic.Update(gameTime, player.BoundingBox,level.GetQuadtree,enemyManager.Enemies,this);
            if (!actions.Contains(EventAction.Exit))
            {
                 if (actions.Contains(EventAction.BlockInput))
                {
                    input = new Inputhandler(player.Pos,options);
                }
                else
                {
                    input = inputhandler;
                }
                if (!actions.Contains(EventAction.BlockUpdate) || firstFrame)
                {
                    firstFrame = false;
                    enemyManager.Update(gameTime, level.GetQuadtree, player.Pos, player.BoundingBox, level.Tiles, camera.getMatrix);

                    collission = player.Update(gameTime, input.Pos, level.GetQuadtree, input.GetInputKeys, input.GetOldInputkeys, input.RunDirection, input.RunFactor, iObjectManager.GetPlayerInfluences());
                    camera.update(gameTime, player.getDifference, player.Pos, false);

                    debugscreen.update(start, player.Pos, player.speed, player.Gravity, player.Jump, input.Pos, collission, input.RunFactor, input.GetInputKeys);
                }
                iObjectManager.Update(gameTime, this);
                input.UpdateRunFactor(gameTime, collission);
                Vector2 relativePosition = new Vector2(-camera.Position.X / (level.Tiles.GetLength(1) * Tile.TILE_SIZE), -camera.Position.Y / ((level.Tiles.GetLength(0) * Tile.TILE_SIZE) - options.ScreenHeight / 2));
                relativePosition.Y = MathHelper.Clamp(relativePosition.Y, 0, 1);
                cloudlayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                frontparallaxLayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                rearparallaxLayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                frontDecoLayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                rearDecoLayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                if (collission.Contains(Star.Game.CollisionType.WalksAgainstIt))
                {
                    input.Pos = player.Pos;
                }

                if (inputhandler.GetMenuKeys.Contains(MenuKeys.Back))
                {
                    return EGameState.Menu;
                }
                rundirection = input.RunDirection;
                while (!enemyManager.IsFinished())
                {
                    Thread.Sleep(0);
                }
            }
            else
            {
                return EGameState.Menu;
            }
            return EGameState.Game;
        }
Example #7
0
        public override CurrentMenu Update(GameTime gametime, Inputhandler inputhandler)
        {
            CurrentMenu currentmenu = CurrentMenu.CustomMaps;
            //DoUpDownMovement(gametime, inputhandler);
            //DoLeftRightMovement(gametime, inputhandler);
            base.Update(gametime, inputhandler);
            List<MenuKeys> keys = inputhandler.GetNewPressedMenuKeys;
            if (keys.Contains(MenuKeys.Enter))
            {
                switch (currentList)
                {
                    case 0:
                        switch (current_position)
                        {
                            case 0:
                                ReScanFolder();
                                break;
                            case 1:
                                currentmenu = CurrentMenu.MainMenu;
                                break;
                        }
                        break;
                    case 1:
                        currentmenu = CurrentMenu.LoadLevel;
                        level_to_load = levels.Buttons[current_position].GetText;
                        break;
                }

            }
            if (keys.Contains(MenuKeys.Back))
            {
                currentmenu = CurrentMenu.MainMenu;
            }
            if (lists[currentList].ActiveButton.Rectangle.Bottom > levels_rect.Bottom-10)
            {
                offset.Y += -(lists[currentList].ActiveButton.Rectangle.Bottom+offset.Y - levels_rect.Bottom) * gametime.GetElapsedTotalSecondsFloat()*10;
            }
            if (lists[currentList].ActiveButton.Rectangle.Top + offset.Y < levels_rect.Top + 10)
            {
                offset.Y -= (lists[currentList].ActiveButton.Rectangle.Top+offset.Y - levels_rect.Top) * gametime.GetElapsedTotalSecondsFloat() *10;
            }

            return currentmenu;
        }
Example #8
0
 protected void DoUpDownMovement(GameTime gametime, Inputhandler inputhandler)
 {
     List<MenuKeys> keys = inputhandler.GetNewPressedMenuKeys;
     if (inputhandler.GetNewPressedMenuKeys.Contains(Star.Input.MenuKeys.Up))
     {
         int temp = current_position;
         temp -= 1;
         if (temp < 0)
         {
             temp = lists[currentList].Buttons.Length - 1;
         }
         lists[currentList].IncreseDecreasePosition(false);
         current_position = lists[currentList].GetCurrentPos;
     }
     if (inputhandler.GetNewPressedMenuKeys.Contains(Input.MenuKeys.Down))
     {
         int temp = current_position;
         temp += 1;
         if (temp >= lists[currentList].Buttons.Length)
         {
             temp = 0;
         }
         lists[currentList].IncreseDecreasePosition(true);
         current_position = lists[currentList].GetCurrentPos;
     }
 }
Example #9
0
 protected void DoLeftRightMovement(GameTime gametime, Inputhandler inputhandler)
 {
     if (lists.Length > 1)
     {
         if (inputhandler.GetNewPressedMenuKeys.Contains(MenuKeys.Right))
         {
             int temp = currentList;
             temp++;
             if (temp >= lists.Length)
                 temp = 0;
             lists[temp].SetActiveButton(lists[temp].GetCurrentPos);
             lists[currentList].ChangeButtonState(lists[currentList].GetCurrentPos, ButtonIndicator.Button_Normal);
             currentList = temp;
         }
         if (inputhandler.GetNewPressedMenuKeys.Contains(MenuKeys.Left))
         {
             int temp = currentList;
             temp--;
             if (temp < 0)
                 temp = lists.Length - 1;
             lists[temp].SetActiveButton(lists[temp].GetCurrentPos);
             lists[currentList].ChangeButtonState(lists[currentList].GetCurrentPos, ButtonIndicator.Button_Normal);
             currentList = temp;
         }
     }
 }
Example #10
0
 public virtual CurrentMenu Update(GameTime gametime, Inputhandler inputhandler)
 {
     DoUpDownMovement(gametime, inputhandler);
     DoLeftRightMovement(gametime, inputhandler);
     return CurrentMenu.NoChange;
 }
Example #11
0
 public EGameState Update(GameTime gameTime, Inputhandler inputhandler, Options options)
 {
     alphatime += 2*(float)gameTime.ElapsedGameTime.TotalSeconds;
     alphaloading = 0.25f * (float)Math.Sin(alphatime) + 0.75f;
     loadingrotation.Update(gameTime);
     for (int i = 0; i < loadingstrings.Count;i++)
     {
         loadingstrings[i].alpha -= (float)gameTime.ElapsedGameTime.TotalSeconds / 10;
     }
     if (loaded)
         return EGameState.Game;
     else if (loaded && inputhandler.GetNewPressedMenuKeys.Contains(MenuKeys.Back))
         return EGameState.Menu;
     return EGameState.Loading;
 }