Esempio n. 1
0
        protected override void ComputeVelocity()
        {
            jumpFrame = false;

            Vector2 move = Vector2.zero;

            move.x = input.Direction.x;

            if (input.GetButtonDown("Jump") && Grounded)
            {
                velocity.y = jumpTakeOffSpeed;
                isJumping  = true;
                jumpFrame  = true;

                jumpLift = currentLift;
            }
            else if (input.GetButtonUp("Jump"))
            {
                if (velocity.y > 0)
                {
                    velocity.y *= 0.5f;
                }
            }

            TargetVelocity = move * maxSpeed;
        }
Esempio n. 2
0
        void Update()
        {
            bool flipSprite = transform.localScale.x <0 ? input.Direction.x> 0.01f : input.Direction.x < -0.01f;

            if (flipSprite)
            {
                var localScale = transform.localScale;
                localScale.x         = -localScale.x;
                transform.localScale = localScale;
            }

            animator.SetBool("grounded", physicsObject.Grounded);
            animator.SetFloat("velocityX", Mathf.Abs(physicsObject.Velocity.x));
            animator.SetFloat("velocityY", physicsObject.Velocity.y);
            animator.SetBool("jump", input.GetButtonDown("Jump"));
        }
        void Update()
        {
            if (gameScript != null)
            {
                spriteRenderer.color = gameScript.isAlive ? Color.white : Color.clear;
            }

            bool flipSprite = spriteRenderer.flipX ? input.Direction.x > 0.01f : input.Direction.x < -0.01f;

            if (flipSprite)
            {
                spriteRenderer.flipX = !spriteRenderer.flipX;
            }

            animator.SetBool("grounded", physicsObject.Grounded);
            animator.SetFloat("velocityX", Mathf.Abs(physicsObject.Velocity.x));
            animator.SetFloat("velocityY", physicsObject.Velocity.y);
            animator.SetBool("jump", input.GetButtonDown("Jump"));
        }
 public static int GetButtonDown(IntPtr l)
 {
     int result;
     try
     {
         BaseInput baseInput = (BaseInput)LuaObject.checkSelf(l);
         string buttonName;
         LuaObject.checkType(l, 2, out buttonName);
         bool buttonDown = baseInput.GetButtonDown(buttonName);
         LuaObject.pushValue(l, true);
         LuaObject.pushValue(l, buttonDown);
         result = 2;
     }
     catch (Exception e)
     {
         result = LuaObject.error(l, e);
     }
     return result;
 }
Esempio n. 5
0
        protected override void ComputeVelocity()
        {
            Vector2 move = Vector2.zero;

            move.x = input.Direction.x;

            if (input.GetButtonDown("Jump") && Grounded)
            {
                velocity.y = jumpTakeOffSpeed;
            }
            else if (input.GetButtonUp("Jump"))
            {
                if (velocity.y > 0)
                {
                    velocity.y *= 0.5f;
                }
            }

            TargetVelocity = move * maxSpeed;
        }