-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathHero.cs
99 lines (95 loc) · 3.51 KB
/
Hero.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Roguelike
{
class Hero : Character
{
public Hero(Point coords, int hitPoints, int expPoints, int rangeOfVision, int speedPoints, string name)
{
Coords = coords;
PrevCoords = new Point(coords.X, coords.Y);
HitPoints = hitPoints; //should depend on class/hit dices
ExpPoints = expPoints;
RangeOfVision = rangeOfVision;
SpeedPoints = speedPoints;
MovePoints = 0;
Name = name;
Symbol = '@';
IsActionDone = false;
Program.GameEngine.SetObject(coords.X, coords.Y, this);
}
public enum GameAction
{
OpenInventory = ConsoleKey.E,
PickUpItem = ConsoleKey.G,
Exit = ConsoleKey.Escape,
InspectMap = ConsoleKey.M,
Attack,
DropItem
} public int ExpPoints { get; set; } public GameAction CurrentGameAction { get; set; } public void DoGameAction()
{
switch (CurrentGameAction)
{
case GameAction.OpenInventory:
//OpenInventory(Hero.Inventory)
//Hero.Inventory is a list, containing many lists of
//weapon, armor, potion and so on..
Program.GameEngine.InfoBorder.WriteNextLine("You open an inventory");
IsActionDone = false;
break;
case GameAction.PickUpItem:
//Hero.AddItem(Item)
Program.GameEngine.InfoBorder.WriteNextLine("You pick up an item");
IsActionDone = true;
break;
case GameAction.Exit:
Program.GameEngine.StartMenu();
IsActionDone = false;
break;
case GameAction.Attack:
//make this as attack function
IsActionDone = true;
break;
case GameAction.DropItem:
//drop item
Program.GameEngine.InfoBorder.WriteNextLine("You drop an item");
IsActionDone = false;
break;
case GameAction.InspectMap:
Program.GameEngine.InfoBorder.Clear();
Program.GameEngine.InfoBorder.WriteNextLine("You are inspecting the map");
Program.GameEngine.InspectMap();
IsActionDone = false;
break;
default:
IsActionDone = false;
break;
}
} protected override void ResetGameAction()
{
CurrentGameAction = (GameAction)(1000);
} protected override bool HandleCollisions(TileFlyweight tile)
{
ResetGameAction();
IsActionDone = true;
if (tile.Object == null) return true;
Target = tile.Object;
if(Target is Monster)
{
CurrentGameAction = GameAction.Attack;
Program.GameEngine.InfoBorder.WriteNextLine($"{Name} ran into {Target.Name}");
return false;
}
return true;
//if (Target is Treasure)...
} }}