Update() protected method

protected Update ( ) : void
return void
 /// <summary>
 /// Frame Update : Weather
 /// </summary>
 void UpdateWeather()
 {
     // Update weather graphic
     weather.Type = InGame.Screen.WeatherType;
     weather.Max  = InGame.Screen.WeatherMax;
     weather.Update();
 }
        public override StateChangeInformation OnUpdate(float elapsedTime)
        {
            _globalTime += elapsedTime;

            _explosionManager.Update(elapsedTime);
            _gameBackground.Update(elapsedTime);
            _carManager.Update(elapsedTime);
            _player.Update(elapsedTime);
            _weather.Update(elapsedTime);

            if (_playerIsDead)
            {
                _waitTimer += elapsedTime;
                if (_waitTimer >= 3.0f)
                {
                    return(StateChangeInformation.StateChange(typeof(GameOverState), typeof(FlipTransition),
                                                              _player.Points));
                }
            }
            else if (!_playerIsDead && _player.PlayerState == PlayerState.Dead)
            {
                SoundService.StopCurrentSong();
                _playerIsDead = true;
                _waitTimer    = 0;
            }

            _carManager.spawnTime = (100 - _player.Points / 50);
            if (_carManager.spawnTime <= 10)
            {
                _carManager.spawnTime = 10;
            }
            _carManager.points = _player.Points + 150;

            return(StateChangeInformation.Empty);
        }
示例#3
0
 /// <summary>
 /// Update weather graphic
 /// </summary>
 void UpdateWeather()
 {
     weather.Type = InGame.Screen.WeatherType;
     weather.Max  = InGame.Screen.WeatherMax;
     weather.Ox   = InGame.Map.DisplayX;
     weather.Oy   = InGame.Map.DisplayY;
     weather.Update();
 }
示例#4
0
 /// <summary>
 /// Updates all features
 /// </summary>
 public static void Update()
 {
     Player.Update();
     Vehicle.Update();
     Weapon.Update();
     DateTimeSpeed.Update();
     Weather.Update();
     Misc.Update();
 }
示例#5
0
        public override void Update()
        {
            Astronomy.Update();
            Weather.Update();

            m_PathPositions.Add(Astronomy.Orbit);

            m_UpdateInterval = 0;
            if (m_UpdateInterval > 0)
            {
                m_UpdateTimer += Time.deltaTime;
                if (m_UpdateTimer < m_UpdateInterval)
                {
                    return;
                }

                m_UpdateTimer = 0;
            }

            //UPDATE GLOABL ENVIRONMENT INFOS

            // TEMPERATURE
            TemperatureScale = Weather.TemperatureScale;
            Temperature      = Weather.Temperature;
            MinTemperature   = Weather.MinTemperature;
            MaxTemperature   = Weather.MaxTemperature;

            // DATE & TIME
            TimeHour    = (int)Astronomy.Hour;
            TimeMinutes = (int)Astronomy.Minutes;
            TimeSeconds = (int)Astronomy.Seconds;

            DateDay   = (int)Astronomy.Day;
            DateMonth = (int)Astronomy.Month;
            DateYear  = (int)Astronomy.Year;

            // ASTRO
            if (Display.UITextDateTime != null)
            {
                Display.UITextDateTime.text = CurrentDateTimeString;
            }

            if (Display.UITextDay != null)
            {
                Display.UITextDay.text = string.Format(Display.UITextDayFormat, Astronomy.DayTotal + (Display.UseFirstDay ? 1 : 0));
            }

            // WEATHER
            if (Display.UITemperatur != null)
            {
                Display.UITemperatur.text = string.Format(Display.UITemperaturFormat, Mathf.RoundToInt(Weather.Temperature));
            }

            // LIGHT
            LightIntensity = Astronomy.SunLightIntensity;
        }
示例#6
0
 protected void Update()
 {
     if (Input.GetKeyDown(KeyCode.F12))
     {
         timeControl = !timeControl;
     }
     if (timeUpdate)
     {
         startTime += Time.deltaTime / dayLength / 60;
     }
     UpdateTime();
     foreach (var activeWeather in activeWeathers)
     {
         if (activeWeather != weather)
         {
             activeWeather.Update(this);
         }
     }
     weather.Update(this);
     if (_skySystem != null)
     {
         _skySystem.Update(this);
     }
 }
