コード例 #1
0
ファイル: ChoiceMenu.cs プロジェクト: Mafmax/MiniUmnik
    private void OnChoice()
    {
        choice = positions.Where(x => x.type.ToString() == EventSystem.current.currentSelectedGameObject.name).FirstOrDefault();

        var menu = UIController.GetMenu <StartMenu>();

        menu.gameType = choice.type;
        menu.OpenMenu(true);
    }
コード例 #2
0
ファイル: ChoiceMenu.cs プロジェクト: Mafmax/MiniUmnik
    private void ConstructField(GameObject field, ChoicePosition choicePositionData)
    {
        var childs = field.GetComponentsInChildren <Transform>(true);

        childs.Where(x => x.name == "Type").FirstOrDefault().gameObject.GetComponent <Text>().text     = choicePositionData.name;
        childs.Where(x => x.name == "Label").FirstOrDefault().gameObject.GetComponent <Image>().sprite = choicePositionData.image;
        var btn = childs.Where(x => x.name == "Choice").FirstOrDefault().gameObject.GetComponent <Button>();

        btn.name = choicePositionData.type.ToString();
        btn.onClick.AddListener(OnChoice);
    }
コード例 #3
0
    /// <summary>
    /// Used to add new dialog choices.
    /// </summary>
    /// <param name="dialog">Dialog that we are adding choice to.</param>
    /// <param name="choiceText">Text in the choice button.</param>
    /// <param name="dialogText">Text in the dialog box when choice is activated.</param>
    /// <param name="dialogChoiceType">What type of dialog choice this is?</param>
    /// <param name="choicePosition">Position of choice in the choices list. It can be at Top or at Bottom. If there is four choices already if on Top the last one will be removed and if on Bottom the first one will be removed.</param>
    public void AddNewChoice(TopDownRpgQuest quest, TopDownUIDialog dialog, string choiceText, string dialogText, DialogType dialogChoiceType, ChoicePosition choicePosition)
    {
        if (choicePosition == ChoicePosition.Top)
        {
            for (int i = dialog.numberOfChoices; i > 0; i--)
            {
                if (i == 4)
                {
                    dialog.choiceFour         = dialog.choiceThree;
                    dialog.choiceFourDialog   = dialog.choiceThreeDialog;
                    dialog.choiceFourType     = dialog.choiceThreeType;
                    dialog.removeOnChoiceFour = dialog.removeOnChoiceThree;
                    dialog.branchFourDialog   = dialog.branchThreeDialog;
                    dialog.typeFourResponse   = dialog.typeThreeResponse;
                    dialog.choiceFourEvent    = dialog.choiceThreeEvent;
                }
                if (i == 3)
                {
                    dialog.choiceThree         = dialog.choiceTwo;
                    dialog.choiceThreeDialog   = dialog.choiceTwoDialog;
                    dialog.choiceThreeType     = dialog.choiceTwoType;
                    dialog.removeOnChoiceThree = dialog.removeOnChoiceTwo;
                    dialog.branchThreeDialog   = dialog.branchTwoDialog;
                    dialog.typeThreeResponse   = dialog.typeTwoResponse;
                    dialog.choiceThreeEvent    = dialog.choiceTwoEvent;
                }
                if (i == 2)
                {
                    dialog.choiceTwo         = dialog.choiceOne;
                    dialog.choiceTwoDialog   = dialog.choiceOneDialog;
                    dialog.choiceTwoType     = dialog.choiceOneType;
                    dialog.removeOnChoiceTwo = dialog.removeOnChoiceOne;
                    dialog.branchTwoDialog   = dialog.branchOneDialog;
                    dialog.typeTwoResponse   = dialog.typeOneResponse;
                    dialog.choiceTwoEvent    = dialog.choiceOneEvent;
                }
                if (i == 1)
                {
                    dialog.choiceOne         = choiceText;
                    dialog.choiceOneDialog   = dialogText;
                    dialog.choiceOneType     = dialogChoiceType;
                    dialog.removeOnChoiceOne = true;
                    dialog.branchOneDialog   = null;
                    dialog.typeOneResponse   = string.Empty;
                    dialog.choiceOneEvent    = null;
                    if (quest == null)
                    {
                        print("No quest");
                    }
                    dialog.choiceOneEvent = quest.questFinishEvents;
                }
            }

            return;
        }
    }