Ejemplo n.º 1
0
        public override void OnEnter()
        {
            // 使用自定义的
            // 菜单界面
            if (setMenuDialog != null)
            {
                // Override the active menu dialog
                MenuDialog.ActiveMenuDialog = setMenuDialog;
            }

            bool hideOption = (hideIfVisited && targetBlock != null && targetBlock.GetExecutionCount() > 0) ||
                              hideThisOption.Value;

            // 获取菜单窗口
            var menuDialog = MenuDialog.GetMenuDialog();

            if (menuDialog != null)
            {
                menuDialog.SetActive(true);

                var flowchart = GetFlowchart();

                // 替换显示文本中的变量
                string displayText = flowchart.SubstituteVariables(text);

                // 添加菜单
                // 传入菜单参数
                menuDialog.AddOption(displayText, interactable, hideOption, targetBlock);
            }

            Continue();
        }
Ejemplo n.º 2
0
		public static MenuDialog GetMenuDialog()
		{
			if (activeMenuDialog == null)
			{
				// Use first Menu Dialog found in the scene (if any)
				MenuDialog md = GameObject.FindObjectOfType<MenuDialog>();
				if (md != null)
				{
					activeMenuDialog = md;
				}
				
				if (activeMenuDialog == null)
				{
					// Auto spawn a menu dialog object from the prefab
					GameObject prefab = Resources.Load<GameObject>("MenuDialog");
					if (prefab != null)
					{
						GameObject go = Instantiate(prefab) as GameObject;
						go.SetActive(false);
						go.name = "MenuDialog";
						activeMenuDialog = go.GetComponent<MenuDialog>();
					}
				}
			}
			
			return activeMenuDialog;
		}
Ejemplo n.º 3
0
 private void Update()
 {
     if (disableMoveWhenActive && !enableMovement)
     {
         if (!HasExecutingBlocks())
         {
             if (!MenuDialog.GetMenuDialog().isActiveAndEnabled)
             {
                 enableMovement = true;
                 frameDelay     = 0;
             }
         }
     }
     else if (disableMoveWhenActive && enableMovement)
     {
         if (frameDelay >= 5)
         {
             if (!HasExecutingBlocks())
             {
                 GameMaster.instance.EnableCharacterMovement();
                 disableMoveWhenActive = false;
             }
         }
         else if (HasExecutingBlocks())
         {
             frameDelay     = 0;
             enableMovement = false;
         }
         else
         {
             frameDelay += 1;
         }
     }
 }
Ejemplo n.º 4
0
        public override void OnEnter()
        {
            if (setMenuDialog != null)
            {
                // Override the active menu dialog
                MenuDialog.ActiveMenuDialog = setMenuDialog;
            }

            bool hideOption = (hideIfVisited && targetBlock != null && targetBlock.GetExecutionCount() > 0);

            if (!hideOption)
            {
                var menuDialog = MenuDialog.GetMenuDialog();
                if (menuDialog != null)
                {
                    menuDialog.SetActive(true);

                    var    flowchart   = GetFlowchart();
                    string displayText = flowchart.SubstituteVariables(text);

                    menuDialog.AddOption(displayText, interactable, targetBlock);
                }
            }

            Continue();
        }