示例#7
0
        /// <summary> ESSENTIALLY THE USER INPUT AND PHYSICS DETAILS
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            var kstate = Keyboard.GetState();
            HashSet <Sprite> groundObjectUpdateOrder = new HashSet <Sprite>();

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.F4))
            {
                Exit();
            }
            if (kstate.IsKeyDown(Keys.F12))
            {
                gameState.SaveGameState();
                Exit();
            }

            // game menu before everything
            if (startingMenu.showMenu)
            {
                startingMenu.Update(kstate, gameTime);
                return;
            }
            else if (startingMenu.selected == "new" && !gameState.ready)
            {
                gameState.CreateNewGame();
                return;
            }
            else if (startingMenu.selected == "load" && !gameState.ready)
            {
                gameState.LoadGameState();
                return;
            }


            // weather
            weather.Update(kstate, gameTime);
            // daylight shader
            dayLight.Update(kstate, gameTime);

            // static update (Menus)
            windArrows.Update(kstate, gameTime, null);
            int windDirection = windArrows.getWindDirection();
            int windSpeed     = windArrows.getWindSpeed();

            inventoryMenu.Update(kstate, gameTime, this.camera);
            craftingMenu.Update(kstate, gameTime, this.camera);

            Collidable.Clear();
            DrawOrder.Clear();

            // set any viewport visible(and not visible when in interior) collidable map pieces for collision - update LandTileLocList and GroundObjLocList
            BoundingBoxLocations.LandTileLocationList.Clear();
            BoundingBoxLocations.OceanTileLocationList.Clear();
            BoundingBoxLocations.GroundObjectLocationList.Clear();
            BoundingBoxLocations.TilesInView.Clear();
            Vector2 minCorner = new Vector2(camera.Position.X - (GameOptions.PrefferedBackBufferWidth / 2), camera.Position.Y - (GameOptions.PrefferedBackBufferHeight / 2));
            Vector2 maxCorner = new Vector2(camera.Position.X + (GameOptions.PrefferedBackBufferWidth / 2), camera.Position.Y + (GameOptions.PrefferedBackBufferHeight / 2));

            foreach (var tp in GameMapTiles.map)
            {
                if ((tp.location.X >= (minCorner.X - GameOptions.tileWidth) && tp.location.X <= (maxCorner.X + GameOptions.tileWidth)) &&
                    (tp.location.Y >= (minCorner.Y - GameOptions.tileHeight) && tp.location.Y <= (maxCorner.Y + GameOptions.tileHeight)))
                {
                    BoundingBoxLocations.TilesInView.Add(tp);

                    if (tp.bbKey.Equals("landTile"))
                    {
                        BoundingBoxLocations.LandTileLocationList.Add(tp);
                        SpatialBounding.SetQuad(tp.GetBase());
                    }
                    else
                    {
                        BoundingBoxLocations.OceanTileLocationList.Add(tp);
                    }

                    if (tp.groundObjects != null)
                    {
                        foreach (var groundObject in tp.groundObjects)
                        {
                            if (!groundObject.remove)
                            {
                                BoundingBoxLocations.GroundObjectLocationList.Add(groundObject);
                            }
                            else
                            {
                                if (groundObject is IGroundObject)
                                {
                                    IGroundObject go = (IGroundObject)groundObject;
                                    go.UpdateRespawn(gameTime);
                                }
                            }
                        }
                    }
                }
            }

            BoundingBoxLocations.InteriorTileList.Clear();
            // set interior for collision for the interior that the player is in
            if (gameState.player.playerInInterior != null)
            {
                // interior tiles for collision
                foreach (var tile in gameState.player.playerInInterior.interiorTiles)
                {
                    BoundingBoxLocations.InteriorTileList.Add(tile);
                    SpatialBounding.SetQuad(tile.GetBase());
                }

                // TODO: update the interior objects for collision (only do this when player is in there)
                foreach (var obj in gameState.player.playerInInterior.interiorObjects)
                {
                    SpatialBounding.SetQuad(obj.GetBase());
                    Collidable.Add(obj);
                }
            }

            Vector2 lastCamPos = camera.Position;

            // update any gameObjects that need to track state (will set camera pos to player)
            HashSet <Sprite> GameStateObjectUpdateOrder = gameState.Update(kstate, gameTime, camera);

            // use this to offset water noise
            camMove.X = ((camera.Position.X % GameOptions.PrefferedBackBufferWidth) / (GameOptions.PrefferedBackBufferWidth));
            camMove.Y = ((camera.Position.Y % GameOptions.PrefferedBackBufferHeight) / (GameOptions.PrefferedBackBufferHeight));

            // update ground objects (they do not track their state since they are encoded in the map)
            foreach (var sp in BoundingBoxLocations.GroundObjectLocationList)
            {
                ICanUpdate updateSp = (ICanUpdate)sp;
                updateSp.Update(kstate, gameTime, this.camera);
                groundObjectUpdateOrder.Add(sp);
            }

            // merge update orders
            HashSet <Sprite> fullUpdateOrder = GameStateObjectUpdateOrder;

            fullUpdateOrder.UnionWith(groundObjectUpdateOrder);

            // Set draw order and collision from the full update order list
            foreach (var sp in fullUpdateOrder)
            {
                if (gameState.player.playerInInterior != null)
                {
                    // only add ships and land tiles when to collision when interior is being viewed
                    if (sp is IShip || sp is ITilePiece || sp is IPlayer)
                    {
                        sp.SetBoundingBox();
                        Collidable.Add(sp);
                        SpatialBounding.SetQuad(sp.GetBase());
                    }
                }
                else
                {
                    Collidable.Add(sp);
                    SpatialBounding.SetQuad(sp.GetBase());
                    DrawOrder.Add(sp);
                }
            }

            // handle collision
            collision.Update(this.camera.Position);
            SpatialCollision();

            this.camera.Update(gameTime);
            base.Update(gameTime);
        }