示例#1
0
    void TwoHandSwordAttack(InputActionPhase _Phase)
    {
        if (_Phase != InputActionPhase.Started)
        {
            return;
        }
        if (!CheckSkillAvailability())
        {
            return;
        }

        if (CheckMotionCancelAvailability())
        {
            SkillAnimationPlay(true, 0.25f);
        }
        else if (!DefaultStateCheck())
        {
            return;
        }
        else
        {
            SkillAnimationPlay();
        }
        m_PlayerCharacter.ActivateOnlyOneWeapon(12);
        SoundManager.Instance.PlayDefaultSound(m_PlayerCharacter.m_SkillAttackClip3);
        StartNewMotion();
    }
示例#2
0
        public void OnFire(InputAction.CallbackContext callbackContext)
        {
            m_fireTriggerPhase = callbackContext.phase;
            switch (callbackContext.phase)
            {
            case InputActionPhase.Started:
                if (State == State.Holding && m_timer >= CoolDown)
                {
                    State        = State.Throwing;
                    m_pressTimer = 0;
                }
                break;

            case InputActionPhase.Canceled:
                if (State == State.Throwing)
                {
                    State = State.Idle;
                    GameHud.Release();
                    m_holdingBait.Throw(this);
                    m_holdingBait = null;
                    m_timer       = 0;
                }
                break;

            case InputActionPhase.Waiting:
                break;

            case InputActionPhase.Disabled:
                break;
            }
        }
    void SwordAttack(InputActionPhase _Phase)
    {
        if (_Phase != InputActionPhase.Started)
        {
            return;
        }
        if (!CheckSkillAvailability())
        {
            return;
        }

        if (CheckMotionCancelAvailability())
        {
            SkillAnimationPlay(true, 0.15f);
        }
        else if (!DefaultStateCheck())
        {
            return;
        }
        else
        {
            SkillAnimationPlay();
        }
        m_PlayerCharacter.ActivateOnlyOneWeapon(11);
        SoundManager.Instance.PlayDefaultSound(m_PlayerCharacter.m_SkillAttackClip1);
        StartNewMotion();
        m_PlayerCharacter.m_Rigidbody.velocity = m_PlayerCharacter.transform.forward * 10;
    }
示例#4
0
            public ActionConstraint(InputActionPhase phase, InputAction action, InputControl control, object value = null, Type interaction = null)
            {
                this.phase       = phase;
                this.action      = action;
                this.control     = control;
                this.value       = value;
                this.interaction = interaction;

                var interactionText = string.Empty;

                if (interaction != null)
                {
                    interactionText = $"{InputInteraction.s_Interactions.FindNameForType(interaction).ToLower()} of ";
                }

                Description = $"{phase} {interactionText}'{action}'";
                if (control != null)
                {
                    Description += $" from '{control}'";
                }
                if (value != null)
                {
                    Description += $" with value {value}";
                }

                foreach (var constraint in m_AndThen)
                {
                    Description += " and\n";
                    Description += constraint.Description;
                }
            }
示例#5
0
    public void OnRotate(InputAction.CallbackContext context)
    {
        var mousepos = Mouse.current.position.ReadValue();

        m_rotatePhase   = context.phase;
        m_rotationValue = context.ReadValue <Vector2>();
    }
 private static void WriteActionEventField(string setName, string actionName, InputActionPhase phase, Writer writer)
 {
     if (char.IsLower(actionName[0]))
     {
         actionName = char.ToUpper(actionName[0]) + actionName.Substring(1);
     }
     writer.WriteLine($"[SerializeField] private ActionEvent m_{setName}{actionName}Action{phase};");
 }
 private static void WriteActionEventField(string setName, string actionName, InputActionPhase phase, Writer writer)
 {
     if (char.IsLower(actionName[0]))
     {
         actionName = char.ToUpper(actionName[0]) + actionName.Substring(1);
     }
     writer.WriteLine(string.Format("[SerializeField] private ActionEvent m_{0}{1}Action{2};",
                                    setName, actionName, phase));
 }
