Advertisement
Stillkill

Boss Move Example

May 8th, 2019
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. Using System.Threading.Tasks
  2.  
  3. private async Task DoBossMoveTimedDescisionAsync()
  4. {
  5.     bool bossCanMove = true;
  6.     Random RandomGen = new Random();
  7.     while (bossCanMove) //Set to true for example purposes
  8.     {
  9.         int decision = RandomGen.Next(1, 3);
  10.         switch (decision)
  11.         {
  12.             case 1:
  13.                 await DoMove1();
  14.                 break;
  15.             case 2:
  16.                 await DoMove2();
  17.                 break;
  18.             case 3:
  19.                 await DoMove3();
  20.                 break;
  21.             default:
  22.                 throw new Exception(); //This should never happen but you know, shit happens.
  23.         }
  24.         //sleep thread for as long as the boss should wait until his next move. (in milliseconds)
  25.         await Task.Delay(5000);
  26.     }
  27. }
  28. private async Task DoMove1()
  29. {
  30.     //Do something
  31. }
  32. private async Task DoMove2()
  33. {
  34.     //Do something
  35. }
  36. private async Task DoMove3()
  37. {
  38.     //Do something
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement