//Change to the next menu.
    public void ChangeMenu(DialogMenu next_menu)
    {
        //If we are advancing to a new menu: Advance
        if(current_menu != next_menu)
        {
            if(next_menu)
                next_menu.SetVisible(true);

            current_menu = next_menu;

            if(current_menu)
                subtitle.SetText(current_menu.original_prompt);
            else
                OnFinish();
        }
        //If we are staying at the same menu: Don't advance and reset timers and original prompt
        else
        {
            current_menu.DeselectAllWidgets();
            current_menu.ResetEndCond();

            subtitle.SetText(current_menu.original_prompt);
        }

        subtitle = GetComponentInChildren<SubtitleWidget>();

        if(!subtitle)
        {
            Debug.Log ("Error: no subtitle");
            Destroy(gameObject);
        }
    }
示例#2
0
    //What happens when the end condition is actually met
    public void OnEndCond(DialogMenu firer, DialogMenu next_menu)
    {
        //Disregard events fired by menus that aren't the current menu
        if (firer != current_menu)
        {
            return;
        }

        //If we're in an action state, don't move on. Just start the allowing of the actio
        if (current_menu.dialog_tree_state == DialogTreeState.Action)
        {
            StartAllowAction();
            return;
        }
        //If the menu is scheduled to halt: start the allowed action. Don't do this if the next menu is the same, as it means
        //we are returning to the same menu, and we don't do checks there.
        if (current_menu.halt_until_good_action && current_menu != next_menu)
        {
            StartAllowAction();
        }
        else
        {
            ChangeMenu(next_menu);
        }
    }
示例#3
0
        override protected void Awake()
        {
            // 子クラスでAwakeを使う場合は
            // 必ず親クラスのAwakeをCallして
            // 複数のGameObjectにアタッチされないようにします.
            base.Awake();

            mainMenu = gameObject.AddComponent <MainMenu>();
            alert    = gameObject.AddComponent <AlertMenu>();
            dialog   = gameObject.AddComponent <DialogMenu>();

            itemBar.MenuButtonHandle = () => { mainMenu.OpenMainMenu(); };

            // iPhoneX対応
            CanvasScaler canvasScaler = GetComponent <CanvasScaler>();

            if (canvasScaler != null)
            {
                float currentAspect = (float)Screen.width / Screen.height;
                // 1 Height 0 Width

                // 縦長端末の場合
                if (currentAspect < STANDARD_ASPECT)
                {
                    canvasScaler.matchWidthOrHeight = 0.0f;
                    itemBar.SetItemBarOffset();
                    NewAspect = true;
                }
                else    //横長or標準
                {
                    canvasScaler.matchWidthOrHeight = 1.0f;
                    NewAspect = false;
                }
            }
        }
示例#4
0
 public MapEventTreasure(SirokoStats status, Map map, TreasureType treasureType, string treasureName, DialogMenu dialog)
 {
     this.status       = status;
     this.map          = map;
     this.eventType    = EventType.TREASURE;
     this.treasureType = treasureType;
     this.treasureName = treasureName;
     this.dialog       = dialog;
 }
示例#5
0
    public bool IsTreeInEndCond()
    {
        if (!menu)
        {
            return(false);
        }

        DialogMenu dmenu = (menu as DialogMenu);

        if (!dmenu)
        {
            return(false);
        }

        return(dmenu.start_check_for_end_cond);
    }
示例#6
0
        // Use this for initialization
        void Start()
        {
            _canvas = transform.Find("Canvas").gameObject;

            startButton.onClick.AddListener(() => StartButtonHandler());
            continueButton.onClick.AddListener(() => ContinueButtonHandle());
            continueButton.gameObject.SetActive(DataManager.Instance.CheckSaveData());
            creditButton.onClick.AddListener(() => CreditButtonHandle());
            exitButton.onClick.AddListener(() => Application.Quit());

            dialog = _canvas.AddComponent <DialogMenu>();

            Invoke("PlayBGM", 3f);

            if (!Persistence.Created)
            {
                Instantiate(GameManagerObj);
                Persistence.Created = true;
            }
        }
