-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObject.cs
More file actions
96 lines (88 loc) · 2.77 KB
/
Copy pathObject.cs
File metadata and controls
96 lines (88 loc) · 2.77 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OOPFirst
{
class Object
{
public int x;
public int y;
public char sym;
protected List<Point> pList;
public Object(int _x, int _y, char _sym)
{
x = _x;
y = _y;
sym = _sym;
}
public Object(int startLine, int lineLength, int secondCoordinateLine, char sym, Direction direction)
{
if (direction == Direction.RIGHT)
{
pList = new List<Point>(lineLength);
for (int x = startLine; x < lineLength + startLine; x++)
{
Point point = new Point(x, secondCoordinateLine, sym);
pList.Add(point);
}
}
else if (direction == Direction.DOWN)
{
pList = new List<Point>(lineLength);
for (int y = startLine; y < lineLength + startLine; y++)
{
Point point = new Point(secondCoordinateLine, y, sym);
pList.Add(point);
}
}
}
/// <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)
{
character.Dmg();
character.ReturnLastPosition();
return true;
}
}
return false;
}
/// <summary>
/// Проверка, не наступил ли перс на одиночное препятствие
/// </summary>
/// <param name="character">Имя персонажа</param>
/// <returns></returns>
public bool BStepBy(Character character)
{
if (character.x == x && character.y == y)
{
character.Dmg();
character.WriteAdditionalStatus("Вы наступили на препятствие");
character.ReturnLastPosition();
return true;
}
return false;
}
public void LineDraw()
{
foreach (Point i in pList)
{
i.Draw();
}
}
public void Draw()
{
Console.SetCursorPosition(x, y);
Console.Write(sym);
}
}
}