Пример #1
0
    private void createSnippets()
    {
        SnippetHandler    snippetHandler    = new SnippetHandler();
        TagHandler        tagHandler        = new TagHandler(this);
        AssocationHandler assocationHandler = new AssocationHandler();

        Assets.Scripts.DataBase.Snippet[] snippetArr = snippetHandler.GetAllSnippets();

        snippetObjectDict = new Dictionary <int, GameObject>();

        foreach (Assets.Scripts.DataBase.Snippet snippet in snippetArr)
        {
            GameObject instantiatedSnippet = Instantiate(snippetPrefab) as GameObject;
            //instantiatedSnippet.tag = "group" + Random.Range(1, 2); //Temporary hack measure, randomly assign snippet to one of two groups

            SnippetState instSnippetState = instantiatedSnippet.GetComponent <SnippetState>();
            instSnippetState.loadState(tagHandler.GetTagBySnippetId(snippet.Snippet_Id),
                                       snippet,
                                       assocationHandler.GetAssociationViewForSnippet(snippet.Snippet_Id));

            instantiatedSnippet.name = instSnippetState.title;  //names each snippet by its title

            snippetObjectDict.Add(instSnippetState.id, instantiatedSnippet);
        }
    }
Пример #2
0
    public void createBlankSnippet()
    {
        TagHandler        tagHandler        = new TagHandler(this);
        AssocationHandler assocationHandler = new AssocationHandler();

        Snippet blankSnippet = SnippetState.CreateBlankSnippet(1);

        GameObject instantiatedSnippet = Instantiate(snippetPrefab) as GameObject;

        SnippetState instSnippetState = instantiatedSnippet.GetComponent <SnippetState>();

        instSnippetState.loadState(tagHandler.GetTagBySnippetId(blankSnippet.Snippet_Id),
                                   blankSnippet,
                                   assocationHandler.GetAssociationViewForSnippet(blankSnippet.Snippet_Id));

        instantiatedSnippet.name = instSnippetState.title;  //names each snippet by its title

        snippetObjectDict.Add(instSnippetState.id, instantiatedSnippet);
    }