Abdula_2314124

DialogController

Mar 23rd, 2024
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. public class DialogController
  2.     {
  3.         private int _index = 0;
  4.         public void SetDialog(Dialog dialog, string[] text, bool isHaveChoise = false)
  5.         {
  6.             _index = 0;
  7.             dialog.text = text;
  8.             dialog.isHaveChoise = isHaveChoise;
  9.         }
  10.  
  11.         public void ShowDialog(Dialog player, Dialog other)
  12.         {
  13.             while (true)
  14.             {
  15.                 if (_index >= player.text.Length && _index >= other.text.Length) break;
  16.  
  17.                 Console.WriteLine($"\n{player.text[_index]}");
  18.                 Console.WriteLine($"\n{other.text[_index]}");
  19.                 Console.WriteLine("Enter \"k\" to continue");
  20.  
  21.                 if (Console.ReadKey().KeyChar == 'k')
  22.                 {
  23.                     UpdateIndex();
  24.                 }
  25.             }
  26.         }
  27.  
  28.         private void UpdateIndex()
  29.         {
  30.             _index++;
  31.         }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment