public void TrySpawn(string animalName1, string animalName2, string animalName3)
{
bool hasSpawned = false;
TestList.Clear();
TestList.Add(0); TestList.Add(1); TestList.Add(2);
while (TestList.Count > 0)
{
var i = random.Next(0, TestList.Count);
var sp = SpawnPoints[TestList[i]];
TestList.RemoveAt(i);
var x = (int) Math.Floor(sp.transform.position.x);
var z = (int) Math.Floor(sp.transform.position.z);
if (TerrainGrid.IsWalkable(x, z))
{
Spawn(sp, animalName1, animalName2, animalName3);
hasSpawned = true;
break;
}
}
if (!hasSpawned)
{
TestList.Add(3); TestList.Add(4);
while (TestList.Count > 0)
{
var i = random.Next(0, TestList.Count);
var sp = SpawnPoints[TestList[i]];
TestList.RemoveAt(i);
var x = (int)Math.Floor(sp.transform.position.x);
var z = (int)Math.Floor(sp.transform.position.z);
if (TerrainGrid.IsWalkable(x, z))
{
Spawn(sp, animalName1, animalName2, animalName3);
hasSpawned = true;
break;
}
}
}
if (hasSpawned)
networkView.RPC("ShowWords", RPCMode.All, animalName1, animalName2, animalName3);
else
Debug.Log("No more space to spawn!");
}