-
Notifications
You must be signed in to change notification settings - Fork 0
/
BasicObject.cs
94 lines (83 loc) · 1.83 KB
/
BasicObject.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
92
93
using System;
using System.Xml;
namespace Game
{
/// <summary>
/// Basic object is only filling of empty map squares.
/// </summary>
public class BasicObject :IPlace
{
protected char symbol;
public BasicObject ()
{
this.symbol = ' ';
}
/// <summary>
/// Symbol of basic object is empty space.
/// </summary>
public virtual char Symbol()
{
return this.symbol;
}
public virtual void SetSymbol(string x)
{
this.symbol = char.Parse(x);
}
public virtual bool CanMoveTo()
{
return true;
}
public virtual bool CanDropItemOnto()
{
return true;
}
public virtual IPlace DropItemOnto(Item i)
{
Chest chest = new Chest("Rubble on the ground", new Inventory(100));
chest.Content.Add(i);
return chest;
}
/// <summary>
/// Write to the xml - just a simple node with no childs or attributes.
/// </summary>
/// <returns>
/// The xml.
/// </returns>
/// <param name='doc'>
/// Document.
/// </param>
/// <param name='elementName'>
/// Element name.
/// </param>
public virtual XmlElement ToXml(XmlDocument doc, string elementName)
{
XmlElement basicObject = doc.CreateElement("BasicObject");
basicObject.SetAttribute("symbol", symbol.ToString());
return basicObject;
}
/// <summary>
/// Performs the action on basicObject - just moves player to the object.
/// </summary>
/// <returns>
/// The action.
/// </returns>
/// <param name='p'>
/// If set to <c>true</c> p.
/// </param>
/// <param name='l'>
/// If set to <c>true</c> l.
/// </param>
/// <param name='msg'>
/// If set to <c>true</c> message.
/// </param>
/// <param name='l2'>
/// If set to <c>true</c> l2.
/// </param>
public virtual IPlace AutomaticAction(Player p)
{
return this;
}
public virtual void VoluntaryAction(Player p)
{}
}
}