Пример #1
0
    protected override void handleGesture()
    {
        List <Tuple <double, Gesture> > similarGestures = new List <Tuple <double, Gesture> >();

        foreach (Gesture recognizableGesture in m_RecognizableSpells)
        {
            if (RecordedGesture.IsSimilarTo(recognizableGesture, Gesture.eAccuracyLevel.Position))
            {
                similarGestures.Add(new Tuple <double, Gesture>(RecordedGesture.SimilarityScoreAgainst(recognizableGesture, Gesture.eAccuracyLevel.Position), recognizableGesture));

                Debug.Log(recognizableGesture.name + " " + RecordedGesture.SimilarityScoreAgainst(recognizableGesture, Gesture.eAccuracyLevel.Position));
            }
        }
        Debug.Log("");


        Gesture bestMatch = similarGestures.OrderBy(gestureScore => gestureScore.Item1)
                            .FirstOrDefault()?
                            .Item2;

        if (bestMatch != null)
        {
            bestMatch.RepresentedSpell.Cast(this);

            if (bestMatch.RepresentedSpell is ElementSelectionSpell)
            {
                CurrentElement = bestMatch.RepresentedSpell as ElementSelectionSpell;
            }
            else if (bestMatch.RepresentedSpell is FormSelectionSpell)
            {
                CombineSpells(CurrentElement, bestMatch.RepresentedSpell as FormSelectionSpell);
            }
        }
    }
Пример #2
0
    public Spell GetSpell(ElementSelectionSpell i_Element, FormSelectionSpell i_SpellToCombine)
    {
        foreach (SpellCombo combo in Spells)
        {
            if (combo.ElementSpell == i_Element && combo.FormSpell == i_SpellToCombine)
            {
                return(combo.ResultSpell);
            }
        }

        return(null);
    }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        ElementSelectionSpell damagingSpellElement = other.GetComponent <DamagingSpell>()?.Element;

        if (damagingSpellElement)
        {
            if (m_ElementalWeaknessChart.CheckWeakness(m_Element, damagingSpellElement))
            {
                m_Animator.SetTrigger("Death");
            }

            Destroy(other.gameObject);
        }
    }
Пример #4
0
    /// <summary>
    /// If any elements are found in the project that aren't already part of the table as attackers, we'll automatically add them.
    /// </summary>
    private void initAttackers()
    {
        foreach (string elementAssetGuid in AssetDatabase.FindAssets("t:ElementSelectionSpell"))
        {
            ElementSelectionSpell element = AssetDatabase.LoadAssetAtPath <ElementSelectionSpell>(AssetDatabase.GUIDToAssetPath(elementAssetGuid));

            if (!m_TargetChart.ElementalWeaknesses.ContainsKey(element))
            {
                Undo.RecordObject(m_TargetChart, "Added Attacking Element");
                m_TargetChart.ElementalWeaknesses.Add(element, new ElementList());
            }

            m_IsDataExpanded.Add(element, false);
        }
    }
Пример #5
0
    private void drawAttackedElementsFor(ElementSelectionSpell attackingElement)
    {
        SerializedProperty weaknessToListProperty    = m_TargetChart.GetWeaknessesToSerializedProperty(attackingElement);
        SerializedProperty strongAgainstListProperty = m_TargetChart.GetStrongAgainstSerializedProperty(attackingElement);

        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
        {
            EditorGUI.indentLevel++;

            //Draws the list of elements weak to this attacking type.
            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.PropertyField(weaknessToListProperty,
                                              new GUIContent($"Elements Weak to {attackingElement.ElementName}"),
                                              includeChildren: true);
            }
            //Since the list we're working on is the serialization assistant list (Since dictionaries can't be serialized or draw in inspector)
            //If the list was changed, we need to deliver the changes back to the dictionary.
            if (EditorGUI.EndChangeCheck())
            {
                weaknessToListProperty.serializedObject.ApplyModifiedProperties();
            }

            //Draws the list of elements strong against this element type.
            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.PropertyField(strongAgainstListProperty,
                                              new GUIContent($"Elements Strong Against {attackingElement.ElementName}"),
                                              includeChildren: true);
            }
            //Since the list we're working on is the serialization assistant list (Since dictionaries can't be serialized or draw in inspector)
            //If the list was changed, we need to deliver the changes back to the dictionary.
            if (EditorGUI.EndChangeCheck())
            {
                //Since the list we use as a serialization assistant is the one detailing elements weak to the given element, and not strong against it, we need to reconstruct that list before serialization.
                m_TargetChart.ApplyChangesFromStrongAgainstList(strongAgainstListProperty);
            }

            EditorGUILayout.Space();
            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndVertical();
    }
Пример #6
0
    private static SerializedProperty getInnerElementListName(this ElementalWeaknessChart i_WeaknessChart, ElementSelectionSpell i_AttackingElement, string i_ListFieldName)
    {
        SerializedObject   serializedChart           = new SerializedObject(i_WeaknessChart);
        SerializedProperty targetElementListProperty = null;

        //This fetches the serialization assistant objects that holds a list elements and a list of ElementList,
        //Each ElementList represents the elements that are weak to the element in the corresponding index of the first list.
        SerializedProperty elementWeaknessKeys   = serializedChart.FindProperty("m_ElementalWeaknessKeys");
        SerializedProperty elementWeaknessValues = serializedChart.FindProperty(i_ListFieldName);

        //Out of these list, we need to find the element that matches the attacking element, and return the ElementList corresponding to the same index in the other list.
        for (int i = 0; i < elementWeaknessKeys.arraySize; ++i)
        {
            ElementSelectionSpell elementAtIndex = elementWeaknessKeys.GetArrayElementAtIndex(i).objectReferenceValue as ElementSelectionSpell;

            if (elementAtIndex.Equals(i_AttackingElement))
            {
                targetElementListProperty = elementWeaknessValues.GetArrayElementAtIndex(i)?.FindPropertyRelative("Elements");
                break;
            }
        }

        return(targetElementListProperty);
    }
Пример #7
0
 public bool CheckWeakness(ElementSelectionSpell i_AttackedElement, ElementSelectionSpell i_AttackingElement)
 {
     return(GetWeaknessesTo(i_AttackedElement).Contains(i_AttackingElement));
 }
Пример #8
0
 public ElementList GetWeaknessesTo(ElementSelectionSpell i_Element)
 {
     return(ElementalWeaknesses.ContainsKey(i_Element) ? ElementalWeaknesses[i_Element] : new ElementList());
 }
Пример #9
0
 public void CombineSpells(ElementSelectionSpell i_Element, FormSelectionSpell i_SpellToCombine)
 {
     m_Spellbook.GetSpell(i_Element, i_SpellToCombine)?.Cast(this);
 }
Пример #10
0
 /// <summary>
 /// Gets the SerializedProperty of the ElementList representing the types that are weak to i_AttackingElement.
 /// </summary>
 public static SerializedProperty GetWeaknessesToSerializedProperty(this ElementalWeaknessChart i_WeaknessChart, ElementSelectionSpell i_AttackingElement)
 {
     return(i_WeaknessChart.getInnerElementListName(i_AttackingElement, i_ListFieldName: "m_ElementsWeakToIndexValues"));
 }
Пример #11
0
 public bool Contains(ElementSelectionSpell i_Element) => Elements.Contains(i_Element);
Пример #12
0
 public override void Cast(SpellWeaver i_Caster)
 {
     SpellElement = i_Caster.CurrentElement;
 }