Пример #1
0
    void Start()
    {
        init();
        GameObject           cS = Instantiate(constellationSpawner);
        ConstellationManager cM = cS.GetComponent <ConstellationManager>();

        NodeInfo mov;

        mov.type      = NodeType.custom;
        mov.name      = "Instructions";
        mov.details   = "Mix and the genres to apply filters! Once you have selected the genres you wish to have simply place the new node in the world. From there take other nodes and spawn further nodes!";
        mov.genreType = GenreType.None;
        cM.init(mov);

        foreach (KeyValuePair <GenreType, NodeInfo> t in genreTypeNodes)
        {
            if (t.Key == GenreType.None)
            {
                continue;
            }
            cM.addNode(t.Value);
        }
    }
Пример #2
0
    /* Spawns a constellation using the nodes currently selected */
    private void spawnConstellation()
    {
        if (selection.Count <= 0)
        {
            return;
        }

        Vector3         tColor = Vector3.zero;
        List <NodeInfo> info   = new List <NodeInfo>();
        NodeInfo        n;
        GameObject      theFab = customNodeFab;

        n.name      = "";
        n.details   = "";
        n.type      = NodeType.custom;
        n.genreType = GenreType.None;
        bool noSkip = true;

        // Special case for movies
        if (selection.Count == 1)
        {
            foreach (GameObject nObject in selection.Values)
            {
                if (nObject.GetComponent <NormalNode>().getType() == NodeType.movie)
                {
                    info = dataContainer.fromMovie(nObject.GetComponent <NormalNode>().getInfo().name);
                    n    = info[0];
                    info.RemoveAt(0);
                    noSkip = false;
                    theFab = movieNodeFab;
                    Color tempColor = nObject.GetComponent <Renderer>().material.color;
                    tColor = new Vector3(tempColor.r, tempColor.g, tempColor.b);
                    nObject.GetComponent <NormalNode>().remove();
                }
            }
        }

        // If no movies see if all the objects are a genre
        if (noSkip)
        {
            bool             isGenre = true;
            List <GenreType> gens    = new List <GenreType>();
            foreach (GameObject nObject in selection.Values)
            {
                if (nObject.GetComponent <NormalNode>().getType() != NodeType.genre)
                {
                    isGenre = false;
                }
                else
                {
                    gens.Add(nObject.GetComponent <NormalNode>().getInfo().genreType);
                }
            }

            n.name    = "Custom Node";
            n.details = "Filters: ";

            // Add in the custom node text
            foreach (GameObject o in selection.Values)
            {
                NormalNode nN = o.GetComponent <NormalNode>();
                n.details += nN.getInfo().name + ", ";
                info.Add(nN.getInfo());
                Color c = nN.getColor();
                tColor += new Vector3(c.r, c.g, c.b);
                nN.remove();
            }
            tColor /= info.Count;
            // If it's a genre load the relevent movies
            if (isGenre)
            {
                info = dataContainer.fromGenres(gens);
            }
        }
        selection.Clear();

        GameObject constellation = Instantiate(ConstellationSpawner);

        constellation.transform.position = controllerPose.transform.position;
        ConstellationManager cM = constellation.GetComponent <ConstellationManager>();

        cM.init(n, theFab, 0.50f);
        cM.mainNode.setColor(new Color(tColor.x, tColor.y, tColor.z));

        // Spawn the nodes
        foreach (NodeInfo i in info)
        {
            NormalNode nN = cM.addNode(i);
            if (nN.getType() == NodeType.movie)
            {
                nN.setColor(new Color(Random.value, Random.value, Random.value));
            }
        }
        cM.mainNode.setColor(new Color(tColor.x, tColor.y, tColor.z));
    }