Exemplo n.º 1
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        //Debug.Log("Mouse enter " + name);
        MainPanel.instance.hoverDetails.SetDetails(course);
        MainPanel.instance.hoverDetails.gameObject.SetActive(true);

        if (equivalent.Count == 0)
        {
            foreach (UILineRenderer line in backEdge)
            {
                line.color = DegreeTree.instance.lineHighlight;
            }
        }
        else
        {
            OneOfNode on = transform.parent.GetComponent <OneOfNode>();
            if (on != null)
            {
                foreach (UILineRenderer line in on.backEdge)
                {
                    line.color = DegreeTree.instance.lineHighlight;
                }
            }
        }
    }
Exemplo n.º 2
0
    public void OnPointerExit(PointerEventData eventData)
    {
        //Debug.Log("Mouse exit " + name);
        //StartCoroutine(DelayedDisable());

        if (equivalent.Count == 0)
        {
            foreach (UILineRenderer line in backEdge)
            {
                line.color = DegreeTree.instance.lineColour;
            }
        }
        else
        {
            OneOfNode on = transform.parent.GetComponent <OneOfNode>();
            if (on != null)
            {
                foreach (UILineRenderer line in on.backEdge)
                {
                    line.color = DegreeTree.instance.lineColour;
                }
            }
        }
    }
Exemplo n.º 3
0
    public void ProcessOneOfs(List <Prereq> oneOfs)
    {
        foreach (Prereq o in oneOfs)
        {
            OneOfNode oNode = Instantiate(oneOfPrefab);

            List <CourseNode> prereqNodes = new List <CourseNode>();

            int        colID = 0;
            List <int> rowID = new List <int>();
            foreach (Course c in o.equivalent)
            {
                currentCourses.Add(c);
                oNode.AddCourse(c);

                /*int pId = ResolvePrereqs(c);
                 * if (pId + 1 > colID)
                 *  colID = pId + 1;*/

                Vector2Int gridPos = vResolvePrereqs(c);
                //if (gridPos.x >= 0)
                //    AddCourseNode(c, gridPos);

                foreach (CourseNode cn in nodes)
                {
                    foreach (Prereq cp in c.prereqs)
                    {
                        foreach (Course cpc in cp.equivalent)
                        {
                            bool skip = false;
                            foreach (CourseNode checkNode in prereqNodes)
                            {
                                foreach (CourseNode checkEq in checkNode.equivalent)
                                {
                                    if (checkEq.course == cpc)
                                    {
                                        skip = true;
                                        break;
                                    }
                                }
                                if (skip)
                                {
                                    break;
                                }
                            }
                            if (skip)
                            {
                                continue;
                            }

                            if (cpc == cn.course && !prereqNodes.Contains(cn))
                            {
                                if (cn.columnID + 1 > colID)
                                {
                                    colID = cn.columnID + 1;
                                }

                                rowID.Add(cn.rowID);

                                prereqNodes.Add(cn);
                            }
                        }
                    }
                }
            }

            /*
             * if (colID >= columns.Count)
             *  AddColumn(colID - columns.Count + 1);
             *
             * oNode.rect.SetParent(columns[colID].transform, false);
             */

            int row = 0;
            if (rowID.Count > 0)
            {
                int[] rowMode = new int[rowID.Count];
                for (int i = 0; i < rowID.Count; i++)
                {
                    for (int j = 0; j < rowID.Count; j++)
                    {
                        if (rowID[i] == rowID[j])
                        {
                            rowMode[i]++;
                        }
                    }
                }

                row = Mathf.Max(rowMode);
                for (int i = 0; i < rowMode.Length; i++)
                {
                    if (rowMode[i] == row)
                    {
                        row = i;
                    }
                }

                row = rowID[row];
            }

            if (colID == 0)
            {
                //make a new chain
                CourseChain chain = Instantiate(treeRow).AddComponent <CourseChain>();
                chain.head = oNode.courses[0];
                chain.transform.SetParent(content, false);
                chains.Add(chain);

                oNode.rowID = chains.Count - 1;

                GameObject chainLink = Instantiate(treeColumn);
                chainLink.transform.SetParent(chain.transform, false);
                chains[chains.Count - 1].chainLinks.Add(chainLink);

                oNode.transform.SetParent(chains[chains.Count - 1].chainLinks[0].transform, false);
            }
            else
            {
                oNode.rowID = row;

                //parent node to chain[gridPos.y].getchild(gridPos.x)
                while (colID >= chains[row].chainLinks.Count)
                {
                    GameObject chainLink = Instantiate(treeColumn);
                    chainLink.transform.SetParent(chains[row].transform, false);
                    chains[row].chainLinks.Add(chainLink);
                }

                oNode.transform.SetParent(chains[row].chainLinks[colID].transform, false);
                if (chains[row].GetComponent <HorizontalLayoutGroup>())
                {
                    chains[row].GetComponent <HorizontalLayoutGroup>().spacing += oNode.rect.sizeDelta.x;
                }
                else if (chains[row].GetComponent <VerticalLayoutGroup>())
                {
                    chains[row].GetComponent <VerticalLayoutGroup>().spacing += oNode.rect.sizeDelta.x;
                }

                if (chains[row].chainLinks[colID].GetComponent <VerticalLayoutGroup>())
                {
                    chains[row].chainLinks[colID].GetComponent <VerticalLayoutGroup>().spacing += oNode.rect.sizeDelta.y;
                }
                else if (chains[row].chainLinks[colID].GetComponent <HorizontalLayoutGroup>())
                {
                    chains[row].chainLinks[colID].GetComponent <HorizontalLayoutGroup>().spacing += oNode.rect.sizeDelta.y;
                }
            }

            oNode.columnID = colID;

            foreach (CourseNode cn in oNode.courses)
            {
                nodes.Add(cn);

                foreach (CourseNode ocn in oNode.courses)
                {
                    if (ocn != cn)
                    {
                        ocn.equivalent.Add(cn);
                    }
                }
            }

            foreach (CourseNode cn in prereqNodes)
            {
                if (cn.equivalent.Count > 0)
                {
                    oNode.backEdge.Add(DrawLine(oNode.rect, cn.rect.parent.GetComponent <RectTransform>()));
                }
                else
                {
                    oNode.backEdge.Add(DrawLine(oNode.rect, cn.rect));
                }
            }

            //columns[colID].GetComponent<VerticalLayoutGroup>().spacing += 32 * o.equivalent.Count;
        }
    }