示例#7
0
    public void Reset()
    {
        test_audio_source.clip = null;

        current_menu = null;

        set_visible_once = false;

        last_response = "";

        good_response_index = 0;
        bad_response_index  = 0;

        action_response_clip = null;

        selected_action_widget = false;

        foreach (Menu m in menus)
        {
            if (m.GetComponent <SubtitleWidget>() || (m.transform.parent && m.transform.parent.GetComponent <SubtitleWidget>()) || m.name == "MenuPosition" || m.GetComponent <TeaDialogTree>())
            {
            }
            else
            {
                m.gameObject.SetActive(true);
                Destroy(m.gameObject);
            }
        }
        foreach (Transform go in GetComponentsInChildren <Transform>())
        {
            if (go.GetComponent <SubtitleWidget>() || (go.transform.parent && go.transform.parent.GetComponent <SubtitleWidget>()) || go.name == "MenuPosition" || go.GetComponent <TeaDialogTree>())
            {
            }
            else
            {
                Destroy(go.gameObject);
            }
        }
        Start();
    }
示例#8
0
    //Change to the next menu.
    public void ChangeMenu(DialogMenu next_menu)
    {
        //If we are advancing to a new menu: Advance
        if (current_menu != next_menu)
        {
            if (next_menu)
            {
                next_menu.SetVisible(true);
            }

            current_menu = next_menu;

            if (current_menu)
            {
                subtitle.SetText(current_menu.original_prompt);
            }
            else
            {
                OnFinish();
            }
        }
        //If we are staying at the same menu: Don't advance and reset timers and original prompt
        else
        {
            current_menu.DeselectAllWidgets();
            current_menu.ResetEndCond();

            subtitle.SetText(current_menu.original_prompt);
        }

        subtitle = GetComponentInChildren <SubtitleWidget>();

        if (!subtitle)
        {
            Debug.Log("Error: no subtitle");
            Destroy(gameObject);
        }
    }
    // Use this for initialization
    void Start()
    {
        menu_position = get_menu_position();

        //Guard against default bad menu scale
        if(menu_scale == Vector3.zero){ menu_scale = Vector3.one; }

        //Load all tea dialog clips
        Object[] objs = Resources.LoadAll("AudioClips/TeaDialog/DialogClips");
        clips = new List<AudioClip>();
        foreach(Object obj in objs)
        {
            AudioClip clip = obj as AudioClip;
            clips.Add(clip);
        }

        //Record all good responses clips
        objs = Resources.LoadAll("AudioClips/TeaDialog/GoodResponses");
        good_response_clips = new List<AudioClip>();
        foreach(Object obj in objs)
            good_response_clips.Add(obj as AudioClip);

        //Record all bad responses clips
        objs = Resources.LoadAll("AudioClips/TeaDialog/BadResponses");
        bad_response_clips = new List<AudioClip>();
        foreach(Object obj in objs)
            bad_response_clips.Add(obj as AudioClip);

        excluded_choices = new List<string>();

        SetResponsesFromXML();

        subtitle = GetComponentInChildren<SubtitleWidget>();

        if(!subtitle)
        {
            Debug.Log("Error: no subtitle");
            Destroy(gameObject);
        }

        if(generate_static_tree)
        {
            //Get all the menus attached. (Don't attach any if you want to dynamically create the tree;
            //this is probably always the case except when debugging.
            DialogMenu[] amenus = GetComponentsInChildren<DialogMenu>();
            foreach(DialogMenu menu in amenus)
            {
                menus.Add(menu);

                foreach(Widget w in menu.widgets)
                {
                    //Debug.Log ("added widget " + w.name + " of menu " + menu.name);
                    w.OnWidgetClick += OnWidgetClick;
                }
            }
        }
        else
        {
            CreateTreeFromXML();

            for(int i=0;i<menus.Count;i++)
            {
                menus[i].tree = this;

                //Neatly arrange the menu's widgets
                menus[i].ArrangeWidgets();

                foreach(Widget w in menus[i].widgets)
                {
                    w.OnWidgetClick += OnWidgetClick;
                    ((DialogWidget)w).DialogMenu = GetChoiceMenuFromName(((DialogWidget)w).choicemenu_name);
                }

                if(menus[i].dialog_tree_state == DialogTreeState.Wait)
                {
                    menus[i].OnEndCond += OnEndCond;
                }

                //All menu's next menus are the ones that come after them in the XML
                if(i < menus.Count - 1)
                {
                    menus[i].next_menu = menus[i+1];
                    menus[i].orig_next_menu = menus[i+1];
                }

            }

            if(Settings.debug && Settings.menu_to_jump_to != "")
                current_menu = GetChoiceMenuFromName(Settings.menu_to_jump_to);
            else
                current_menu = menus[0];
        }

        subtitle.SetText(current_menu.original_prompt);
    }
    public void Reset()
    {
        test_audio_source.clip = null;

        current_menu = null;

        set_visible_once = false;

        last_response = "";

        good_response_index = 0;
        bad_response_index = 0;

        action_response_clip = null;

        selected_action_widget = false;

        foreach(Menu m in menus)
        {
            if(m.GetComponent<SubtitleWidget>() || (m.transform.parent && m.transform.parent.GetComponent<SubtitleWidget>()) || m.name == "MenuPosition" || m.GetComponent<TeaDialogTree>()){}
            else
            {
                m.gameObject.SetActive(true);
                Destroy (m.gameObject);
            }
        }
        foreach(Transform go in GetComponentsInChildren<Transform>())
        {
            if(go.GetComponent<SubtitleWidget>() || (go.transform.parent && go.transform.parent.GetComponent<SubtitleWidget>()) || go.name == "MenuPosition" || go.GetComponent<TeaDialogTree>()){}
            else
                Destroy (go.gameObject);
        }
        Start ();
    }
 //Gear up the tree to prepare to change to a new menu
 public void PrepareChangeMenu(DialogMenu next_menu)
 {
     current_menu.StartEndCond();
     current_menu.next_menu = next_menu;
     current_menu.OnEndCond += OnEndCond;
 }
    //What happens when the end condition is actually met
    public void OnEndCond(DialogMenu firer, DialogMenu next_menu)
    {
        //Disregard events fired by menus that aren't the current menu
        if(firer != current_menu){ return; }

        //If we're in an action state, don't move on. Just start the allowing of the actio
        if(current_menu.dialog_tree_state == DialogTreeState.Action)
        {
            StartAllowAction();
            return;
        }
        //If the menu is scheduled to halt: start the allowed action. Don't do this if the next menu is the same, as it means
        //we are returning to the same menu, and we don't do checks there.
        if(current_menu.halt_until_good_action && current_menu != next_menu)
        {
            StartAllowAction();
        }
        else
        {
            ChangeMenu(next_menu);
        }
    }
