示例#1
0
    private void highlightAttackTiles(CoordinateSet currentTankCoordinates)
    {
        gs.toggleTankRings(playerTurn == PlayerColors.Red ? redTanks : blueTanks, currentTankCoordinates, true);
        gs.toggleTankRings(playerTurn == PlayerColors.Red ? blueTanks : redTanks, new CoordinateSet(-1, -1), true);


        Tank currentTank = gs.getPlayerTank(playerTurn, currentTankCoordinates);

        TileHighlighter.highlightValidTiles(currentTank.getWeapon().getValidAttacks(gs.getGrid()), round);
    }
示例#2
0
    private void handleMove(RaycastHit hit)
    {
        if ((hit.transform.gameObject.tag == "Red Tank" && playerTurn == PlayerColors.Red) || (hit.transform.gameObject.tag == "Blue Tank" && playerTurn == PlayerColors.Blue))
        {
            tankClicked = hit.transform.gameObject;
            CoordinateSet tankCoordinates = new CoordinateSet((int)hit.transform.position.x, (int)hit.transform.position.z);
            Tank          currentTank     = gs.getPlayerTank(playerTurn, tankCoordinates);

            // If the player didn't choose one of their own tanks, or if that tank is dead, just ignore
            if (currentTank.isDead() || currentTank.getPlayer().getPlayerColor() != playerTurn)
            {
                tankClicked = null;
                return;
            }

            TileHighlighter.resetTiles();
            TileHighlighter.highlightValidTiles(currentTank.getValidMovements(gs.getGrid(), tankCoordinates), round);
            gs.toggleTankRings(playerTurn == PlayerColors.Red ? redTanks : blueTanks, tankCoordinates, true);
            gs.toggleTankRings(playerTurn == PlayerColors.Red ? blueTanks : redTanks, new CoordinateSet(-1, -1), false);
            updateTooltips("Move2");
        }
        else if (tankClicked != null)
        {
            tileClicked = hit.transform.gameObject;

            CoordinateSet tankCoordinates = new CoordinateSet((int)tankClicked.transform.position.x, (int)tankClicked.transform.position.z);
            CoordinateSet tileCoordinates = new CoordinateSet((int)tileClicked.transform.position.x, (int)tileClicked.transform.position.z);

            if (gs.checkValidMove(playerTurn, tankCoordinates, tileCoordinates, true))
            {
                TileHighlighter.resetTiles();
                Tank currentTank = gs.getPlayerTank(playerTurn, tileCoordinates);

                // Tank moving animation
                StartCoroutine(moveTank(tileClicked, tankClicked, currentTank));

                tileClicked = null;
                tankClicked = null;
                round       = Rounds.Attack;
                TileHighlighter.resetTiles();
                printTurn();
                updateTooltips("Attack1");
                gs.toggleTankRings(redTanks, new CoordinateSet(-1, -1), false);
                gs.toggleTankRings(blueTanks, new CoordinateSet(-1, -1), false);
            }
        }
    }