IEnumerator PreEnvironmentTurn() { if (stormAudio && stormNum > 0) { GetComponent <AudioSource>().PlayOneShot(stormAudio, stormAudioAmplitude); } Vector2Int yRange = GridExtensions.GetPlayerChessyRange(); yRange.x = Mathf.Max(0, yRange.x - stormAroundDistance); yRange.y = Mathf.Min(GridManager.instance.size.y - 1, yRange.y + stormAroundDistance); for (int i = 0; i < stormNum; i++) { Vector2Int location; do { location = GridExtensions.GetRandomLocation(yRange); }while (stormLocation.Contains(location)); stormLocation.Add(location); } foreach (var location in stormLocation) { GameObject t = GridExtensions.CreateParticleAt(prefabStorm, location); Material mat = t.GetComponent <MeshRenderer>().material; Color color = mat.GetColor("_Color"); mat.SetColor("_Color", Color.yellow); stormParticle.Add(t); yield return(new WaitForSeconds(1f)); mat.SetColor("_Color", color); } }
Vector2Int GetValidLocation(Vector2Int yRange) { Vector2Int t = new Vector2Int(); do { t = GridExtensions.GetRandomLocation(yRange); } while (!GridManager.instance.CheckTransitability(t)); return(t); }
Vector2Int GetValidLocation(int round, int id) { if (spawnModifier?.enable == true && spawnModifier.roundSpawnDatas[round][id].speceficLocation && id < spawnModifier.roundSpawnDatas[round].Count) { return(spawnModifier.roundSpawnDatas[round][id].spawnLocation); } else { Vector2Int t = new Vector2Int(); do { t = GridExtensions.GetRandomLocation(new Vector2Int(0, 0), GridManager.instance.size); } while (!GridManager.instance.CheckTransitability(t)); return(t); } }