A.I. Pressing next turn after 1 second.

Hello
I’m working on a turn-based strategy game. But I can’t seem to make my A.I. “press” next turn. I thought about making it so that it does it after 1 second. So what I basically need is a timer that goes of when it is the A.I. turn.

I have a variable that tells the turn. (turnNumber) which tells it who’s turn it is. Then I need it to add 1 to turnNumber. “turnNumber ++;” How can I do so that it does that after 1 second?

Thanks for your time.

[EDIT]: I use JavaScript.

Use StartCoroutine. This code will not work without proper construction. This is an example.

int playerUp, rounds;

public void Start()
{
	StartCoroutine(CheckPlayerState());
}

public void OnGUI()
{
	GUI.Label(new Rect(20, 20, 100, 20), "" + rounds);
}

public IEnumerator CheckPlayerState()
{
	if(playerUp == 2)
	{
		yield return new EnemyPlay();
	}else if(playerUp == 1){
		yield return new YouPlay();
	}
}

public IEnumerator EnemyPlay()
{
	// AI System;
	yield return new WaitForSeconds(1);
	
	if(AI.Strategy == null) // PSEUDO-CODE
	{
		playerUp = 1;
		rounds++;
	}
    yield return null;
}