示例#8
0
        private void ProcessButtonEvent(InputActionPhase actionPhase, EInputButton inputButton)
        {
            switch (actionPhase)
            {
            case InputActionPhase.Started:
                InvokeEventIfBound(ButtonPressed, myControllerID, inputButton);
                break;

            case InputActionPhase.Performed:
                InvokeEventIfBound(ButtonReleased, myControllerID, inputButton);
                break;
            }
        }
 public void Fire(InputActionPhase context)
 {
     //only fires when the input actiopn is being performed
     //seth - also slows player down when shooting
     if (context == InputActionPhase.Performed)
     {
         _gun.Fire();
         _playerMovement.MoveSpeed = _initialMoveSpeed * _playerMovement._SpeedReductionMultiplier;
     }
     else
     {
         _playerMovement.MoveSpeed = _initialMoveSpeed;
     }
 }
示例#10
0
    private void ProcessHandInput(AbilityIndex index, InputActionPhase phase)
    {
        if (downAction.isNew && index < downAction.index)
        {
            return;
        }

        if (phase == InputActionPhase.Started)
        {
            downAction = new QueuedAction(index);
        }
        else if (phase == InputActionPhase.Canceled)
        {
            fighter.UseAbility(index, false, out _);
        }
    }
示例#11
0
    private Option <Vector2> applyPhase(InputActionPhase phase, Vector2 vector)
    {
        switch (phase)
        {
        case InputActionPhase.Started:
            return(Some(vector));

        case InputActionPhase.Performed:
            return(Some(vector));

        case InputActionPhase.Canceled:
            return(None);

        default:
            return(None);
        }
    }
    void Dash(InputActionPhase _Phase)
    {
        if (_Phase != InputActionPhase.Started)
        {
            return;
        }
        if (InputManager.Instacne.m_Move2D == Vector2.zero)
        {
            return;
        }
        if (m_PlayerCharacter.m_Stemina < m_DashSteminaPoint)
        {
            return;
        }
        if (m_CharacterBase.m_IsDashing)
        {
            return;
        }
        if (CheckMotionCancelAvailability())
        {
            m_PlayerCharacter.AllWeaponDisable();
            m_PlayerCharacter.StartMotionCancelRim(5.0f, 0.5f);
            m_CharacterBase.m_Animator.CrossFade(m_DashAnimKey, 0.0f);
            m_PlayerCharacter.CreateSpectrumMesh(1.0f, true, GameManager.Instacne.m_Main.m_SpectrumMaterial);
        }
        else if (!DefaultStateCheck())
        {
            return;
        }

        if (m_CharacterBase.m_Animator.GetCurrentAnimatorStateInfo(0).shortNameHash == m_DashAnimKey)
        {
            m_CharacterBase.m_Animator.CrossFade(m_DashAnimKey, 0.0f);
        }
        else
        {
            m_CharacterBase.m_Animator.CrossFade(m_DashAnimKey, 0.05f);
        }

        m_PlayerCharacter.SubStemina(m_DashSteminaPoint);
        m_CharacterBase.m_ActiveMotionRunning = true;
        m_CharacterBase.m_IsDashing           = true;
        m_CharacterBase.m_Animator.SetFloat(m_DashAxisKeyX, InputManager.Instacne.m_Move2D.x);
        m_CharacterBase.m_Animator.SetFloat(m_DashAxisKeyY, InputManager.Instacne.m_Move2D.y);
        m_CharacterBase.m_Rigidbody.velocity = (m_CharacterBase.transform.rotation * new Vector3(InputManager.Instacne.m_Move2D.x, 0.0f, InputManager.Instacne.m_Move2D.y)) * m_DashSpeed;
    }
示例#13
0
            public ActionConstraint(InputActionPhase phase, InputAction action, InputControl control, object value = null, Type interaction = null, double?time = null, double?duration = null)
            {
                this.phase       = phase;
                this.time        = time;
                this.duration    = duration;
                this.action      = action;
                this.control     = control;
                this.value       = value;
                this.interaction = interaction;

                var interactionText = string.Empty;

                if (interaction != null)
                {
                    interactionText = InputInteraction.GetDisplayName(interaction);
                }

                var actionName = action.actionMap != null ? $"{action.actionMap}/{action.name}" : action.name;
                // Use same text format as InputActionTrace for easier comparison.
                var description = $"{{ action={actionName} phase={phase}";

                if (time != null)
                {
                    description += $" time={time}";
                }
                if (control != null)
                {
                    description += $" control={control}";
                }
                if (value != null)
                {
                    description += $" value={value}";
                }
                if (interaction != null)
                {
                    description += $" interaction={interactionText}";
                }
                if (duration != null)
                {
                    description += $" duration={duration}";
                }
                description += " }";
                Description  = description;
            }
        public static StratusInputActionPhase Convert(InputActionPhase phase)
        {
            switch (phase)
            {
            case InputActionPhase.Disabled:
                break;

            case InputActionPhase.Waiting:
                break;

            case InputActionPhase.Started:
                return(StratusInputActionPhase.Started);

            case InputActionPhase.Performed:
                return(StratusInputActionPhase.Performed);

            case InputActionPhase.Canceled:
                return(StratusInputActionPhase.Canceled);
            }
            throw new NotImplementedException(phase.ToString());
        }
