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(); }
public IEnumerator SpawnEnemy() { Vector2Int yRange = GridFunctionUtility.GetPlayerChessyRange(); yRange.x = Mathf.Max(0, yRange.x - spawnDistance); yRange.y = Mathf.Min(GridManager.instance.size.y - 1, yRange.y + spawnDistance); int cntNum = AIManager.instance.AIs.Count; foreach (CAICompoment t in AIManager.instance.AIs) { if (t.actor.elementComponent.state == ElementState.Frozen) { cntNum--; } } int maxEnemyNum = maxEnemyOverNum + GridManager.instance.GetPlayerActiveChesses().Count; int spawnnum = Mathf.Min(num, maxEnemyNum - cntNum); for (int i = 0; i < spawnnum; i++) { Vector2Int targetLocation = GetValidLocation(yRange); GridManager.instance.InstansiateChessAt(ChooseRandomEnemy(), targetLocation); GameObject t = UIManager.instance.CreateFloorHUD(targetLocation, Color.yellow); UIManager.instance.eRefreshFloorHUD.Invoke(); yield return(1f); Destroy(t); } yield return(0.5f); }