internal SpaceBattleController(Conflict conflict, GameController gameController, MainGame mainGame) { this.playerListeners = new Dictionary <Player, IBattleEventListener>(); this.battleGame = new SpaceBattleGame(conflict.Location, SpaceBattleProcessor.ConflictDuration(conflict.StartTime), mainGame); this.mainGame = mainGame; this.gameController = gameController; this.star = mainGame.States.Stars.At[battleGame.Location]; this.processor = new SpaceBattleProcessor(this.battleGame, mainGame); this.processor.Initialize(conflict.Fleets); }
public SpaceBattleGame(Vector2D location, IEnumerable <FleetMovement> fleets, double startTime, MainGame mainGame) { this.Combatants = new List <Combatant>(); this.Planets = new CombatPlanet[mainGame.States.Planets.At[mainGame.States.Stars.At[location]].Count]; this.PlayOrder = new Queue <Combatant>(); this.Retreated = new List <Combatant>(); this.Rng = new Random(); this.Processor = new SpaceBattleProcessor(this, mainGame); this.Turn = 0; this.Location = location; this.Processor.Initialize(fleets, startTime); }
private void playNextUnit() { var currentUnit = this.battleGame.PlayOrder.Peek(); Task.Factory.StartNew(() => playerListeners[currentUnit.Owner].PlayUnit(new CombatantInfo( currentUnit, mainGame, SpaceBattleProcessor.ValidMoves(currentUnit) )), Task.Factory.CancellationToken, TaskCreationOptions.None, TaskScheduler.Default ); //TODO(later) check for exception }