示例#15
0
            public ActionConstraint(InputActionPhase phase, InputAction action, InputControl control, object value = null, Type interaction = null, double?time = null)
            {
                this.phase       = phase;
                this.time        = time;
                this.action      = action;
                this.control     = control;
                this.value       = value;
                this.interaction = interaction;

                var interactionText = string.Empty;

                if (interaction != null)
                {
                    interactionText = $"{InputInteraction.s_Interactions.FindNameForType(interaction).ToLower()} of ";
                }

                var actionName = action.actionMap != null ? $"{action.actionMap}/{action.name}" : action.name;

                // Use same text format as InputActionTrace for easier comparison.
                Description = $"{{ action={actionName} phase={phase} time={time} control={control} value={value} interaction={interactionText} }}";
            }
示例#16
0
    void FinishPunch(InputActionPhase _Phase)
    {
        if (_Phase != InputActionPhase.Started)
        {
            return;
        }
        if (UIManager.Instacne.m_ComboViewer.GetCurrentCombo() < 7)
        {
            return;
        }
        if (!CheckSkillAvailability())
        {
            return;
        }

        if (CheckMotionCancelAvailability())
        {
            SkillAnimationPlay(true, 0.5f);
        }
        else if (!DefaultStateCheck())
        {
            return;
        }
        else
        {
            SkillAnimationPlay();
        }
        m_PlayerCharacter.AllWeaponDisable();
        LifeTimerWithObjectPool life = ObjectPool.GetObject <LifeTimerWithObjectPool>(m_ChargeEffect);

        life.Initialize();
        life.SetTargetTransform(m_CharacterBase.m_RightHandPoint);
        life.gameObject.SetActive(true);
        SoundManager.Instance.PlayDefaultSound(m_PlayerCharacter.m_FinishAttackClip1);
        StartNewMotion();

        m_PlayerCharacter.m_Immortal      = true;
        m_PlayerCharacter.m_StopCharacter = true;
        m_PlayerCharacter.m_FinishCamera.SetFocus();
    }
示例#17
0
    void EscapeButton(InputActionPhase _Phase)
    {
        if (_Phase != InputActionPhase.Started)
        {
            return;
        }

        if (m_MenuList.activeSelf)
        {
            Time.timeScale = 1.0f;
            m_MenuList.SetActive(false);

            GameManager.Instacne.m_Main.IsGameStop = false;
            GameManager.Instacne.m_Main.MouseLock(true);
        }
        else
        {
            Time.timeScale = 0.0f;
            m_MenuList.SetActive(true);

            GameManager.Instacne.m_Main.IsGameStop = true;
            GameManager.Instacne.m_Main.MouseLock(false);
        }
    }
    void MouseEvent(InputActionPhase _Phase)
    {
        if (_Phase != InputActionPhase.Started)
        {
            return;
        }
        if (!DefaultStateCheck())
        {
            return;
        }

        StartNewMotion();
        m_PlayerCharacter.AllWeaponDisable();
        switch (m_AttackLevel)
        {
        case 0:
            m_CharacterBase.m_Animator.CrossFade(m_AnimKeyAttack1, 0.15f);
            SoundManager.Instance.PlayDefaultSound(m_PlayerCharacter.m_NormalAttackClip, 0.5f);
            SoundManager.Instance.PlayDefaultSound(m_CharacterBase.m_AudioList[0], 0.5f);
            break;

        case 1:
            SoundManager.Instance.PlayDefaultSound(m_PlayerCharacter.m_NormalAttackClip, 0.5f);
            m_CharacterBase.m_Animator.CrossFade(m_AnimKeyAttack2, 0.15f);
            SoundManager.Instance.PlayDefaultSound(m_CharacterBase.m_AudioList[0], 0.5f);
            break;

        case 2:
            SoundManager.Instance.PlayDefaultSound(m_PlayerCharacter.m_NormalAttackClip, 0.5f);
            m_CharacterBase.m_Animator.CrossFade(m_AnimKeyAttack3, 0.1f);
            SoundManager.Instance.PlayDefaultSound(m_CharacterBase.m_AudioList[0], 0.5f);
            break;
        }
        m_AttackLevel = (m_AttackLevel + 1) % 3;
        m_Timer       = 1.25f;
    }
        private static void WriteActionEventGetter(string setName, string actionName, InputActionPhase phase, Writer writer)
        {
            var actionNameCased = actionName;

            if (char.IsLower(actionNameCased[0]))
            {
                actionNameCased = char.ToUpper(actionNameCased[0]) + actionNameCased.Substring(1);
            }

            writer.WriteLine(string.Format("public ActionEvent {1}{2} {{ get {{ return m_Wrapper.m_{0}{3}Action{2}; }} }}",
                                           setName, actionName, phase, actionNameCased));
        }
