Start() public method

public Start ( ) : void
return void
Example #1
0
    // Update is called once per frame
    public virtual void Update()
    {
        if (null != m_currentState)
        {
            if (!m_currentState.StartExecuted)
            {
                m_currentState.StartExecuted = true;
                m_currentState.Start();
            }

            m_currentState.Update();
        }
    }
Example #2
0
 virtual protected void InitState()
 {
     {
         State state = new IdleState();
         state.Init(this);
         _stateMap[eStateType.IDLE] = state;
     }
     {
         State state = new MoveState();
         state.Init(this);
         _stateMap[eStateType.MOVE] = state;
     }
     {
         State state = new AttackState();
         state.Init(this);
         _stateMap[eStateType.ATTACK] = state;
     }
     {
         State state = new DamageState();
         state.Init(this);
         _stateMap[eStateType.DAMAGE] = state;
     }
     {
         State state = new DeathState();
         state.Init(this);
         _stateMap[eStateType.DEATH] = state;
     }
     _state = _stateMap[eStateType.IDLE];
     _state.Start();
 }
Example #3
0
    /// <summary>
    /// ステート更新
    /// </summary>
    protected virtual void UpdateState()
    {
        State state = GetState();


        // ステート不明なら終了
        if (state == null)
        {
            EndBeforeStatus(state);
            return;
        }

        // 初回
        if (beforeState != state)
        {
            // 前回ステータス終了
            EndBeforeStatus(state);

            // 新規ステータス開始
            beforeState = state;
            state.Start(animator, this);
            return;
        }

        // 二回目以降は普通に更新
        state.Execute(this);
    }
    private void Update()
    {
        if (startDelay > 0f)
        {
            startDelay -= Time.deltaTime;
            return;
        }

        if (currentState == null)
        {
            currentState = new StartMenuState();
            currentState.Start();
            SignalManager.Inst.FireSignal(new StateStartedSignal(currentState));
        }
        State nextState = currentState.Update();

        if (nextState != currentState)
        {
            currentState.End();
            SignalManager.Inst.FireSignal(new StateEndingSignal(currentState));
            currentState = nextState;
            nextState.Start();
            SignalManager.Inst.FireSignal(new StateStartedSignal(currentState));
        }
    }
Example #5
0
    public void GotoState(StateType stateType)
    {
        curState.End();

        curStateType = stateType;
        curState     = states[curStateType];

        curState.Start();
    }
 public void SetState(State state)
 {
     if (currentState != null)
     {
         StartCoroutine(currentState.Exit());
     }
     currentState = state;
     StartCoroutine(currentState.Start());
 }
Example #7
0
 void ChangeState(eStateType nextState)
 {
     if (null != _state)
     {
         _state.Stop();
     }
     _state = _stateMap[nextState];
     _state.Start();
 }
Example #8
0
 public void ChangeState(eState nextState)
 {
     if (null != _currentState)
     {
         _currentState.Stop();
     }
     _currentState = _stateDic[nextState];
     _currentState.Start();
 }
 public void ChangeState(State newState)
 {
     if (newState == null)
     {
         return;
     }
     currentState?.Exit();
     currentState = newState;
     newState.Start();
 }
Example #10
0
    public void SetState(State state)
    {
        if (currentState != null)
        {
            previousState = currentState;
        }

        currentState = state;
        StartCoroutine(currentState.Start());
    }
Example #11
0
    public void ChangeState(eStateType nextState)
    {
        if (null != _curState)
        {
            _curState.Stop();
        }

        _curState = _stateMap[nextState];
        _curState.Start();
        _curStateType = nextState;
    }
Example #12
0
    public void ChangeState(UnitStates state)
    {
        if (State != null)
        {
            State.Dispose();
            State = null;
        }

        State = _stateFactory.CreateState(state);
        State.Start();
    }
Example #13
0
    void Awake( )
    {
        audiosource.loop         = true;
        audiosource.volume       = 1.0f;
        audiosource.spatialBlend = 1.0f;

        startPos = transform.position;
        SetColor(this.gameObject, Color.white);

        DefineStateMachine( );
        rootState.Start( );
    }
Example #14
0
    public void DoTransition <T>() where T : StateTransition
    {
        if (currentState != null)
        {
            currentState.Finish();
        }

        KeyValuePair <StateTransition, State> transitionPair = GetTransitionPairByKey <T>();

        currentState = transitionPair.Value;

        currentState.Start();
    }
