Ejemplo n.º 1
0
        private StateCommand ChangeState(Type type, object[] args)
        {
            StateCommand prevState = _state;

            _state = null;

            if (prevState != null)
            {
                prevState.Terminate();

                StopAllCommands();
            }

            _state = CreateState(type, args);

#if UNITY_EDITOR
            _stateHistory.Add(type.Name);

            StateHistory = _stateHistory.ToArray();
#endif
            _state.AsyncToken.AddResponder(new Responder <StateCommand>(OnStateFinished, OnStateFinished));

            if (Changed != null)
            {
                Changed(this);
            }

            return(_state);
        }
Ejemplo n.º 2
0
        private void OnStateFinished(StateCommand state)
        {
            if (state == _state)
            {
                _state = null;

                StopAllCommands();

                _container.Next(state);
            }
        }
Ejemplo n.º 3
0
        private void OnDownloadFault(StateCommand command)
        {
            DownloadManagerCommand downloadManagerCommand = (DownloadManagerCommand)command;

            _downloadQueue.Remove(downloadManagerCommand.File.Path);

            if (Fault != null)
            {
                Fault(downloadManagerCommand.File);
            }
        }
Ejemplo n.º 4
0
        private void OnDownloadFinished(StateCommand command)
        {
            DownloadManagerCommand downloadManagerCommand = (DownloadManagerCommand)command;

            _downloadQueue.Remove(downloadManagerCommand.File.Path);

            if (Complete != null)
            {
                Complete(downloadManagerCommand.File);
            }
        }
Ejemplo n.º 5
0
        public StateCommand Execute(Type type, params object[] args)
        {
            StateCommand command = (StateCommand)MonoCommand.ExecuteOn(type, _container.GameObject, args);

            _commands.Add(command);

            command.AsyncToken.AddResponder(new Responder <StateCommand>(delegate(StateCommand result)
            {
                _commands.Remove(result);
            }));

            return(command);
        }
Ejemplo n.º 6
0
        public void Next(StateCommand prevState)
        {
            NextStatePair pair = null;

            if (prevState != null)
            {
                pair = _stateFlow.Find(delegate(NextStatePair nextStatePair)
                {
                    return(nextStatePair.Target == prevState.GetType());
                });
            }

            if (pair != null)
            {
                if (prevState.FinishedWithSuccess)
                {
                    _stateMachine.ApplyState(pair.Success, _container);
                }
                else
                {
                    _stateMachine.ApplyState(pair.Fail, _container);
                }
            }
        }
Ejemplo n.º 7
0
 public void Next(StateCommand previousState)
 {
 }