Ejemplo n.º 1
0
    //function called when a saying is clicked
    public static void SetSelected(bool isKey, ClickableSaying cs)
    {
        //do nothing if cs allready selected
        if (selectedKey == cs)
        {
            return;
        }
        else if (selectedValue == cs)
        {
            return;
        }

        //sets a given key saying
        if (isKey)
        {
            SetKeySaying(cs);
        }
        //sets a given value saying
        else
        {
            SetValueSaying(cs);
        }

        //if both a key and value is selcted, a line has been drawn
        //therefore, they are now unselected, so a new line can be drawn
        if (selectedValue != null && selectedKey != null)
        {
            selectedValue.ii.Activate();
            selectedKey.ii.Activate();
            instance.ConnectTwoSayings(selectedKey.saying, selectedValue.saying);
            selectedKey   = null;
            selectedValue = null;
        }
    }
Ejemplo n.º 2
0
 //destroys gameobjects not needed after scene, and resets static variables
 static void TearDownScene()
 {
     instance.teardown = true;
     foreach (string k in lines.Keys)
     {
         Line       l  = lines[k];
         GameObject go = l.lineObject;
         Destroy(go);
     }
     lines         = null;
     selectedKey   = null;
     selectedValue = null;
     colorIndex    = 0;
     instance      = null;
 }
Ejemplo n.º 3
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();
    }
Ejemplo n.º 4
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();
    }