예제 #1
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);
    }
예제 #2
0
    private void OnEnable()
    {
        m_TargetChart = target as ElementalWeaknessChart;

        initAttackers();
    }
예제 #3
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"));
 }