Пример #1
0
    // Use this for initialization
    void Start()
    {
        romance.Prepare();
        dialogue      = "";
        characterName = "Mateo";
        pose          = 0;
        guion         = GameObject.Find("DialogueParser").GetComponent <DialogueParser>();
        lineNum       = 0;

        choiceBox1 = GameObject.Find("Button1").GetComponent <ChoiceButton> ();
        choiceBox2 = GameObject.Find("Button2").GetComponent <ChoiceButton> ();
        choiceBox3 = GameObject.Find("Button3").GetComponent <ChoiceButton> ();

        choiceBox1.GetComponent <Button>().onClick.AddListener(() => Responder1());
        choiceBox2.GetComponent <Button>().onClick.AddListener(() => Responder2());
        choiceBox3.GetComponent <Button>().onClick.AddListener(() => Responder3());

        SetDialog(1);

        //SpriteRenderer ganaste = GameObject.Find ("huevito").GetComponent<SpriteRenderer> ();
        //SpriteRenderer sr = gameObject.GetComponent<SpriteRenderer>();

        Analytics.CustomEvent("DialogosEmpezar", new Dictionary <string, object> {
            { "quien", Controlador.NombresPerfiles[SceneManager.GetActiveScene().buildIndex] }
        });
    }
Пример #2
0
 void CreateButtons()
 {
     for (int i = 0; i < choices.Length - 1; i++)
     {
         GameObject   buttonObj     = (GameObject)Instantiate(choiceButton);
         Button       button        = buttonObj.GetComponent <Button>();
         ChoiceButton choiceBtn     = buttonObj.GetComponent <ChoiceButton>();
         string[]     choiceOptions = choices[i].Split(':');
         choiceBtn.SetText(choiceOptions[0]);
         choiceBtn.SetNextLine(choiceOptions[1]);
         string choiceText = "";
         for (int j = 2; j < choiceOptions.Length; j++)
         {
             choiceText += choiceOptions[j];
             if (j != choiceOptions.Length - 1)
             {
                 choiceText += ":";
             }
         }
         choiceBtn.SetChoice(choiceText);
         choiceBtn.manager = this;
         button.transform.SetParent(canvas.transform, true);
         button.transform.localPosition = new Vector3(0, -25 + (i * 50));
         button.transform.localScale    = new Vector3(1, 1, 1);
         buttons.Add(button);
         if (choices[choices.Length - 1] == "false")
         {
             choiceBtn.ParseChoice();
             break;
         }
     }
 }
Пример #3
0
    private void GenerateButtons()
    {
        for (int i = 0; i < choices.Length; i++)
        {
            GameObject   obj           = GameObject.Instantiate(choicePrefab, dialogueBox.transform.GetChild(2));
            ChoiceButton choice        = obj.GetComponent <ChoiceButton>();
            string[]     choiceOptions = choices[i].Split(':');
            Debug.Log(choices[i] + " |  " + choiceOptions.Length);
            choice.SetText(choiceOptions[0]);
            choice.nextLine = choiceOptions[1];

            string choiceText = "";
            for (int j = 2; j < choiceOptions.Length; j++)
            {
                choiceText += choiceOptions[j];
                if (j != choiceOptions.Length - 1)
                {
                    choiceText += ":";
                }
            }
            choice.choice = choiceText;

            btns.Add(obj.GetComponent <Button>());
        }
    }
Пример #4
0
    // public override void Awake()
    // {
    //     base.Awake();
    //     Debug.Log("q window awake");
    // }

    // protected override void Activate()
    // {
    //     Debug.Log("activate window q");
    //     // windowElement.Activate();
    //     gameObject.SetActive(true);
    // }

    private void ProcessChoice(ChoiceButton choiceButton)
    {
        if (choicesObjects.Contains(choiceButton))
        {
            ChoicePicked.Invoke(choicesObjects.IndexOf(choiceButton));
        }
    }
