Exemplo n.º 1
0
        private void InitStateMachine()
        {
            IAIState state = null;

            if (_stateMachine != null)
            {
                state = _stateMachine.Current;
                _stateMachine.StateChanged -= this.OnStateChanged;
                _stateMachine = null;
            }

            switch (_stateSource)
            {
            case AIStateMachineSourceMode.SelfSourced:
                _stateMachine = TypedStateMachine <IAIState> .CreateFromComponentSource(this.gameObject);

                break;

            case AIStateMachineSourceMode.ChildSourced:
                _stateMachine = TypedStateMachine <IAIState> .CreateFromParentComponentSource(this.gameObject, false, true);

                break;
            }
            _stateMachine.StateChanged += this.OnStateChanged;
            foreach (var st in _stateMachine)
            {
                st.Init(this);
            }
        }
        protected override void Awake()
        {
            base.Awake();

            _stateMachine = TypedStateMachine<Camera>.CreateFromParentComponentSource(this.gameObject, false, false);
            _stateMachine.StateChanged += this.OnStateChanged;
        }
        protected override void Awake()
        {
            base.Awake();

            this.animation.playAutomatically = false;

            _states = TypedStateMachine <ISPAnimatorState> .CreateFromComponentSource(this.gameObject); //new ComponentStateMachine<ISPAnimatorState>(this.gameObject);

            _states.StateChanged += this.OnStateChanged;
        }
        public void SyncStates()
        {
            var state = _stateMachine.Current;

            _stateMachine.ChangeState((IAIState)null);
            _stateMachine.SetStateMachine(TypedStateMachine <IAIState> .CreateFromParentComponentSource(this.gameObject, false, true));
            if (state != null && _stateMachine.Contains(state))
            {
                _stateMachine.ChangeState(state);
            }
        }
        protected override void Awake()
        {
            base.Awake();

            if (_allowStatesAsChildren)
            {
                _stateMachine = TypedStateMachine <ICameraMovementControllerState> .CreateFromParentComponentSource(this.gameObject, true, false);
            }
            else
            {
                _stateMachine = TypedStateMachine <ICameraMovementControllerState> .CreateFromComponentSource(this.gameObject);
            }
            _stateMachine.StateChanged += this.OnStateChanged_Internal;
        }
        private void InitStateMachine()
        {
            IAIState state = null;

            if (_stateMachine != null)
            {
                state = _stateMachine.Current;
                _stateMachine.StateChanged -= this.OnStateChanged;
                _stateMachine = null;
            }

            switch (_stateSource)
            {
            case AIStateMachineSourceMode.SelfSourced:
                _stateMachine = TypedStateMachine <IAIState> .CreateFromComponentSource(this.gameObject);

                break;

            case AIStateMachineSourceMode.ChildSourced:
                _stateMachine = TypedStateMachine <IAIState> .CreateFromParentComponentSource(this.gameObject, false, true);

                break;
            }
            _stateMachine.StateChanged += this.OnStateChanged;
            foreach (var st in _stateMachine)
            {
                st.Init(this);
            }

            if (this.started)
            {
                if (!state.IsNullOrDestroyed() && _stateMachine.Contains(state))
                {
                    _stateMachine.ChangeState(state);
                }
                else
                {
                    _stateMachine.ChangeState((IAIState)null);
                }
            }
        }