forked from fxwkes/Roguelike
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonster.cs
More file actions
75 lines (71 loc) · 2.2 KB
/
Copy pathMonster.cs
File metadata and controls
75 lines (71 loc) · 2.2 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Roguelike
{
class Monster : Character
{
public Monster(Point coords, int hitPoints, int rangeOfVision, int speedPoints, string name, char symbol, IMonsterIntelligence ai)
{
Coords = coords;
PrevCoords = new Point(coords);
HitPoints = hitPoints; //should depend on class/hit dices
RangeOfVision = rangeOfVision;
SpeedPoints = speedPoints;
MovePoints = 0;
Name = name;
Symbol = symbol;
AI = ai;
IsActionDone = false;
Program.GameEngine.SetObject(coords.X, coords.Y, this);
}
public enum GameAction
{
Attack
}
public GameAction CurrentGameAction { get; set; }
public IMonsterIntelligence AI { private get; set; }
public void MoveTo(BaseEntity enemy)
{
if (Coords.GetDistance(enemy.Coords) > RangeOfVision)
{
IsActionDone = false;
return;
}
AI.FindPath(this, enemy);
Move();
}
public void DoGameAction()
{
switch (CurrentGameAction)
{
case GameAction.Attack:
//make this as attack function
IsActionDone = true;
break;
default:
IsActionDone = false;
break;
}
}
protected override void ResetGameAction()
{
CurrentGameAction = (GameAction)(1000);
}
protected override bool HandleCollisions(TileFlyweight tile)
{
ResetGameAction();
if (tile.Object == null) return true;
Target = tile.Object;
if (Target.Symbol == '@') //simple check, <=> (this is Hero)
{
CurrentGameAction = GameAction.Attack;
Program.GameEngine.InfoBorder.WriteNextLine($"{Name} ran into {Target.Name}");
return false;
}
return true;
}
}
}