Exemple #1
0
        public void onStrokeComplete()
        {
            DrawLine       script = drawLineObj.GetComponent <DrawLine>();
            List <Vector3> points = script.getPointsList();

            this.corners = ShortStraw.getCornerPoints(points);
            script.clearLine();

            if (showMarks)
            {
                markCorners(corners);
            }

            charCorners[curStroke] = corners; // FIXME
            Debug.Log("Stroke Complete!");
            //foreach (Vector3 corner in corners) {
            //    Debug.Log(string.Format("    {0}, {1}, {2}", corner.x, corner.y, corner.z));
            //}

            Recognizer  recognizer = new Recognizer();
            StrokeScore score      = recognizer.getResults(corners, charData.strokes[curStroke]);

            Debug.Log(string.Format("    *** {0} *** angle: {1}, corners: {2}, dist: {3}",
                                    score.Pass ? "Pass" : "Fail", score.Angle, score.Corners, score.Distance));

            // show sprite stroke for the just completed stroke
            if (score.Pass)
            {
                setStrokeSprite(charData.spriteNames[curStroke]);
                curStroke++;
            }

            if (curStroke >= charData.numStrokes)
            {
                // the character is complete, back out of scene
                Debug.Log("Character complete!");
                curStroke--;
            }
            else
            {
                StartCoroutine(displayStrokeHint(curStroke));
            }
        }
Exemple #2
0
    public StrokeScore getResults(List <Vector3> userStroke, List <Vector3> targetStroke, bool hasFlag = false)
    {
        StrokeScore strokeScore = new StrokeScore();

        strokeScore.Angle    = checkAngle(userStroke, targetStroke);
        strokeScore.Corners  = checkCorners(userStroke, targetStroke, hasFlag);
        strokeScore.Distance = checkDistance(userStroke, targetStroke);

        if (strokeScore.Angle < 0 || strokeScore.Corners < 0 || strokeScore.Distance < 0)
        {
            strokeScore.Pass = false;
        }
        else
        {
            strokeScore.Pass = true;
        }

        return(strokeScore);
    }