示例#20
0
 public bool GetPhaseChanged(InputActionPhase phase)
 {
     return(UpdatePhaseTrack.Value == phase);
 }
    void Update()
    {
        InputActionPhase jumpPhase     = InputActionPhase.Waiting;
        bool             jumpTriggered = false;

        if (controls == null)
        {
            Debug.Log("HOW IS GAMEPLAY NULL");
        }
        if (controls.Gameplay.Jump != null)
        {
            jumpPhase     = controls.Gameplay.Jump.phase;
            jumpTriggered = controls.Gameplay.Jump.triggered;
        }
        // Debug.LogFormat("Jump Phase: {0} Triggered: {1}", jumpPhase, jumpTriggered);

        GameObject tracerObj = Instantiate(tracerPrefab, transform.position, Quaternion.identity);

        tracerObj.transform.parent = tracers.transform;
        TracerDot tracer = tracerObj.GetComponent <TracerDot>();

        Vector2 input = controls.Gameplay.Move.ReadValue <Vector2>();
        // Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        float targetX = input.x * moveSpeed;

        if (Mathf.Abs(input.x) < 0.1)
        {
            targetX = 0;
        }
        Vector3 initialVelocity = velocity;

        if (moveController.collisions.above)
        {
            velocity.y = 0;
        }

        if (moveController.collisions.left || moveController.collisions.right)
        {
            velocity.x = 0;
        }

        switch (jumpState)
        {
        case JumpState.Grounded:
            tracer.color = Color.white;

            if (dash())
            {
                break;
            }
            else if (controls.Gameplay.Jump.phase == InputActionPhase.Started)
            {
                // } else if (Input.GetButton("Jump")) {
                velocity.y = jumpVelocity;
                if (input.x >= 0.25f)
                {
                    velocity.x = moveSpeed * maxForwardJumpBoost;
                }
                else if (input.x <= -0.25f)
                {
                    velocity.x = -moveSpeed * maxForwardJumpBoost;
                }
                else
                {
                    velocity.x = 0f;
                }
                setJumpState(JumpState.Ascending);
                break;
            }
            else
            {
                velocity.y = gravity * Time.deltaTime;
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxRunSpeed);
            }
            break;

        case JumpState.Dash:
            tracer.color = Color.red;
            velocity.x   = Mathf.SmoothDamp(velocity.x, velocity.x >= 0 ? moveSpeed : -moveSpeed, ref velocityXSmoothing, dashTime);
            velocity.y   = 0;
            float timeDashing = Time.time - lastDashTime;
            if (timeDashing >= dashTime)
            {
                if (moveController.isGrounded)
                {
                    setJumpState(JumpState.Grounded);
                }
                else
                {
                    setJumpState(JumpState.Falling);
                }
            }
            break;

        case JumpState.Ascending:
            tracer.color = Color.green;

            // n starts at 0 and goes to 1 as we ascend
            float n = Mathf.InverseLerp(0, timeToJumpApex, Time.time - jumpStateStart);

            // the drag coefficient gets bigger as we ascend, terminating at 1
            float dragCoefficient = n * n;

            if (dash())
            {
                break;
                // } else if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) {
            }
            else if (controls.Gameplay.Jump.triggered && jumpCount < maxJumps)
            {
                velocity.y = jumpVelocity;
                if (input.x >= 0.25f)
                {
                    velocity.x = moveSpeed * maxForwardJumpBoost;
                }
                else if (input.x <= -0.25f)
                {
                    velocity.x = -moveSpeed * maxForwardJumpBoost;
                }
                else
                {
                    velocity.x = 0f;
                }
                setJumpState(JumpState.Ascending);
                break;
                // } else if (Input.GetButton("Jump")) {
            }
            else if (controls.Gameplay.Jump.phase == InputActionPhase.Started)
            {
                float jumpDrag = jumpVelocity * dragCoefficient;
                if (n <= 0.7)
                {
                    jumpDrag = 0;
                }
                velocity.y = jumpVelocity - jumpDrag;
            }
            else
            {
                // if we're not pressing jump any more we add all the gravity
                velocity.y += 4 * gravity * Time.deltaTime;

                // the amount of time spent floating is equal to the amount of
                // time the player held down the jump button.
                if (wasHoldingJump)
                {
                    apexTime = Time.time - jumpStartTime;
                }
            }

            float forwardBoost = maxForwardJumpBoost - (maxForwardJumpBoost * dragCoefficient);
            forwardBoost = Mathf.Clamp(forwardBoost, 1, maxForwardJumpBoost);

            switch (jumpDirection)
            {
            case JumpDirection.Neutral:
                // you can wiggle out of a neutral jump in either direction
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                break;

            case JumpDirection.Left:
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX < 0 ? targetX * forwardBoost : 0, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                break;

            case JumpDirection.Right:
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX > 0 ? targetX * forwardBoost : 0, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                break;
            }

            // if we were rising in the last frame but will be falling in this
            // frame, we should zero out the velocity to float instead.
            if (initialVelocity.y >= 0 && velocity.y <= 0)
            {
                velocity.y = 0;
                // if (wasHoldingJump && Input.GetButton("Jump")) {
                if (wasHoldingJump && controls.Gameplay.Jump.phase == InputActionPhase.Started)
                {
                    apexTime = maxApexTime;
                }
                setJumpState(JumpState.Apex);
            }
            break;

        case JumpState.Apex:
            tracer.color = Color.magenta;

            if (dash())
            {
                break;
                // } else if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) {
            }
            else if (controls.Gameplay.Jump.triggered && jumpCount < maxJumps)
            {
                velocity.y = jumpVelocity;
                if (input.x >= 0.25f)
                {
                    velocity.x = moveSpeed * maxForwardJumpBoost;
                }
                else if (input.x <= -0.25f)
                {
                    velocity.x = -moveSpeed * maxForwardJumpBoost;
                }
                else
                {
                    velocity.x = 0f;
                }
                setJumpState(JumpState.Ascending);
                break;
            }
            else
            {
                switch (jumpDirection)
                {
                case JumpDirection.Neutral:
                    velocity.x = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                    break;

                case JumpDirection.Left:
                    velocity.x = Mathf.SmoothDamp(velocity.x, targetX < 0 ? targetX : 0, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                    break;

                case JumpDirection.Right:
                    velocity.x = Mathf.SmoothDamp(velocity.x, targetX > 0 ? targetX : 0, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                    break;
                }

                float timeAtApex        = Time.time - jumpStateStart;
                float apexTimeRemaining = apexTime - timeAtApex;
                if (apexTimeRemaining < 0)
                {
                    velocity.y += gravity * -apexTimeRemaining;
                    setJumpState(JumpState.Descending);
                }
                else
                {
                    velocity.y = 0;
                }
            }
            break;

        case JumpState.Descending:
            tracer.color = Color.yellow;

            // if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) {
            if (controls.Gameplay.Jump.triggered && jumpCount < maxJumps)
            {
                velocity.y = jumpVelocity;
                if (input.x >= 0.25f)
                {
                    velocity.x = moveSpeed * maxForwardJumpBoost;
                }
                else if (input.x <= -0.25f)
                {
                    velocity.x = -moveSpeed * maxForwardJumpBoost;
                }
                else
                {
                    velocity.x = 0f;
                }
                setJumpState(JumpState.Ascending);
                break;
            }

            float n2 = (Time.time - jumpStateStart) / timeToJumpApex;
            n2 = Mathf.Clamp(n2, 0, 1);
            switch (jumpDirection)
            {
            case JumpDirection.Neutral:
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                break;

            case JumpDirection.Left:
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX < 0 ? targetX : 0, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                break;

            case JumpDirection.Right:
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX > 0 ? targetX : 0, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                break;
            }

            // fall speed is increasing when descending
            velocity.y += gravity * Time.deltaTime * (Mathf.Clamp(4 * n2 * n2, 1, 4));
            break;

        case JumpState.CoyoteTime:
            tracer.color = Color.blue;
            velocity.x   = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxRunSpeed);

            if (dash())
            {
                break;
                // } else if (Input.GetButtonDown("Jump")) {
            }
            else if (controls.Gameplay.Jump.triggered)
            {
                setJumpState(JumpState.Ascending);
                velocity.y = jumpVelocity;
            }
            else
            {
                float elapsedCoyoteTime   = Time.time - jumpStateStart;
                float coyoteTimeRemaining = coyoteTime - elapsedCoyoteTime;
                if (coyoteTimeRemaining < 0)
                {
                    setJumpState(JumpState.Falling);
                }
                velocity.y += gravity * Time.deltaTime;
            }
            break;

        case JumpState.Falling:
            tracer.color = Color.grey;

            // if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) {
            if (controls.Gameplay.Jump.triggered && jumpCount < maxJumps)
            {
                velocity.y = jumpVelocity;
                if (input.x >= 0.25f)
                {
                    velocity.x = moveSpeed * maxForwardJumpBoost;
                }
                else if (input.x <= -0.25f)
                {
                    velocity.x = -moveSpeed * maxForwardJumpBoost;
                }
                else
                {
                    velocity.x = 0f;
                }
                setJumpState(JumpState.Ascending);
                break;
            }

            switch (jumpDirection)
            {
            case JumpDirection.Neutral:
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                break;

            case JumpDirection.Left:
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX < 0 ? targetX : 0, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                break;

            case JumpDirection.Right:
                velocity.x = Mathf.SmoothDamp(velocity.x, targetX > 0 ? targetX : 0, ref velocityXSmoothing, timeToMaxAirmoveSpeed);
                break;
            }
            velocity.y += gravity * Time.deltaTime;
            break;

        default:
            throw new System.Exception("bad jump state: " + jumpState);
        }

        if (velocity.y < maxFallSpeed)
        {
            velocity.y = maxFallSpeed;
        }

        moveController.Move(velocity * Time.deltaTime);
        if (jumpState == JumpState.Grounded && !moveController.isGrounded)
        {
            setJumpState(JumpState.CoyoteTime);
        }
        if (jumpState != JumpState.Grounded && moveController.isGrounded)
        {
            setJumpState(JumpState.Grounded);
        }
        // wasHoldingJump = Input.GetButton("Jump");
        wasHoldingJump = controls.Gameplay.Jump.phase == InputActionPhase.Started;

        CheckCollisions();
    }
        private static void WriteActionEventInitializer(string setName, string actionName, InputActionPhase phase, Writer writer, bool removeCallback = false)
        {
            var actionNameCased = actionName;

            if (char.IsLower(actionNameCased[0]))
            {
                actionNameCased = char.ToUpper(actionNameCased[0]) + actionNameCased.Substring(1);
            }

            string callbackName;

            switch (phase)
            {
            case InputActionPhase.Started: callbackName = "started"; break;

            case InputActionPhase.Performed: callbackName = "performed"; break;

            case InputActionPhase.Cancelled: callbackName = "cancelled"; break;

            default:
                throw new Exception("Internal error: No known callback for " + phase);
            }

            writer.WriteLine(string.Format("if (m_{0}{1}Action{2} != null)", setName, actionNameCased, phase));
            ++writer.indentLevel;
            writer.WriteLine(string.Format("m_{0}_{4}.{3} {5}= m_{0}{1}Action{2}.Invoke;",
                                           setName, actionNameCased, phase, callbackName, CSharpCodeHelpers.MakeIdentifier(actionName),
                                           removeCallback ? "-" : "+"));
            --writer.indentLevel;
        }
