void SelectObjective() { if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.D)) { if (objectiveIndex >= interactableObjectives.Count - 1) { objectiveIndex = 0; } else { objectiveIndex++; } PlayerCursor.instance.PinPointTile(interactableObjectives[objectiveIndex]); } else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S)) { if (objectiveIndex <= 0) { objectiveIndex = interactableObjectives.Count - 1; } else { objectiveIndex--; } PlayerCursor.instance.PinPointTile(interactableObjectives[objectiveIndex]); } else if (Input.GetKeyDown(KeyCode.Escape)) { ArrivedAtDestination(possibleDestination.GetTileCoordX(), possibleDestination.GetTileCoordY()); //Map.instance.ReturnTilesToNormal(); } }
public void EstablishNewTile(ClickableTile newTile) { gameObject.transform.position = new Vector3(newTile.GetTileCoordX(), newTile.GetTileCoordY(), gameObject.transform.position.z); newTile.AssignUnit(this); originTile = newTile; TireUnit(); }
public void PinPointTile(ClickableTile tile) { //TeleportCursorToTile(tile.GetTileCoordX(), tile.GetTileCoordY()); currentPositionX = tile.GetTileCoordX(); currentPositionY = tile.GetTileCoordY(); SetCursorPosition(); }
//Unit has been selected by the cursor public void UnitSelected() { if (propietary == GameManager.instance.activePlayer && unitUsed == false) { if (GameManager.gameState != GameManager.state.MOVING_UNIT) { unitSelected = true; GameManager.instance.unitSelected = this; Map.instance.ActivateMovementArea(originTile.GetTileCoordX(), originTile.GetTileCoordY(), movementPoints); GameManager.gameState = GameManager.state.MOVING_UNIT; } else { ArrivedAtDestination(originTile.GetTileCoordX(), originTile.GetTileCoordY()); } } else { //TODO: What happens when you select a unit you cannot move (other player's unit or already used unit) GameManager.instance.unitSelected = this; Map.instance.ActivateAttackArea(originTile.GetTileCoordX(), originTile.GetTileCoordY(), movementPoints, ranged, minAttackRange, maxAttackRange); GameManager.gameState = GameManager.state.CHECKING_ENEMY_UNIT; } }
//Player confirms the movement after the unit has moved and/or attacked public void EstablishNewTile() { ClickableTile newTile = possibleDestination; if (unitHasMoved == true && decidedToCapture == false) { capturePoints = 0; } gameObject.transform.position = new Vector3(newTile.GetTileCoordX(), newTile.GetTileCoordY(), gameObject.transform.position.z); originTile.UnassignUnit(); newTile.AssignUnit(this); originTile = newTile; GameManager.instance.unitSelected = null; TireUnit(); Map.instance.ReturnTilesToNormal(); }
int GetHCost(ClickableTile origin, ClickableTile destination) { return(Math.Abs(origin.GetTileCoordX() - destination.GetTileCoordX()) + Math.Abs(origin.GetTileCoordY() - destination.GetTileCoordY())); }