当前位置: 首页>>代码示例>>C#>>正文


C# GameTime.GetElapsedTotalSecondsFloat方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.GameTime.GetElapsedTotalSecondsFloat方法的典型用法代码示例。如果您正苦于以下问题:C# GameTime.GetElapsedTotalSecondsFloat方法的具体用法?C# GameTime.GetElapsedTotalSecondsFloat怎么用?C# GameTime.GetElapsedTotalSecondsFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.GameTime的用法示例。


在下文中一共展示了GameTime.GetElapsedTotalSecondsFloat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateEvent

        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;
        }
开发者ID:pampersrocker,项目名称:STAR,代码行数:19,代码来源:StartLevelCountdown.cs

示例2: Update

        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;
        }
开发者ID:pampersrocker,项目名称:STAR,代码行数:74,代码来源:GameManager.cs

示例3: Update

        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;
        }
开发者ID:pampersrocker,项目名称:STAR,代码行数:44,代码来源:CustMapMenu.cs

示例4: Update

 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());
 }
开发者ID:pampersrocker,项目名称:STAR,代码行数:29,代码来源:Inputhandler.cs

示例5: Update

        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();
                    }
                }

            }
        }
开发者ID:pampersrocker,项目名称:STAR,代码行数:62,代码来源:Music.cs


注:本文中的Microsoft.Xna.Framework.GameTime.GetElapsedTotalSecondsFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。