示例#13
0
        public override void OnClick(Client sender)
        {
            DialogMenu dm = new DialogMenu(this, Greeting);

            if (HasBuy)
            {
                dm.Options.Add(Dialog.DIALOG_BUY_01, new Buy_1());
            }
            if (HasSell)
            {
                dm.Options.Add(Dialog.DIALOG_SELL_01, new Sell_1());
            }
            if (HasDeposit)
            {
                dm.Options.Add(Dialog.DIALOG_DEPOSIT_01, new Deposit_1());
            }
            if (HasWithdraw)
            {
                dm.Options.Add(Dialog.DIALOG_WITHDRAW_01, new Withdraw_1());
            }
            if (HasLearnSkill)
            {
                dm.Options.Add(Dialog.DIALOG_LEARNSKILL_01, new LearnSkill_1());
            }
            if (HasLearnSpell)
            {
                dm.Options.Add(Dialog.DIALOG_LEARNSPELL_01, new LearnSpell_1());
            }
            if (HasForgetSkill)
            {
                dm.Options.Add(Dialog.DIALOG_FORGETSKILL_01, new ForgetSkill_1());
            }
            if (HasForgetSpell)
            {
                dm.Options.Add(Dialog.DIALOG_FORGETSPELL_01, new ForgetSpell_1());
            }
            if (HasUpgradeSkill)
            {
                dm.Options.Add(Dialog.DIALOG_UPGRADESKILL_01, new UpgradeSkill_1());
            }
            if (HasUpgradeSpell)
            {
                dm.Options.Add(Dialog.DIALOG_UPGRADESPELL_01, new UpgradeSpell_1());
            }

            if (DialogMenuOptions.Count == 1 && dm.Options.Count == 0)
            {
                var type = DialogMenuOptions[0];
                var dmo  = GameServer.DialogMenuOptionDatabase[type];

                if (dmo.CanOpen(sender.Player) && !(dmo is QuestMenuOption))
                {
                    var dialog = dmo.Open(sender.Player, this, null);
                    GiveDialog(sender.Player, dialog);
                    return;
                }
            }

            for (int i = 0; i < DialogMenuOptions.Count; i++)
            {
                var type = DialogMenuOptions[i];
                var dmo  = GameServer.DialogMenuOptionDatabase[type];

                if (dmo.CanOpen(sender.Player) && !dmo.Hidden)
                {
                    if (dmo is QuestMenuOption)
                    {
                        var qmo   = dmo as QuestMenuOption;
                        var quest = sender.Player.Quests[qmo.QuestType];
                        if (quest.Progress == QuestProgress.Finished ||
                            quest.QuestStep.Progress < qmo.MinimumProgress ||
                            quest.QuestStep.Progress > qmo.MaximumProgress ||
                            quest.CurrentStep != qmo.QuestStep ||
                            sender.Player.Level < quest.MinimumLevel ||
                            sender.Player.Level > quest.MaximumLevel ||
                            !quest.Prerequisites.TrueForAll(req => sender.Player.Quests[req].Progress == QuestProgress.Finished))
                        {
                            continue;
                        }
                    }
                    var id = (ushort)(Dialog.DIALOG_GLOBAL_MAX + i);
                    dm.Options.Add(id, dmo);
                }
            }

            sender.Enqueue(dm.ToPacket());
        }
