IEnumerator SpawnBlockEnemiesStep(BlockPreset bp, Vector3 center) { /*if (bp.enemies == null) * { * yield break; * }*/ if (bp.enemies.Count > 0) { in_combat = true; SC.sounds.PlayMusic("combat", 10f); Dictionary <int, List <EnemyPositionPreset> > ens_by_wave = new Dictionary <int, List <EnemyPositionPreset> >(); foreach (EnemyPositionPreset ep in bp.enemies) { if (!ens_by_wave.ContainsKey(ep.wave)) { ens_by_wave.Add(ep.wave, new List <EnemyPositionPreset>()); } ens_by_wave[ep.wave].Add(ep); } List <KeyValuePair <int, List <EnemyPositionPreset> > > ens_list = ens_by_wave.ToList(); ens_list.Sort((a, b) => a.Key.CompareTo(b.Key)); center.y = SC.env.ground_y; foreach (List <EnemyPositionPreset> ep_list in ens_list.ConvertAll(kv => kv.Value)) { foreach (EnemyPositionPreset ep in ep_list) { Explosion e = SC.effects["explosion"] as Explosion; SC.sounds.PlayResource("explosion", .3f, new FloatRange(.9f, 1.1f)); e.speed = 2f; e.color_1 = e.color_2 = Color.black; e.lifetime = .5f; e.Play(center + ep.position.Vector3() + Vector3.up * .7f); yield return(new WaitForSeconds(.5f)); Generate(ep, center + ep.position.Vector3()); //yield return new WaitForSeconds(.3f); } while (Enemy.all_enemies.Count > 0) { yield return(null); } yield return(new WaitForSeconds(2f)); center = GM.player.transform.position; center.y = SC.env.ground_y; } in_combat = false; SC.sounds.PlayMusic("theme", 10f); } }
public void TriggerStartBlock() { BlockPreset bp = Entity.Create <BlockPreset>(Setup.GetSetup(level_file).GetChainedNode <YamlMappingNode>("level:start")); ProgressEnvironment(bp); }
/// <summary>генерация линии по данным таблицы</summary> public void CreateLineUsingGenerationTable() { var coinsToCreate = CoinsToCreateOnTableGenerationStep(); foreach (var coin in coinsToCreate) { CreateItem(coin); } if (game.RequireBossOnLevel) { int bossTotalHp = game.BossHpChengePerLevel * generationTable.bossesData.deltaHP + generationTable.bossesData.starterHP; CreateItem <BossController>(TurnCount, 3, bossTotalHp); return; } foreach (var blockStat in generationTable.blockStats.blocks) { blockStat.createdOnLine = 0; } BlockPreset currentBlockPreset = generationTable.blockPresets[0]; foreach (var preset in generationTable.blockPresets) { if (preset.startLevel <= TurnCount && preset.endLevel >= TurnCount) { currentBlockPreset = preset; break; } } List <BlockLifeCounter> currentPreset = new List <BlockLifeCounter>(); float totalPossibility = 0f; foreach (var preset in currentBlockPreset.presets) { totalPossibility += preset.relativePossibility; } float randomChoise = Random.Range(0f, totalPossibility); float currentResult = 0f; foreach (var preset in currentBlockPreset.presets) { if (randomChoise > currentResult && randomChoise < currentResult + preset.relativePossibility) { currentPreset = preset.preset.ToList(); break; } currentResult += preset.relativePossibility; } foreach (var presetItem in currentPreset) { switch (presetItem) { case BlockLifeCounter.Single: CreateItem(BlockToCreateOnTableGenerationStep(), GameSave.BrickHp.singleHP); break; case BlockLifeCounter.Double: CreateItem(BlockToCreateOnTableGenerationStep(), GameSave.BrickHp.doubleHP); break; case BlockLifeCounter.Random: CreateItem(BlockToCreateOnTableGenerationStep(), Random.Range(0f, 100f) > 50f ? GameSave.BrickHp.singleHP : GameSave.BrickHp.doubleHP); break; } } }
public void SpawnBlockEnemies(BlockPreset bp, Vector3 center) { StartCoroutine(SpawnBlockEnemiesStep(bp, center), spawnblock_routine); }