public void CreateClusters()
    {
        positions = new List <List <Vector3> >();

        for (int i = 0; i < Image.numberOfclusters + 1; i++)
        {
            positions.Add(new List <Vector3>());
        }

        for (int i = 0; i < allImages.Length; i++)
        {
            if (allImages[i].cluster != -1)
            {
                positions[allImages[i].cluster].Add(allImages[i].transform.position);
            }
        }
        int clusterTextCounter = 0;

        for (int i = 0; i < positions.Count; i++)
        {
            Vector3 sum = new Vector3();

            for (int k = 0; k < positions[i].Count; k++)
            {
                sum += positions[i][k];
            }
            if (positions[i].Count > 0)
            {
                if (createdClusterTexts.Count - 1 < clusterTextCounter)
                {
                    createdClusterTexts.Add(Instantiate(clusterPrefab));
                }
                sum.y = 0;
                sum.x = sum.x / positions[i].Count;
                sum.z = sum.z / positions[i].Count;
                createdClusterTexts[clusterTextCounter].transform.position = sum;

                ClusterText ct = createdClusterTexts[clusterTextCounter].GetComponent <ClusterText>();

                ct.overs  = "Group " + (clusterTextCounter + 1);
                ct.unders = positions[i].Count + " Image";
                if (positions[i].Count > 1)
                {
                    ct.unders = ct.unders + "s";
                }


                clusterTextCounter++;
            }
        }

        while (clusterTextCounter <= createdClusterTexts.Count - 1)
        {
            GameObject obj = createdClusterTexts[createdClusterTexts.Count - 1];
            createdClusterTexts.Remove(obj);
            Destroy(obj);
        }
    }
Exemplo n.º 2
0
    public void Done()
    {
        if (clusters.createdClusterTexts.Count <= 0)
        {
            buttonText.text = "Make at least 1 group first";
        }
        else if (!isLooking)
        {
            if (currentGroup < clusters.createdClusterTexts.Count)
            {
                overText.gameObject.SetActive(true);
                Mover.SetActive(false);

                buttonText.text = "Click when done looking";


                Vector3 newcampos;
                newcampos   = clusters.createdClusterTexts[currentGroup].transform.position;
                newcampos.y = Camera.main.transform.position.y;

                ClusterText ct = clusters.createdClusterTexts[currentGroup].GetComponent <ClusterText>();

                currentCluster = ct.gameObject;

                overText.text = "Look at the " + ct.unders + " in " + ct.overs;



                ct.gameObject.SetActive(false);

                Camera.main.transform.position = newcampos;

                Camera.main.orthographicSize = 2;

                hideOtherImages();
                isLooking = true;
            }
            else
            {
                overText.text = "Thank you for participating";
                buttonText.transform.parent.gameObject.SetActive(false);
            }
        }
        else
        {
            Camera.main.transform.position = new Vector3(11111, Camera.main.transform.position.y, 1111);
            isLooking = false;
            otherCanvas.SetActive(false);


            datasend.SetActive(true);
        }
    }