コード例 #1
0
ファイル: StateMachine.cs プロジェクト: tosh1k/Framework
        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);
        }
コード例 #2
0
ファイル: StateMachine.cs プロジェクト: tosh1k/Framework
        private void OnStateFinished(StateCommand state)
        {
            if (state == _state)
            {
                _state = null;

                StopAllCommands();

                _container.Next(state);
            }
        }
コード例 #3
0
        private void OnDownloadFault(StateCommand command)
        {
            DownloadManagerCommand downloadManagerCommand = (DownloadManagerCommand)command;

            _downloadQueue.Remove(downloadManagerCommand.File.Path);

            if (Fault != null)
            {
                Fault(downloadManagerCommand.File);
            }
        }
コード例 #4
0
        private void OnDownloadFinished(StateCommand command)
        {
            DownloadManagerCommand downloadManagerCommand = (DownloadManagerCommand)command;

            _downloadQueue.Remove(downloadManagerCommand.File.Path);

            if (Complete != null)
            {
                Complete(downloadManagerCommand.File);
            }
        }
コード例 #5
0
ファイル: StateMachine.cs プロジェクト: tosh1k/Framework
        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);
        }
コード例 #6
0
ファイル: StateMachine.cs プロジェクト: tosh1k/Framework
        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);
                }
            }
        }
コード例 #7
0
 public void Next(StateCommand previousState)
 {
 }