-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
72 lines (60 loc) · 1.42 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : Entity{
public List<InventoryItem> Inventory = new System.Collections.Generic.List<InventoryItem>();
public Player(){
this.Name = "Jocelin";
this.Occupation = "Knight";
this.Health = 150;
this.MaxHealth = this.Health;
this.Money = 200;
}
public void AddinventoryItem(InventoryItem item)
{
this.Strength += item.Strength;
this.Armor += item.Armor;
Inventory.Add(item);
}
public void GainMoney(int amount){
this.Money += amount;
}
public void GainEXP(int amount){
this.Experience += amount;
}
public void HealHp(int amount){
if (this.Health + amount < this.MaxHealth) {
this.Health += amount;
} else {
this.Health = this.MaxHealth;
}
}
public void LevelUp(){
this.Level += 1;
this.MaxHealth += 50;
this.Strength += 4;
this.Armor += 1;
if (this.Experience > this.MaxExperience) {
this.Experience -= this.MaxExperience;
if (this.Level == 3) {
this.MaxExperience = 99999;
} else {
this.MaxExperience *= 3;
}
} else {
if (this.Level == 3) {
this.MaxExperience = 99999;
} else {
this.MaxExperience *= 3;
}
}
}
public bool CheckinventoryItem(string itemName){
bool found = false;
foreach (InventoryItem item in GameState.currentPlayer.Inventory) {
if (item.ItemName.CompareTo (itemName) == 0)
found = true;
}
return found;
}
}