-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrainingModeLogic.cs
More file actions
111 lines (105 loc) · 4.23 KB
/
TrainingModeLogic.cs
File metadata and controls
111 lines (105 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
namespace KeyboardMaster
{
class TrainingModeLogic:ITrainingModeLogic
{
static TrainingMode trainingMode;
ConfigurationRequest ConfigurationRequest = new ConfigurationRequest();
static float speed = 4;
public static int counter = 0;
static int lvlspeedGL;
public static bool verification = true;
public static char currentChar;
public static DispatcherTimer timer = new DispatcherTimer();
static char[] en_Alpha = new char[26] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
public TrainingModeLogic(TrainingMode tr)
{
trainingMode = tr;
}
public void Start(int levelspeed)
{
timer = new DispatcherTimer();
var lang = ConfigurationRequest.GetDictonary().LanguageDictonary;
lvlspeedGL = levelspeed;
speed /= levelspeed;
timer.Tick += timer_tick;
timer.Interval = new TimeSpan(0, 0, 0, 0, (int)speed*1000);
App.isTraining = true;
StartGenerating();
}
public void StartGenerating()
{
trainingMode.movesCount.Content = $"Пройдено шагов: {counter}";
timer.Stop();
Random rnd = new Random();
if (lvlspeedGL != 4)
{
switch (counter)
{
}
if (counter < 15)
{
trainingMode.speedUp.Content = $"Повышение скорости через: {15 - counter}";
}
else if (counter == 15)
{
trainingMode.speedUp.Content = $"Повышение скорости через: {30 - counter}";
lvlspeedGL++;
speed = 4 / lvlspeedGL;
timer.Tick += timer_tick;
timer.Interval = new TimeSpan(0, 0, 0, (int)speed * 1000);
}
else if (counter<30)
{
trainingMode.speedUp.Content = $"Повышение скорости через: {30 - counter}";
}
else if (counter == 30)
{
trainingMode.speedUp.Content = $"Повышение скорости через: {60 - counter}";
lvlspeedGL++;
speed = 4 / lvlspeedGL;
timer.Tick += timer_tick;
timer.Interval = new TimeSpan(0, 0, 0, (int)speed * 1000);
}
else if (counter <60)
{
trainingMode.speedUp.Content = $"Повышение скорости через: {60 - counter}";
}
else if (counter==60)
{
trainingMode.speedUp.Content = $"Повышение скорости через: Макс";
lvlspeedGL++;
speed = 4 / lvlspeedGL;
timer.Tick += timer_tick;
timer.Interval = new TimeSpan(0, 0, 0, (int)speed * 1000);
}
}
else
{
trainingMode.speedUp.Content = $"Повышение скорости через: Макс";
}
trainingMode.speed.Content = $"Текущая скорость: {lvlspeedGL}";
currentChar = en_Alpha[rnd.Next(0, 24)];
trainingMode.charLb.Content = currentChar.ToString();
timer.Start();
}
public void timer_tick(object sender, EventArgs e)
{
App.isTraining = false;
trainingMode.rect.Fill = Brushes.Red;
timer.Stop();
MessageBox.Show($"Тренировка окончена. Ваш результат: {counter}");
counter = 0;
trainingMode.rect.Fill = null;
trainingMode.startBut.IsEnabled = true;
speed = 4;
}
}
}