-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathplayer.cs
34 lines (32 loc) · 978 Bytes
/
player.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
using System;
namespace asciiadventure {
class Player : MovingGameObject {
public Player(int row, int col, Screen screen, string name) : base(row, col, "@", screen) {
Name = name;
}
public string Name {
get;
protected set;
}
public override Boolean IsPassable(){
return true;
}
public String Action(int deltaRow, int deltaCol){
int newRow = Row + deltaRow;
int newCol = Col + deltaCol;
if (!Screen.IsInBounds(newRow, newCol)){
return "nope";
}
GameObject other = Screen[newRow, newCol];
if (other == null){
return "negative";
}
// TODO: Interact with the object
if (other is Treasure){
other.Delete();
return "Yay, we got the treasure!";
}
return "ouch";
}
}
}