Пример #5
0
    //creates buttons for player inputs
    void CreateButtons()
    {
        spaceText.text = "(Enter)";
        spaceText.rectTransform.localPosition = new Vector3(spaceText.rectTransform.localPosition.x, -76, spaceText.rectTransform.localPosition.z);

        int xPos = -125;
        int yPos = -127;

        for (int i = 0; i < options.Length; i++)
        {
            GameObject   button = Instantiate(choiceBox);
            Button       b      = button.GetComponent <Button>();
            ChoiceButton cb     = button.GetComponent <ChoiceButton>();

            cb.SetText(options[i].Split(':')[0]);
            cb.option      = options[i].Split(':')[1];
            cb.choiceKey   = "";
            cb.choiceValue = "";

            cb.box = this;

            cb.transform.SetParent(thisCanvas.transform, false);
            RectTransform transform = b.gameObject.GetComponent <RectTransform>();
            transform.anchoredPosition = new Vector2(xPos + (i * 250), yPos);
            buttons.Add(b);
            if (i == 0)
            {
                b.Select();
            }
        }
    }
    void CreateButtons()
    {
        for (int i = 0; i < options.Length; i++)
        {
            GameObject   button = (GameObject)Instantiate(choiceBox);
            Button       b      = button.GetComponent <Button>();
            ChoiceButton cb     = button.GetComponent <ChoiceButton>();
            if ((options[i].Split(':')[0]).Contains("(Player)"))
            {
                cb.SetText(PutPlayerName(options[i].Split(':')[0]));
            }
            else
            {
                cb.SetText(options[i].Split(':')[0]);
            }
            cb.option = options[i].Split(':')[1];
            cb.number = i;
            cb.box    = this;
            ColorBlock block = b.colors;

            if ((cb.option.Split(',')[0]) == "lineRight")
            {
                block.pressedColor = new Color32(113, 247, 159, 255);
            }
            else if ((cb.option.Split(',')[0]) == "lineWrong")
            {
                block.pressedColor = new Color32(213, 87, 59, 255);
            }
            if ((cb.option.Split(',')[0]) == "scene")
            {
                miniGame();
            }

            b.colors = block;
            b.transform.SetParent(GameObject.Find("GamePanel").transform);
            b.transform.localPosition = new Vector3(0, -25 + (i * 50));
            b.transform.localScale    = new Vector3(1, 1, 1);
            buttons.Add(b);
            thingy.SetActive(false);
            charAnimator.SetBool("startIndicator", false);
            charAnimator.SetBool("stopIndicator", true);
        }
        if (playerTalking)
        {
            print("SHOULD PRINT");
        }

        if (buttons.Count > 1)
        {
            playerControl    = false;
            characterName    = parser.GetName(lineNum - 1);
            dialogue         = parser.GetContent(lineNum - 1);
            dialogueBox.text = dialogue;
            nameBox.text     = characterName;
            thingy.SetActive(false);
        }
        //buttons[buttons.Count - 1].Select();
        //buttonSelect = buttons.Count - 1;
    }
Пример #7
0
 public static void AddInvokerForMakeChoiceEvent(ChoiceButton invoker)
 {
     invokersForMakeChoiceEvent.Add(invoker);
     foreach (UnityAction <int> listener in listenersForMakeChoiceEvent)
     {
         invoker.MakeChoiceEventAddedEventListener(listener);
     }
 }
Пример #8
0
    private void CreateButton(Choice _choice, int _index)
    {
        ChoiceButton choiceButton = Instantiate(this.choiceButtonPrefab).GetComponent <ChoiceButton>();

        choiceButton.transform.SetParent(this.choiceButtonParent, false);
        choiceButton.transform.localPosition = this.buttonPositions[_index];
        choiceButton.Init(_choice, this.Finish);
        this.choiceButtons.Add(choiceButton);
    }
Пример #9
0
    static void CreateChoice(string choice)
    {
        GameObject ob = Instantiate(instance.choicePrefab.gameObject, instance.choicePrefab.transform.parent);

        ob.SetActive(true);
        ChoiceButton b = ob.GetComponent <ChoiceButton>();

        b.text        = choice;
        b.choiceIndex = choices.Count;

        choices.Add(b);
    }
