예제 #1
0
 void InGameDrawHnadler(object sender, EventArgs args)
 {
     if (Input.GetMouseButtonDown(0))
     {
         lines.Add(Instantiate <GameObject>(linesample.gameObject).GetComponent <LineRenderer>());
         currentPointsToRecognize.Clear();
         currentPointsToRecognize.Add(new Point(Input.mousePosition.x, -Input.mousePosition.y, 0));
         linesPositions.Add(new List <Vector3>());
         currentPositions = linesPositions[linesPositions.Count - 1];
         currentPositions.Add(Camera.main.ScreenToWorldPoint(Input.mousePosition));
     }
     else if (Input.GetMouseButtonUp(0))
     {
         if (currentPointsToRecognize.Count > 1)
         {
             PDollarGestureRecognizer.Result result = PDollarGestureRecognizer.PointCloudRecognizer.Classify(new Gesture(currentPointsToRecognize.ToArray(), ""), gestureLibrary.ToArray());
             if (result.Score >= passCoef && result.GestureClass == patternToRecognize)
             {
                 scoreLabel.text = (++score).ToString();
                 totalDevider   *= timeDevider;
                 ShowRandomPattern(null, null);
             }
             //stats.text = result.GestureClass + " " + result.Score;
         }
         currentPointsToRecognize.Clear();
     }
     else if (Input.GetMouseButton(0) && Vector2.Distance(new Vector2(currentPointsToRecognize[currentPointsToRecognize.Count - 1].X, -currentPointsToRecognize[currentPointsToRecognize.Count - 1].Y), Input.mousePosition) >= 2)
     {
         currentPositions.Add(Camera.main.ScreenToWorldPoint(Input.mousePosition));
         currentPositions[currentPositions.Count - 1] = new Vector3(currentPositions[currentPositions.Count - 1].x, currentPositions[currentPositions.Count - 1].y, 1f);
         lines[lines.Count - 1].SetVertexCount(linesPositions[linesPositions.Count - 1].Count);
         lines[lines.Count - 1].SetPositions(linesPositions[linesPositions.Count - 1].ToArray());
         currentPointsToRecognize.Add(new Point(Input.mousePosition.x, -Input.mousePosition.y, 0));
     }
 }
예제 #2
0
 public void ParseGestureChoice(PDollarGestureRecognizer.Result gestureResult)
 {
     if (waitingForChoice)
     {
         for (int i = 0; i < inkStory.currentChoices.Count; i++)
         {
             if (gestureResult.GestureClass.ToLower() == inkStory.currentChoices[i].text.ToLower() && gestureResult.Score > gestureScoreThreshold)
             {
                 ChooseChoice(i);
                 return;
             }
         }
         // did not find any choice, picks last as default
         ChooseChoice(inkStory.currentChoices.Count - 1);
     }
 }
예제 #3
0
    void onRecognizeShape(PDollarGestureRecognizer.Result gestureData)
    {
        if (array_images != null && array_images.Count > 0)
        {
            if (array_images[0] != null)
            {
                if (gestureData.GestureClass == array_images[0].name)
                {
                    score_script.sum_score(2);
                    effets.startHitMagicIn(transform.position, index_images[0]);
                    Image imageGesture = array_images[0];
                    array_images.Remove(imageGesture);
                    index_images.RemoveAt(0);
                    Destroy(imageGesture.gameObject);
                    orderImageGestures();
                    //reordenar imagenes gestures

                    if (array_images.Count == 0)
                    {
                        currentState       = State.Dead;
                        pathfinder.enabled = false;
                        animator_controller.SetTrigger("is_dead");
                        manager.onShapeRecognition -= onRecognizeShape;
                        //FindObjectOfType<MapGeneratorFM> ().maps [0].seed = (int)Random.Range(0,20);
                        //FindObjectOfType<MapGeneratorFM> ().GenerateMap ();
                        if (OnDeath != null)
                        {
                            OnDeath();
                        }
                        Destroy(this.gameObject, 3);
                    }
                    else
                    {
                        animator_controller.SetTrigger("hit");
                    }
                }
            }
        }
    }