Hello, I created custom class called Monster (to contain Monster data). After that I created MonsterDatabase class where I want to store all Monsters. Here is my database code:
public class MonsterDatabase : MonoBehaviour {
public List<Monster> Monsters;
List<Item> items;
void Start () {
Monsters = new List<Monster>();
items = GameObject.FindGameObjectWithTag("ItemDatabase").GetComponent<ItemDatabase>().Items;
Monsters.Add(new Monster("InitialMonster",
100,
25,
15,
0,
5,
MonsterType.BEAST,
RarityType.UNCOMMON,
AttackType.CRUSHED,
new List<Item>(){items[0], items[1]},
new List<float>(){0.90f, 0.50f}));
}
}
Everything is okey, I can see all values and Lists with Items & chances to loot them in inspector after starting game.
Now I want to spawn Monster which will have in script MonsterController copy of that monster created in Database. I have that:
Monster monster;
void Start () {
monsterDatabase = GameObject.FindGameObjectWithTag("MonsterDatabase").GetComponent<MonsterDatabase>();
this.monster = monsterDatabase.Monsters[0].GetMonster();
//Die();
}
where GetMonster() is method inside Monster Class to get copy of it:
public Monster GetMonster()
{
return new Monster(this.monsterName, this.experience, this.health, this.defense, this.damageFrom, this.damageTo, this.monsterType, this.rarityType, this.attackType, this.lootItems, this.itemProbability);
}
Unfortunatelly inside MonsterController monsterDatabase seems to be empty. I don’t know why cus i can see it have “InitialMonster” when I open it in inspector. Can someone tell me what I am doing wrong? If I am not clear please leave a comment, I will try to explain my problem better.