-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
73 lines (60 loc) · 2.31 KB
/
Program.cs
File metadata and controls
73 lines (60 loc) · 2.31 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
using PatternBehaviorTree.Auxiliary;
using System;
using System.Collections.Generic;
using System.Threading;
namespace PatternBehaviorTree
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("=== СИСТЕМА ИИ ОХРАННИКА (BEHAVIOR TREE) ===\n");
var patrolPoints = new List<Vector2>
{
new Vector2(3, 0),
new Vector2(3, 3),
new Vector2(0, 3),
new Vector2(0, 0)
};
var guard = new GuardAI(new Vector2(0, 0), patrolPoints);
var player = new PlayerController(new Vector2(5, 5));
guard.Player = player;
Console.WriteLine("Игра началась!");
Console.WriteLine("Управление: W/A/S/D - движение игрока");
Console.WriteLine("Нажмите ESC для выхода\n");
int tick = 0;
bool isRunning = true;
while (isRunning)
{
tick++;
Console.WriteLine($"\n--- Тик {tick} ---");
player.HandleInput();
guard.Update();
Console.WriteLine($"Охранник: {guard.Position}");
player.ShowPosition();
if (guard.CanSeePlayer)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("ОХРАННИК ВИДИТ ИГРОКА!");
Console.ResetColor();
}
else if (guard.IsAlerted)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("ОХРАННИК В ТРЕВОГЕ!");
Console.ResetColor();
}
Thread.Sleep(1000);
if (Console.KeyAvailable)
{
var exitKey = Console.ReadKey(true);
if (exitKey.Key == ConsoleKey.Escape)
{
isRunning = false;
Console.WriteLine("\nИгра завершена.");
}
}
}
}
}
}