public void Start() { if (singleton == null) { singleton = this; } }
/// <summary> /// Prompts players to select one the players. /// </summary> /// <param name="players">The available options.</param> /// <param name="title">The title for the dialog.</param> /// <returns>Index value of the selected player.</returns> public int PromptPlayerSelection(Player[] players, string title) { int value; string helpText; UIPosition position; UIDialog dialog; position = new UIPosition(0, 1); helpText = "Use A, D or ArrowLeft and ArrowRight to select one " + "of the buttons bellow and then press Enter."; dialog = new UIDialog("userSelection", position, title, helpText, players[0].Name, players[1].Name); Screen.Add(dialog, UITitleRef.BottomLeft); dialog.Display(); value = dialog.GetSelected(); Screen.Remove(); return(value); }
void updateTurnSummary() { UIDialog turnDialog = turnDialogObj.GetComponent <UIDialog>(); turnDialog.title.text = string.Format("Year: {0:N0} | Week: {1:N0}", (turn / turnsInYear) + 1, turn % turnsInYear); turnDialog.buttonLister = new TurnSummary(cash, causalityBreaches); }
public void AddDialog(UIDialog dialog) { _dialogStack.Add(dialog); if (_dialogStack.Count == 1) sendActiveDialogChangeNotif(); }
/// <summary> /// Consstructs a new UIProgressBar instance. /// </summary> /// <param name="Screen">A UIScreen instance.</param> /// <param name="Width">The width of this UIProgressBar instance.</param> /// <param name="Parent">A UIElement that acts as a parent (optional).</param> public UIStatusBar(UIScreen Screen, Vector2 ProgressBarPosition, int Width, UIElement Parent = null) : base(Screen, Parent) { m_Font = m_Screen.Font9px; m_CSTCurrentStatus = StringManager.StrTable(210); if (Parent != null) { //Would a text edit ever be attached to anything but a UIDialog instance? Probably not. UIDialog Dialog = (UIDialog)Parent; Dialog.OnDragged += Dialog_OnDragged; } m_ProgressBarBack = new UIImage(FileManager.Instance.GetTexture((ulong)FileIDs.UIFileIDs.dialog_progressbarback), new Vector2(0, 0), Screen, null, 0.800f); m_ProgressBarFront = new UIImage(FileManager.Instance.GetTexture((ulong)FileIDs.UIFileIDs.dialog_progressbarfront), new Vector2(0, 0), Screen, null, 0.800f); string InitialValue = m_ProgressInPercentage.ToString() + " %"; m_LblCurrentStatus = new UILabel(m_CSTCurrentStatus[4], 1, Position + new Vector2(Width / 2, 0), m_Font.MeasureString(InitialValue), Color.Wheat, 9, m_Screen); Position = ProgressBarPosition; m_Size.X = Width; m_Size.Y = m_ProgressBarBack.Texture.Height; }
internal void SetCurrentDialog(UIDialog dlg) { if (this.CurrentDialog != null && this.CurrentDialog != dlg) { this.CurrentDialog.Close(); } this.CurrentDialog = dlg; }
public void PushDialogImmediately(UIDialog dialog, params object[] paras) { DialogParameter parameter = new DialogParameter(dialog, paras); UIDialogBase activeDialog = LoadScene(parameter.dialog); openedList.Add(activeDialog); activeDialog.transform.SetAsLastSibling(); activeDialog.OnSceneActivated(parameter.paras); }
private void sendActiveDialogChangeNotif() { UIDialog activeDialog = this.ActiveDialog; for (int i = 0; i < _activeDialogChangedCallbacks.Count; ++i) { _activeDialogChangedCallbacks[i](activeDialog); } }
public void AddDialog(UIDialog dialog) { _dialogStack.Add(dialog); if (_dialogStack.Count == 1) { sendActiveDialogChangeNotif(); } }
public void CloseUI() { if (mCurrentDialog) { mCurrentDialog.gameObject.SetActive(false); mCurrentDialog = null; } mDialogs.Clear(); }
/// <summary> /// A UIDialog can call this to add itself as a parent to /// this UIElement. This UIElement will then subscribe to /// the dialog's OnDragged event. /// </summary> /// <param name="Parent">The parent to add (should be a UIDialog).</param> public void AddParent(UIElement Parent) { m_Parent = Parent; DrawOrder = Parent.DrawOrder; m_Position += Parent.m_Position; UIDialog Dialog = (UIDialog)Parent; Dialog.OnDragged += Dialog_OnDragged; }
public void RemoveDialog(UIDialog dialog) { if (_dialogStack.Count > 0) { bool change = _dialogStack[0] == dialog; _dialogStack.Remove(dialog); if (change) sendActiveDialogChangeNotif(); } }
public void PushPool(UIDialog dia) { if (pools.ContainsKey(dia.Name)) { return; } else { pools.Add(dia.Name, dia); } }
void Start() { PlayerPrefs.SetInt("Position", 0); index = 1; UIDialog.SetActive(true); WajahDukun(); tuturan = "Kamu sakti sekali nak"; jeneng = "Ki Demanggung"; StartCoroutine(ShowText()); nxtbtn.SetActive(true); }
public void PopPool(UIDialog dia) { if (pools.ContainsKey(dia.Name)) { pools.Remove(dia.Name); } else { return; } }
public void RemoveDialog(UIDialog dialog) { if (_dialogStack.Count > 0) { bool change = _dialogStack[0] == dialog; _dialogStack.Remove(dialog); if (change) { sendActiveDialogChangeNotif(); } } }
public Field(GameObject dialogObj, Tilemap tilemap, Vector3Int pos, Farm farm) { this.dialog = dialogObj.GetComponent <UIDialog>(); this.tilemap = tilemap; this.pos = pos; this.Charge = farm.Charge; this.farmHarvestedCrops = farm.harvestedCrops; SpriteAtlas atlas = Resources.Load <SpriteAtlas>("game-sprites"); sprites.Add("empty_field", atlas.GetSprite("empty_field")); }
UIDialogBase FindInCache(UIDialog key) { foreach (UIDialogBase dialog in cacheList) { if (dialog.dialog == key) { cacheList.Remove(dialog); return(dialog); } } return(null); }
private void activeDialogChanged(UIDialog activeDialog) { if (activeDialog == this) { _timedCallbacks.RemoveCallbacksForOwner(this); _timedCallbacks.AddCallback(this, beginAcceptingInput, BEGIN_ACCEPTING_INPUT_DELAY); } else { _timedCallbacks.RemoveCallbacksForOwner(this); _handler.AcceptingInput = false; } }
private void activeDialogChanged(UIDialog activeDialog) { if (activeDialog == this) { _timedCallbacks.RemoveCallbacksForOwner(this); _timedCallbacks.AddCallback(this, beginAcceptingInput, BEGIN_ACCEPTING_INPUT_DELAY); } else { _timedCallbacks.RemoveCallbacksForOwner(this); _handler.AcceptingInput = false; } }
public void CloseCurrentDialog() { //m_currentDialog.GetComponent<UIDialog>().PanelClose(); m_currentDialog.gameObject.SetActive(false); m_currentDialog = null; if (m_dialogs.Count != 0) { GameObject uiDialog = m_dialogs.Pop(); uiDialog.SetActive(true); m_currentDialog = uiDialog.GetComponent <UIDialog>(); } }
public T ShowDialog <T>(Dictionary <string, object> varList = null) where T : UIDialog { if (m_currentDialog != null) { m_currentDialog.gameObject.SetActive(false); m_currentDialog = null; } string name = typeof(T).ToString(); GameObject uiObject; Transform dialogTran = m_panel.transform.Find(name); if (!dialogTran) { string perfbName = "UI/Dialog/" + typeof(T).ToString(); Debug.Log(perfbName); GameObject perfb = null; if (perfb == null) { Debug.Log("UIDialog Can`t Find Perfab"); } uiObject = GameObject.Instantiate(perfb); uiObject.name = name; T t = uiObject.AddComponent <T>(); uiObject.transform.SetParent(m_dialog.transform); //t.PanelInit(); } else { uiObject = dialogTran.gameObject; } if (uiObject) { T panel = uiObject.GetComponent <T>(); //panel.PanelOpen(); if (varList != null) { panel.m_userData = varList; } m_currentDialog = panel; m_dialogs.Push(uiObject); uiObject.SetActive(true); } return(uiObject.GetComponent <T>()); }
void Update() { if (Application.platform == RuntimePlatform.Android) { UIDialog activeDialog = GetActiveDialog().GetComponent <UIDialog>(); if (activeDialog && activeDialog.bResponseBackButton) { if (Input.GetKeyUp(KeyCode.Escape)) { activeDialog.ShowOut(); } } } }
public void CloseUI(UIPanelBase uiPanel) { if (uiPanel.GetType().IsSubclassOf(typeof(UIWindow))) { UIWindow tempWnd = windowsStack.Peek(); Debug.Log(tempWnd.name); if (!(uiPanel as UIWindow).isMain && tempWnd == uiPanel) { tempWnd = windowsStack.Pop(); tempWnd.OnDispose(); Destroy(tempWnd.gameObject); tempWnd = windowsStack.Peek(); tempWnd.gameObject.SetActive(true); tempWnd.OnShow(); } else { Debug.LogError("要关闭的界面不是栈顶元素或是栈底元素"); } } else if (uiPanel.GetType().IsSubclassOf(typeof(UIDialog))) { UIDialog tempDlg = dialogsStack.Peek(); Debug.Log(tempDlg.gameObject.name + " " + uiPanel.gameObject.name); if (tempDlg == uiPanel) { tempDlg = dialogsStack.Pop(); tempDlg.OnDispose(); Destroy(tempDlg.gameObject); if (dialogsStack.Count > 0) { tempDlg = dialogsStack.Peek(); tempDlg.OnShow(); } } else { Debug.LogError("要关闭的界面不是栈顶元素"); } } else { Debug.LogError("关闭的UI類型有問題,請檢測類型"); } }
private void personalMode() { gameSystem.currentGameMode = GameMode.personal; uiSelectModeWindow.Visible = false; var dialog = new UIDialog(gameSystem, "message", "developing"); dialog.okButtonClicked = () => { uiSelectModeWindow.Visible = true; dialog.Close(); }; dialog.Show(uiSelectModeWindow); }
public void ShowUI <T> (bool bPushHistory = true, Dictionary <string, object> varList = null) where T : UIDialog { if (mCurrentDialog != null) { mCurrentDialog.gameObject.SetActive(false); mCurrentDialog = null; } string name = typeof(T).ToString(); GameObject uiObject; if (!mAllUIs.TryGetValue(name, out uiObject)) { string perfbName = "UI/Dialog/" + typeof(T).ToString(); Debug.Log(perfbName); GameObject perfb = AssetsManager.LoadPrefabs <GameObject> (perfbName); uiObject = GameObject.Instantiate(perfb); uiObject.name = name; uiObject.AddComponent <T> (); uiObject.transform.SetParent(mDialog.transform); mAllUIs.Add(name, uiObject); } else { uiObject.SetActive(true); } if (uiObject) { T panel = uiObject.GetComponent <T> (); if (varList != null) { panel.mUserData = varList; } mCurrentDialog = panel; uiObject.SetActive(true); if (bPushHistory) { mDialogs.Enqueue(panel); } } }
public T OpenUI <T>() where T : UIPanelBase { System.Type type = typeof(T); GameObject prefab = ResourcesMgr.Instance.LoadUIPrefab(type.ToString()); if (type.IsSubclassOf(typeof(UIWindow))) { GameObject go = Instantiate(prefab, Vector3.zero, Quaternion.identity, wndParent); UIWindow wnd = go.GetComponent <UIWindow>(); wnd.OnCreate(); //创建新的主界面时,删除所有界面 if (wnd.isMain) { while (windowsStack.Count > 0) { UIWindow temp = windowsStack.Pop(); temp.OnDispose(); Destroy(temp.gameObject); } } else if (windowsStack.Count > 0) { UIWindow temp = windowsStack.Peek(); temp.OnHide(); temp.gameObject.SetActive(false); } wnd.OnShow(); windowsStack.Push(wnd); return(wnd as T); } else if (type.IsSubclassOf(typeof(UIDialog))) { GameObject go = Instantiate(prefab, Vector3.zero, Quaternion.identity, dlgParent); UIDialog dlg = go.GetComponent <UIDialog>(); dlg.OnCreate(); dlg.OnShow(); dialogsStack.Push(dlg); return(dlg as T); } else { Debug.LogError("打開的UI類型有問題,請檢測類型"); return(null); } }
private void talk() { if (!__dialog_ongoing) { __dialog_ongoing = true; GameObject ui_go = Instantiate(dialogUI); __loaded_dialog_ui = ui_go.GetComponent <UIDialog>(); __curr_dialog_index = 0; __talk_bubble.setIsTalking(true); if (!!__animator) { __animator.SetBool(__animator_talk_parm, true); } } if (__loaded_dialog_ui == null) { return; } if (!__loaded_dialog_ui.message_is_displayed() && __loaded_dialog_ui.has_a_message_to_display()) { __loaded_dialog_ui.force_display(); } else { if (__loaded_dialog_ui.overflows) { __loaded_dialog_ui.display(npc_name, __loaded_dialog_ui.overflowing_text); } else { if (__curr_dialog_index >= __dialog.Length) { end_dialog(); return; } __loaded_dialog_ui.display(npc_name, __dialog[__curr_dialog_index]); playVoice(); __curr_dialog_index++; } } }
GameObject InitDialog(string name, IButtonLister buttonLister, bool startHidden) { GameObject dialogObj = GameObject.Find("/" + name); if (dialogObj == null) { Debug.LogError("missing dialog: " + name); return(null); } print(dialogObj.name + ": " + dialogObj.activeSelf); UIDialog dialog = dialogObj.GetComponent <UIDialog>(); if (buttonLister != null && buttonLister.Buttons != null) { dialog.buttonLister = buttonLister; } if (startHidden) { dialog.HidePanel(); } return(dialogObj); }
public UIDialogBase LoadScene(UIDialog key) { UIDialogBase dialog = FindInCache(key); if (dialog == null) { string strPrefabeName = Utils.GetEnumDes(key); GameObject newSceneGameObject = Resources.Load(strPrefabeName) as GameObject; if (newSceneGameObject != null) { newSceneGameObject = UIUtils.AddChild(this.gameObject, newSceneGameObject); if (newSceneGameObject.activeSelf == true) { Debug.Log("newSceneGameObject activity true:" + newSceneGameObject.name); } else { Debug.Log("newSceneGameObject activity false:" + newSceneGameObject.name); } if (newSceneGameObject != null) { dialog = newSceneGameObject.GetComponent <UIDialogBase>(); dialog.InitializeScene(); } else { Debug.LogWarning("UISystem::LoadDialog() Failed to add new scene to parent UISystem with name: " + key); } } else { Debug.LogWarning("UISystem::LoadDialog() Failed to load new scene with name: " + key); } } return(dialog); }
//////////////// internal void Update() { if (this.CurrentDialog == null) { return; } if (Main.InGameUI.CurrentState != this.CurrentDialog) { this.CurrentDialog.Close(); } if (!this.CurrentDialog.IsOpen) { if (this.ForcedModalDialog) { this.CurrentDialog.Open(); } else { this.CurrentDialog = null; } } }
public void Initialize(Action <bool> initializationCallback = null) { GameEventsManager.EndGame.Subscribe(OnGameEnded); GameEventsManager.PauseMenu.Subscribe(OnGamePaused); UIObject uiObject = UIManager.Instance.CreateNewUIObject(UIDialogPrefabId, UILayerId.Overlay); if (uiObject == null) { initializationCallback?.Invoke(false); return; } _uiDialog = uiObject as UIDialog; if (_uiDialog == null) { initializationCallback?.Invoke(false); return; } _uiDialog.Initialize(); HideCurrentDialog(); _uiDialog.OnContinue += OnDialogContinue; initializationCallback?.Invoke(true); }
public void OnDrawGizmos(){ if(Selection.activeGameObject != null && !Application.isPlaying && this.EditorAutoScreenChange){ // If the UIScreen selected is part of this UIScreenManager if(Selection.activeGameObject.GetComponentInParent<UIScreen>() != null && this.Screens.Contains(Selection.activeGameObject.GetComponentInParent<UIScreen>())){ this.OpenScreen(Selection.activeGameObject.GetComponentInParent<UIScreen>()); // Close popups this.CurrentPopUp = null; this.CloseAllPopUp(); this.HidePopUp(); } // If the UIPopupSelected is part of this UIScreenManager else if(Selection.activeGameObject.GetComponentInParent<UIPopUp>() != null && this.Popups.Contains(Selection.activeGameObject.GetComponentInParent<UIPopUp>())){ //this.PopupCanvas.enabled = true; this.OpenPopUp(Selection.activeGameObject.GetComponentInParent<UIPopUp>()); } // If the UIDialogSelected is part of this UIScreenManager else if(Selection.activeGameObject.GetComponentInParent<UIDialog>() != null && this.Dialogs.Contains(Selection.activeGameObject.GetComponentInParent<UIDialog>())){ //this.DialogCanvas.enabled = true; this.OpenDialog(Selection.activeGameObject.GetComponentInParent<UIDialog>(), null); } else{ this.CurrentScreen = null; this.CloseAllScreen(); this.CurrentPopUp = null; this.CloseAllPopUp(); this.HidePopUp(); this.CurrentDialog = null; this.CloseAllDialog(); this.HideDialog(); } } }
/// <summary> /// Character leaves the trigger. /// </summary> /// <param name="character">Character. NOTE: This can be null if triggered by something that is not a character.</param> virtual protected bool LeaveTrigger(Character character) { if (enabled && ExitConditionsMet(character)) { if (autoLeaveRoutine != null) { StopCoroutine(autoLeaveRoutine); autoLeaveRoutine = null; } OnTriggerExited(character); for (int i = 0; i < receivers.Length; i++) { if (receivers[i] != null) { // TODO Should only be one implementation of these switch (receivers[i].leaveAction) { case TriggerActionType.SEND_MESSAGE: receivers[i].receiver.SendMessage("EnterTrigger", SendMessageOptions.DontRequireReceiver); break; case TriggerActionType.ACTIVATE_PLATFORM: receivers[i].platform.Activate(character); break; case TriggerActionType.DEACTIVATE_PLATFORM: receivers[i].platform.Deactivate(character); break; case TriggerActionType.ACTIVATE_GAMEOBJECT: receivers[i].receiver.SetActive(true); break; case TriggerActionType.DEACTIVATE_GAMEOBJECT: receivers[i].receiver.SetActive(false); break; case TriggerActionType.CHANGE_CAMERA_ZONE: PlatformCamera.DefaultCamera.ChangeZone(receivers[i].cameraZone); break; case TriggerActionType.SWITCH_SPRITE: SpriteRenderer spriteRenderer = receivers[i].receiver.GetComponentInChildren <SpriteRenderer>(); if (spriteRenderer != null) { spriteRenderer.sprite = receivers[i].newSprite; } else { Debug.LogError("Trigger tried to switch sprite but no SpriteRenderer was found"); } break; case TriggerActionType.SHOW_DIALOG: UIDialog dialog = receivers[i].receiver.GetComponentInChildren <UIDialog>(); if (dialog != null) { dialog.ShowDialog(transform); } else { Debug.LogError("Trigger tried to show dialog but no UIDialog was found."); } break; case TriggerActionType.HIDE_DIALOG: UIDialog dialogToHide = receivers[i].receiver.GetComponentInChildren <UIDialog>(); if (dialogToHide != null) { dialogToHide.HideDialog(); } else { Debug.LogError("Trigger tried to show dialog but no UIDialog was found."); } break; case TriggerActionType.OPEN_DOOR: Door doorToOpen = receivers[i].receiver.GetComponent <Door>(); if (doorToOpen != null) { doorToOpen.Open(character); } else { Debug.LogError("Trigger tried to open door but no Door was found."); } break; case TriggerActionType.CLOSE_DOOR: Door doorToClose = receivers[i].receiver.GetComponent <Door>(); if (doorToClose != null) { doorToClose.Close(character); } else { Debug.LogError("Trigger tried to close door but no Door was found."); } break; case TriggerActionType.ACTIVATE_SPAWN_POINT: RespawnPoint point = receivers[i].receiver.GetComponentInChildren <RespawnPoint>(); if (point != null) { point.SetActive(); } else { Debug.LogError("Trigger tried to activate respawn point but no RespawnPoint was found"); } break; case TriggerActionType.FORWARD: receivers[i].combiner.LeftTrigger(this, character); break; } } } return(true); } return(false); }
public void ShowDialog (string msg, bool isOneBtn, UIDialog.DialogDelegate dealMethod) { UiDialog.ShowMsgHaveBtn (msg, isOneBtn, dealMethod); }
/// <summary> /// Opens the Dialog. /// </summary> /// <param name="uip">Dialog to open.</param> /// <param name="closeMethod">Close Method used by this dialog </param> public void OpenDialog(UIDialog uid, UIDialog.CloseDialogMethod closeMethod = null){ // Setup the last screen var if (uid != this.CurrentDialog) { this.LastUIDialog = this.CurrentDialog; } //Debug.Log ("UIScreenManager.OpenScreen - "+uis.name); this.CurrentDialog = uid; this.CloseAllDialog (); this.ShowDialog (); uid.OpenDialog(closeMethod); }
/// <summary> /// Function to process the answer for multichoice dialogs /// </summary> public void ProcessMultiChoiceAnswer(UIDialog dialog, EmotionType answer) { Log.Info("Dialog "+dialog.Id+" answer:"+answer); }
// Use this for initialization void Start() { uiDialog = GameObject.FindObjectOfType<UIDialog>(); if (singleton == null) singleton = this; else { //Add a new set of quests at original singleton Instance ().quests.AddRange (quests); DestroyImmediate (this); } DontDestroyOnLoad (this); }
/// <summary> /// Open the Dialog /// </summary> /// <param name="dialogID">ID of the Dialog to open</param> /// <param name="closeMethod">Close Method used by this Dialog</param> public void OpenDialog(string dialogID, UIDialog.CloseDialogMethod closeMethod = null) { UIDialog uid = this.GetUIDialogByID(dialogID); if (uid != null) { this.OpenDialog(uid, closeMethod); } }