Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UlearnGame/Controllers/UIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace UlearnGame.Controllers
{
// Эта штука больше похожа на View а не на контроллер, т.к. контроллер передает запросы от пользователя к модели
// а этот класс определяет отображение характеристик
public class UIController
{
private readonly Player player;
Expand Down
6 changes: 6 additions & 0 deletions UlearnGame/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace UlearnGame
public partial class MainForm : Form
{

// класс формы контролирует все, такой код будет сложно тестировать.
private Player mainPlayer;
private readonly Timer updateTimer;
private EnemyController enemyController;
Expand Down Expand Up @@ -120,7 +121,10 @@ private void OnTimerEvent()
if (!IsDead)
Invalidate();
else
{
// после этого таймер продолжает работу
MessageBox.Show("Потрачено");
}
}

private void Init()
Expand Down Expand Up @@ -179,6 +183,8 @@ private void DrawEnemyMissles(Graphics graph)
}
}


// Получается игрок сам собой не управляет, если все делать в этой Form - она станет очень большой.
private void Movement(Player player)
{
if (Keyboard.IsKeyDown(Key.W) || Keyboard.IsKeyDown(Key.Up))
Expand Down
3 changes: 3 additions & 0 deletions UlearnGame/Models/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public Player(Form form)
for (var i = 0; i < MisslePool.Capacity; i++)
MisslePool.Add(new PlayerMissle(missleSource, Direction.None, MissleSpeed, activeForm.ClientSize.Height, activeForm.ClientSize.Width, -2000, -2000));


// Отдельный таймер у игрока может рассогласоваться с другими таймерами в системе. Это приводит к недетерминированности игры.
// Хорошо бы использовать один таймер для всей игры
shootTimer = new Timer
{
Interval = shootInterval
Expand Down