-
Notifications
You must be signed in to change notification settings - Fork 1
/
Player.cs
158 lines (134 loc) · 4.4 KB
/
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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormJam
{
class Player
{
private Game game;
public string Name { get; private set; }
private int str { get; set; } //amount of dmg done
private int dex { get; set; } //chances to hit
private int agi { get; set; } //chances to get hit
private int cons { get; set; } //max HP
private int charisma { get; set; } //affect sell/buy price
public int currentHP { get; private set; }
//public int MaxHP { get; private set; }
public int Level { get; protected set; }
public int CurrentExp { get; set; }
//public int NextExp { get; private set; }
public int Gold { get; set; }
private Item[] equipement;
private enum equip { Weapon, Helmet, Chest, Pants, Boots }
private Weapon weapon { get; set; } //equipement
private Helmet helmet { get; set; }
private Chest chest { get; set; }
private Pants pants { get; set; }
private Boots boots { get; set; }
public List<Item> Inventory { get; private set; }
public int X { get; set; }
public int Y { get; set; }
public Player(string name, int ID, Game game)
{
Name = name;
this.game = game;
}
public Player(string name, int str, int dex, int agi, int cons, int charisma, Game game)
{
Name = name;
this.str = str;
this.dex = dex;
this.agi = agi;
this.cons = cons;
this.charisma = charisma;
currentHP = cons * 10;
Level = 1;
CurrentExp = 0;
Gold = 0;
this.game = game;
}
public void TakeDmg(int attack)
{
currentHP -= attack;
if (currentHP <= 0)
{
//using (StreamWriter writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "Char.csv"))
//{
// writer.Write(this.toString());
//}
game.GameForm.DeathAnimation();
//game.GameForm.game = new Game(game.GameForm);
}
}
public void GetExp(int amount)
{
if (CurrentExp + amount >= (5 + Level) * Level)//NextExp)
{
Level++;
CurrentExp = Math.Abs(CurrentExp - /*NextExp*/((5 + Level) * Level));
//NextExp = (5 + Level) * Level;
}
else
{
CurrentExp += amount;
}
}
public void Spawn(string[,] map)
{
for (int i = 0; i < map.GetLength(0); i++)
{
for (int j = 0; j < map.GetLength(1); j++)
{
if (map[i, j] == "c")
{
X = j;
Y = i;
}
}
}
}
public void Equip(Item item)
{
//TODO: put equipment back into inventory
switch(item.GetType().ToString())
{
case "Weapon":
equipement[(int)equip.Weapon] = item;
weapon = (Weapon)item;
break;
case "Helmet":
equipement[(int)equip.Helmet] = item;
helmet = (Helmet)item;
break;
case "Chest":
equipement[(int)equip.Chest] = item;
chest = (Chest)item;
break;
case "Pants":
equipement[(int)equip.Pants] = item;
pants = (Pants)item;
break;
case "Boots":
equipement[(int)equip.Boots] = item;
boots = (Boots)item;
break;
}
}
public int Strength
{
get
{
var property = weapon.GetType().GetProperty("Str");
return 0;
}
set { }
}
//public string toString()
//{
// return MaxHP.ToString() + ";" + Level.ToString() + ";" + CurrentExp.ToString() + ";" + Gold.ToString();
//}
}
}