IEnumerator PreEnvironmentTurn() { Vector2Int yRange = GridFunctionUtility.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 = GridFunctionUtility.GetRandomLocation(yRange); }while (stormLocation.Contains(location)); stormLocation.Add(location); } foreach (var location in stormLocation) { GameObject t = GridFunctionUtility.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); } GameManager.instance.EnvironmentPreTurnEnd(); }
Vector2Int GetValidLocation(Vector2Int yRange) { Vector2Int t = new Vector2Int(); do { t = GridFunctionUtility.GetRandomLocation(yRange); } while (!GridManager.instance.CheckTransitability(t)); return(t); }