public void SpawnMessage(CustomColors.Colors color) { GameObject newMessage = poolBehaviour.GetObject(); Renderer rend = newMessage.GetComponent <Renderer>(); rend.material.color = customColors.colors[(int)color]; int tryCounter = 0; do { newMessage.transform.position = GetFreePosition(); tryCounter++; } while (Vector3.Distance(newMessage.transform.position, players[(int)color].position) <= minSpawnDistance && tryCounter < maxTryCounter); newMessage.layer = startMessageLayer + (int)color; BlockPosition(newMessage.transform.position); ParticleSystem newMessageParticles = newMessage.GetComponentInChildren <ParticleSystem>(); //color of particle system ParticleSystem.MinMaxGradient grad = new ParticleSystem.MinMaxGradient(firstRandomColor, customColors.colors[(int)color]); //grad.mode = ParticleSystemGradientMode.RandomColor; var particleMain = newMessageParticles.main; particleMain.startColor = grad; newMessageParticles.Play(); }
public void SpawnCollectable() { GameObject newMessage = poolBehaviour.GetObject(); int tryCounter = 0; do { newMessage.transform.position = GetFreePosition(); tryCounter++; } while (tryCounter < maxTryCounter); BlockPosition(newMessage.transform.position); }