Example #15
0
    void Start()
    {
        Idle  idleState  = new Idle(ballSpawner, enemySpawner);
        Shoot shootState = new Shoot(ballSpawner, enemySpawner);
        Move  moveState  = new Move(player, ballSpawner);

        idleState.SetNext(shootState);
        shootState.SetNext(moveState);
        moveState.SetNext(idleState);

        state = idleState;
        state.Start();
    }
Example #16
0
    void Go(State state)
    {
        Previous = Current;
        Current  = state;
        if (Previous != null)
        {
            Previous.Exit();
        }

        Current.Start(this);
        Debug.Log(gameObject.name + " enter State: " + state.ToString());
        Current.Enter();
    }
Example #17
0
    void Start()
    {
        states[StateType.EquippedItemSelect] = new SelectEquippedItemsState(this);
        states[StateType.OtherItemSelect]    = new SelectOtherItemsState(this);

        curStateType = StateType.EquippedItemSelect;
        curState     = states[curStateType];

        initEquippedPartsViaPlayerSchematic();

        updateTankDisplayToCurrent();

        curState.Start();
    }
Example #18
0
        public void SwitchState(State state)
        {
            if (CurrentState != null)
            {
                CurrentState.End();
            }

            CurrentState = state;

            if (CurrentState != null)
            {
                CurrentState.Start();
            }
        }
    public void setState(State state)
    {
        if (currentState != null)
        {
            currentState.Exit();
        }

        currentState = state;
        Debug.ClearDeveloperConsole();

        if (currentState != null)
        {
            currentState.Start();
        }
    }
Example #20
0
    void Update()
    {
        if (state != null)
        {
            if (state.CanGoNext())
            {
                state = state.Next();
                state.Start();
            }
            state.Update();
        }

        if (player.Hp() <= 0)
        {
            state = null;
            SceneManager.LoadScene("title");
        }
    }
Example #21
0
        public override void Initialize()
        {
            Input.AddButtonControl("left")
            .Keyboard(Keys.A, Keys.Left);

            Input.AddButtonControl("right")
            .Keyboard(Keys.D, Keys.Right);

            Input.AddButtonControl("up")
            .Keyboard(Keys.W, Keys.Up);

            Input.AddButtonControl("down")
            .Keyboard(Keys.S, Keys.Down);

            Input.AddButtonControl("continue")
            .Keyboard(Keys.Space, Keys.Enter);

            State.Start <GameplayState>();
        }
Example #22
0
    public static void SetState(State state, bool shouldContinue = false)
    {
        if (State == state)
        {
            return;
        }

        Debug.Log($"Changed state from {State?.Name ?? "None"} to {state.Name}");
        State?.End();
        State = state;

        if (shouldContinue)
        {
            State.Continue();
        }
        else
        {
            State.Start();
        }
    }
    public void ChangeState(ZombieStateType nextState)
    {
        if (Running)
        {
            StopRunningState();
        }

        if (!States.ContainsKey(nextState))
        {
            return;
        }
        CurrentState = States[nextState];
        CurrentState.Start();

        if (CurrentState.UpdateInterval > 0)
        {
            InvokeRepeating(nameof(IntervalUpdate), 0.0f, CurrentState.UpdateInterval);
        }

        Running = true;
    }
        public void Update(GameTime gameTime)
        {
            if (_stateAsked.HasValue)
            {
                if (_stateActive != null)
                {
                    ManagerUI.Instance.Clear();
                    _stateActive.End();
                }

                _stateActive = GetState(_stateAsked.Value);

                _stateActive.Start();
                _stateActive.Initialize(MyGame.Instance.Graphics);

                _stateAsked = null;
            }

            if (_stateActive != null)
            {
                _stateActive.Update(gameTime);
            }
        }
Example #25
0
    public void ChangeState(string nm)
    {
        if (running)
        {
            StopRunningState();
        }

        if (!states.ContainsKey(nm))
        {
            Debug.Log("STATE NOT FOUND");
            return;
        }

        currentState = states[nm];
        currentState.Start();

        if (currentState.UpdateInterval > 0)
        {
            InvokeRepeating(nameof(IntervalUpdate), 0.0f, currentState.UpdateInterval);
        }

        running = true;
    }
