示例#1
0
    public override void ShowCorrection()
    {
        Transform sol = transform.Find("Solutions");

        SolutionGroupes[] solutions = sol.GetComponents <SolutionGroupes>();
        Groupe[]          grs       = transform.GetComponents <Groupe>();

        foreach (Groupe g in grs)
        {
            bool groupeOk = false;

            foreach (SolutionGroupes s in solutions)
            {
                if (s.TestGroupes(g) == 1)
                {
                    groupeOk = true;
                    break;
                }
            }

            if (groupeOk)
            {
                g.SetGood();
            }
            else
            {
                g.SetWrong();
            }
        }

        foreach (SolutionGroupes s in solutions)
        {
            bool solOk = false;
            foreach (Groupe g in grs)
            {
                if (s.TestGroupes(g) == 1)
                {
                    solOk = true;
                    break;
                }
            }

            if (!solOk)
            {
                Groupe gr = gameObject.AddComponent <Groupe>();
                gr.correction = true;
                gr.width      = 0.35f;
                gr.elements   = s.elements;
                gr.groupName  = s.GroupName;
                gr.color      = s.GroupName.GetComponent <Image>().color;
                gr.DrawGroupe();
            }
        }
    }
示例#2
0
    public void NameGroup(GameObject btn)
    {
        int selectedCount = 0;

        foreach (GameObject go in accepteurs)
        {
            if (go.GetComponent <ElementManager>().isSelected)
            {
                selectedCount++;
            }
        }

        if (selectedCount < 1)
        {
            return;
        }
        GameObject[] listElements = new GameObject[selectedCount];

        selectedCount = 0;
        foreach (GameObject go in accepteurs)
        {
            if (go.GetComponent <ElementManager>().isSelected)
            {
                listElements[selectedCount++] = go;
            }
        }


        Groupe gr = gameObject.AddComponent <Groupe>();

        gr.elements  = listElements;
        gr.groupName = btn;
        gr.color     = btn.GetComponent <Image>().color;
        gr.DrawGroupe();

        foreach (GameObject go in listElements)
        {
            go.GetComponent <ElementManager>().ReactWith(btn);
            go.GetComponent <ElementManager>().unSelectElement();
        }
    }