Ejemplo n.º 5
0
        public override void OnEnter()
        {
            CheckEventSystem();

            if (setMenuDialog != null)
            {
                // Override the active menu dialog
                MenuDialog.activeMenuDialog = setMenuDialog;
            }

            bool hideOption = (hideIfVisited && targetBlock != null && targetBlock.GetExecutionCount() > 0);

            if (!hideOption)
            {
                MenuDialog menuDialog = MenuDialog.GetMenuDialog();
                if (menuDialog != null)
                {
                    menuDialog.gameObject.SetActive(true);
                    string displayText = text;
                    menuDialog.AddOption(displayText, targetBlock);
                }
            }

            Continue();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a menu dialog by searching for one in the scene or creating one if none exists.
        /// </summary>
        public static MenuDialog GetMenuDialog()
        {
            if (ActiveMenuDialog == null)
            {
                // Use first Menu Dialog found in the scene (if any)
                var md = GameObject.FindObjectOfType <MenuDialog>();
                if (md != null)
                {
                    ActiveMenuDialog = md;
                }

                if (ActiveMenuDialog == null)
                {
                    // Auto spawn a menu dialog object from the prefab
                    GameObject prefab = Resources.Load <GameObject>("Prefabs/MenuDialog");
                    if (prefab != null)
                    {
                        GameObject go = Instantiate(prefab) as GameObject;
                        go.SetActive(false);
                        go.name          = "MenuDialog";
                        ActiveMenuDialog = go.GetComponent <MenuDialog>();
                    }
                }
            }

            return(ActiveMenuDialog);
        }
        // Use this for initialization
        void _create_menu_command(string menu_dialog, Block targetBlock)
        {
            var menuDialog = MenuDialog.GetMenuDialog();

            if (menuDialog != null)
            {
                menuDialog.SetActive(true);

                menuDialog.AddOption(menu_dialog, true, false, targetBlock);
            }
        }
Ejemplo n.º 8
0
        public override void OnEnter()
        {
            if (menuDialog != null)
            {
                activeMenuDialog = menuDialog;
            }

            // Populate the static cached dialog
            GetActiveMenuDialog();

            Continue();
        }
Ejemplo n.º 9
0
        public override void OnEnter()
        {
            MenuDialog menuDialog = SetMenuDialog.GetActiveMenuDialog();

            if (menuDialog != null &&
                targetSequence != null)
            {
                menuDialog.ShowTimer(duration, targetSequence);
            }

            Continue();
        }
Ejemplo n.º 10
0
        public override void OnEnter()
        {
            MenuDialog menuDialog = MenuDialog.GetMenuDialog();

            if (menuDialog != null &&
                targetBlock != null)
            {
                menuDialog.ShowTimer(duration, targetBlock);
            }

            Continue();
        }
Ejemplo n.º 11
0
        public override void OnEnter()
        {
            var menuDialog = MenuDialog.GetMenuDialog();

            //if we shuffle every time or we haven't shuffled yet
            if (shuffleMode == Mode.Every || seed == -1)
            {
                seed = UnityEngine.Random.Range(0, 1000000);
            }

            if (menuDialog != null)
            {
                menuDialog.Shuffle(new System.Random(seed));
            }

            Continue();
        }
Ejemplo n.º 12
0
        void RememberMenu()
        {
            // if we've already found a reference, move on
            if (menuDialog != null)
            {
                return;
            }
            // find the root parent of this object

            // try to get a reference to the parent MenuDialog
            menuDialog = GetComponentInParent <MenuDialog>();
            // if we didn't find a MenuDialog then there is something wrong
            if (menuDialog == null)
            {
                // Bad problem
                Debug.LogError("Couldn't find parent MenuDialog in menu item " + this.name);
            }
        }
Ejemplo n.º 13
0
        public override void OnEnter()
        {
            if (!menuDialogName.Contains("(Clone)"))
            {
                menuDialogName = menuDialogName + "(Clone)";
            }


            var thisCanvas = StorySystem.StoryDataUtilities.StoryMainCanvas.transform;

            menuDialog = thisCanvas.Find(menuDialogName).GetComponent <MenuDialog>();
            if (menuDialog != null)
            {
                MenuDialog.ActiveMenuDialog = menuDialog;
            }

            Continue();
        }
Ejemplo n.º 14
0
        public override void OnEnter()
        {
            var menuDialog = MenuDialog.GetMenuDialog();

            if (menuDialog != null)
            {
                menuDialog.SetActive(true);

                var     flowchart   = GetFlowchart();
                string  displayText = flowchart.SubstituteVariables(text);
                manager m           = GameObject.FindGameObjectWithTag("manager").GetComponent <manager>();

                menuDialog.AddOption(displayText, interactable, () => {
                    StartCoroutine(m.switchscenes(before, after));
                });
            }


            Continue();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Extension for MenuDialog that allows AddOption to call a Lua function when an option is selected.
        /// </summary>
        public static bool AddOption(this MenuDialog menuDialog, string text, bool interactable, LuaEnvironment luaEnvironment, Closure callBack)
        {
            if (!menuDialog.gameObject.activeSelf)
            {
                menuDialog.gameObject.SetActive(true);
            }

            bool addedOption = false;

            foreach (Button button in menuDialog.cachedButtons)
            {
                if (!button.gameObject.activeSelf)
                {
                    button.gameObject.SetActive(true);

                    button.interactable = interactable;

                    Text textComponent = button.GetComponentInChildren <Text>();
                    if (textComponent != null)
                    {
                        textComponent.text = text;
                    }

                    button.onClick.AddListener(delegate {
                        menuDialog.StopAllCoroutines(); // Stop timeout
                        menuDialog.Clear();
                        menuDialog.HideSayDialog();

                        if (callBack != null)
                        {
                            luaEnvironment.RunLuaFunction(callBack, true);
                        }
                    });

                    addedOption = true;
                    break;
                }
            }

            return(addedOption);
        }
Ejemplo n.º 16
0
        public static MenuDialog GetActiveMenuDialog()
        {
            if (activeMenuDialog == null)
            {
                activeMenuDialog = GameObject.FindObjectOfType <MenuDialog>();
            }

            if (activeMenuDialog == null)
            {
                // Auto spawn a menu object from the prefab
                GameObject go = Resources.Load <GameObject>("FungusMenuDialog");
                if (go != null)
                {
                    GameObject spawnedGO = Instantiate(go) as GameObject;
                    spawnedGO.name = "MenuDialog";
                    spawnedGO.SetActive(false);
                    activeMenuDialog = spawnedGO.GetComponent <MenuDialog>();
                }
            }

            return(activeMenuDialog);
        }
Ejemplo n.º 17
0
        public override void OnEnter()
        {
            CheckEventSystem();

            MenuDialog menuDialog = SetMenuDialog.GetActiveMenuDialog();

            if (menuDialog != null)
            {
                menuDialog.gameObject.SetActive(true);

                if (hideIfVisited &&
                    targetSequence != null &&
                    targetSequence.GetExecutionCount() > 0)
                {
                    // Don't show this option
                }
                else
                {
                    menuDialog.AddOption(text, targetSequence);
                }
            }

            Continue();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Extension for MenuDialog that allows ShowTimer to call a Lua function when the timer expires.
        /// </summary>
        public static IEnumerator ShowTimer(this MenuDialog menuDialog, float duration, LuaEnvironment luaEnvironment, Closure callBack)
        {
            if (menuDialog.cachedSlider == null ||
                duration <= 0f)
            {
                yield break;
            }

            menuDialog.cachedSlider.gameObject.SetActive(true);
            menuDialog.StopAllCoroutines();

            float  elapsedTime   = 0;
            Slider timeoutSlider = menuDialog.GetComponentInChildren <Slider>();

            while (elapsedTime < duration)
            {
                if (timeoutSlider != null)
                {
                    float t = 1f - elapsedTime / duration;
                    timeoutSlider.value = t;
                }

                elapsedTime += Time.deltaTime;

                yield return(null);
            }

            menuDialog.Clear();
            menuDialog.gameObject.SetActive(false);
            menuDialog.HideSayDialog();

            if (callBack != null)
            {
                luaEnvironment.RunLuaFunction(callBack, true);
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Returns the current menu dialog
 /// </summary>
 public virtual MenuDialog GetMenuDialog()
 {
     return(MenuDialog.GetMenuDialog());
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Sync the active menu dialog with what Lua things the MenuDialog should be
 /// </summary>
 public virtual void SetMenuDialog(MenuDialog menuDialog)
 {
     MenuDialog.ActiveMenuDialog = menuDialog;
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Sync the active menu dialog with what Lua thinks the MenuDialog should be
 /// </summary>
 public void SetMenuDialog(MenuDialog menuDialog)
 {
     MenuDialog.ActiveMenuDialog = menuDialog;
 }