Time for action – add computer control
Let's build a function so that the computer can take a turn. Add a ComputerTakeATurn
function to the GameLogic
script:
function ComputerTakeATurn() { }
When do we want the computer to take a turn? After player 1, the human, has taken a turn, and the currentPlayer
variable updates to 2
.
Therefore in the ClickSquare
function, after we show the player prompt, let's let the computer take a turn:
ShowPlayerPrompt(); ComputerTakeATurn();
Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.