I'm using Unity to make a game. I have multiple animal enemies in the game.
I'm working on missions inside the game that you have to kill a random number of random animals, this I already have.
What I have a problem with is to increase the mission count when you kill an animal.
I got a script (dead) sitting on each animal, when the animal dies it calls a public function inside the dead script.
From the dead script it should increase an int value in the "MissionHolder" script where all the animals have a int value to increase when you kill a animal.
The problem is I don't know which animal gets killed when the player kills a animal, what I did is this:
public string Name;
public MissionHolder missionHolder;
public void Kill()
{
if (name == "Tiger")
{
missionHolder.Tiger += 1;
}
if (name == "Hyena")
{
missionHolder.Hyena += 1;
}
if (name == "Gorilla")
{
missionHolder.Gorilla += 1;
}
if (name == "Giraffe")
{
missionHolder.Giraffe += 1;
}
if (name == "Gazelle")
{
missionHolder.Gazelle += 1;
}
etc.
Now I just name each animal by its name on the dead script but this is not really efficient.
Does anyone knows a better way to do this?