Пример #1
0
    float GetFinalAngle(LineSwitchAngle entryAngle, LineSwitchAngle currentAngle)
    {
        float finalAngle = (float)entryAngle - (float)currentAngle;

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

        return(finalAngle);
    }
Пример #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();
            }
        }
    }
Пример #3
0
 // Use this for initialization
 void Start()
 {
     currentAngle      = startingAngle;
     currentAngleIndex = switchOrder.IndexOf(currentAngle);
     UpdateAngle();
 }
Пример #4
0
 void SwitchAngle()
 {
     currentAngleIndex = (currentAngleIndex + 1) % switchOrder.Count;
     currentAngle      = switchOrder[currentAngleIndex];
     UpdateAngle();
 }