Beispiel #1
0
 public void ActivateSpecial()
 {
     if (special > 2)
     {
         special = -1;
         motor.ChangeImage(transform.position.x);
         specialActivated = true;
     }
     else
     {
     }
 }
Beispiel #2
0
    //Checks collision, adds velocity according to hit point
    //Then checks the special cases for activating them
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Racket")
        {
            if (movesSpecial)
            {
                ClearSpecials();
            }

            float velocityX = rb.velocity.x + (speedGain * Mathf.Sign(rb.velocity.x));
            velocityX = -velocityX;

            float velocityY = (transform.position.y - col.transform.position.y) * 3f;

            Vector2 dir = new Vector2(velocityX, velocityY);

            rb.velocity = dir;

            if (col.transform.position.x < 0)
            {
                motor.racket1.special += 1;
                if (motor.racket1.special == 3)
                {
                    motor.ChangeImage(motor.racket1.transform.position.x);
                }
                if (motor.racket1.specialActivated)
                {
                    if (motor.racket1.character == "Raptor")
                    {
                        movesSpecial = true;
                        transparent  = true;
                        motor.racket1.specialActivated = false;
                    }
                    else if (motor.racket1.character == "Sonata")
                    {
                        movesSpecial = true;
                        wiggles      = true;
                        motor.racket1.specialActivated = false;
                    }
                    else if (motor.racket1.character == "Candyman")
                    {
                        movesSpecial     = true;
                        goesThroughWalls = true;
                        motor.racket1.specialActivated = false;
                    }
                }
            }
            else if (col.transform.position.x > 0)
            {
                if (Application.loadedLevel == 1)
                {
                    motor.ai.special += 1;
                    if (motor.ai.special == 3)
                    {
                        motor.ChangeImage(motor.ai.transform.position.x);
                    }
                    if (motor.ai.specialActivated)
                    {
                        if (motor.ai.character == "Raptor")
                        {
                            movesSpecial = true;
                            transparent  = true;
                            motor.ai.specialActivated = false;
                        }
                        else if (motor.ai.character == "Sonata")
                        {
                            movesSpecial = true;
                            wiggles      = true;
                            motor.ai.specialActivated = false;
                        }
                        else if (motor.ai.character == "Candyman")
                        {
                            movesSpecial              = true;
                            goesThroughWalls          = true;
                            motor.ai.specialActivated = false;
                        }
                    }
                }
                else
                {
                    motor.racket2.special += 1;
                    if (motor.racket2.special == 3)
                    {
                        motor.ChangeImage(motor.racket2.transform.position.x);
                    }
                    if (motor.racket2.specialActivated)
                    {
                        if (motor.racket2.character == "Raptor")
                        {
                            movesSpecial = true;
                            transparent  = true;
                            motor.racket2.specialActivated = false;
                        }
                        else if (motor.racket2.character == "Sonata")
                        {
                            movesSpecial = true;
                            wiggles      = true;
                            motor.racket2.specialActivated = false;
                        }
                        else if (motor.racket2.character == "Candyman")
                        {
                            movesSpecial     = true;
                            goesThroughWalls = true;
                            motor.racket2.specialActivated = false;
                        }
                    }
                }
            }
        }
    }