Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Using System.Threading.Tasks
- private async Task DoBossMoveTimedDescisionAsync()
- {
- bool bossCanMove = true;
- Random RandomGen = new Random();
- while (bossCanMove) //Set to true for example purposes
- {
- int decision = RandomGen.Next(1, 3);
- switch (decision)
- {
- case 1:
- await DoMove1();
- break;
- case 2:
- await DoMove2();
- break;
- case 3:
- await DoMove3();
- break;
- default:
- throw new Exception(); //This should never happen but you know, shit happens.
- }
- //sleep thread for as long as the boss should wait until his next move. (in milliseconds)
- await Task.Delay(5000);
- }
- }
- private async Task DoMove1()
- {
- //Do something
- }
- private async Task DoMove2()
- {
- //Do something
- }
- private async Task DoMove3()
- {
- //Do something
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement