// updates logical bounds of visible tiles private void updateVisibleArea() { var cameraWidth = this.cameraWidth(); visibleArea.set((int)(cameraTarget.x - cameraWidth + 1), (int)(cameraTarget.y - camera.orthographicSize + 1), (int)(cameraTarget.x + cameraWidth - 1), (int)(cameraTarget.y + camera.orthographicSize - 1)); }
// updates camera bounds to make 3 tiles around map visible private void updateCameraBounds() { LocalMap map = GameModel.localMap; cameraBounds.set(0, 0, map.xSize, map.ySize); cameraBounds.extendX((int)(overlookTiles - cameraWidth())); cameraBounds.extendY((int)(overlookTiles - camera.orthographicSize)); cameraBounds.move(0, GameModel.get().selector.position.z / 2f); }
// updates camera bounds to make 3 tiles around map visible private void updateCameraBounds() { LocalMap map = GameModel.localMap; cameraBounds.set(0, 0, map.xSize, map.ySize); cameraBounds.extendX((int)(overlookTiles - cameraWidth())); cameraBounds.extendY((int)(overlookTiles - camera.orthographicSize)); cameraBounds.move(0, -target.z / 4f); }
//Defines rectangular bounds where camera can move. Supports fixed padding on world borders. private void defineCameraBounds() { bounds.set(0, 0, worldSize, worldSize); bounds.extend(padding - camera.orthographicSize); // add padding to map to clearly show world's borders if (bounds.minX > bounds.maxX) { bounds.minX = (worldSize + padding) / 2; bounds.maxX = bounds.minX; } float hiddenTiles = (1f - paneSize.height / paneSize.width) * camera.orthographicSize; bounds.minY -= hiddenTiles; bounds.maxY += hiddenTiles; effectiveCameraSize.set(-camera.orthographicSize, hiddenTiles - camera.orthographicSize, camera.orthographicSize - 1, camera.orthographicSize - hiddenTiles - 1); Debug.Log(effectiveCameraSize); cameraFovRange.max = worldSize / 2 + padding + hiddenTiles; }
// moves camera towards pointer private void checkPointer() { visibleArea.set(effectiveCameraSize).move(camera.transform.localPosition); speed = visibleArea.getDirectionVector(pointerController.targetPosition); }