Exemplo n.º 1
0
    private void Update()
    {
        Vector3 targetPosition = p.transform.position + new Vector3(
            p.FacingRight() ? 1 : -1,
            Controller2D.Direction2Vector(p.GetDirection()).y) * range;

        transform.position = targetPosition;
    }
Exemplo n.º 2
0
    private void Jetpack()
    {
        if (Input.GetButtonUp("Fire1"))
        {
            jetpack = true;
        }

        if (controller.collisions.below)
        {
            jetpack = false; jetpackFuel = movement.jetpackFuelRechargeAmount;
        }

        var emission = fx.jetpackParticles.emission;

        if (jetpack && Input.GetButton("Fire1") && (movementInput.y != 0 || movementInput.x != 0) && jetpackFuel > 0.0f)
        {
            bool sputters = (jetpackFuel < (movement.jetpackFuelRechargeAmount * .25f));

            Vector3 jetpackVelocity = Controller2D.Direction2Vector(direction);

            emission.enabled = true;

            emission.rateOverTime = (sputters ? 5 : 20);

            if (movementInput.x != 0)
            {
                jetpackVelocity = facingRight ? Vector2.right : Vector2.left;
            }

            jetpackVelocity *= (sputters ? .5f : 1.0f);

            if (!stats.godMode)
            {
                jetpackFuel -= Time.deltaTime;
            }
            velocity = jetpackVelocity * movement.jetpackSpeed;
        }
        else
        {
            emission.enabled = false;
        }
    }
Exemplo n.º 3
0
 public float GetLookValue()
 {
     return(Mathf.Clamp01(Controller2D.Direction2Vector(direction).y));
 }