예제 #1
0
    public void buildRoad(Player type)      // Function the build a road, passes the plyaer through the argument
    {
        if (type.playerType == "player")    // If a player is building
        {
            road             = "player";    // Set the road ownership to player
            edge.image.color = Color.green; //Change the road colour to the player's colour
        }

        else if (type.playerType == "ai") // If the ai is building
        {
            road             = "ai";      // Set the ownership to the AI
            edge.image.color = Color.red; // Change the road colour to rhe AI's colour
        }

        if (type.roadBuilding == false && game.roadSetup == false) //If it is not setup or roadbuilding charge the player resoruces to build
        {
            type.lumber = type.lumber - 1;
            type.bricks = type.bricks - 1;
        }

        else if (humanPlayer.roadBuilding == true)  //If the road building development card was played
        {
            humanPlayer.roadBuildingCount++;        // Counts how many roads were placed
            if (humanPlayer.roadBuildingCount == 2) //If two roads have been placed
            {
                dev.endRoadBuilding();              // End the development card effect
            }
        }

        else if (game.roadSetup == true && game.gameTurn == "player") // If it is the setup phase and it is the plaeyrs turn
        {
            game.setupEdgePointsChosen++;                             // Tracks the number of roads palced
            game.gameTurn = "ai";                                     // Sets the turn to the AI
            aiScript.createRoad();                                    // AI places its setup road
            game.gameTurn = "player";                                 // Sets the game turn to player
            if (game.setupEdgePointsChosen == 2)                      // If two raods have been placed
            {
                diceroll.produce();                                   //Produce resoruces for the start of the game
                announcements.text = "Your Turn";                     // Tells the player its their turn
                game.roadSetup     = false;
                game.setup         = false;                           // Ends setup
            }
        }
    }