public void SaveLastGesture(SpellHandler.SpellType type, bool twoHanded)
    {
        if (currentGesture == null)
        {
            return;
        }

        currentGesture.SetSpell(type);

        SaveGesture(currentGesture, twoHanded);

        Debug.Log("Saved Gesture for Spell Type: " + type);
    }
Beispiel #2
0
    public Gesture(GestureHand startingHand)
    {
        switch (startingHand)
        {
        case GestureHand.LEFT:
            leftNodes  = new List <Vector3>();
            rightNodes = null;
            break;

        case GestureHand.RIGHT:
            leftNodes  = null;
            rightNodes = new List <Vector3>();
            break;

        case GestureHand.BOTH:
            leftNodes  = new List <Vector3>();
            rightNodes = new List <Vector3>();
            break;
        }

        curHands = startingHand;
        spell    = SpellHandler.SpellType.NONE;
    }
Beispiel #3
0
 public void SetSpell(SpellHandler.SpellType spell)
 {
     this.spell = spell;
 }
 public void Init(int buttonId, SpellHandler.SpellType type, GestureCalibrationMenu gestureCalibrationMenu)
 {
     this.gestureCalibrationMenu = gestureCalibrationMenu;
     this.buttonId = buttonId;
     this.type     = type;
 }
 public void ChangeCalibrationType(SpellHandler.SpellType type)
 {
     calibrationType = type;
 }
    //Returns the index of the best match in validGestures or -1 if none are close enough
    private SpellHandler.SpellType FindBestMatch(Gesture inputGesture)
    {
        SpellHandler.SpellType bestMatch = SpellHandler.SpellType.NONE;
        float matchDiff = 0;

        Gesture.GestureHand hands = inputGesture.GetCurHands();

        if ((hands == Gesture.GestureHand.BOTH && (inputGesture.NumNodes(Gesture.GestureHand.LEFT) == 1 || inputGesture.NumNodes(Gesture.GestureHand.RIGHT) == 1)) ||
            (hands != Gesture.GestureHand.BOTH && inputGesture.NumNodes(hands) == 1))
        {
            return(bestMatch);
        }

        if (hands == Gesture.GestureHand.BOTH)
        {
            Debug.Log("both hands involved");

            //If there's only 1 node just stop
            if (inputGesture.NumNodes(Gesture.GestureHand.LEFT) < 2 || inputGesture.NumNodes(Gesture.GestureHand.RIGHT) < 2)
            {
                return(bestMatch);
            }

            foreach (Gesture g in twoHandGestures)
            {
                float diff = g.AverageDifference(inputGesture, lengthAccuracyFactor, Gesture.GestureHand.LEFT)
                             + g.AverageDifference(inputGesture, lengthAccuracyFactor, Gesture.GestureHand.RIGHT) / 2;

                //Debug.Log("diff = " + diff);

                if ((bestMatch == SpellHandler.SpellType.NONE && diff < accuracyPerSample) || diff < matchDiff)
                {
                    bestMatch = g.GetSpell();
                    matchDiff = diff;
                }
            }
        }
        else
        {
            //If there's only 1 node just stop
            if (inputGesture.NumNodes(hands) < 2)
            {
                return(bestMatch);
            }

            foreach (Gesture g in oneHandGestures)
            {
                float diff = g.AverageDifference(inputGesture, lengthAccuracyFactor, hands);

                //Debug.Log("diff = " + diff);

                if ((bestMatch == SpellHandler.SpellType.NONE && diff < accuracyPerSample) || diff < matchDiff)
                {
                    bestMatch = g.GetSpell();
                    matchDiff = diff;
                }
            }
        }

        return(bestMatch);
    }
Beispiel #7
0
    public override void Awake()
    {
        base.Awake();

        currentGestureType = SpellHandler.SpellType.NONE;
    }
Beispiel #8
0
    public void SetCurrentGesture(SpellHandler.SpellType type)
    {
        //Update the currently shown gesture display
        if (currentDisplay != null)
        {
            Destroy(currentDisplay);
        }

        //Make the pressed button and it's mirror uninteractable and update the element sprite
        switch (type)
        {
        case SpellHandler.SpellType.ONE_QUICK:
            gestureQuickUIButton.interactable = false;
            currentDisplay       = Instantiate(quickDisplay);
            gestureNameText.text = "Quick";
            break;

        case SpellHandler.SpellType.ONE_HEAVY:
            gestureHeavyUIButton.interactable = false;
            currentDisplay       = Instantiate(heavyDisplay);
            gestureNameText.text = "Heavy";
            break;

        case SpellHandler.SpellType.ONE_SPECIAL:
            gestureSpecialUIButton.interactable = false;
            currentDisplay       = Instantiate(specialDisplay);
            gestureNameText.text = "Special";
            break;

        case SpellHandler.SpellType.TWO_OFFENSE:
            gestureOffensiveUIButton.interactable = false;
            currentDisplay       = Instantiate(offensiveDisplay);
            gestureNameText.text = "Offense";
            break;

        case SpellHandler.SpellType.TWO_DEFENSE:
            gestureDefensiveUIButton.interactable = false;
            currentDisplay       = Instantiate(defensiveDisplay);
            gestureNameText.text = "Defense";
            break;
        }

        //Make the previously pressed button interactable again
        switch (currentGestureType)
        {
        case SpellHandler.SpellType.ONE_QUICK:
            gestureQuickUIButton.interactable = true;
            break;

        case SpellHandler.SpellType.ONE_HEAVY:
            gestureHeavyUIButton.interactable = true;
            break;

        case SpellHandler.SpellType.ONE_SPECIAL:
            gestureSpecialUIButton.interactable = true;
            break;

        case SpellHandler.SpellType.TWO_OFFENSE:
            gestureOffensiveUIButton.interactable = true;
            break;

        case SpellHandler.SpellType.TWO_DEFENSE:
            gestureDefensiveUIButton.interactable = true;
            break;
        }

        currentGestureType = type;

        gestureManager.ChangeCalibrationType(type);

        timesToPerform          = maxTimesToPerform;
        timesToPerformText.text = timesToPerform.ToString();
    }