-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entity.cs
131 lines (103 loc) · 2.36 KB
/
Entity.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Entity : ScriptableObject
{
public string Name;
public string Occupation;
public int Level = 1;
public int Experience = 0;
public int MaxExperience = 20;
public int Health = 2;
public int MaxHealth = 2;
public int Strength = 1;
public int Armor = 0;
public int Money = 0;
public int TakeDamage(int Amount) {
int totalDamage;
float randomiser = Random.Range (0.8f, 1.2f);
totalDamage = Mathf.FloorToInt(Mathf.Clamp((Amount - Armor),0, int.MaxValue)*randomiser);
if (this.Health - totalDamage < 0) {
this.Health = 0;
} else {
this.Health -= totalDamage;
}
return totalDamage;
}
public int TakeResistedDamage(int Amount){
int totalDamage;
float randomiser = Random.Range (0.8f, 1.2f);
totalDamage = Mathf.FloorToInt(((Mathf.Clamp((Amount - this.Armor),0, int.MaxValue))/(int)2)*randomiser);
if (this.Health - totalDamage < 0) {
this.Health = 0;
} else {
this.Health -= totalDamage;
}
return totalDamage;
}
public void Attack(Entity Entity) {
Entity.TakeDamage(Strength);
}
//Setters//
public void SetName(string Name){
this.Name = Name;
}
public void SetOccupation(string Occupation){
this.Occupation = Occupation;
}
public void SetLevel(int Level){
this.Level = Level;
}
public void SetExperience(int Experience){
this.Experience = Experience;
}
public void SetHealth(int Health){
this.Health = Health;
}
public void SetMaxHealth(int MaxHealth){
this.MaxHealth = MaxHealth;
}
public void SetStrength(int Strength){
this.Strength = Strength;
}
public void SetMaxExperience(int MaxExperience){
this.MaxExperience = MaxExperience;
}
public void SetArmor(int Armor){
this.Armor = Armor;
}
public void SetMoney(int Money){
this.Money = Money;
}
//Getters//
public string GetName(){
return this.Name;
}
public string GetOccupation(){
return this.Occupation;
}
public int GetLevel(){
return this.Level;
}
public int GetExperience(){
return this.Experience;
}
public int GetHealth(){
return this.Health;
}
public int GetMaxHealth(){
return this.MaxHealth;
}
public int GetStrength(){
return this.Strength;
}
public int GetMaxExperience(){
return this.MaxExperience;
}
public int GetArmor(){
return this.Armor;
}
public int GetMoney(){
return this.Money;
}
}