/// <summary> /// /// </summary> /// <param name="nextSteps">it contains the chosen steps of the given teams</param> private void ProcessSteps(AIStep[] nextSteps) { //process the explosions first for (int i = 0; i < nextSteps.Length; ++i) { Team currentPlayer = m_teams.ToArray()[i]; if (currentPlayer == null) { continue; } if (currentPlayer.Field == null) { continue; } if (currentPlayer.IsDead) //dead players doesn't do anything { continue; } if (nextSteps[i].nextStep == AIStep.StepEnum.EXPLODE) { Bomb[] currentPlayerBombs = currentPlayer.getBombs(); ExplosionFieldCollector explodedFields = new ExplosionFieldCollector(); for (int j = 0; j < currentPlayerBombs.Length; ++j) { m_gameBoard.explodeFields(this, currentPlayerBombs[j], explodedFields); } processExplodedFields(i, currentPlayer, explodedFields); } } //process the moves after explosions for (int i = 0; i < nextSteps.Length; ++i) { Team currentPlayer = m_teams.ToArray()[i]; if (currentPlayer == null) { continue; } if (currentPlayer.Field == null) { continue; } if (currentPlayer.IsDead) //players dead from the explosions doesn't do anything { continue; } if (nextSteps[i].nextStep == AIStep.StepEnum.PUT_BOMB) { bool isValid = false; if (MaxCountOfPlayerBombs <= 0 || (MaxCountOfPlayerBombs > 0 && currentPlayer.getNumberOfBombs() < MaxCountOfPlayerBombs)) { Bomb newBomb = new Bomb(currentPlayer, m_gameBoard, currentPlayer.Field, this, getExplosiveRadius(), out isValid); } } else if (nextSteps[i].nextStep == AIStep.StepEnum.MOVE) { Field target; if (getTargetField(currentPlayer.Field.X, currentPlayer.Field.Y, nextSteps[i].nextMove, out target)) { if (isValidToMove(target, m_gameBoard, currentPlayer)) { currentPlayer.Field.removeTeam(currentPlayer); target.addTeam(currentPlayer, i); } } } } }
public static void EnqueBomb(Bomb bomb) { bombs[bomb.PlayerOwner].Enqueue(bomb); }
public BombDTO getBombDTO() // get bomb in data transfer format { return(Bomb.getBombDTO(this.connectionId, GetPointPosition())); }
public void RemoveBomb(Bomb bomb) { bombs.Remove(bomb); }