Esempio n. 1
0
        public override void Update()
        {
            AbstractViewControllerState <TEnum> controller = null;

            if (_states.ContainsKey(_currentState))
            {
                controller = _states[_currentState];
                controller.UpdateState();
            }
        }
Esempio n. 2
0
        public override void RemoveView()
        {
            AbstractViewControllerState <TEnum> vc = null;

            _states.TryGetValue(_currentState, out vc);

            if (vc != null)
            {
                vc.RemoveView();
            }

            base.RemoveView();
        }
Esempio n. 3
0
        private void SetState(TEnum state, bool isInitialState)
        {
            //TaskProvider.Instance.DelayedAction(() =>
            //{
            Debug.Log("[AbstractViewControllerFsm][" + state + "] SetState Start");

            if (state.Equals(_currentState) && !isInitialState)
            {
                return;
            }

            if (!_states.ContainsKey(state))
            {
                throw new NotImplementedException(string.Format("State '{0}' has not been implemented by this machine.", state));
            }

            AbstractViewControllerState <TEnum> newController = _states[state];
            AbstractViewControllerState <TEnum> oldController = null;

            if (_states.ContainsKey(_currentState))
            {
                oldController = _states[_currentState];
            }

            Debug.LogFormat("[EnterState] {0}", state);

            if (OnEnterState != null)
            {
                OnEnterState(state);
            }
            if (oldController != null && !isInitialState)
            {
                oldController.LeaveState(state);
            }

            _currentState = state;
            newController.EnterState(_currentState);
            Debug.Log("[AbstractViewControllerFsm][" + state + "] SetState Done");
            //});
        }