示例#14
0
 public MapEventStore(Map map, StoreMenu storeMenu, DialogMenu dialog)
 {
     this.eventType = EventType.STORE;
     this.store     = storeMenu;
     this.dialog    = dialog;
 }
示例#15
0
    // Use this for initialization
    void Start()
    {
        menu_position = get_menu_position();

        //Guard against default bad menu scale
        if (menu_scale == Vector3.zero)
        {
            menu_scale = Vector3.one;
        }

        //Load all tea dialog clips
        Object[] objs = Resources.LoadAll("AudioClips/TeaDialog/DialogClips");
        clips = new List <AudioClip>();
        foreach (Object obj in objs)
        {
            AudioClip clip = obj as AudioClip;
            clips.Add(clip);
        }

        //Record all good responses clips
        objs = Resources.LoadAll("AudioClips/TeaDialog/GoodResponses");
        good_response_clips = new List <AudioClip>();
        foreach (Object obj in objs)
        {
            good_response_clips.Add(obj as AudioClip);
        }

        //Record all bad responses clips
        objs = Resources.LoadAll("AudioClips/TeaDialog/BadResponses");
        bad_response_clips = new List <AudioClip>();
        foreach (Object obj in objs)
        {
            bad_response_clips.Add(obj as AudioClip);
        }

        excluded_choices = new List <string>();

        SetResponsesFromXML();

        subtitle = GetComponentInChildren <SubtitleWidget>();

        if (!subtitle)
        {
            Debug.Log("Error: no subtitle");
            Destroy(gameObject);
        }

        if (generate_static_tree)
        {
            //Get all the menus attached. (Don't attach any if you want to dynamically create the tree;
            //this is probably always the case except when debugging.
            DialogMenu[] amenus = GetComponentsInChildren <DialogMenu>();
            foreach (DialogMenu menu in amenus)
            {
                menus.Add(menu);

                foreach (Widget w in menu.widgets)
                {
                    //Debug.Log ("added widget " + w.name + " of menu " + menu.name);
                    w.OnWidgetClick += OnWidgetClick;
                }
            }
        }
        else
        {
            CreateTreeFromXML();

            for (int i = 0; i < menus.Count; i++)
            {
                menus[i].tree = this;

                //Neatly arrange the menu's widgets
                menus[i].ArrangeWidgets();

                foreach (Widget w in menus[i].widgets)
                {
                    w.OnWidgetClick += OnWidgetClick;
                    ((DialogWidget)w).DialogMenu = GetChoiceMenuFromName(((DialogWidget)w).choicemenu_name);
                }

                if (menus[i].dialog_tree_state == DialogTreeState.Wait)
                {
                    menus[i].OnEndCond += OnEndCond;
                }

                //All menu's next menus are the ones that come after them in the XML
                if (i < menus.Count - 1)
                {
                    menus[i].next_menu      = menus[i + 1];
                    menus[i].orig_next_menu = menus[i + 1];
                }
            }

            if (Settings.debug && Settings.menu_to_jump_to != "")
            {
                current_menu = GetChoiceMenuFromName(Settings.menu_to_jump_to);
            }
            else
            {
                current_menu = menus[0];
            }
        }

        subtitle.SetText(current_menu.original_prompt);
    }
