Esempio n. 1
0
    // Player right clicks
    public void PlayerRightClicksAtWorldPosition(Vector3 worldPosition)
    {
        // Return if no selected piece
        if (!selectedPiece)
        {
            return;
        }

        // Get clicked on hex
        GameHex targetHex = gameMap.GetWorldPositionHex(worldPosition);

        if (targetHex == null)
        {
            return;
        }

        // Move or attack piece
        if (actionMap.MoveableToTileAtTileCoords(targetHex.tileCoords))
        {
            gameMap.MovePiece((Unit)selectedPiece, targetHex.hexCoords);
            actionMap.ClearActionTiles();
            return;
        }
        if (actionMap.AttackableTileAtTileCoords(targetHex.tileCoords))
        {
            gameMap.AttackPiece(selectedPiece, targetHex.piece);
            actionMap.ClearActionTiles();
            return;
        }
    }
        public void HexIsAttackable()
        {
            Vector3Int targetHexCoords = new Vector3Int(2, -2, 0);

            gameMap.AddPiece(unit2, targetHexCoords);
            actionMap.CreateActionMap(unit1, gameMap);
            Vector3Int targetTileCoords = Hex.HexToTileCoords(targetHexCoords);

            Assert.IsTrue(actionMap.AttackableTileAtTileCoords(targetTileCoords));
        }