示例#23
0
 /// <summary>
 /// Return true if the given phase is <see cref="InputActionPhase.Started"/> or <see cref="InputActionPhase.Performed"/>.
 /// </summary>
 /// <param name="phase">An action phase.</param>
 /// <returns>True if the phase is started or performed.</returns>
 /// <seealso cref="InputAction.phase"/>
 public static bool IsInProgress(this InputActionPhase phase)
 {
     return(phase == InputActionPhase.Started || phase == InputActionPhase.Performed);
 }
示例#24
0
 public void OnScroll(InputAction.CallbackContext context)
 {
     Debug.Log(string.Format("{0 }Scroll {1}", Time.frameCount, context.ReadValue <Vector2>()));
     m_scrollPhase = context.phase;
     m_scrollValue = context.ReadValue <Vector2>();
 }
示例#25
0
 public void OnMove(InputAction.CallbackContext context)
 {
     m_movePhase = context.phase;
     m_moveValue = context.ReadValue <Vector2>();
 }
示例#26
0
 /// <summary>
 /// Converts an input action phase enumerated value from Unity's to this system
 /// </summary>
 /// <param name="phase"></param>
 /// <returns></returns>
 public StratusInputActionPhase Convert(InputActionPhase phase) => StratusInputUtility.Convert(phase);