Пример #10
0
 void CreateButtons()
 {
     for (int i = 0; i < options.Length; i++)
     {
         GameObject   button = (GameObject)Instantiate(choiceBox);
         Button       b      = button.GetComponent <Button>();
         ChoiceButton cb     = button.GetComponent <ChoiceButton>();
         cb.SetText(options[i].Split(':')[0]);
         cb.option = options[i].Split(':')[1];
         cb.box    = this;
         b.transform.SetParent(this.transform);
         b.transform.localPosition = new Vector3(0, -25 + (i * 50));
         b.transform.localScale    = new Vector3(1, 1, 1);
         buttons.Add(b);
     }
 }
Пример #11
0
 //  選択ボタン作成
 void CreateButtons()
 {
     for (int i = 0; i < m_options.Length; i++)
     {
         GameObject   button = (GameObject)Instantiate(m_choiceBox);
         Button       b      = button.GetComponent <Button>();
         ChoiceButton cb     = button.GetComponent <ChoiceButton>();
         cb.SetText(m_options[i].Split(':')[0]);                     //errorOK
         cb.m_option = m_options[i].Split(':')[1];
         cb.m_box    = this;
         b.transform.SetParent(this.transform);
         b.transform.localPosition = new Vector3(0, -75 + (i * 30));
         b.transform.localScale    = new Vector3(1.0f, 0.8f, 0.8f);
         m_buttons.Add(b);
     }
 }
Пример #12
0
    public void LoadQuestion()
    {
        // Ensure currentQuestion is a valid index
        if (currentQuestionIndex < 0 || currentQuestionIndex >= questions.Count)
        {
            Debug.Log("currentQuestion does not fall under the range 0 to questions.Count");
            return;
        }
        currentQuestion = questions[currentQuestionIndex];
        // Set GUI text to string from question
        questionText.text = currentQuestion.text;

        // Ensure we have same number of buttons as choices
        if (choices.transform.childCount != currentQuestion.choices.Count)
        {
            Debug.Log(choices.transform.childCount + " buttons but " + currentQuestion.choices.Count + " choices.");
            return;
        }

        // Set each button text to current question choices text
        for (int i = 0; i < currentQuestion.choices.Count; i++)
        {
            ChoiceButton currentChoiceButton = choices.transform.GetChild(i).GetComponent <ChoiceButton>();
            Choice       currentChoice       = currentQuestion.choices[i];
            // Set button text to current choice text
            currentChoiceButton.label.text = currentChoice.text;

            // Will be used to set button colors
            ColorBlock colors = currentChoiceButton.button.colors;

            // Remove all listeners from button
            currentChoiceButton.button.onClick.RemoveAllListeners();
            // Add listeners for right and wrong responses
            if (currentChoice.correct)
            {
                currentChoiceButton.button.onClick.AddListener(NextQuestion);
                colors.pressedColor = Color.green;
            }
            else
            {
                colors.pressedColor = Color.red;
                currentChoiceButton.button.onClick.AddListener(() => ShowPopup(currentChoice.correction_text));
            }
            currentChoiceButton.button.colors = colors;
        }
    }
Пример #13
0
 public void Finish(ChoiceButton _button)
 {
     for (int i = 0; i < this.choiceButtons.Count; i++)
     {
         if (_button != this.choiceButtons[i])
         {
             this.choiceButtons[i].Finish();
             this.icons[i].Finish();
         }
         else
         {
             this.finishButton = this.choiceButtons[i];
             this.finishIcon   = this.icons[i];
         }
     }
     this.choiceButtons.Clear();
     this.icons.Clear();
     this.StartCoroutine(this.SelectButtonFinish());
 }
Пример #14
0
 void CreateButtons()
 {
     for (int i = 0; i < options.Length; i++)
     {
         GameObject   button = Instantiate(choiceBox);
         Button       b      = button.GetComponent <Button>();
         ChoiceButton cb     = button.GetComponent <ChoiceButton>();
         cb.SetText(options[i].Split(':')[0]);
         cb.option = options[i].Split(':')[1];
         cb.box    = this;
         cb.parser = GameObject.Find("DialogueParser").GetComponent <DialogueParser>();
         b.transform.SetParent(this.transform);
         b.transform.localPosition = new Vector3(0, 70 - (i * 50));
         print(cb.GetComponentInChildren <Text>().text);
         print(b.transform.localPosition);
         b.transform.localScale = new Vector3(1, 1, 1);
         buttons.Add(b);
     }
 }
