Forráskód Böngészése

feat: add function save progress game Hotkeys

klmnvan 5 hónapja
szülő
commit
38444d6502

+ 10 - 3
HelloItQuantum/Function/WorkWithFile.cs

@@ -1,4 +1,5 @@
-using HelloItQuantum.Models;
+using DynamicData;
+using HelloItQuantum.Models;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -64,8 +65,14 @@ namespace HelloItQuantum.Function
 		static public void UpdateValueGameProgress(int game, int value, User currentUser)
 		{
             List<User>? users = GetAllUsers();
-			users.Remove(currentUser);
-			if (game == 1) currentUser.GameHotkeys = value;
+            users.Remove(users.FirstOrDefault(it => it.Nickname == currentUser.Nickname));
+			if (game == 1)
+			{
+                if (currentUser.GameHotkeys < value)
+                {
+                    currentUser.GameHotkeys = value;
+                }
+			}
 			if (game == 2) currentUser.GameLabyrinth = value;
 			if (game == 3) currentUser.GameCreateFriend = value;
             users.Add(currentUser);

+ 0 - 6
HelloItQuantum/Models/User.cs

@@ -15,11 +15,5 @@ namespace HelloItQuantum.Models
 		public int GameCreateFriend { get; set; }
 		public int GameLabyrinth { get; set; }
 
-		public User()
-		{
-			GameHotkeys = 0;
-            GameCreateFriend = 0;
-            GameLabyrinth = 0;
-        }
 	}
 }

+ 4 - 1
HelloItQuantum/ViewModels/CreateProfileViewModel.cs

@@ -27,7 +27,10 @@ namespace HelloItQuantum.ViewModels
             newUser.Nickname = Nickname;
             newUser.Name = Name;
             newUser.Surname = Name;
-            if(WorkWithFile.IsWriteUserInFile(newUser))
+            newUser.GameHotkeys = 0;
+            newUser.GameCreateFriend = 0;
+            newUser.GameLabyrinth = 0;
+            if (WorkWithFile.IsWriteUserInFile(newUser))
             {
                 AuthVM = new AuthViewModel();
                 PageSwitch.View = new AuthView();

+ 32 - 1
HelloItQuantum/ViewModels/HotkeysViewModel.cs

@@ -37,7 +37,38 @@ namespace HelloItQuantum.ViewModels
 
         public HotkeysViewModel()
         {
-            act = act = (1, "Изучать программирование - значит уметь выполнять различные действия на компьютере с помощью клавиатуры", 1);
+            string directory = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory))));
+            switch (CurrentUser.GameHotkeys)
+            {
+                case 20:
+                    {
+                        act = (6, "Ты молодец. Знаешь ли ты, как с помощью клавиатуры скопировать текст?", 2);
+                        path = $"{directory}\\Assets\\HotkeysAudio\\voice6.wav";
+                        TextShowAct = "2/5";
+                    }
+                    break;
+                case 40:
+                    {
+                        act = (9, "Отлично справляешься. Знаешь ли ты, как с помощью клавиатуры вставить скопированный текст?", 2);
+                        path = $"{directory}\\Assets\\HotkeysAudio\\voice11.wav";
+                        TextShowAct = "3/5";
+                    }
+                    break;
+                case 60:
+                    {
+                        act = (12, "Почти конец! Знаешь ли ты, как стереть символ спереди курсора?", 2);
+                        path = $"{directory}\\Assets\\HotkeysAudio\\voice15.wav";
+                        TextShowAct = "4/5";
+                    }
+                    break;
+                case 80:
+                    {
+                        act = (15, "И мой последний вопрос. Знаешь ли ты, как закрыть приложение, в котором ты сейчас находишься, с помощью клавиш?", 2);
+                        path = $"{directory}\\Assets\\HotkeysAudio\\voice19.wav";
+                        TextShowAct = "5/5";
+                    } break;
+                default: act = act = (1, "Изучать программирование - значит уметь выполнять различные действия на компьютере с помощью клавиатуры", 1); break;
+            }
             ParsAct();
         }
 

+ 1 - 1
HelloItQuantum/ViewModels/MainWindowViewModel.cs

@@ -23,7 +23,7 @@ namespace HelloItQuantum.ViewModels
 		static GameCreateFriendViewModel? gameCreateFriendVM;
 		public static GameCreateFriendViewModel GameCreateFriendVM { get => gameCreateFriendVM; set => gameCreateFriendVM = value; }
 