示例#16
0
        public void LoadMenu(DialogMenu menu)
        {
            __menu.MenuItems.Clear();

            LoadMenu(__menu.MenuItems, menu.Root);
        }
示例#17
0
 public MapEventGoal(Map map, DialogMenu dialog)
 {
     this.map       = map;
     this.dialog    = dialog;
     this.eventType = EventType.GOAL;
 }
示例#18
0
    void CreateTreeFromXML()
    {
        TextAsset textAsset = (TextAsset)Resources.Load("XMLs/tea_dialog");

        XmlReader reader = XmlReader.Create(new StringReader(textAsset.text));

        DialogMenu   current_dialog_menu = null;
        DialogWidget current_widget      = null;

        string last_element   = "";
        string last_attr_name = "";
        string last_attr_val  = "";

        while (reader.Read())
        {
            if (reader.NodeType == XmlNodeType.Element)
            {
                last_element = reader.Name;

                if (last_element == "Prompt")
                {
                    current_dialog_menu = Instantiate(choice_menu_prefab, menu_position, Quaternion.identity) as DialogMenu;

                    //Set the submenus to the speficied submenu scale, and set their rotation to the same rotation as this.
                    current_dialog_menu.transform.localScale = menu_scale;

                    current_dialog_menu.transform.parent        = transform;
                    current_dialog_menu.transform.localRotation = Quaternion.identity;

                    menus.Add(current_dialog_menu);
                }
                else if (last_element == "Choice")
                {
                    current_widget = Instantiate(dialog_widget_prefab, Vector3.zero, current_dialog_menu.background.transform.rotation) as DialogWidget;

                    current_widget.transform.localScale = menu_scale;

                    current_dialog_menu.AddWidget(current_widget);
                }
                while (reader.MoveToNextAttribute())                 // Read the attributes.
                {
                    last_attr_name = reader.Name;
                    last_attr_val  = reader.Value;

                    if (last_element == "Prompt")
                    {
                        if (last_attr_name == "id")
                        {
                            AudioClip next_clip;
                            current_dialog_menu.name = last_attr_val;
                            if (last_attr_val == "Preamble1")
                            {
                                next_clip = clips.Find(clip => clip.name == "Welcome(mandarin)");
                            }
                            else if (last_attr_val == "Preamble2")
                            {
                                next_clip = clips.Find(clip => clip.name == "TodayIWillTeachYou");
                            }
                            else
                            {
                                next_clip = clips.Find(clip => clip.name == last_attr_val);
                            }

                            if (next_clip == null)
                            {
                                Debug.Log(last_attr_val + " failed to generate a clip.");
                            }

                            // note - name the animations Preamble1 and Preamble2
                            current_dialog_menu.SetDialogClip(next_clip, test_audio_source, last_attr_val, animatedCharacterName);
                        }
                        else if (last_attr_name == "progression")
                        {
                            //Set the current menu's progression here
                            if (last_attr_val == "wait")
                            {
                                current_dialog_menu.dialog_tree_state = DialogTreeState.Wait;
                            }
                            else if (last_attr_val == "choice")
                            {
                                current_dialog_menu.dialog_tree_state = DialogTreeState.Choice;
                            }
                        }
                        else if (last_attr_name == "haltUntilGoodAction")
                        {
                            current_dialog_menu.halt_until_good_action = true;
                        }
                        else if (last_attr_name == "haltAtEnd")
                        {
                            current_dialog_menu.halt_at_end = true;
                        }
                        else if (last_attr_name == "displayResponseForAction")
                        {
                            current_dialog_menu.display_response_for_action = true;
                        }
                    }
                    else if (last_element == "Choice")
                    {
                        //Create a dialog widget
                        if (last_attr_name == "id")
                        {
                            current_widget.name          = last_attr_val;
                            current_widget.animationClip = last_attr_val;
                            AudioClip next_clip = clips.Find(clip => clip.name == last_attr_val);

                            if (next_clip == null)
                            {
                                Debug.Log(last_attr_val + " failed to generate a clip.");
                            }

                            current_widget.audio_clip = next_clip;
                        }
                        else if (last_attr_name == "gotoPromptId")
                        {
                            current_widget.choicemenu_name = last_attr_val;
                        }
                        else if (last_attr_name == "haltUntilGoodAction")
                        {
                            current_widget.halt_until_good_action = true;
                        }
                        else if (last_attr_name == "excludeChoice")
                        {
                            string[] excluded = last_attr_val.Split(',');
                            current_widget.excluded_choices = excluded;
                        }
                    }
                }
            }
            else if (reader.NodeType == XmlNodeType.Text)
            {
                if (last_element == "EnglishSubtitles")
                {
                    string val = reader.Value;

                    //Remove all newlines and whitespace following newlines from val
                    val = StringUtils.RemoveNewlineAndIndents(val);

                    current_dialog_menu.original_prompt = val;
                }
                else if (last_element == "ChineseText")
                {
                    //current_widget.SetText(reader.Value);
                    current_widget.chinese_text = reader.Value;
                }
                else if (last_element == "EnglishText")
                {
                    //current_widget.AppendText("\n(" + reader.Value + ")");
                    current_widget.english_text = reader.Value;
                }
                else if (last_element == "Pinyin")
                {
                    current_widget.pinyin = reader.Value;
                }
                else if (last_element == "EnglishResponse")
                {
                    //Remove all newlines and whitespace following newlines from val
                    string val = StringUtils.RemoveNewlineAndIndents(reader.Value);

                    current_widget.response = val;
                }
            }
        }
    }
示例#19
0
 //Gear up the tree to prepare to change to a new menu
 public void PrepareChangeMenu(DialogMenu next_menu)
 {
     current_menu.StartEndCond();
     current_menu.next_menu  = next_menu;
     current_menu.OnEndCond += OnEndCond;
 }
示例#20
0
 public void SetChoiceMenu(DialogMenu achoicemenu)
 {
     DialogMenu = achoicemenu;
 }
 public void SetChoiceMenu(DialogMenu achoicemenu)
 {
     DialogMenu = achoicemenu;
 }