//Add a nice slow slide-down effect, if game is won shoot the rings up
    void OnTriggerStay2D(Collider2D collision)
    {
        collision.GetComponentInParent <RingScript>().SetMaxVelocity(15);

        if (ruleManager.GameWon())
        {
            collision.gameObject.GetComponentInParent <Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
            collision.gameObject.GetComponentInParent <Rigidbody2D>().AddForce(RandomUpwardsDirection() * ringEjectForce);
        }
    }
Beispiel #2
0
 //Freeze the Y position of the ring when it is placed on a pin, this is to avoid the player being able to nudge other rings off the pin with the held ring, do not freeze if the game is won
 private void FreezeYPosition()
 {
     if (rigidbody.constraints != RigidbodyConstraints2D.FreezePositionY && !ruleManager.AllRingsPlaced(ringSize) && rigidbody.velocity == Vector2.zero && !ruleManager.GameWon())
     {
         rigidbody.constraints = RigidbodyConstraints2D.FreezePositionY;
     }
 }