Пример #1
0
    //compares current scales and starts countdown if they match
    public void CheckAnswer()
    {
        //game is still ongoing
        if (!gameOver)
        {
            //get total masses of both scales
            int leftMass  = LeftHand.GetTotalMass();
            int rightMass = RightHand.GetTotalMass();

            //save the totals as a string so we can keep track of when it changes
            string massString = leftMass.ToString() + rightMass.ToString();
            //if the strings are the same, the calculation has already started,
            //so we dont need to start it again
            if (currentMassString != massString)
            {
                currentMassString = massString;
                //make sure they're the same and above 0 (so an empty scale doesnt count)
                if (leftMass == rightMass && leftMass + rightMass > 0)
                {
                    coroutineId++;
                    StartCoroutine(_CheckAnswer(currentMassString, coroutineId));
                }
            }
        }
    }