예제 #1
0
        public override void Execute()
        {
            if (Model.Phase != BattlePhase.NotStarted)
            {
                Model.ResetUnitState();
                Model.Battle.EndTurn();
            }

            // If there are any events slated to happen at the start of this turn,
            // run them before releasing control back to the player.
            var turnEventHanders = Model.Battle.GetCurrentTurnEvents()
                                   .Select(eventName => BattleEventRegistry.GetHandler(eventName))
                                   .Where(x => x != null)
                                   .ToList();

            if (turnEventHanders.Count > 0)
            {
                Retain();
                Action action = null;
                action = new Action(() => {
                    StartNextTurn();
                    Release();
                });
                EventHandlersCompleteSignal.AddListener(action);
                ProcessEventHandlersSignal.Dispatch(turnEventHanders);
            }
            else
            {
                StartNextTurn();
            }
        }
예제 #2
0
        public static void ProcessEvents(Command command, IEnumerable <IEnumerator> events,
                                         ProcessEventHandlersSignal processSignal, EventHandlersCompleteSignal completeSignal, Action onComplete)
        {
            command.Retain();
            Action action = null;

            action = new Action(() => {
                onComplete();
                command.Release();
                completeSignal.RemoveListener(action);
            });

            completeSignal.AddListener(action);
            processSignal.Dispatch(events);
        }