LabyrinthViewModel.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Media;
  5. using Avalonia;
  6. using Avalonia.Controls;
  7. using Avalonia.Media;
  8. using ExCSS;
  9. using HelloItQuantum.Function;
  10. using HelloItQuantum.Views;
  11. namespace HelloItQuantum.ViewModels
  12. {
  13. public class LabyrinthViewModel : MainWindowViewModel
  14. {
  15. bool isVisibleContextWindow = true;
  16. string textInSP = "Æèë-áûë ðîáîò Ðàêåòà. Îí õîòåë ïîìî÷ü ïðîôåññîðó íà ñòàíöèè, íî ìåæäó íèìè áûë ëàáèðèíò èç îðàíæåâûõ è êðàñíûõ êëåòîê. Ðàêåòà ìîã èäòè òîëüêî ïî îðàíæåâûì, èçáåãàÿ êðàñíûõ. Ïîìîãè Ðàêåòå äîáðàòüñÿ äî ñòàíöèè ïðîôåññîðà.";
  17. string textInBTN = "Äàëåå";
  18. StackPanel listCommandForRobots = new StackPanel();
  19. public StackPanel ListCommandForRobots { get => listCommandForRobots; set => SetProperty(ref listCommandForRobots, value); }
  20. public bool IsVisibleContextWindow { get => isVisibleContextWindow; set => SetProperty(ref isVisibleContextWindow, value); }
  21. public string TextInSP { get => textInSP; set => SetProperty(ref textInSP, value); }
  22. public string TextInBTN { get => textInBTN; set => SetProperty(ref textInBTN, value); }
  23. List<string> listContent = new List<string>();
  24. public void GoNext() {
  25. TextInSP = "Çäîðîâî! Ðàêåòà îêàçàëñÿ íà èññëåäîâàòåëüñêîé ñòàíöèè è ïîìîã ïðîôåññîðó ïî÷èíèòü ëàáîðàòîðèþ. Ìèññèÿ âûïîëíåíà!";
  26. IsVisibleContextWindow = false;
  27. }
  28. public void GoBack()
  29. {
  30. PageSwitch.View = new PlaySectionView();
  31. }
  32. public void AddButton(string comand)
  33. {
  34. ListCommandForRobots.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center;
  35. TextBlock tb = new TextBlock();
  36. tb.Text = "go " + comand;
  37. tb.TextAlignment = TextAlignment.Center;
  38. tb.FontSize = 24;
  39. tb.Width = 150;
  40. tb.Margin = new Thickness(10);
  41. Border border = new Border();
  42. border.CornerRadius = new CornerRadius(20);
  43. border.Background = new SolidColorBrush(Avalonia.Media.Color.FromArgb(242, 101, 39, 0));
  44. border.Child = tb;
  45. border.Margin = new Thickness(5);
  46. ListCommandForRobots.Children.Add(border);
  47. listContent.Add(tb.Text);
  48. }
  49. public void DeleteCommand() {
  50. ListCommandForRobots.Children.Clear();
  51. listContent.Clear();
  52. }
  53. public void CheckCommand()
  54. {
  55. //ListCommandForRobots.Children.Clear();
  56. var c = ListCommandForRobots.Children;
  57. bool googCommands = true;
  58. if (listContent.Count < 9)
  59. {
  60. googCommands = false;
  61. }
  62. else {
  63. for (int i = 0; i < listContent.Count; i++) {
  64. if (listContent[0] != "go right") {
  65. googCommands = false; break;
  66. }
  67. if (listContent[1] != "go right")
  68. {
  69. googCommands = false; break;
  70. }
  71. if (listContent[2] != "go up")
  72. {
  73. googCommands = false; break;
  74. }
  75. if (listContent[3] != "go up")
  76. {
  77. googCommands = false; break;
  78. }
  79. if (listContent[4] != "go left")
  80. {
  81. googCommands = false; break;
  82. }
  83. if (listContent[5] != "go up")
  84. {
  85. googCommands = false; break;
  86. }
  87. if (listContent[6] != "go up")
  88. {
  89. googCommands = false; break;
  90. }
  91. if (listContent[7] != "go right")
  92. {
  93. googCommands = false; break;
  94. }
  95. if (listContent[8] != "go right")
  96. {
  97. googCommands = false; break;
  98. }
  99. }
  100. }
  101. if (googCommands)
  102. {
  103. WorkWithFile.UpdateValueGameProgress(2, 100, CurrentUser);
  104. TextInSP = "Çäîðîâî! Ðàêåòà îêàçàëñÿ íà èññëåäîâàòåëüñêîé ñòàíöèè è ïîìîã ïðîôåññîðó ïî÷èíèòü ëàáîðàòîðèþ. Ìèññèÿ âûïîëíåíà!";
  105. IsVisibleContextWindow = true;
  106. TextInBTN = "Çàêðûòü";
  107. }
  108. else {
  109. TextInSP = "Ê ñîæàëåíèþ, Ðàêåòà çàáëóäèëñÿ è íå äîáðàëñÿ äî èññëåäîâàòåëüñêîé ñòàíöèè. Íå îò÷àèâàéñÿ! Ïîïðîáóé çàíîâî!";
  110. IsVisibleContextWindow = true;
  111. TextInBTN = "Çàêðûòü";
  112. }
  113. }
  114. }
  115. public class NameComand {
  116. public string name { get; set; }
  117. }
  118. }