protected override void Execute(List <PoolEntity> entities) { if (pool.isNextTurn) { pool.isNextTurn = false; } var turnOrder = pool.turnOrder.value; if (turnOrder.Empty()) { return; // nothing to do } if (pool.hasCurrentTurnNode) { pool.ReplaceCurrentTurnNode(pool.currentTurnNode.value.NextOrFirst()); } else { pool.SetCurrentTurnNode(turnOrder.First); } var nextEntity = pool.currentTurnNode.value.Value; // delay the next entity becoming active var baseDelay = nextEntity.turnBased.delay; bool onlyEntity = turnBasedEntities.count < 2; var delayTime = onlyEntity ? baseDelay * 2 : baseDelay; pool.CreateEntity() .AddCoroutine(ActivateAfterDelay(delayTime, nextEntity)); }
public static PoolEntity PlayAudio(this PoolContext context, BaseAudioComponent source) { var e = context.CreateEntity(); e.AddAudio(source.clips, source.randomizePitch); return(e); }
void SetupScene(int level) { Debug.Log("Setup level " + level); var config = pool.config; var gameBoard = pool.gameBoard; if (config.columns != gameBoard.columns || config.rows != gameBoard.rows) { // Update gameboard to match the current config pool.ReplaceGameBoard(config.columns, config.rows); gameBoard = pool.gameBoard; } //Creates the outer walls and floor. BoardSetup(gameBoard); ResetGridPositions(gameBoard); LayoutObjectAtRandom(WALLS, config.wallCountMin, config.wallCountMax, (e, i, ri) => { e.AddDestructible(4); e.AddDamageSprite(DAMAGED_WALLS[ri]); }); LayoutObjectAtRandom(FOOD, config.foodCountMin, config.foodCountMax, (e, i, ri) => { bool soda = e.resource.prefab == Prefab.Soda; int points = soda ? config.sodaPoints : config.foodPoints; var audio = soda ? new [] { Audio.scavengers_soda1, Audio.scavengers_soda2 } : new [] { Audio.scavengers_fruit1, Audio.scavengers_fruit2 }; e.AddFood(points); e.AddAudioPickupSource(audio); }); int enemyCount = Mathf.FloorToInt(Mathf.Log(level, 2f)) * config.enemyCountMultiplier; LayoutObjectAtRandom(ENEMIES, enemyCount, enemyCount, (e, i, ri) => { bool enemy1 = e.resource.prefab == Prefab.Enemy1; int dmg = enemy1 ? config.enemy1Dmg : config.enemy2Dmg; // start at 1 because 0 is reserved for player e.AddTurnBased(i + 1, config.turnDelay); e.isAIMove = true; e.AddFoodDamager(dmg); e.AddSmoothMove(config.turnDelay); e.AddAudioAttackSource(Audio.scavengers_enemy1, Audio.scavengers_enemy2); }); // Create exit var exit = pool.CreateEntity(); exit.AddResource(Prefab.Exit); exit.isExit = true; exit.isGameBoardElement = true; exit.isDeleteOnExit = true; exit.AddPosition(gameBoard.columns - 1, gameBoard.rows - 1); // Create player var player = pool.CreateEntity(); player.AddResource(Prefab.Player); player.isGameBoardElement = true; player.isDeleteOnExit = true; player.AddPosition(0, 0); player.AddSmoothMove(config.turnDelay); player.isControllable = true; player.AddTurnBased(0, config.turnDelay); player.isAIMoveTarget = true; player.AddAudioAttackSource(Audio.scavengers_chop1, Audio.scavengers_chop2); player.AddAudioDeathSource(Audio.scavengers_die); player.AddAudioWalkSource(Audio.scavengers_footstep1, Audio.scavengers_footstep2); }