-
Notifications
You must be signed in to change notification settings - Fork 0
/
NPC.cs
74 lines (69 loc) · 1.98 KB
/
NPC.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
using System;
using System.Collections.Generic;
namespace ttc_wtc
{
[Serializable]
class NPC : Entity
{
public List<Item> NPCInventory;
public Dialog Dialog { get; set; }
public NPC(string name, int hp, int damage, int defense, int mapId, int x, int y,char symb, Dialog dialog, List<Item> items = null) :
base(name, hp, damage, defense, mapId, x, y, symb)
{
Dialog = dialog;
if (items != null)
{
NPCInventory = items;
}
else
{
NPCInventory = new List<Item>();
}
}
public Item GetItemFromThisNPC(string name)
{
Item GetItem=null;
if (NPCInventory.Count>0)
{
foreach (Item item in NPCInventory)
{
if (item.Name == name)
{
GetItem = item;
NPCInventory.Remove(item);
return GetItem;
}
}
}
return GetItem;
}
public bool Have(string name)
{
if (NPCInventory.Count > 0)
{
foreach (Item item in NPCInventory)
{
if (item.Name == name)
{
return true;
}
}
}
return false;
}
public List<string> GetTiefsItemNames()
{
List<string> TiefsItemsName = new List<string>();
for (int i = 0; i < NPCInventory.Count; i++)
{
TiefsItemsName.Add(NPCInventory[i].Name);
}
if (NPCInventory.Count > 0)
{
TiefsItemsName.Add("Забрать все");
}
TiefsItemsName.Add("Выйти");
return TiefsItemsName;
}
}
}