-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChest.cs
67 lines (59 loc) · 1.35 KB
/
Chest.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
using System;
using System.Collections.Generic;
namespace ttc_wtc
{
[Serializable]
class Chest
{
public List<Item> Items { get; }
public int MapId { get; }
public int X { get; }
public int Y { get; }
public Chest(int mapId, int x, int y, List<Item> items = null)
{
if (items != null)
{
Items = items;
}
else
{
Items = new List<Item>();
}
MapId = mapId;
X = x;
Y = y;
}
public string[] GetItemNames()
{
string[] result = new string[Items.Count];
for (int i = 0; i < Items.Count; i++)
{
result[i] = Items[i].Name;
}
return result;
}
public void DeleteItem(int index)
{
Items.RemoveAt(index);
}
public Item GetItemByIndex(int i)
{
return Items[i];
}
public int GetItemsAmount()
{
return Items.Count;
}
public void AddItem(Item item)
{
Items.Add(item);
}
public void AddItems(Item[] items)
{
foreach (Item item in items)
{
AddItem(item);
}
}
}
}