public SpellNode AddNode(MagicCircleType type, Transform parent = null)
    {
        if (parent == null)
        {
            parent = transform;
        }
        SpellNode  node;
        GameObject obj = (GameObject)Instantiate(MagicList.defaultSpellNode, parent);

        obj.name = type.ToString() + " Magic Circle";
        switch (type)
        {
        case MagicCircleType.Element:
        {
            node = obj.AddComponent <ElementMagicCircle>();
            break;
        }

        case MagicCircleType.Form:
        {
            node = obj.AddComponent <FormMagicCircle>();
            break;
        }

        case MagicCircleType.Movement:
        {
            node = obj.AddComponent <MovementMagicCircle>();
            break;
        }

        case MagicCircleType.Input:
        {
            node = obj.AddComponent <UserInputNode>();
            break;
        }

        case MagicCircleType.Logic:
        {
            node = obj.AddComponent <LogicNode>();
            break;
        }

        case MagicCircleType.Math:
        {
            Debug.LogWarning("The Math Type doesn't exist yet");
            return(null);

            break;
        }

        default:
        {
            Debug.LogWarning("This type doesn't exist yet");
            return(null);
        }
        }

        AddNode(node);
        return(node);
    }
Beispiel #2
0
    public void OnCreateMC()
    {
        if (spell == null)
        {
            CreateSpell();
        }
        if (rootMagicCircle == null || !rootMagicCircle.Contains((int)mcType))
        {
            if (mcType == MagicCircleType.None)
            {
                rootMagicCircle = null;
            }
            OnEmissionRateChanged(value1Slider.value);
            Transform pos = rootMagicCircle == null ? defaultMagicCircle.transform : rootMagicCircle.transform;
            // GameObject newObj = Instantiate( defaultMagicCircle, pos ) as GameObject;
            // newObj.name = mcType.ToString() + " Magic Circle";
            SpellNode newNode = spell.AddNode(mcType);
            newNode.name = mcType.ToString() + " Magic Circle";
            MagicCircle newMc;
            switch (mcType)
            {
            case MagicCircleType.Element:
                ElementMagicCircle tempMC = newNode as ElementMagicCircle;
                // tempMC.SetMcType( mcType );
                tempMC.SetElement((ElementType)subType);
                tempMC.emissionRate.SetDefaultValue(emissionRate);
                newMc = tempMC as MagicCircle;
                break;

            case MagicCircleType.Form:
                FormMagicCircle tempFormMC = newNode as FormMagicCircle;
                // tempMC.SetMcType( mcType );
                // tempMC.SetElement( (ElementType) subType );
                tempFormMC.SetForm((FormType)subType);
                tempFormMC.sizeMultiplier.SetDefaultValue(sizeMultiplier);
                newMc = tempFormMC as MagicCircle;
                break;

            case MagicCircleType.Movement:
                MovementMagicCircle tempMovementMC = newNode as MovementMagicCircle;
                // tempMC.SetMcType( mcType );
                // tempMC.SetElement( (ElementType) subType );
                tempMovementMC.SetMovement((MovementType)subType);
                tempMovementMC.force.SetDefaultValue(force);
                newMc = tempMovementMC as MagicCircle;
                break;

            default:
                newMc = newNode as MagicCircle;
                newMc.SetMcType(mcType);
                break;
            }
            if (rootMagicCircle == null)
            {
                rootMagicCircle = newMc;
            }
            else
            {
                // rootMagicCircle.AddMagicCircle( newMc );
            }
            selectedMagicCircle = newMc;
        }
    }