protected override EventAction UpdateEvent(GameTime gameTime, List<Enemy.Enemy> enemies)
        {
            EventAction action = EventAction.Nothing;
            elapsedTime -= gameTime.GetElapsedTotalSecondsFloat();
            if (elapsedTime < timeThreshold && elapsedTime > 0)
            {
                action = EventAction.BlockUpdate;
            }
            if (elapsedTime < timeThreshold/4)
            {
                grayScale.Alpha -= gameTime.GetElapsedTotalSecondsFloat()/(timeThreshold/4);
            }
            if (elapsedTime <=0)
            {
                Enabled = false;
            }

            return action;
        }
Beispiel #2
0
        public GameAction Update(GameTime gametime,GraphicsDevice device)
        {
            if (gametime.GetElapsedTotalSecondsFloat() < 0.1)
            {

                gameTimes[currentPosTime] = gametime.ElapsedGameTime;
                currentPosTime++;
                currentPosTime = currentPosTime % numberOfTimes;
            }
            GameTime newGameTime = new GameTime(gametime.TotalGameTime, GetAverageTimeSpan());
            gametime = newGameTime;
            GameAction action = GameAction.Nothing;
            inputhandler.Update(gametime,game.Player.Pos);
            EGameState tempState;
            //options.InitObjectHolder.particleManagers[cur_state].Update(gametime);
            pthreadManager.Update(gametime, options.InitObjectHolder.particleManagers[cur_state]);
            switch (cur_state)
            {
                case EGameState.Intro:
                    break;
                case EGameState.Game:
                    tempState = game.Update(gametime,inputhandler,options);
                    CheckGameStateChange(tempState);
                    if (cur_state == EGameState.Menu)
                    {
                        menu.CurrentMenu = Star.Menu.CurrentMenu.MainMenu;
                    }
                    break;
                case EGameState.Loading:
                    tempState = loadingscreen.Update(gametime, inputhandler, options);
                    CheckGameStateChange(tempState);
                    if (cur_state == EGameState.Menu)
                    {
                        menu.CurrentMenu = Star.Menu.CurrentMenu.MainMenu;
                    }
                    if(cur_state == EGameState.Game)
                        inputhandler.Pos = game.Level.Startpos;
                    break;
                case EGameState.Menu:
                    tempState = menu.Update(gametime, inputhandler,options);
                    CheckGameStateChange(tempState);
                    if (cur_state == EGameState.Loading)
                    {
                        //game.LoadLevel(serviceprovider,device, menu.GetLevelName, menu.GetLevelType, options);
                        loadingscreen.LoadLevel(game, serviceprovider, device, menu.GetLevelName, menu.GetLevelType, options);

                        //cur_state = EGameState.Game;
                        //game.Update(gametime, inputhandler);
                    }
                    break;
                case EGameState.Quit:
                    action = GameAction.Exit;
                    break;
                case EGameState.Credits:
                    tempState = credits.Update(gametime, inputhandler, options);
                    CheckGameStateChange(tempState);
                    break;
            }

            music.Update(gametime);
            oldStateScale += (float)gametime.ElapsedGameTime.TotalSeconds;
            oldStateScale = MathHelper.Clamp(oldStateScale, 1, 1.3f);
            oldStateAlpha = 1 - ((oldStateScale - 1) / 0.3f);
            curStateScale += (float)gametime.ElapsedGameTime.TotalSeconds;
            curStateScale = MathHelper.Clamp(curStateScale, 0, 1);

            curStateMatrix = Matrix.CreateTranslation(new Vector3(options.ScreenWidth / 2 /curStateScale, options.ScreenHeight / 2 / curStateScale, 0)) *
                Matrix.CreateScale(curStateScale) *
                Matrix.CreateTranslation(new Vector3(-options.ScreenWidth / (2/curStateScale), -options.ScreenHeight / (2/curStateScale), 0));
            oldStateMatrix = Matrix.CreateTranslation(new Vector3(options.ScreenWidth / 2 /oldStateScale, options.ScreenHeight / 2 / oldStateScale, 0)) *
                Matrix.CreateScale(oldStateScale) *
                Matrix.CreateTranslation(new Vector3(-options.ScreenWidth / (2 / oldStateScale), -options.ScreenHeight / (2 / oldStateScale), 0));
            return action;
        }
