Exemplo n.º 1
0
        private void turnProcessing()
        {
#if DEBUG
            ShipCounter = new ShipDebugger(this.gameObj.States.Fleets);
#endif
            gameObj.Processor.ProcessPrecombat();
#if DEBUG
            ShipCounter.Check("Precombat", this.gameObj.States.Fleets);
#endif

            while (gameObj.Processor.HasAudience)
            {
                processingSync.WaitOne();                 //TODO(v0.9) try blocking only participants
                this.holdAudience();
            }
            //TODO(v0.9) diplomatic actions don't take place this turn
            processingSync.WaitOne();             //TODO(v0.9) make more orderly synchronization mechanism
            processingSync.Set();

            while (gameObj.Processor.HasConflict)
            {
                processingSync.WaitOne();                 //TODO(v0.9) try blocking only participants
                this.initaiteCombat();
            }
            processingSync.WaitOne();             //TODO(v0.9) make more orderly synchronization mechanism
            processingSync.Set();

            gameObj.Processor.ProcessPostcombat();
#if DEBUG
            ShipCounter.Check("Postcombat", this.gameObj.States.Fleets);
#endif
            processingSync.Set();

            lock (threadLocker)
            {
                this.endTurnCopy = null;
                this.endedTurnPlayers.Clear();
            }

            if (gameObj.Processor.IsOver)
            {
                stateListener.OnGameOver();
            }
            else
            {
                stateListener.OnNewTurn();
                restartAiGalaxyPhase();
            }
        }
Exemplo n.º 2
0
        private void turnProcessing()
        {
            gameObj.Processor.ProcessPrecombat();

            while (gameObj.Processor.HasAudience)
            {
                processingSync.WaitOne();                 //TODO(v0.8) try blocking only participants
                this.holdAudience();
            }
            //TODO(v0.8) diplomatic actions don't take place this turn
            processingSync.WaitOne();             //TODO(v0.8) make more orderly synchronization mechanism
            processingSync.Set();

            while (gameObj.Processor.HasConflict)
            {
                processingSync.WaitOne();                 //TODO(v0.8) try blocking only participants
                this.initaiteCombat();
            }
            processingSync.WaitOne();             //TODO(v0.8) make more orderly synchronization mechanism
            processingSync.Set();

            while (this.gameObj.Derivates.Players.Any(x => x.HasBreakthrough))
            {
                processingSync.WaitOne();                 //TODO(v0.8) per player sync instead of global
                this.presentBreakthrough();
            }

            processingSync.WaitOne();
            gameObj.Processor.ProcessPostcombat();
            processingSync.Set();

            lock (threadLocker)
            {
                this.endTurnCopy = null;
                this.endedTurnPlayers.Clear();
            }

            if (gameObj.Processor.IsOver)
            {
                stateListener.OnGameOver();
            }
            else
            {
                stateListener.OnNewTurn();
                restartAiGalaxyPhase();
            }
        }