示例#27
0
    public void OnInteract(InputActionPhase phase)
    {
        if (phase == InputActionPhase.Started)
        {
            // Event 1 : OnPrepareToRaise
            if (onPrepareToRaise != null)
            {
                onPrepareToRaise();
            }
            if (gameObject == BeamManager.PlayerNorth || gameObject == BeamManager.PlayerSouth)
            {
                if (isPreparedToRaise)
                {
                    #region Décompte HOLD
                    coeff_raising = 1;
                    #endregion
                    #region Déclenchement animation
                    gameObject.GetComponent <Animator>().SetBool("PrepareToRaise", false);
                    gameObject.GetComponent <Animator>().SetBool("TryToRaise", true);
                    #endregion
                } // Action : SOULEVER LA POUTRE
                else
                {
                    #region Positionnement des controllers
                    if (gameObject.transform.tag == "Player 1")
                    {
                        if (BeamManager.Player1IsIn != null)
                        {
                            _controler_HandL_Ref.transform.position    = BeamManager.Player1IsIn.transform.Find("HandL").transform.position;
                            _controler_HandR_Ref.transform.position    = BeamManager.Player1IsIn.transform.Find("HandR").transform.position;
                            _controler_Armature_Ref.transform.position = BeamManager.Player1IsIn.transform.position;
                        }
                    }
                    else if (gameObject.transform.tag == "Player 2")
                    {
                        if (BeamManager.Player2IsIn != null)
                        {
                            _controler_HandL_Ref.transform.position    = BeamManager.Player2IsIn.transform.Find("HandL").transform.position;
                            _controler_HandR_Ref.transform.position    = BeamManager.Player2IsIn.transform.Find("HandR").transform.position;
                            _controler_Armature_Ref.transform.position = BeamManager.Player2IsIn.transform.position;
                        }
                    }
                    _controler_Head_Ref.transform.position = GameObject.Find("HeadAim").transform.position;
                    #endregion
                    #region Déclencement animation
                    gameObject.GetComponent <Animator>().SetBool("PrepareToRaise", true);
                    #endregion
                    isPreparedToRaise = true;
                    raise_cooldown    = 1.0f;
                } // Action : SE PREPARER A SOULEVER
            }
        }

        if (phase == InputActionPhase.Performed)
        {
        }
        if (phase == InputActionPhase.Canceled)
        {
            if (gameObject == BeamManager.PlayerNorth || gameObject == BeamManager.PlayerSouth)
            {
                if (isPreparedToRaise)
                {
                    #region FIN Décompte HOLD
                    coeff_raising     = 0;
                    _timeSinceRaising = 0.0f;
                    #endregion
                    #region Déclenchement animation
                    gameObject.GetComponent <Animator>().SetBool("PrepareToRaise", true);
                    gameObject.GetComponent <Animator>().SetBool("TryToRaise", false);
                    #endregion
                } //Action : SOULEVER LA POUTRE
            }
        }
    }