-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMines.cs
More file actions
93 lines (84 loc) · 2.24 KB
/
Copy pathMines.cs
File metadata and controls
93 lines (84 loc) · 2.24 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OOPFirst
{
class Mines
{
public int mineActiv = 0;
int x;
int y;
char sym = ' ';
List<Mines> pList;
Random randX = new Random();
Random randY = new Random();
public Mines (int _number)
{
pList = new List<Mines>(_number);
for (int i = 0; i < _number; i++)
{
x = randX.Next(1,48);
y = randY.Next(1,18);
Mines m = new Mines(x, y);
pList.Add(m);
}
}
public Mines(int _x, int _y)
{
x = _x;
y = _y;
}
public void DrawMines()
{
foreach (Mines i in pList)
{
i.Draw();
}
}
/// <summary>
/// Проверка нахождение на мину
/// </summary>
/// <param name="character">Имя персонажа</param>
/// <returns></returns>
public bool StepBy(Character character)
{
for (int i = 0; i < pList.Count; i++)
{
if (character.x == pList[i].x && character.y == pList[i].y)
{
if (pList[i].MineActiv())
{
character.Dmg();
character.WriteAdditionalStatus("Вы наступили на мину");
pList[i].mineActiv = 1;
pList[i].sym = 'M';
return true;
}
}
}
return false;
}
public void Draw()
{
Console.SetCursorPosition(x, y);
Console.Write(sym);
}
/// <summary>
/// Проверка, наступал ли персонаж на эту мину
/// </summary>
/// <returns></returns>
public bool MineActiv()
{
if (mineActiv == 0)
{
return true;
}
else
{
return false;
}
}
}
}