public void ReturnToShapeQueue() { currentShape = null; currentlyDragging = false; ClearPreviewTiles(); shapeQueuePanel.CancelPreparedSelections(); }
public void BeginDraggingPiece(ForecastShape shape, float _rotation = 0f) { rotation = _rotation; dragOrigin = Input.mousePosition; currentShape = shape; currentlyDragging = true; // StartCoroutine(BuildTileArraySlow()); BuildTileArray(); UpdateTileArray(); }
public bool AllTilesValid(int x, int y, ForecastShape shape, float rotation = 0f) { for (int i = 0; i < shape.tiles.Count; i++) { Vector2Int offs = ShapePositioning.RotateOffset(shape.tiles[i].offset, rotation); if (!ValidCoordinate(offs.x + x, offs.y + y)) { return(false); } } return(true); }
public void EndDragging() { if (PGTileStateManager.instance.AllTilesValid(currentOriginTile.x, currentOriginTile.y, currentShape, rotation)) { applyForecastShape.ApplyCurrentTetramino(currentShape); if (onPlaceShape != null) { onPlaceShape(); } currentShape = null; currentlyDragging = false; } else { ReturnToShapeQueue(); } }
public void ApplyCurrentTetramino(int x, int y, float rotation = 0f) { ForecastShape _shape = forecastQueue.forecastShapes[0]; for (int i = 0; i < _shape.tiles.Count; i++) { Vector2Int offs = RotateOffset(_shape.tiles[i].offset, rotation); if (_shape.tiles[i].type == ForecastType.Water) { state.AddWater(x + offs.x, y + offs.y, 1); } if (_shape.tiles[i].type == ForecastType.Sun) { state.AddSunlight(x + offs.x, y + offs.y, 1); } } forecastQueue.forecastShapes.RemoveAt(0); }
// public ForecastQueue forecastQueue; public void ApplyCurrentTetramino(ForecastShape _shape) { // Debug.Log("Applying!!!"); int x = shapePositioning.currentOriginTile.x; int y = shapePositioning.currentOriginTile.y; ForecastType type = WeatherQueue.currentWeather; for (int i = 0; i < _shape.tiles.Count; i++) { Vector2Int offs = ShapePositioning.RotateOffset(_shape.tiles[i].offset, shapePositioning.rotation); // note that this is not using the type on the forecastTile (deprecated), but is instead using the current weather in the weatherqueue. if (_shape.tiles[i].type != ForecastType.None) { state.AddWeather(x + offs.x, y + offs.y, type, 1); } // if(_shape.tiles[i].type == ForecastType.Sun) state.AddSunlight(x+offs.x, y+offs.y, 1); } }