Beispiel #1
0
    void ShowSpellEffects()
    {
        Debug.Log(spell.transform.childCount);
        for (int i = 0; i < spell.transform.childCount; i++)
        {
            var effect = spell.transform.GetChild(i).GetComponent <SpellEffect>();
            Debug.Log(effect.spellType);
            Debug.Log("teeest " + (effect.spellType == SpellEffect.SpellType.DAMAGEEFFECT));

            if (effect.spellType == SpellEffect.SpellType.DAMAGEEFFECT)
            {
                effect.test();
                EditorGUILayout.LabelField("Damage On hit");
                var tmp = effect as DamageEffect;
                Debug.Log(tmp == null);
                Debug.Log(effect.GetType());
                var damage = tmp.SpellEditorDamage;
                damage = EditorGUILayout.IntField("Damage", damage);
                if (damage != tmp.SpellEditorDamage)
                {
                    tmp.SetDamageEffect(damage);
                }
            }

            if (effect.spellType == SpellEffect.SpellType.DAMAGEOVERTIME)
            {
                EditorGUILayout.LabelField("Damage Over Time");
                DamageOverTime tmp    = effect as DamageOverTime;
                int            damage = tmp.SpellEditorDamage;
                int            turn   = tmp.SpellEditorTurns;
                damage = EditorGUILayout.IntField("Damage", damage);
                turn   = EditorGUILayout.IntField("Turn", turn);
                if (damage != tmp.SpellEditorDamage || turn != tmp.SpellEditorTurns)
                {
                    tmp.SetDamageOverTime(damage, turn);
                }
            }

            if (effect.spellType == SpellEffect.SpellType.HEAL)
            {
                EditorGUILayout.LabelField("Heal On hit");
                HealEffect tmp  = effect as HealEffect;
                int        heal = tmp.SpellEditorHeal;
                heal = EditorGUILayout.IntField("Heal", heal);
                if (heal != tmp.SpellEditorHeal)
                {
                    tmp.SetHealEffect(heal);
                }
            }

            if (effect.spellType == SpellEffect.SpellType.HEALOVERTIME)
            {
                EditorGUILayout.LabelField("Heal Over Time");
                HealOverTime tmp  = effect as HealOverTime;
                int          heal = tmp.SpellEditorHeal;
                int          turn = tmp.SpellEditorTurns;
                heal = EditorGUILayout.IntField("Heal", heal);
                turn = EditorGUILayout.IntField("Turn", turn);
                if (heal != tmp.SpellEditorHeal || turn != tmp.SpellEditorTurns)
                {
                    tmp.SetHealOverTime(heal, turn);
                }
            }

            if (effect.spellType == SpellEffect.SpellType.BUFFEFFECT)
            {
                EditorGUILayout.LabelField("Buff Effect");
                BuffEffect tmp    = effect as BuffEffect;
                int        index  = tmp.SpellEditorIndex;
                int        amount = tmp.SpellEditorAmount;
                int        turn   = tmp.SpellEditorTurn;
                index  = EditorGUILayout.Popup("Choose a stat", index, tmp.stats);
                amount = EditorGUILayout.IntField("Amount", amount);
                turn   = EditorGUILayout.IntField("Turn", turn);
                if (index != tmp.SpellEditorIndex || amount != tmp.SpellEditorAmount || turn != tmp.SpellEditorTurn)
                {
                    tmp.SetBuffEffect(index, amount, turn);
                }
            }

            if (GUILayout.Button("Remove Effect"))
            {
                DestroyImmediate(spell.transform.GetChild(i).gameObject);
            }
        }
    }