Example #26
0
        public XmlJsonReader(XmlReader xmlReader, string rootPath)
        {
            _closed    = false;
            _disposed  = false;
            _xmlReader = xmlReader;
            _value     = null;
            _tokenType = JsonToken.None;
            _level     = 0;

            _processingInstructions = new Dictionary <string, List <string> >();

            var rootPathChunks = rootPath == null ? new string[0] : rootPath.Trim("/".ToCharArray()).Split("/".ToCharArray());

            _rootPathChunks    = new Queue <string>(rootPathChunks);
            _matchedPathChunks = new Stack <string>();

            _tokens = new Queue <Token>();
            _states = new Stack <State>();

            _states.Push(State.Start());
            _tokens.Enqueue(Token.GetStartObject());

            _readExecuted = false;
        }
Example #27
0
 public void StartAI()
 {
     state = TankAIState.doing;
     currentMotionState.Start();
     currentShootingState.Start();
 }
Example #28
0
        private void Update()
        {
            if (state == TankAIState.waiting)
            {
                return;
            }

            if (Time.time - lastCheckTime > configs.checkInterval)
            {
                sensoringSimulator.FindEnemyTanksWithinDistance(
                    transform.position, configs.findingDistance, ObservedEnemyTanks, tank.seatID);
                sensoringSimulator.LoseEnemyTanksWithoutDistance(
                    transform.position, configs.findingDistance, ObservedEnemyTanks);
                if (ObservedEnemyTanks.Contains(TargetTank) && TryIfShootable(TargetTank.transform.position) && (targetTank.transform.position - transform.position).magnitude > keepingDistance)
                {
                    if (currentMotionState == MotionStates[(int)MotionStateIndices.going])
                    {
                        currentMotionState = MotionStates[(int)MotionStateIndices.stopping];
                        currentMotionState.Start();
                    }
                }
                else if (ObservedEnemyTanks.Contains(TargetTank) &&
                         (!TryIfShootable(TargetTank.transform.position) || (targetTank.transform.position - transform.position).magnitude > keepingDistance))
                {
                    DestinationPosition = TargetTank.transform.position;
                    currentMotionState  = MotionStates[(int)MotionStateIndices.going];
                    currentMotionState.Start();
                }
                else
                {
                    for (int i = 0; i < ObservedEnemyTanks.Count; i++)
                    {
                        if (TryIfShootable(ObservedEnemyTanks[i].transform.position))
                        {
                            TargetTank           = ObservedEnemyTanks[i];
                            currentShootingState = ShootingStates[(int)ShootingStateIndices.shooting];
                            currentShootingState.Start();
                            break;
                        }
                    }
                }
                lastCheckTime = Time.time;
            }

            currentMotionState.Action();
            State nextState = currentMotionState.Decide();

            if (nextState != currentMotionState)
            {
                tankStateInfo_motion.lastState = currentMotionState;
                currentMotionState             = nextState;
                currentMotionState.Start();
            }
            currentShootingState.Action();
            nextState = currentShootingState.Decide();
            if (nextState != currentShootingState)
            {
                currentShootingState = nextState;
                currentShootingState.Start();
            }
        }
Example #29
0
 public void Start()
 {
     State = QRCodeInitial;
     State.Start();
 }
Example #30
0
 public void SetState(State st)
 {
     state = st;
     StartCoroutine(state.Start());
 }
        /// <summary>
        /// Changes to the given <paramref name="newState"/>.
        /// </summary>
        /// <param name="newState">The <see cref="State"/> to change to.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="newState"/> is null.</exception>
        private void ChangeState(State newState)
        {
            // validate arguments
            if (newState == null)
                throw new ArgumentNullException("newState");

            // if we are disposed of do not change the state
            if (IsDisposed)
            {
                // dispose the new state
                newState.Dispose();
                return;
            }

            // dispose the current state if there is one
            if (currentState != null)
                currentState.Dispose();

            // set the new state
            currentState = newState;

            // start the new state
            newState.Start();
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="state"></param>
 public void AddState( State state )
 {
     States.Add( state.Name, state );
     state.Owner = this;
     state.Start();
 }
Example #33
0
 //  State Changing Commands
 public void CreateState(String s_Key, State.BaseState s_State)
 {
     dGameStates[s_Key] = s_State;
     s_State.Start(_Content);
 }