public virtual bool AddMagicCircle(MagicCircle mc)
 {
     if (innerMagicCircleList.ContainsKey((int)mc.GetMcType()))
     {
         Debug.LogError("This Magic Circle already contains this type.  Can't add new Magic Circle " + mc.mcType);
         return(false);
     }
     else
     {
         mc.mcParent = this;
         innerMagicCircleList.Add((int)mc.GetMcType(), mc);
         UpdateCirclePositions();
         return(true);
     }
 }
    public void AddNode(SpellNode node)
    {
        node.spellParent = this;
        nodes.Add(node);
        MagicCircle mc = (MagicCircle)node.GetComponent <MagicCircle>();

        if (mc != null)
        {
            if (baseNode == null)
            {
                baseNode = mc;
            }
            if (initialMagicCircle == null && mc.GetMcType() == MagicCircleType.Element)
            {
                initialMagicCircle = (ElementMagicCircle)mc;
            }

            if (previousMagicCircle != null && autoLinkTransition)
            {
                MagicCircleTransitionLinks link = (MagicCircleTransitionLinks)AddLink(LinkTypes.Transition);
                link.source      = previousMagicCircle;
                link.destination = mc;
                updateLinksList.Add(link);
            }
            previousMagicCircle = mc;
        }
    }
 public virtual bool RemoveMagicCircle(MagicCircle mc)
 {
     foreach (int currMcType in innerMagicCircleList.Keys)
     {
         Debug.Log("innerMagicCircleList: " + ((MagicCircleType)currMcType).ToString());
     }
     if (innerMagicCircleList.ContainsKey((int)mc.GetMcType()))
     {
         mc.Deactivate();
         mc.RemoveAllMagicCircles();
         innerMagicCircleList.Remove((int)mc.GetMcType());
         Destroy(mc.gameObject);
         UpdateCirclePositions();
         return(true);
     }
     else
     {
         Debug.LogError("This Magic Circle is not on the parent magic circle.  Can't remove it " + mc.mcType);
         return(false);
     }
 }
示例#4
0
    public void UpdateSelectSensitiveDropdowns()
    {
        // Update Linkable Properties Sink
        string[] linkProperties = LinkableFinder.FindAllLinkableProperty(selectedMagicCircle);
        linkablePropertiesSink.options.Clear();
        for (int i = 0; i < linkProperties.Length; i++)
        {
            print("new prop: " + linkProperties[i]);
            linkablePropertiesSink.options.Add(new Dropdown.OptionData(linkProperties[i]));
        }
        linkablePropertiesSink.RefreshShownValue();

        if (selectedMagicCircle != null)
        {
            // Update Main types Dropdown
            mainTypeDropdown.value = (int)selectedMagicCircle.GetMcType();

            // Update sub types Dropdown
            subTypeDropdown.value = selectedMagicCircle.GetSubType();
        }
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // if left click is pressed...
            Vector3    mousePoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Collider2D obj        = Physics2D.OverlapPoint((Vector2)mousePoint);
            if (obj != null)
            {
                MagicCircle mc = obj.GetComponent <MagicCircle>();
                if (mc != null)
                {
                    drag = true;
                }
                if (mc != null && selectedMagicCircle != mc)
                {
                    selectedMagicCircle = mc;
                    if (selectedMagicCircle.GetMcType() == MagicCircleType.None)
                    {
                        rootMagicCircle = selectedMagicCircle;
                    }
                    UpdateSelectSensitiveDropdowns();
                }
            }
        }
        if (Input.GetMouseButtonDown(2))
        {
            if (selectedMagicCircle != null)
            {
                Vector3    mousePoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Collider2D obj        = Physics2D.OverlapPoint((Vector2)mousePoint);
                if (obj != null)
                {
                    MagicCircle mc = obj.GetComponent <MagicCircle>();
                    if (mc != null && selectedMagicCircle != mc)
                    {
                        linkableSourceMagicCircle = mc;
                        print(linkablePropertiesSink.captionText.text);
                        string[] linkableMethods = LinkableFinder.FindPropertiesToLinkTo(linkablePropertiesSink.captionText.text, selectedMagicCircle, linkableSourceMagicCircle);

                        linkablePropertiesSource.options.Clear();
                        for (int i = 0; i < linkableMethods.Length; i++)
                        {
                            linkablePropertiesSource.options.Add(new Dropdown.OptionData(linkableMethods[i]));
                        }
                        linkablePropertiesSource.RefreshShownValue();
                    }
                }
            }
        }
        if (Input.GetMouseButtonUp(1))
        {
            selectedMagicCircle = null;
            linkablePropertiesSink.options.Clear();
            linkablePropertiesSource.options.Clear();
        }
        if (Input.GetMouseButtonUp(0))
        {
            drag = false;
        }
        if (drag)
        {
            Vector3 mousePoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            selectedMagicCircle.transform.position = new Vector3(mousePoint.x, mousePoint.y, selectedMagicCircle.transform.position.z);
        }
    }