public void SetNextPoint() { if (CurrentPath.Count <= 0) { return; } Vector2Int nextPoint = CurrentPath.Peek(); if (CurrentPath.Count == 1 && !TilemapGrid.IsWalkable(nextPoint.x, nextPoint.y)) { _player.Stats.ViewDirection = MoveDirection.FromNextPoint(new Vector2(nextPoint.x, nextPoint.y), _player); InvokeCollisionNotification(nextPoint); CurrentPath.Dequeue(); return; } else { _character.Components.RealPosition.position = new Vector3(nextPoint.x, nextPoint.y, 0); CurrentPath.Dequeue(); } }
public void TestGridCollisionCells() { Assert.False(grid.IsWalkable(new TilemapCell(1, 3, 0))); Assert.False(grid.IsWalkable(new TilemapCell(1, 4, 0))); Assert.False(grid.IsWalkable(new TilemapCell(1, 5, 0))); Assert.False(grid.IsWalkable(new TilemapCell(1, 6, 0))); Assert.False(grid.IsWalkable(new TilemapCell(2, 3, 0))); Assert.False(grid.IsWalkable(new TilemapCell(2, 4, 0))); Assert.False(grid.IsWalkable(new TilemapCell(2, 5, 0))); Assert.False(grid.IsWalkable(new TilemapCell(2, 6, 0))); Assert.False(grid.IsWalkable(new TilemapCell(4, 1, 0))); Assert.False(grid.IsWalkable(new TilemapCell(4, 2, 0))); Assert.False(grid.IsWalkable(new TilemapCell(4, 3, 0))); Assert.False(grid.IsWalkable(new TilemapCell(4, 4, 0))); Assert.False(grid.IsWalkable(new TilemapCell(4, 5, 0))); Assert.False(grid.IsWalkable(new TilemapCell(4, 6, 0))); Assert.False(grid.IsWalkable(new TilemapCell(4, 7, 0))); Assert.False(grid.IsWalkable(new TilemapCell(4, 8, 0))); Assert.False(grid.IsWalkable(new TilemapCell(5, 1, 0))); Assert.False(grid.IsWalkable(new TilemapCell(5, 2, 0))); Assert.False(grid.IsWalkable(new TilemapCell(5, 3, 0))); Assert.False(grid.IsWalkable(new TilemapCell(5, 4, 0))); Assert.False(grid.IsWalkable(new TilemapCell(5, 5, 0))); Assert.False(grid.IsWalkable(new TilemapCell(5, 6, 0))); Assert.False(grid.IsWalkable(new TilemapCell(5, 7, 0))); Assert.False(grid.IsWalkable(new TilemapCell(5, 8, 0))); Assert.False(grid.IsWalkable(new TilemapCell(6, 1, 0))); Assert.False(grid.IsWalkable(new TilemapCell(6, 2, 0))); Assert.False(grid.IsWalkable(new TilemapCell(6, 6, 0))); Assert.False(grid.IsWalkable(new TilemapCell(6, 7, 0))); Assert.False(grid.IsWalkable(new TilemapCell(6, 8, 0))); Assert.False(grid.IsWalkable(new TilemapCell(7, 1, 0))); Assert.False(grid.IsWalkable(new TilemapCell(7, 2, 0))); Assert.False(grid.IsWalkable(new TilemapCell(7, 6, 0))); Assert.False(grid.IsWalkable(new TilemapCell(7, 7, 0))); Assert.False(grid.IsWalkable(new TilemapCell(7, 8, 0))); Assert.False(grid.IsWalkable(new TilemapCell(8, 1, 0))); Assert.False(grid.IsWalkable(new TilemapCell(8, 6, 0))); Assert.False(grid.IsWalkable(new TilemapCell(8, 7, 0))); Assert.False(grid.IsWalkable(new TilemapCell(8, 8, 0))); Assert.False(grid.IsWalkable(new TilemapCell(9, 6, 0))); }