Exemple #1
0
    float GetFinalAngle(LineSwitchAngle entryAngle, LineSwitchAngle currentAngle)
    {
        float finalAngle = (float)entryAngle - (float)currentAngle;

        if (finalAngle < 0)
        {
            finalAngle = 360 + finalAngle;
        }

        return(finalAngle);
    }
Exemple #2
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        Ball ball = collision.gameObject.GetComponent <Ball>();

        if (ball != null)
        {
            locked = true;
            float           ballAngle  = (float)ball.GetAngle();
            LineSwitchAngle entryAngle = entryAngles[ballAngle];
            float           finalAngle = GetFinalAngle(entryAngle, currentAngle);

            // the ball didn't enter from the right direction
            if (!passageRules[finalAngle])
            {
                ball.Hit();
            }
        }
    }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     currentAngle      = startingAngle;
     currentAngleIndex = switchOrder.IndexOf(currentAngle);
     UpdateAngle();
 }
Exemple #4
0
 void SwitchAngle()
 {
     currentAngleIndex = (currentAngleIndex + 1) % switchOrder.Count;
     currentAngle      = switchOrder[currentAngleIndex];
     UpdateAngle();
 }