Beispiel #1
0
    public void ChangeLolFunction(LoLFunction newLolFunction)
    {
        if (!newLolFunction.isDumbGraphFunction)
        {
            uiLinks.questionText.text    = newLolFunction.ToString();
            uiLinks.sampleInputText.text = GV.OutputSampleInput(newLolFunction.inputVars);
            uiLinks.graphFunctionObject.SetActive(false);
            uiLinks.questionText.gameObject.SetActive(true);
        }
        else
        {
            //uiLinks.questionText.text = newLolFunction.ToString();
            uiLinks.sampleInputText.text = GV.OutputSampleInput(newLolFunction.inputVars);
            uiLinks.graphFunctionObject.SetActive(true);
            uiLinks.questionText.gameObject.SetActive(false);

            float slope = newLolFunction.coefficents[0];
            if (newLolFunction.isGraphCoefficientInverse)
            {
                slope = 1f / slope;
            }
            int offset = newLolFunction.coefficents[3];
            //int output = newLolFunction.Solve();

            int scale = 1;
            //while (output > (scale * 8))
            //    scale *= 2;

            for (int i = 0; i < 5; i++)
            {
                uiLinks.graphTextX[i].text = uiLinks.graphTextY[i].text = (i * scale * 2).ToString();
            }

            float curveOffset = 0.1111f * offset / scale;
            uiLinks.graphCurve.anchorMin = new Vector2(uiLinks.graphCurve.anchorMin.x, curveOffset);
            uiLinks.graphCurve.anchorMax = new Vector2(uiLinks.graphCurve.anchorMax.x, curveOffset);

            float curveAngle = Mathf.Atan(slope * graphAspect) * 180f / Mathf.PI;
            uiLinks.graphCurve.localEulerAngles = new Vector3(uiLinks.graphCurve.localEulerAngles.x, uiLinks.graphCurve.localEulerAngles.y, curveAngle);
        }
    }
Beispiel #2
0
 public string DebugOutput()
 {
     //return inputVars[0]*coefficents[0] + inputVars[1] * coefficents[1] + inputVars[2] * coefficents[2] + coefficents[3];
     return(string.Format("Level{0}, Function:{1}, Inputs:{2}, Ans:{3}", currentLevel, ToString(), GV.OutputSampleInput(inputVars), Solve()));
 }