123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Media;
- using Avalonia;
- using Avalonia.Controls;
- using Avalonia.Controls.Shapes;
- using Avalonia.Media;
- using ExCSS;
- using HelloItQuantum.Function;
- using HelloItQuantum.Views;
- namespace HelloItQuantum.ViewModels
- {
- public class LabyrinthViewModel : MainWindowViewModel
- {
- List<string> listContent = new List<string>();
- bool isVisibleContextWindow = true;
- string textInSP = "Æèë-áûë ðîáîò Ðàêåòà. Îí õîòåë ïîìî÷ü ïðîôåññîðó íà ñòàíöèè, íî ìåæäó íèìè áûë ëàáèðèíò èç îðàíæåâûõ è êðàñíûõ êëåòîê. Ðàêåòà ìîã èäòè òîëüêî ïî îðàíæåâûì, èçáåãàÿ êðàñíûõ. Ïîìîãè Ðàêåòå äîáðàòüñÿ äî ñòàíöèè ïðîôåññîðà.";
- string textInBTN = "Äàëåå";
- string pathAudio = $"LabyrinthAudio\\voice_start.wav";
- StackPanel listCommandForRobots = new StackPanel();
- public StackPanel ListCommandForRobots { get => listCommandForRobots; set => SetProperty(ref listCommandForRobots, value); }
- public bool IsVisibleContextWindow { get => isVisibleContextWindow; set => SetProperty(ref isVisibleContextWindow, value); }
- public string TextInSP { get => textInSP; set => SetProperty(ref textInSP, value); }
- public string TextInBTN { get => textInBTN; set => SetProperty(ref textInBTN, value); }
- /// <summary>
- /// Ôóíêöèÿ çàïóñêà àóäèî
- /// </summary>
- public void PlayTask()
- {
- SoundPlayer snd = new SoundPlayer(pathAudio);
- snd.Play();
- }
- public void GoNext()
- {
- IsVisibleContextWindow = false;
- }
- /// <summary>
- /// Âåðíóòüñÿ â ãëàâíîå ìåíþ
- /// </summary>
- public void GoBack()
- {
- PageSwitch.View = new PlaySectionView();
- }
- /// <summary>
- /// Äîáàâëåíèå ñïèñêà êîìàíä ïðè íàæàòèè íà êíîïêó
- /// </summary>
- /// <param name="comand">ïåðåäàâàåìàÿ êîìàíäà (âëåâî, âïðàâî, âíèç, ââåðõ)</param>
- public void AddButton(string comand)
- {
- ListCommandForRobots.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center;
- TextBlock tb = new TextBlock();
- tb.Text = "go " + comand;
- tb.TextAlignment = TextAlignment.Center;
- tb.FontSize = 24;
- tb.Width = 150;
- tb.Margin = new Thickness(10);
- Border border = new Border();
- border.CornerRadius = new CornerRadius(20);
- border.Background = new SolidColorBrush(Avalonia.Media.Color.FromArgb(242, 101, 39, 0));
- border.Child = tb;
- border.Margin = new Thickness(5);
- ListCommandForRobots.Children.Add(border);
- listContent.Add(tb.Text);
- }
- /// <summary>
- /// Î÷èùåíèå ñïèñêà êîìàíä äëÿ ðîáîòà
- /// </summary>
- public void DeleteCommand() {
- ListCommandForRobots.Children.Clear();
- listContent.Clear();
- }
- /// <summary>
- /// Ïðîâåðêà ïðàâèëüíîñòè ñïèñêà êîìàíä
- /// </summary>
- public void CheckCommand()
- {
- //ListCommandForRobots.Children.Clear();
- var c = ListCommandForRobots.Children;
- bool googCommands = true;
- if (listContent.Count < 9)
- {
- googCommands = false;
- }
- else {
- for (int i = 0; i < listContent.Count; i++) {
- if (listContent[0] != "go right") {
- googCommands = false; break;
- }
- if (listContent[1] != "go right")
- {
- googCommands = false; break;
- }
- if (listContent[2] != "go up")
- {
- googCommands = false; break;
- }
- if (listContent[3] != "go up")
- {
- googCommands = false; break;
- }
- if (listContent[4] != "go left")
- {
- googCommands = false; break;
- }
- if (listContent[5] != "go up")
- {
- googCommands = false; break;
- }
- if (listContent[6] != "go up")
- {
- googCommands = false; break;
- }
- if (listContent[7] != "go right")
- {
- googCommands = false; break;
- }
- if (listContent[8] != "go right")
- {
- googCommands = false; break;
- }
- }
- }
- if (googCommands)
- {
- WorkWithFile.UpdateValueGameProgress(2, 100, CurrentUser);
- pathAudio = $"LabyrinthAudio\\voice_win.wav";
- TextInSP = "Çäîðîâî! Ðàêåòà îêàçàëñÿ íà èññëåäîâàòåëüñêîé ñòàíöèè è ïîìîã ïðîôåññîðó ïî÷èíèòü ëàáîðàòîðèþ. Ìèññèÿ âûïîëíåíà!";
- IsVisibleContextWindow = true;
- TextInBTN = "Çàêðûòü";
- }
- else {
-
- TextInSP = "Ê ñîæàëåíèþ, Ðàêåòà çàáëóäèëñÿ è íå äîáðàëñÿ äî èññëåäîâàòåëüñêîé ñòàíöèè. Íå îò÷àèâàéñÿ! Ïîïðîáóé çàíîâî!";
- pathAudio = $"LabyrinthAudio\\voice_loss.wav";
- IsVisibleContextWindow = true;
- TextInBTN = "Çàêðûòü";
- }
- }
-
- }
- }
|