internal SpaceBattleController(SpaceBattleGame battleGame, GameController gameController, MainGame mainGame)
        {
            this.playerListeners = new Dictionary <Player, IBattleEventListener>();

            this.battleGame     = battleGame;
            this.mainGame       = mainGame;
            this.gameController = gameController;
            this.Star           = mainGame.States.Stars.At[battleGame.Location];
        }
示例#2
0
        public void ConflictResolved(SpaceBattleGame battleGame)
        {
            //TODO(later) decide what to do with retreated ships, send them to nearest fiendly system?
            foreach (var unit in battleGame.Combatants.Concat(battleGame.Retreated))
            {
                unit.Ships.Damage = this.game.Derivates.Of(unit.Owner).DesignStats[unit.Ships.Design].HitPoints - unit.HitPoints;
                var fleet = new Fleet(unit.Owner, battleGame.Location, new LinkedList <AMission>());
                fleet.Ships.Add(unit.Ships);

                this.game.States.Fleets.Add(fleet);
            }
        }
示例#3
0
 internal void SpaceCombatResolved(SpaceBattleGame battleGame, bool doBombardment)
 {
     if (doBombardment)
     {
         this.initiateBombardment(battleGame);
     }
     else
     {
         this.gameObj.Processor.ConflictResolved(battleGame);
         processingSync.Set();
     }
 }
        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);
        }
示例#5
0
        void initiateBombardment(SpaceBattleGame battleGame)
        {
            var controller = new BombardmentController(new BombardBattleGame(battleGame), this.gameObj, this);

            foreach (var player in controller.Participants)
            {
                var playerController = (player.ControlType == PlayerControlType.Neutral) ?
                                       this.organelleController :
                                       this.playerControllers.First(x => this.gameObj.MainPlayers[x.PlayerIndex] == player);
                if (player.OffscreenControl != null)
                {
                    controller.Register(playerController, player.OffscreenControl.StartBombardment(controller));
                }
                else
                {
                    controller.Register(playerController, this.stateListener.OnDoBombardment(controller));
                }
            }

            this.combatPhase = Task.Factory.StartNew(controller.Start).ContinueWith(checkTaskException);
        }
示例#6
0
        void initiateBombardment(SpaceBattleGame battleGame)
        {
            var controller = new BombardmentController(battleGame, this.gameObj, this);

            //TODO(v0.6) doesn't take proper players into account
            foreach (var player in battleGame.Combatants.Select(x => x.Owner).Distinct())
            {
                var playerController = (player.ControlType == PlayerControlType.Neutral) ?
                                       this.organelleController :
                                       this.playerControllers.First(x => this.gameObj.MainPlayers[x.PlayerIndex] == player);
                if (player.OffscreenControl != null)
                {
                    controller.Register(playerController, player.OffscreenControl.StartBombardment(controller));
                }
                else
                {
                    controller.Register(playerController, this.stateListener.OnDoBombardment(controller));
                }
            }

            controller.Start();
        }
示例#7
0
 public SpaceBattleProcessor(SpaceBattleGame battleGame, MainGame mainGame) : base(mainGame)
 {
     this.game = battleGame;
 }
示例#8
0
 internal void BombardmentResolved(SpaceBattleGame battleGame)
 {
     this.gameObj.Processor.ConflictResolved(battleGame);
     processingSync.Set();
 }