コード例 #1
0
    void FixedUpdate()
    {
        debugAccessor.DisplayFloat("Speed", c_playerData.f_currentSpeed);
        debugAccessor.DisplayState("air state", c_airMachine.GetCurrentState());
        if (!c_stateData.b_updateState)
        {
            return;
        }

        c_lastFrameData.v_lastFramePosition    = c_playerData.v_currentPosition;
        c_lastFrameData.q_lastFrameRotation    = c_positionData.q_currentModelRotation;
        c_lastFrameData.q_lastFrameCoGRotation = c_positionData.q_currentModelRotation * c_positionData.q_centerOfGravityRotation;

        UpdateStateMachine();

        c_airMachine.Act();
        c_accelMachine.Act();
        c_turnMachine.Act();
        sm_tricking.Act();
        sm_trickPhys.Act();

        EngineUpdate();

        LateEnginePull();
        // send normal
        MessageServer.SendMessage(MessageID.PLAYER_POSITION_UPDATED, new Message(c_playerData.v_currentPosition, c_playerData.q_currentRotation, c_playerData.f_currentSpeed)); // NOT the model rotation INCLUDE AIR STATE
    }
コード例 #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        EnginePull();

        UpdateStateMachine();
        sm_menuItem.Act();
    }
コード例 #3
0
    void FixedUpdate()
    {
        if (!c_stateData.b_updateState)
        {
            return;
        }
        FixedEnginePull();

        sm_cameraBehavior.Act();

        c_lastFrameData.v_lastTargetPosition = c_targetData.v_currentTargetPosition;
        c_lastFrameData.q_lastTargetRotation = c_targetData.q_currentTargetRotation;
    }
コード例 #4
0
ファイル: Program.cs プロジェクト: jersmart/state-machine
        static void Main(string[] args)
        {
            Console.WriteLine("Press A to attack, R to retreat, D to kill the player, B to finish retreating.");

            var sm = new StateMachine<States, Triggers>(States.Patrolling);
            sm.AddTransition(States.Patrolling, Triggers.EnemyDetected, States.Attacking)
                .AddTransition(States.Attacking, Triggers.EnemyOutOfRange, States.Retreating)
                .AddTransition(States.Retreating, Triggers.ReturnedToPatrollPosition, States.Patrolling)
                .AddTransition(States.Attacking, Triggers.EnemyDied, States.Retreating);
            sm.AddAction(States.Patrolling, () => {
                Console.WriteLine("I'm patrolling");
            });
            sm.AddAction(States.Attacking, () => {
                Console.WriteLine("I'm attacking");
            });
            sm.AddAction(States.Retreating, () => {
                Console.WriteLine("I'm retreating");
            });

            var done = false;
            do
            {
                while (!Console.KeyAvailable)
                {
                    sm.Act();
                    System.Threading.Thread.Sleep(1000);
                }

                var key = Console.ReadKey(true).Key;
                if (key == ConsoleKey.A && sm.CurrentState == States.Patrolling)
                {
                    sm.Transition(Triggers.EnemyDetected);
                }
                else if (key == ConsoleKey.R && sm.CurrentState == States.Attacking)
                {
                    sm.Transition(Triggers.EnemyOutOfRange);
                }
                else if (key == ConsoleKey.D && sm.CurrentState == States.Attacking)
                {
                    sm.Transition(Triggers.EnemyDied);
                }
                else if (key == ConsoleKey.B && sm.CurrentState == States.Retreating)
                {
                    sm.Transition(Triggers.ReturnedToPatrollPosition);
                }
                else if (key == ConsoleKey.Escape)
                {
                    done = true;
                }
            } while (!done);
        }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        if (!c_stateData.b_updateState)
        {
            return;
        }

        EnginePull();

        UpdateStateMachine();

        sm_scoring.Act();

        EngineUpdate();
    }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        if (!c_stateData.b_updateState)
        {
            return;
        }

        UpdateStateMachine();
        sm_timer.Act();

        float displayTime = c_timerData.f_currentTime;
        int   minutes     = (int)displayTime / 60;
        int   seconds     = (int)displayTime % 60;
        int   millis      = (int)(displayTime * 100) % 100;

        /*
         * c_timerData.s_timerString.Clear();
         * c_timerData.s_timerString.AppendFormat(Constants.TIME_FORMAT_STRING, minutes, seconds, millis);
         * timerText.text = c_timerData.s_timerString.ToString();
         */
    }
コード例 #7
0
    void FixedUpdate()
    {
        c_activeMenuData.v_lastFramePosition = c_activeMenuData.v_currentPosition;
        if (c_activeMenuData.b_showMenu == true)
        {
            float inputAxisValue = GlobalInputController.GetAnalogInputAction(ControlAction.FLIP_AXIS);
            if (inputAxisValue > 0.5f)
            {
                c_activeMenuData.i_menuDir = -1; // menus are often organized top to bottom
            }
            else if (inputAxisValue < -0.5f)
            {
                c_activeMenuData.i_menuDir = 1;
            }
            else
            {
                c_activeMenuData.i_menuDir = 0;
            }

            if (GlobalInputController.GetInputAction(ControlAction.CONFIRM, KeyValue.PRESSED))
            {
                c_activeMenuItem.ExecuteMenuCommand();
            }
        }

        UpdateStateMachine();

        sm_menuInput.Act();
        sm_pauseMenu.Act();

        if (i_activeMenuItemIndex != c_activeMenuData.i_activeMenuItemIndex)
        {
            c_activeMenuItem.ExecuteStateMachineCommand(Command.UNSELECT);
            i_activeMenuItemIndex = c_activeMenuData.i_activeMenuItemIndex;
            c_activeMenuItem      = MenuItems[i_activeMenuItemIndex];
            c_activeMenuItem.ExecuteStateMachineCommand(Command.SELECT);
        }
    }
コード例 #8
0
 // Update is called once per frame
 void FixedUpdate()
 {
     UpdateStateMachine();
     sm_countdown.Act();
     EnginePush();
 }
コード例 #9
0
 void FixedUpdate()
 {
     c_lastFrameData.v_lastFramePosition = c_activeMenuData.v_currentPosition;
     sm_menuInput.Act();
     sm_showHide.Act();
 }