Beispiel #3
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;
        }
Beispiel #4
0
 public void Update(GameTime gametime,Vector2 playerPos)
 {
     SetOldState();
     inputkeys.Clear();
     menukeys.Clear();
     gamepadhandler.Update(gametime, run_factor, playerPos);
     keyboardhandler.Update(gametime, run_factor, playerPos);
     keyboardstate = keyboardhandler.getDownKeys;
     gamepadstate = gamepadhandler.GetState.Buttons;
     switch (controller)
     {
         case(Controller.Keyboard):
             pos = keyboardhandler.Pos;
             inputkeys.AddRange(keyboardhandler.GetInputKeys());
             break;
         case(Controller.Xbox_360_Controller):
             pos = gamepadhandler.Pos;
             inputkeys.AddRange(gamepadhandler.GetInputKeys());
             break;
     }
     if (inputkeys.Contains(InputKeys.Right) && inputkeys.Contains(InputKeys.Left))
     {
         while (inputkeys.Contains(InputKeys.Left))
             inputkeys.Remove(InputKeys.Left);
         while (inputkeys.Contains(InputKeys.Right))
             inputkeys.Remove(InputKeys.Right);
     }
     CheckMenuKeys(gametime.GetElapsedTotalSecondsFloat());
 }
Beispiel #5
0
        public void Update(GameTime gameTime)
        {
            if (currentMusic == null)
            {
                currentMusic = soundBank.GetCue(GetRandomTrack(currentPlaylist));
                //Fake 3D Sound for Surround Effect ;)
                currentMusic.Apply3D(new AudioListener(), new AudioEmitter());
                currentMusic.Play();
                popUpText.Text = currentPlaylist[currentMusic.Name];
                StartPopUp();
            }
            if (currentMusic.IsStopped)
            {
                currentMusicindex++;
                if (currentMusicindex >= playList.Keys.Count)
                    currentMusicindex = 0;
                currentMusic = soundBank.GetCue(GetRandomTrack(currentPlaylist));
                currentMusic.Apply3D(new AudioListener(), new AudioEmitter());
                currentMusic.Play();
                popUpText.Text = currentPlaylist[currentMusic.Name];
                StartPopUp();
            }
            if (transition)
            {
                oldVolume -= gameTime.GetElapsedTotalSecondsFloat();
                oldVolume = MathHelper.Clamp(oldVolume, 0, options.MusicVolumeFloat);
                currentVolume += gameTime.GetElapsedTotalSecondsFloat();
                if (currentVolume >= options.MusicVolumeFloat)
                {
                    transition = false;
                    currentVolume = MathHelper.Clamp(currentVolume, 0, options.MusicVolumeFloat);
                    oldCategory.Stop(AudioStopOptions.Immediate);
                    oldMusic.Stop( AudioStopOptions.Immediate);
                }
                oldCategory.SetVolume(oldVolume);
                currentCategory.SetVolume(currentVolume);
            }
            if (popUpActive)
            {
                if (popUpFloatIn)
                {
                    popUp.Y += (int)(popUpSpeed * gameTime.GetElapsedTotalSecondsFloat());
                    AlignPopUpText();
                    if (popUp.Y >= 0)
                    {
                        popUpFloatIn = false;
                    }
                }
                else
                {
                    popUpStillStandelpasedTime += gameTime.GetElapsedTotalSecondsFloat();
                    if (popUpStillStandelpasedTime >= popUpStillStandThreshold)
                    {
                        popUp.Y-= (int)(popUpSpeed * gameTime.GetElapsedTotalSecondsFloat());
                        if (popUp.X <= -(int)(options.Resolution.ScreenHeight * 0.1))
                            popUpActive = false;
                        AlignPopUpText();
                    }
                }

            }
        }