Пример #15
0
    // Instantiates buttons for each available choice in the current point in the story
    private void PopulateChoices()
    {
        choicePanel.SetActive(true);

        for (int i = 0; i < story.currentChoices.Count; i++)
        {
            GameObject      btn = Instantiate(buttonPrefab, choicePanel.transform);
            TextMeshProUGUI gui = btn.transform.Find("ChoiceText").GetComponent <TextMeshProUGUI>();
            gui.text             = story.currentChoices[i].text;
            gui.enableAutoSizing = false;
            gui.enableAutoSizing = true;
            ChoiceButton choiceBtn = btn.GetComponent <ChoiceButton>();
            choiceBtn.index         = i;            // Set button's choice index
            choiceBtn.buttonAction += SelectButton; // Subscribe to buttonAction event

            choices.Add(choiceBtn);
        }
        eventSystem.SetSelectedGameObject(choices[0].gameObject);
    }
Пример #16
0
    public void displayChoices(Dictionary <string, string> choiceToFileMap, Dictionary <string, string> metadata)
    {
        choiceDisplay.enabled = true;
        // make sure there are no other buttons
        foreach (Transform child in choiceContainer.transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        foreach (KeyValuePair <string, string> entry in choiceToFileMap)
        {
            GameObject newButton = Instantiate(choiceButtonPrefab);
            newButton.transform.SetParent(choiceContainer.transform);
            Text         choiceText   = newButton.transform.Find("ChoiceText").GetComponent <Text>();
            ChoiceButton choiceButton = newButton.GetComponent <ChoiceButton>();
            choiceButton.setChoiceFile(entry.Value);
            choiceText.text = entry.Key;
            if (metadata.ContainsKey(choiceText.text))
            {
                // have metadata for this, so one of these choice buttons needs to toggle a screen
                switch (metadata[choiceText.text])
                {
                case "reselect":
                    choiceButton.midgameShowWeapons();
                    break;

                case "heal":
                    choiceButton.midgameShowHeal();
                    break;

                case "upgrade":
                    choiceButton.midgameShowUpgrade();
                    break;

                case "skip":
                    choiceButton.midgameStartNewRound();
                    break;
                }
            }
        }
    }
        protected override SharpUIBase BuildMainPanel()
        {
            // use non drawing graphic to block input
            SharpUINonDrawingGraphic toReturn = new SharpUINonDrawingGraphic("UIConfirmationDialog");

            toReturn.SetFillSize();

            toReturn.SubscribeToEvent(EEventType.PointerClick, (object sender, EventSystemEventArgs e) =>
            {
                OnCancelClicked?.Invoke();
            });

            _background = new SharpUIImage($"{toReturn.Name}_bg", null);
            _background.SetFixedSize(Size);
            _background.alignment = EAlignment.MiddleCenter;
            _background.Color     = new Color(0f, 0f, 0f, 0.5f);
            toReturn.AddChild(_background);

            SharpUIHorizontalLayout buttonLayout = new SharpUIHorizontalLayout($"{toReturn.Name}_button_layout");

            buttonLayout.SetFitSize();
            buttonLayout.spacing   = 40;
            buttonLayout.alignment = EAlignment.BottomCenter;
            buttonLayout.margin    = new RectOffset(0, 0, 0, 20);
            _background.AddChild(buttonLayout);

            ChoiceButton okButton = new ChoiceButton(() => { OnOKClicked?.Invoke(); }, $"{toReturn.Name}_ok_button", "OK");

            buttonLayout.AddChild(okButton);

            ChoiceButton cancelButton = new ChoiceButton(() => { OnCancelClicked?.Invoke(); }, $"{toReturn.Name}_cancel_button", "Cancel");

            buttonLayout.AddChild(cancelButton);

            return(toReturn);
        }
Пример #18
0
 public void MakeChoice(ChoiceButton button)
 {
     choice.index = button.choiceIndex;
     choice.title = button.text;
 }
Пример #19
0
        public ChoicePage() : base("Choose List Type", new BaseViewModel())
        {
            const string listViewListTitle = "ListView Page List<T>, ";
            const string listViewObservableCollectionTitle       = "ListView Page ObservableCollection<T>, ";
            const string collectionViewListTitle                 = "CollectionView Page List<T>, ";
            const string collectionViewObservableCollectionTitle = "CollectionView Page ObservableCollection<T>, ";

            const string configureAwaitTrue  = "ConfigureAwait(true)";
            const string configureAwaitFalse = "ConfigureAwait(false)";

            var keyLabel = new Label
            {
                FontAttributes          = FontAttributes.Italic,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalOptions         = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                Text = "Note: Red Buttons will open a page that crashes the app"
            };

            var listViewListPageTrueButton = new ChoiceButton(Color.Green, Color.White, listViewListTitle + configureAwaitTrue);

            listViewListPageTrueButton.Clicked += async(s, e) => await NavigateToPage(new ListViewPage(listViewListTitle + configureAwaitTrue, new ListViewModel(true)));

            var listViewListPageFalseButton = new ChoiceButton(Color.Green, Color.White, listViewListTitle + configureAwaitFalse);

            listViewListPageFalseButton.Clicked += async(s, e) => await NavigateToPage(new ListViewPage(listViewListTitle + configureAwaitFalse, new ListViewModel(false)));

            var listViewObservableCollectionPageTrueButton = new ChoiceButton(Color.Green, Color.White, listViewObservableCollectionTitle + configureAwaitTrue);

            listViewObservableCollectionPageTrueButton.Clicked += async(s, e) => await NavigateToPage(new ListViewPage(listViewObservableCollectionTitle + configureAwaitTrue, new ObservableCollectionViewModel(true)));

            var listViewObservableColletionPageFalseButton = new ChoiceButton(Color.Green, Color.White, listViewObservableCollectionTitle + configureAwaitFalse);

            listViewObservableColletionPageFalseButton.Clicked += async(s, e) => await NavigateToPage(new ListViewPage(listViewObservableCollectionTitle + configureAwaitFalse, new ObservableCollectionViewModel(false)));


            var collectionViewListPageTrueButton = new ChoiceButton(Color.Green, Color.White, collectionViewListTitle + configureAwaitTrue);

            collectionViewListPageTrueButton.Clicked += async(s, e) => await NavigateToPage(new CollectionViewPage(collectionViewListTitle + configureAwaitTrue, new ListViewModel(true)));

            var collectionViewListPageFalseButton = new ChoiceButton(Color.Green, Color.White, collectionViewListTitle + configureAwaitFalse);

            collectionViewListPageFalseButton.Clicked += async(s, e) => await NavigateToPage(new CollectionViewPage(collectionViewListTitle + configureAwaitFalse, new ListViewModel(false)));

            var collectionViewObservableCollectionPageTrueButton = new ChoiceButton(Color.Green, Color.White, collectionViewObservableCollectionTitle + configureAwaitTrue);

            collectionViewObservableCollectionPageTrueButton.Clicked += async(s, e) => await NavigateToPage(new CollectionViewPage(collectionViewListTitle + configureAwaitTrue, new ObservableCollectionViewModel(true)));

            var collectionViewObservableCollectionPageFalseButton = new ChoiceButton(Color.DarkRed, Color.White, collectionViewObservableCollectionTitle + configureAwaitFalse);

            collectionViewObservableCollectionPageFalseButton.Clicked += async(s, e) => await NavigateToPage(new CollectionViewPage(collectionViewListTitle + configureAwaitFalse, new ObservableCollectionViewModel(false)));

            var stackLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Children          =
                {
                    keyLabel,
                    listViewListPageTrueButton,
                    listViewListPageFalseButton,
                    listViewObservableCollectionPageTrueButton,
                    listViewObservableColletionPageFalseButton,
                    collectionViewListPageTrueButton,
                    collectionViewListPageFalseButton,
                    collectionViewObservableCollectionPageTrueButton,
                    collectionViewObservableCollectionPageFalseButton
                }
            };

            Padding = new Thickness(10);

            Content = new ScrollView {
                Content = stackLayout
            };
        }