Пример #1
0
        private void IdleCheck(ControlProperty control, StateProperty state, InputProperty input)
        {
            if (InputUtils.HasAnyInput(input) || state.HasState(State.Fall))
            {
                if (control.m_idle)
                {
                    control.m_idleTimer = 1 + Random.Range(0, 3);
                }
                control.m_idle = false;
            }
            else
            {
                control.m_idleTimer += Time.deltaTime;

                if (control.m_idleTimer >= 10)
                {
                    control.m_idle = true;
                    if (Random.Range(1, 400) == 1)
                    {
                        control.m_lookDirection = new Vector3(
                            Random.Range(-1, 1), Random.Range(-0.2f, 1), Random.Range(-1, 1)).normalized;
                    }
                }

                if (control.m_idleTimer >= 20)
                {
                    control.m_run = true;
                }
            }
        }
Пример #2
0
        private void DirectionCheck(ControlProperty control, InputProperty input)
        {
            control.m_rawDirection = new Vector3(input.Move.x, 0, input.Move.y);

            if (InputUtils.ValidMove(input.Move))
            {
                control.m_direction = control.m_rawDirection.normalized;
            }

            if (!control.m_idle)
            {
                control.m_lookDirection = control.m_direction + new Vector3(0, 0.2f, 0);
            }
        }
Пример #3
0
 public static void BindActions(this PlayerCoreECS.InputProperty input, CharacterActions actions, InputDevice device)
 {
     input.m_actions = actions;
     input.m_device  = device;
 }
Пример #4
0
 public static bool HasAnyInput(PlayerCoreECS.InputProperty input)
 {
     return(input.Attack || input.JumpWasPressed || input.PickWasPressed ||
            input.ThrowWasPressed || ValidMove(input));
 }
Пример #5
0
 public static bool ValidMove(PlayerCoreECS.InputProperty input)
 {
     return(ValidMove(input.Move));
 }
Пример #6
0
        private void JumpRunCheck(ControlProperty control, StateProperty state, InputProperty input)
        {
            if (control.m_jumpDelay > 0f)
            {
                control.m_jumpDelay -= Time.deltaTime;
            }

            if (state.m_lastState == State.Stand &&
                !InputUtils.ValidMove(new Vector2(control.m_rawDirection.x, control.m_rawDirection.z)) &&
                !control.m_idle)
            {
                control.m_run = false;
            }

            if (input.JumpWasPressed)
            {
                control.m_jumpTimer = 0f;
            }

            if (input.Jump)
            {
                if (control.m_jumpTimer > 0.4f)
                {
                    control.m_run      = true;
                    control.m_runTimer = 1f;
                }
                control.m_jumpTimer += Time.deltaTime;
            }
            else
            {
                if (control.m_runTimer >= 0)
                {
                    control.m_runTimer -= Time.deltaTime;
                }
                else
                {
                    control.m_runTimer = 0;
                    if (!control.m_idle)
                    {
                        control.m_run = false;
                    }
                }
            }

            if (input.JumpWasReleaseed)
            {
                if (control.m_jumpTimer <= 0.8f)
                {
                    control.m_jump = true;

                    if (control.m_jumpDelay <= 0f && !state.HasState(State.Jump) && !state.HasState(State.Fall))
                    {
                        control.m_fallTimer       -= 0.4f;
                        control.m_jumpDelay        = 0.8f;
                        control.m_groundCheckDelay = 0.1f;
                        state.m_state = State.Jump;
                    }
                }
            }
            else
            {
                control.m_jump = false;
            }
        }