-		static HotkeysViewModel hotkeysVM = new HotkeysViewModel();
+		static HotkeysViewModel hotkeysVM;
         public static HotkeysViewModel HotkeysVM { get => hotkeysVM; set => hotkeysVM = value; }
         
         static LabyrinthViewModel labyrinthVM = new LabyrinthViewModel();

+ 10 - 4
HelloItQuantum/Views/HomeView.axaml

@@ -22,13 +22,19 @@
 
 	<Panel>
 		<Image Source="/Assets/ImgHomeView/bg.png" Stretch="Fill"/>
-		<Grid ColumnDefinitions="1*,3*,1*,3*,1*" RowDefinitions="*,200,20,140,20,70,*">
+		<Grid ColumnDefinitions="1*,3*,1*,3*,1*" RowDefinitions="1*,6*,20,5*,20,3*,*" Height="{Binding $parent[Panel].Bounds.Height}">
 			<StackPanel Grid.Column="1" Grid.RowSpan="7" VerticalAlignment="Center" HorizontalAlignment="Stretch">
 				<Image Source="/Assets/ImgHomeView/logoIT.png" MaxWidth="600"/>
 			</StackPanel>
-			<Button Grid.Column="3" Grid.Row="1" Content="Играть" Command="{Binding HomeVM.ClickPlay}" Background="#006838"/>
-			<Button Grid.Column="3" Grid.Row="3" Content="Прогресс" Command="{Binding HomeVM.ClickStatistic}" Background="#F26527"/>
-			<Button Grid.Column="3" Grid.Row="5" Content="Выйти" Command="{Binding HomeVM.ClickExit}" Background="#B21E22"/>
+			<Border Grid.Column="3" Grid.Row="1" CornerRadius="20" Background="#006838" BoxShadow="0 5 #013E21" HorizontalAlignment="Stretch">
+				<Button Content="Играть" Command="{Binding HomeVM.ClickPlay}" CornerRadius="20"/>
+			</Border>
+			<Border Grid.Column="3" Grid.Row="3" CornerRadius="20" Background="#F26527" BoxShadow="0 5 #753417" HorizontalAlignment="Stretch">
+				<Button Content="Прогресс" Command="{Binding HomeVM.ClickStatistic}" CornerRadius="20"/>
+			</Border>
+			<Border Grid.Column="3" Grid.Row="5" CornerRadius="20" Background="#B21E22" BoxShadow="0 5 #470C0D" HorizontalAlignment="Stretch">
+				<Button Content="Выйти" Command="{Binding HomeVM.ClickExit}" CornerRadius="20"/>
+			</Border>
 		</Grid>
 	</Panel>
 	

+ 0 - 2
HelloItQuantum/Views/PlaySectionView.axaml

@@ -41,7 +41,6 @@
 					<Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Center"
 							Command="{Binding PlaySectionVM.GoLabyrinth}" CornerRadius="40">
 						<StackPanel>
-							<ProgressBar Margin="30 20" Height="20" Minimum="0" Maximum="100" Value="14" Foreground="#973F19" Background="#FFFFFF" ShowProgressText="True"/>
 							<Svg Path="/Assets/ImgPlaySection/icon_labyrinth.svg" Margin="30 20"/>
 							<Border Background="White" BorderThickness="1" HorizontalAlignment="Stretch" Margin="30 0 30 10"/>
 							<TextBlock Text="Лабиринт" FontSize="24" TextAlignment="Center" Foreground="#FFFFFF" Margin="0 0 0 30"/>
@@ -55,7 +54,6 @@
 					<Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Center"
 							Command="{Binding PlaySectionVM.GoCreateFriend}" CornerRadius="40">
 						<StackPanel>
-							<ProgressBar Margin="30 20" Height="20" Minimum="0" Maximum="100" Value="14" Foreground="#006838" Background="#FFFFFF" ShowProgressText="True"/>
 							<Svg Path="/Assets/ImgPlaySection/icon_create_friend.svg" Margin="30 20"/>
 							<Border Background="White" BorderThickness="1" HorizontalAlignment="Stretch" Margin="30 0 30 10"/>
 							<TextBlock Text="Создай друга" FontSize="24" TextAlignment="Center" Foreground="#FFFFFF" Margin="0 0 0 30"/>