Game Development Reference
In-Depth Information
public int Health = 2;
public int Strength = 1;
public int Magic = 0;
public int Defense = 0;
public int Speed = 1;
public int Damage = 1;
public int Armor = 0;
public int NoOfAttacks = 1;
public string Weapon;
public Vector2 Position;
}
Note
The entity class is inherited from a specialized class called
ScriptableObject
. This
is essential to know how we will use it in the game. We will cover
ScriptableOb-
ject
in more detail in
Chapter 5
,
NPCs and Interactions
.
The player object
Basing the player's character on the
Entity
object makes the definition of the player a
lot simpler. So, you only need to focus on what is specific to the player's character itself,
that is, the differences between the player and all the other game entities.
So, the player character we see here is the only one who has
Inventory
,
Money
, and
Skills
since they are specific to our hero's work in our game. This is implemented in the
following code with the player inheriting all the properties from the
Entity
class: