|
|
@ -29,7 +29,6 @@ public class blockSpawn : MonoBehaviour |
|
|
|
{ |
|
|
|
SpawnBlocks.Clear(); |
|
|
|
SpawnBlocks = FindObjectsOfType<Block>().Where(p => p.isCollectableSpawnable).ToList(); |
|
|
|
Debug.Log("Count after wakeup function " + SpawnBlocks.Count); |
|
|
|
} |
|
|
|
|
|
|
|
public void Spawn() |
|
|
@ -44,29 +43,20 @@ public class blockSpawn : MonoBehaviour |
|
|
|
min_x = (int)ConnectedClients[ConnectedClients.Count - 1].playerCharacter.transform.position.x; |
|
|
|
max_x = (int)ConnectedClients[0].playerCharacter.transform.position.x + 4; |
|
|
|
|
|
|
|
Debug.Log("count before update " + SpawnBlocks.Count); |
|
|
|
updatePlayerPositions(); |
|
|
|
Debug.Log("count mid update " + SpawnBlocks.Count); |
|
|
|
updatePositions(min_x - 1); |
|
|
|
Debug.Log("count after update " + SpawnBlocks.Count); |
|
|
|
|
|
|
|
//Check points within the bounds of players
|
|
|
|
possibleSpawnLocations.Clear(); |
|
|
|
foreach (Block point in SpawnBlocks) |
|
|
|
{ |
|
|
|
//Debug.Log("Position: " + point.transform.position.x + " and " + point.transform.position.z);
|
|
|
|
if(point.transform.position.x >= min_x && point.transform.position.x <= max_x) |
|
|
|
{ |
|
|
|
possibleSpawnLocations.Add(point); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//pick a random value from those available, checks the location
|
|
|
|
//then removes it to remove the possibility of duplicates
|
|
|
|
Debug.Log("possibleSpawnLocations count " + possibleSpawnLocations.Count); |
|
|
|
|
|
|
|
int triesCount = 0; |
|
|
|
|
|
|
|
if(possibleSpawnLocations.Count > 0) |
|
|
|
{ |
|
|
|
while (spawnNumber > 0 && triesCount < 25) |
|
|
@ -164,7 +154,6 @@ public class blockSpawn : MonoBehaviour |
|
|
|
{ |
|
|
|
for(int i = SpawnBlocks.Count -1; i>=0; i--) |
|
|
|
{ |
|
|
|
//Debug.Log(SpawnBlocks[i].transform.position.x);
|
|
|
|
if(SpawnBlocks[i].transform.position.x < min) |
|
|
|
{ |
|
|
|
SpawnBlocks.Remove(SpawnBlocks[i]); |
|
|
|