/// <summary> /// Main method for updating the game engine. /// </summary> /// <param name="elapsedTime">Elapsed time in milleseconds</param> internal void Update(float elapsedTime) { _itemSystem.UpdateItemSystem(elapsedTime, _playerSystem.Player); _playerSystem.Update(elapsedTime, _enemySystem.Enemies); _enemySystem.Update(_playerSystem.Player, elapsedTime); _questSystem.UpdateActiveQuest(_enemySystem.SpawnList, _npcSystem.NonPlayerCharacters, _playerSystem.Player.BackPack.BackpackItems, _level); #region Interaction objectlayer-player if (PlayerEnters(_playerSystem.Player)) { _level.ForegroundVisible = false; } else { _level.ForegroundVisible = true; } //Collision handling -player if (PlayerAndTileCollide()) { _playerSystem.Player.ThisUnit.Bounds.X = _playerSystem.Player.LastPosition.X; _playerSystem.Player.ThisUnit.Bounds.Y = _playerSystem.Player.LastPosition.Y; _playerSystem.Player.MoveToPosition = new Vector2(_playerSystem.Player.ThisUnit.Bounds.Center.X, _playerSystem.Player.ThisUnit.Bounds.Center.Y); _playerSystem.Player.Direction = new Vector2(_playerSystem.Player.ThisUnit.Bounds.Center.X, _playerSystem.Player.ThisUnit.Bounds.Center.Y); } else { if (!(_playerSystem.Player.ThisUnit.Bounds.X == _playerSystem.Player.LastPosition.X && _playerSystem.Player.ThisUnit.Bounds.Y == _playerSystem.Player.LastPosition.Y)) { _playerSystem.Player.CanMoveDown = true; _playerSystem.Player.CanMoveLeft = true; _playerSystem.Player.CanMoveRight = true; _playerSystem.Player.CanMoveUp = true; } _playerSystem.Player.LastPosition = _playerSystem.Player.ThisUnit.Bounds.Location; } #endregion }
internal void UpdateSimulation(float a_elapsedTime) { m_itemSystem.UpdateItemSystem(a_elapsedTime, m_playerSystem.m_player); m_playerSystem.Update(a_elapsedTime, m_enemySystem.m_enemies); m_enemySystem.Update(m_playerSystem.m_player, a_elapsedTime); //m_friendSystem.Update(m_playerSystem.m_player); m_questSystem.UpdateActiveQuest(m_enemySystem.m_spawnList, m_friendSystem.m_friends, m_playerSystem.m_player.BackPack.BackpackItems, m_level); if (PlayerEnters(m_playerSystem.m_player)) { m_level.foregroundVisible = false; } else { m_level.foregroundVisible = true; } if (PlayerAndTileCollide()) { m_playerSystem.m_player.ThisUnit.Bounds.X = m_playerSystem.m_player.LastPosition.X; m_playerSystem.m_player.ThisUnit.Bounds.Y = m_playerSystem.m_player.LastPosition.Y; m_playerSystem.m_player.MoveToPosition = new Vector2(m_playerSystem.m_player.ThisUnit.Bounds.Center.X, m_playerSystem.m_player.ThisUnit.Bounds.Center.Y); m_playerSystem.m_player.Direction = new Vector2(m_playerSystem.m_player.ThisUnit.Bounds.Center.X, m_playerSystem.m_player.ThisUnit.Bounds.Center.Y); } else { if (!(m_playerSystem.m_player.ThisUnit.Bounds.X == m_playerSystem.m_player.LastPosition.X && m_playerSystem.m_player.ThisUnit.Bounds.Y == m_playerSystem.m_player.LastPosition.Y)) { m_playerSystem.m_player.CanMoveDown = true; m_playerSystem.m_player.CanMoveLeft = true; m_playerSystem.m_player.CanMoveRight = true; m_playerSystem.m_player.CanMoveUp = true; } m_playerSystem.m_player.LastPosition = m_playerSystem.m_player.ThisUnit.Bounds.Location; } }