public void ShowInformation(bool undamagedShips, bool damagedShips, bool destroyedShips, bool hitTiles) { List <Gameplay.Tile> drawnTiles = new List <Gameplay.Tile>(); for (int i = 0; i < player.board.ships.Length; i++) { Ship ship = player.board.ships[i]; if ((undamagedShips && ship.health == ship.maxHealth) || (damagedShips && ship.health < ship.maxHealth && ship.health > 0) || (destroyedShips && ship.health == 0)) { ship.transform.position = ship.placementInfo.boardPosition + Vector3.up * MiscellaneousVariables.it.boardUIRenderHeight; ship.transform.rotation = ship.placementInfo.boardRotation; ship.gameObject.SetActive(true); foreach (Gameplay.Tile tile in ship.tiles) { drawnTiles.Add(tile); SetTileGraphic(tile.coordinates, ship.concealedBy != null ? TileGraphicMaterial.SHIP_CONCEALED : TileGraphicMaterial.SHIP_INTACT); } } } if (hitTiles) { for (int x = 0; x < player.board.tiles.GetLength(0); x++) { for (int y = 0; y < player.board.tiles.GetLength(1); y++) { Gameplay.Tile tile = player.board.tiles[x, y]; if (tile.hit) { drawnTiles.Add(tile); SetTileGraphic(tile.coordinates, tile.containedShip != null ? TileGraphicMaterial.SHIP_DAMAGED : TileGraphicMaterial.TILE_HIT); } } } } foreach (Gameplay.Tile tile in player.board.tiles) { if (!drawnTiles.Contains(tile)) { SetTileGraphic(tile.coordinates, TileGraphicMaterial.NONE, Color.clear); } } }
public override void ProcessExternalInputWhileHeld(Vector3 inputPosition) { base.ProcessExternalInputWhileHeld(inputPosition); Gameplay.Tile targetedTile = grid.GetTileAtPosition(inputPosition); if (effect == null) { if (targetedTile != null) { effect = Effect.CreateEffect(typeof(ArtilleryAttack)); effect.targetedPlayer = Battle.main.defender; effect.visibleTo = Battle.main.attacker; } else { hookedPosition = Utilities.GetPositionOnElevationFromPerspective(inputPosition, Camera.main.transform.position, pickupPosition.y).projectedPosition; } } if (effect != null) { ArtilleryAttack attack = effect as ArtilleryAttack; if (targetedTile != null) { if (targetedTile != attack.target) { attack.target = targetedTile; RefreshEffectRepresentation(); } } else { Destroy(attack.gameObject); effect = null; } } }
protected override void ProcessInput() { base.ProcessInput(); if (tap) { bool newShipSelected = false; foreach (Ship ship in player.board.placementInfo.allShips) { Vector3 localInputPosition = ship.transform.InverseTransformPoint(currentInputPosition.world); if (Mathf.Abs(localInputPosition.x) < 0.5f && Mathf.Abs(localInputPosition.z) < ship.maxHealth / 2.0f) { if (player.board.placementInfo.selectedShip != null) { player.board.placementInfo.selectedShip.Place(player.board.placementInfo.selectedShip.placementInfo.lastLocation); } ship.Pickup(); newShipSelected = true; // foreach (Gameplay.Tile tile in managedBoard.placementInfo.validTiles) // { // RemoveTileAgent(tile.coordinates); // } UpdateMarkers(); break; } } if (!newShipSelected) //If no other ship was selected { bool clickedOnBoard = grid.GetTileAtPosition(currentInputPosition.world) != null; bool clickedOnDrawer = shipbox.IsPressed(); if (player.board.placementInfo.selectedShip != null) //If a ship is already selected { if (!clickedOnBoard) //If the user clicked outside of the board { if (clickedOnDrawer) //And the player clicks on the drawer { //Put the ship into the drawer player.board.placementInfo.selectedShip.Place(null); } else { //Place the ship back where it was player.board.placementInfo.selectedShip.Place(player.board.placementInfo.selectedShip.placementInfo.lastLocation); } UpdateMarkers(); } } else { if (clickedOnDrawer && player.board.placementInfo.notplacedShips.Count == 0) { Battle.main.NextTurn(); gameObject.SetActive(false); FindAgent(x => { return(true); }, typeof(TurnNotifier)).gameObject.SetActive(true); } } } } if (pressed && player.board.placementInfo.selectedShip != null) { Gameplay.Tile candidateTile = grid.GetTileAtPosition(currentInputPosition.world); if (candidateTile != null) { if (player.board.placementInfo.selectableTiles.Contains(candidateTile)) { player.board.SelectTileForPlacement(candidateTile); UpdateMarkers(); } } } if (endPress) { if (player.board.placementInfo.selectedShip) { player.board.placementInfo.selectedTiles = new List <Gameplay.Tile>(); player.board.ReevaluateTiles(); UpdateMarkers(); } } }
void UpdateMarkers() { List <Gameplay.Tile> setTiles = new List <Gameplay.Tile>(); //CONCEALMENT foreach (Ship ship in player.board.placementInfo.placedShips) { if (ship is Cruiser) { Cruiser cruiser = ship as Cruiser; foreach (Gameplay.Tile tile in cruiser.concealmentArea) { if (!player.board.placementInfo.occupiedTiles.Contains(tile) && !player.board.placementInfo.invalidTiles.Contains(tile) && !player.board.placementInfo.selectedTiles.Contains(tile)) { if (cruiser.concealing == null) { grid.SetTileGraphic(tile.coordinates, Agents.Grid.TileGraphicMaterial.TILE_CONCEALMENT_AREA); setTiles.Add(tile); } } } } } //INVALID foreach (Gameplay.Tile tile in player.board.placementInfo.invalidTiles) { if (!player.board.placementInfo.occupiedTiles.Contains(tile) && !player.board.placementInfo.selectedTiles.Contains(tile)) { grid.SetTileGraphic(tile.coordinates, Agents.Grid.TileGraphicMaterial.TILE_RESTRICTED); setTiles.Add(tile); } } //SELECTED foreach (Gameplay.Tile tile in player.board.placementInfo.selectedTiles) { if (!player.board.placementInfo.occupiedTiles.Contains(tile)) { grid.SetTileGraphic(tile.coordinates, Agents.Grid.TileGraphicMaterial.TILE_SELECTED_FOR_PLACEMENT); setTiles.Add(tile); } } //OCCUPIED foreach (Ship ship in player.board.placementInfo.placedShips) { for (int i = 0; i < ship.tiles.Length; i++) { Gameplay.Tile tile = ship.tiles[i]; if (ship.concealedBy) { grid.SetTileGraphic(tile.coordinates, Agents.Grid.TileGraphicMaterial.SHIP_CONCEALED); } else { grid.SetTileGraphic(tile.coordinates, Agents.Grid.TileGraphicMaterial.SHIP_INTACT); } setTiles.Add(tile); } } for (int x = 0; x < player.board.tiles.GetLength(0); x++) { for (int y = 0; y < player.board.tiles.GetLength(1); y++) { Gameplay.Tile candidate = player.board.tiles[x, y]; if (!setTiles.Contains(candidate)) { grid.SetTileGraphic(candidate.coordinates, Agents.Grid.TileGraphicMaterial.NONE, Color.clear); } } } //SetDestroyerFiringAreaMarkers(true, player.board.placementInfo.placedShips.ToArray()); }