protected void Update(NativeWindow window, IStatsService statsService, IGameUpdateService gameService, IKeyboardService keyboard, IWorldController world, HUDController hud, EntityController entities, ScreensController screens) { world.Update(gameService); hud.Update(gameService); entities.Update(gameService); screens.Update(gameService); }
public void Update(IGameUpdateService gameService) { var action = gameService.IsPressed(_key); _wasReleased = _lastAction == true && action == false; _lastAction = action; }
public void Update(IGameUpdateService gameService) { _topLeft = gameService.WindowSize / 2; _topLeft *= -1; _topLeft += new Position(0, 2); _inventory = _entities.FindPlayer()?.Inventory; }
public void Update(IGameUpdateService gameService) { _blocks = GetAliveBlocks(); foreach (var block in _blocks) { block.Value.Update(gameService); } }
public virtual void Update(IGameUpdateService gameService) { var realPosition = ChunkPosition + Position; _positionOnScreen = realPosition - gameService.GamePosition; //_positionOnScreen = (ChunkPosition - gameService.GamePosition) + Position; //_positionOnScreen = new Position(0, 0); }
private void HandlePlayerMove(IGameUpdateService gameService, Position worldPosition) { var deepGroundedBlock = gameService.WorldController.GetBlock(worldPosition.Add(0, -0.1)); if (deepGroundedBlock != null && deepGroundedBlock.IsCollidable) { gameService.GamePosition.Y = deepGroundedBlock.WorldPosition.Y; } var bottomLeft = worldPosition + new Position(-Width, -0.1); var bottomRight = worldPosition + new Position(Width, -0.1); var topLeft = worldPosition + new Position(-Width, -1.9); var topRight = worldPosition + new Position(Width, -1.9); var isLeft = gameService.WorldController.IsGrounded(bottomLeft) || gameService.WorldController.IsGrounded(topLeft); var isRight = gameService.WorldController.IsGrounded(bottomRight) || gameService.WorldController.IsGrounded(topRight); var isGrounded = gameService.WorldController.IsGrounded(worldPosition); var isTop = gameService.WorldController.IsGrounded(worldPosition + new Position(0, -2)); if (!isGrounded) { if (_jumpPosition == 0) { _jumpPosition = 30; } _jumpPosition++; } else { _jumpPosition = 0; if (gameService.IsPressed(Key.UP)) { _jumpPosition = 0.2; } } if (gameService.IsPressed(Key.LEFT) && !isLeft) { gameService.GamePosition.X -= MoveSpeed; _playerDirection = PlayerDirection.LEFT; } if (gameService.IsPressed(Key.RIGHT) && !isRight) { gameService.GamePosition.X += MoveSpeed; _playerDirection = PlayerDirection.RIGHT; } if (isTop && _jumpPosition < 30) { _jumpPosition = 30; } if (_jumpPosition != 0) { gameService.GamePosition.Y += GetJumpHeight(); } }
public void Update(IGameUpdateService gameService) { var worldPosition = _playerPosition + gameService.GamePosition; _topLeft = gameService.WindowSize * new Position(-0.5, -0.5); HandlePlayerMove(gameService, worldPosition); HandlePlayerHit(gameService, worldPosition); HandlePlayerInventory(gameService); }
public void Update(IGameUpdateService gameService) { var positions = GetChunksPositionsOnScreen(gameService.GamePosition); _selectedChunks = positions.Select(x => GetChunkExact(x)).ToList(); foreach (var chunk in _selectedChunks) { chunk.Update(gameService); } }
private void HandlePlayerHit(IGameUpdateService gameService, Position worldPosition) { if (gameService.IsPressed(Key.INVENTORY)) { return; } if (gameService.IsPressed(Key.DIG_DOWN)) { var bottom = worldPosition + new Position(0, 0.1); var bottomBlock = gameService.WorldController.GetBlock(bottom); HitBlock(bottomBlock, gameService.WorldController); } else if (gameService.IsPressed(Key.DIG_UP)) { var top = worldPosition + new Position(0, -2.1); var topBlock = gameService.WorldController.GetBlock(top); HitBlock(topBlock, gameService.WorldController); } else if (gameService.IsPressed(Key.DIG_LEFT)) { var top = worldPosition + new Position(-Width, -1.1); var bottom = worldPosition + new Position(-Width, -0.1); var topBlock = gameService.WorldController.GetBlock(top); var bottomBlock = gameService.WorldController.GetBlock(bottom); if (topBlock != null) { HitBlock(topBlock, gameService.WorldController); } else if (bottomBlock != null) { HitBlock(bottomBlock, gameService.WorldController); } } else if (gameService.IsPressed(Key.DIG_RIGHT)) { var top = worldPosition + new Position(Width, -1.1); var bottom = worldPosition + new Position(Width, -0.1); var topBlock = gameService.WorldController.GetBlock(top); var bottomBlock = gameService.WorldController.GetBlock(bottom); if (topBlock != null) { HitBlock(topBlock, gameService.WorldController); } else if (bottomBlock != null) { HitBlock(bottomBlock, gameService.WorldController); } } }
public void Update(IGameUpdateService gameService) { _escape = gameService.IsPressed(Key.ESCAPE); _left = gameService.IsPressed(Key.LEFT); _right = gameService.IsPressed(Key.RIGHT); _up = gameService.IsPressed(Key.UP); _drawPos = (gameService.WindowSize / 2); _drawPos.X *= -1; _lastPosition = gameService.GamePosition.Clone(); }
private void HandlePlayerInventory(IGameUpdateService gameService) { _invDown.Update(gameService); _invUp.Update(gameService); if (_invUp.WasReleased()) { Inventory.NextItem(); } if (_invDown.WasReleased()) { Inventory.PreviousItem(); } }
public void Update(IGameUpdateService gameService) { if (gameService.IsPressed(Enums.Key.INVENTORY)) { _visibleScreen = Screen.INVENTORY; } else { _visibleScreen = Screen.NONE; } switch (_visibleScreen) { case Screen.INVENTORY: _inventroyScreen.Update(gameService); break; case Screen.NONE: break; } }
public override void Update(IGameUpdateService gameService) { base.Update(gameService); var realPosition = ChunkPosition + Position; var isConnected = false; for (var x = -2; x <= 2; x++) { for (var y = -2; y <= 2; y++) { var b = gameService.WorldController.GetBlock(realPosition.Add(x, y)); if (b != null) { // DEbug here } if (b != null && b is Tree) { isConnected = true; break; } } } if (isConnected) { _health += 2; if (_health > MaxHealth) { _health = MaxHealth; } } else { _health -= (new Random()).Next(0, 5); } }
public void Update(IGameUpdateService gameService) { _player.Update(gameService); }
public void Update(IGameUpdateService gameService) { FPS = gameService.GetFPS(); _position = (gameService.WindowSize / 2) - new Position(1, 1); _position.Y *= -1; }
public void Update(IGameUpdateService gameService) { _counter.Update(gameService); _debugKeys.Update(gameService); }