Example #1
0
    //sets a key saying, called from SetSaying
    private static void SetKeySaying(ClickableSaying cs)
    {
        //gets the line connected to a saying
        Line l = lines[cs.saying];

        //if a clicked key saying is allready in a drawn line, it is now unselected for drawing
        if (l.lineTo != null && selectedValue == null)
        {
            cs.ii.Activate();
            l.lineTo.GetComponent <ClickableSaying>().ii.Activate();
            l.lineTo         = null;
            lines[cs.saying] = l;
            selectedKey      = null;
            selectedValue    = null;
            instance.DisconnectTwoSayings(cs.saying);
            return;
        }
        //if a clicked key saying is allready in a drawn line, but a value saying is selected, a new line is made between the two
        else if (l.lineTo != null && selectedValue != null)
        {
            instance.DisconnectTwoSayings(cs.saying);
            instance.ConnectTwoSayings(cs.saying, selectedValue.saying);
            l.lineTo         = selectedValue.go;
            lines[cs.saying] = l;
            selectedKey      = null;
            selectedValue.ii.Activate();
            selectedValue = null;
            return;
        }

        //unselects the last chosen saying
        if (selectedKey != null)
        {
            selectedKey.UnselectSaying();
        }
        selectedKey = cs;
        //sets saying as From point in line
        l.lineFrom = cs.go;
        //sets the key saying to connect to the selected value saying
        if (selectedValue != null)
        {
            l.lineTo = selectedValue.go;
        }
        lines[cs.saying] = l;

        cs.ii.Deactivate();
    }
Example #2
0
    //sets a value saying, called from SetSaying
    private static void SetValueSaying(ClickableSaying cs)
    {
        //iterates over lines to see if values saying is in a drawn line
        //if it is, that line will no longer be drawn
        Line checkLine;

        foreach (string k in lines.Keys)
        {
            checkLine = lines[k];
            if (checkLine.lineTo == null)
            {
                continue;
            }
            ClickableSaying valueSaying = checkLine.lineTo.GetComponent <ClickableSaying>();
            ClickableSaying keySaying   = checkLine.lineFrom.GetComponent <ClickableSaying>();
            //if one selects a value saying that is allready connected
            if (valueSaying == cs && selectedKey == null)
            {
                keySaying.ii.Activate();
                cs.ii.Activate();
                checkLine.lineTo        = null;
                lines[keySaying.saying] = checkLine;
                selectedKey             = null;
                selectedValue           = null;
                instance.DisconnectTwoSayings(keySaying.saying);
                return;
            }
            //if one selects a value saying that is connected, while having selected a new key, a new line is drawn between the two
            else if (valueSaying == cs && selectedKey != null)
            {
                keySaying.ii.Activate();
                instance.DisconnectTwoSayings(keySaying.saying);
                instance.ConnectTwoSayings(selectedKey.saying, cs.saying);
                checkLine.lineTo        = null;
                lines[keySaying.saying] = checkLine;
                checkLine                 = lines[selectedKey.saying];
                checkLine.lineTo          = cs.go;
                lines[selectedKey.saying] = checkLine;
                selectedKey.ii.Activate();
                selectedKey   = null;
                selectedValue = null;
                return;
            }
        }

        //if another saying is selected, then it is unselected
        if (selectedValue != null)
        {
            selectedValue.UnselectSaying();
        }

        //if a key is selected, a line is formed
        if (selectedKey != null)
        {
            Line l = lines[selectedKey.saying];
            //sets sayig as lineto value
            l.lineTo = cs.go;
            lines[selectedKey.saying] = l;
        }
        selectedValue = cs;
        cs.ii.Deactivate();
    }