Exemplo n.º 1
0
 void Jump()
 {
     CurrentLedge = null;
     OnJump.SafeInvoke();
     PhysicsState.SetVerticalVelocity(_jumpPower[MaxJumpCount - JumpCount]);
     CmdJump();
 }
Exemplo n.º 2
0
        void LimitFallSpeed()
        {
            var yVel = PhysicsState.Velocity.y;

            if (IsFastFalling)
            {
                PhysicsState.SetVerticalVelocity(-FastFallSpeed);
            }
            else if (yVel < -MaxFallSpeed)
            {
                PhysicsState.SetVerticalVelocity(-MaxFallSpeed);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        void Update()
        {
            if (!isLocalPlayer)
            {
                return;
            }
            if (Mathf.Approximately(Time.deltaTime, 0))
            {
                return;
            }
            if (HitState != null && HitState.Hitstun > 0)
            {
                return;
            }
            if (CurrentState.Data.MovementType == MovementType.Locked)
            {
                PhysicsState.SetHorizontalVelocity(0f);
                PhysicsState.SetVerticalVelocity(0f);
                return;
            }
            var movement = new MovementInfo {
                facing = Direction
            };

            // If currently hanging from a edge
            if (CurrentLedge != null)
            {
                LedgeMovement();
                if (Time.time > _grabTime + Config.Player.MaxLedgeHangTime)
                {
                    CurrentLedge = null;
                }
                else
                {
                    PhysicsState.SetHorizontalVelocity(movement.Speed.x);
                    return;
                }
            }
            var movementInput = InputState.Movement;

            if (PhysicsState.IsGrounded)
            {
                IsFastFalling = false;
                if (JumpCount != MaxJumpCount)
                {
                    CmdResetJumps();
                }
                if (movementInput.x > DirectionalInput.DeadZone)
                {
                    movement.facing = true;
                }
                if (movementInput.x < -DirectionalInput.DeadZone)
                {
                    movement.facing = false;
                }
                Direction = movement.facing;
            }
            else
            {
                if (GetKeysDown(KeyCode.S, KeyCode.DownArrow) || InputState.Smash.y < -DirectionalInput.DeadZone)
                {
                    IsFastFalling = true;
                }
                LimitFallSpeed();
            }
            movement = ApplyControlledMovement(movement, movementInput);
            PhysicsState.SetHorizontalVelocity(movement.Speed.x);
        }