Ejemplo n.º 1
0
    void FixedUpdate()
    {
        if (status == LightBallStatus.bounce)
        {
            switch (nextStatus)
            {
            case LightBallStatus.weak:
                speed -= Time.deltaTime * (BOUNCE_SPEED - WEAK_SPEED) / BOUNCE_DECAY_TIME;
                if (speed < WEAK_SPEED)
                {
                    speed  = WEAK_SPEED;
                    status = LightBallStatus.weak;
                }
                break;

            case LightBallStatus.standar:
                speed -= Time.deltaTime * (BOUNCE_SPEED - originalSpeed) / BOUNCE_DECAY_TIME;
                if (speed < originalSpeed)
                {
                    speed  = originalSpeed;
                    status = LightBallStatus.standar;
                }
                break;
            }
            velocity.Set(velocity.normalized.x * speed, velocity.normalized.y * speed);
        }
        rb2d.velocity = velocity;
    }
Ejemplo n.º 2
0
    void OnPadImpact(PadImpactMessage msg)
    {
        switch (msg.impact)
        {
        case Impact.weak:
            speed      = BOUNCE_SPEED;
            status     = LightBallStatus.bounce;
            nextStatus = LightBallStatus.weak;
            break;

        case Impact.strong:
            speed  = STRONG_SPEED;
            status = LightBallStatus.strong;
            break;

        case Impact.standar:
            speed      = BOUNCE_SPEED;
            status     = LightBallStatus.bounce;
            nextStatus = LightBallStatus.standar;
            break;

        default:
            break;
        }
        velocity.Set(msg.direction.normalized.x * speed, msg.direction.normalized.y * speed);
    }
Ejemplo n.º 3
0
    void Start()
    {
        BOUNCE_SPEED = PlayerController.Speed + 10;

        // Get the rigid body component
        rb2d              = GetComponent <Rigidbody2D> ();
        lineRenderer      = GetComponent <LineRenderer> ();
        spriteRenderer    = GetComponent <SpriteRenderer> ();
        isInsidePlayfield = false;
        status            = LightBallStatus.standar;
    }