Ejemplo n.º 1
0
    public void ShowChoiceButtons(DialogueFragment hubFragment)
    {
        HideChoiceButtons();
        if (hubFragment.OutputPins[0].Connections.Count <= 0)
        {
            Debug.LogError("Hub has no choices!");
        }

        List <SortingHelper> sorts = new List <SortingHelper>();

        for (int i = 0; i < hubFragment.OutputPins[0].Connections.Count; ++i)
        {
            DialogueFragment    frag           = hubFragment.OutputPins[0].Connections[i].Target as DialogueFragment;
            IObjectWithPosition positionObject = hubFragment.OutputPins[0].Connections[i].Target as IObjectWithPosition;

            SortingHelper sort = new SortingHelper();
            sort.Fragment  = frag;
            sort.PositionY = positionObject.Position.y;
            sorts.Add(sort);
        }

        sorts = sorts.OrderBy(f => f.PositionY).ToList();

        for (int i = 0; i < sorts.Count; ++i)
        {
            if (sorts[i].Fragment.InputPins[0].Evaluate())
            {
                DialogueChoiceButton choiceButton = Instantiate(ButtonChoiceTemplate);

                choiceButton.gameObject.SetActive(true);
                choiceButton.gameObject.transform.SetParent(PanelChoice, false);
                choiceButton.SetChoice(i, sorts[i].Fragment);
                ButtonChoiceList.Add(choiceButton);
            }
        }
    }
Ejemplo n.º 2
0
    public override void InitManager()
    {
        base.InitManager();
        instance = this;

        if (MirrorReference.HasReference)
        {
            MirrorTemplate = MirrorReference.GetObject <template_item>();
        }
        if (EraserReference.HasReference)
        {
            EraserTemplate = EraserReference.GetObject <template_item>();
        }
        if (ShopKeeperAltGreetReference.HasReference)
        {
            List <SortingHelper> sorts            = new List <SortingHelper>();
            Dialogue             altGreetDialogue = ShopKeeperAltGreetReference.GetObject <Dialogue>();
            for (int i = 0; i < altGreetDialogue.Children.Count; ++i)
            {
                DialogueFragment frag = altGreetDialogue.Children[i] as DialogueFragment;
                if (frag != null)
                {
                    IObjectWithPosition positionObject = frag as IObjectWithPosition;

                    SortingHelper sort = new SortingHelper();
                    sort.Fragment  = frag;
                    sort.PositionY = positionObject.Position.y;
                    sorts.Add(sort);
                }
            }

            sorts.OrderBy(f => f.PositionY);

            for (int i = 0; i < sorts.Count; ++i)
            {
                AltGreetFragments.Add(sorts[i].Fragment);
            }
        }

        for (int i = 0; i < 3; ++i)
        {
            ItemDictionary.Add(i, new List <template_item>());
        }
        if (StarterBodyReference.HasReference)
        {
            StarterBody = StarterBodyReference.GetObject <template_item>();
        }
        if (StarterHeadReference.HasReference)
        {
            StarterHead = StarterHeadReference.GetObject <template_item>();
        }

        if (ItemFolderReference.HasReference)
        {
            UserFolder itemFolder = ItemFolderReference.GetObject <UserFolder>();

            if (itemFolder != null)
            {
                for (int i = 0; i < itemFolder.Children.Count; ++i)
                {
                    UserFolder childFolder = itemFolder.Children[i] as UserFolder;
                    for (int j = 0; j < childFolder.Children.Count; ++j)
                    {
                        template_item item = childFolder.Children[j] as template_item;

                        UserFolder childSubfolder = childFolder.Children[j] as UserFolder;
                        if (childSubfolder != null)
                        {
                            for (int y = 0; y < childSubfolder.Children.Count; ++y)
                            {
                                template_item subfolderItem = childSubfolder.Children[y] as template_item;
                                if (subfolderItem != null)
                                {
                                    ReadItemData(subfolderItem);
                                }
                            }
                        }
                        if (item != null)
                        {
                            ReadItemData(item);
                        }
                    }
                }
            }
            Debug.Log("Found " + ItemDictionary[0].Count + " Slot 0 items");
            Debug.Log("Found " + ItemDictionary[1].Count + " Slot 1 items");
            Debug.Log("Found " + ItemDictionary[2].Count + " Slot 2 items");

            Debug.Log("Found " + HeadList.Count + " heads");
            Debug.Log("Found " + BodyList.Count + " bodies");
        }
    }