public void RemoveWindowsFromList(UIConsts.FORM_ID formID) { if (WindowExists(formID)) { _uiList.Remove(formID); } }
//public void ShowFormFromID(UIConsts.FORM_ID id) //{ // if (IsOpened(id)) // { // return; // } // // turn on clicks catcher // _uiCreator.ClicksCatcher.SetActive(true); // _uiCreator.ClicksCatcher.transform.SetAsLastSibling(); // // // GameObject windowObj = _uiCreator.GetFormFromID(id); // windowObj.SetActive(true); // windowObj.SendMessage("Show"); // windowObj.transform.SetAsLastSibling(); // BaseUIController window = windowObj.GetComponent<BaseUIController>(); // WindowsQueue.Add(window); // GameManager.Instance.EventManager.CallOnShowWindowEvent(); //} public void ShowFormFromID(UIConsts.FORM_ID id, EventData e) { if (id != UIConsts.FORM_ID.TUTOR_WINDOW && IsOpened(id)) { // only tutorial can be opened many times return; } if (!_uiCreator.WindowExists(id)) { _uiCreator.CreateWindow(GetFormDataByID(id)); } GameObject windowObj = _uiCreator.GetFormFromID(id); if (windowObj == null) { return; } BaseUIController window = windowObj.GetComponent <BaseUIController>(); if (window.OpenForm(e) == true) { // turn on clicks catcher _uiCreator.ShowClicksCatcher(GetFormDataByID(id).FaderType); // windowObj.SetActive(true); windowObj.SendMessage("Show"); windowObj.transform.SetAsLastSibling(); WindowsQueue.Add(window); GameManager.Instance.EventManager.CallOnShowWindowEvent(); } }
public FormData(int type, UIConsts.FORM_ID formType, string path, int faderType, EFormCreationMethod creationMethod = EFormCreationMethod.Static) { Type = type; Id = formType; CreationMethod = creationMethod; Path = path; FaderType = faderType; }
public SceneData(string name) { Menu = UIConsts.FORM_ID.NONE; Name = name; Forms = new List <FormData>(); PreloadSceneName = UIConsts.SCENE_ID.NONE; DesignResolutionWidth = 0; DesignResolutionHeight = 0; DesignMatchWidthOrHeight = 1; // by default match height }
public FormData GetFormDataByID(UIConsts.FORM_ID id) { foreach (FormData formData in _scenesData[UIConsts.SCENE_NAMES[(int)_currentScene]].Forms) { if (formData.Id == id) { return(formData); } } return(null); }
public GameObject GetFormFromID(UIConsts.FORM_ID id) { //Debug.Log ("++++++++++++++++++++++++ " + id.ToString()); if (_uiCreator != null) { return(_uiCreator.GetFormFromID(id)); } else { return(null); } }
// Возвращает ссылку на экземпляр формы типа GameObject public GameObject GetFormFromID(UIConsts.FORM_ID form) { if (_uiList.ContainsKey(form)) { GameObject f = _uiList[form]; return(f); } else { Debug.LogError("FORM NAME '" + form.ToString() + "' NOT EXIST!"); return(null); } }
private void CreateUiForms() { SceneData sceneData = _scenesData[UIConsts.SCENE_NAMES[(int)_currentScene]]; if (sceneData.Menu != UIConsts.FORM_ID.NONE) { _currentBackgroundMenu = sceneData.Menu; } _uiCreator.CreateUIs(sceneData); ShowBackgroundMenu(); if (sceneData.PreloadSceneName != UIConsts.SCENE_ID.NONE && !_scenePreloadersOperations.ContainsKey(sceneData.PreloadSceneName)) { GameManager.Instance.StartCoroutine(PreloadSceneAsync(sceneData.PreloadSceneName)); //Debug.Log("Preloading " + UIConsts.SCENE_NAMES[(int)sceneData.PreloadSceneName] + " scene in background."); } }
public bool IsOpened(UIConsts.FORM_ID id) { // find if double bool isDouble = false; for (int i = 0; i < WindowsQueue.Count; ++i) { if (WindowsQueue[i].FormID == id) { isDouble = true; break; } } if (isDouble) { return(true); } return(false); }
public void CreateWindow(FormData formData) { UIConsts.FORM_ID formID = formData.Id; // проверка на наличие дублей форм if (_uiList.ContainsKey(formID)) { Debug.LogError("FORM TYPE '" + formID.ToString() + "' ALREADY EXISTS"); return; } Object loadetPrefab = Resources.Load(formData.Path); if (loadetPrefab == null) { Debug.LogError("PREFAB '" + formData.Path + "' NOT EXIST!"); return; } GameObject obj = (GameObject)Instantiate(loadetPrefab); obj.name = formID.ToString(); obj.transform.SetParent(_newCanvas.transform, false); obj.GetComponent <BaseUIController>().CreationMethod = formData.CreationMethod; _uiList.Add(formID, obj); RectTransform rectTransf = obj.GetComponent <RectTransform>(); // start position rectTransf.pivot = new Vector2(0.5f, 0.5f); rectTransf.anchorMin = new Vector2(0f, 0f); rectTransf.anchorMax = new Vector2(1f, 1f); rectTransf.sizeDelta = new Vector2(0f, 0f); rectTransf.anchoredPosition3D = UIConsts.START_POSITION; // scale //obj.transform.localScale = new Vector3(formData.scale, formData.scale, 1); //BoardUIResponder resp = obj.GetComponent<BoardUIResponder>(); //if (resp != null) //{ // resp.AfterUIInitialized(); //} }
public void FindWindowOnSceneOrCreate(FormData formData) { UIConsts.FORM_ID formID = formData.Id; GameObject newForm = null; string formName = formID.ToString(); foreach (var w in WindowsAvailableAtStart) { if (w.name == formName) { newForm = w; break; } } if (newForm != null) { newForm.GetComponent <BaseUIController>().CreationMethod = formData.CreationMethod; _uiList.Add(formID, newForm); } else { CreateWindow(formData); } }
private void OnOpenFormNeeded(EventData e) { UIConsts.FORM_ID formId = (UIConsts.FORM_ID)e.Data["form"]; ShowFormFromID(formId, e); }
private void parseXmlData() { TextAsset _xmlString = Resources.Load <TextAsset>("Data/GameFlow"); NanoXMLDocument document = new NanoXMLDocument(_xmlString.text); NanoXMLNode RotNode = document.RootNode; foreach (NanoXMLNode node in RotNode.SubNodes) { if (node.Name.Equals("screens")) { foreach (NanoXMLNode nodeScreens in node.SubNodes) { string sceneName = nodeScreens.GetAttribute("name").Value; SceneData sceneData = new SceneData(sceneName); string preloadNextScene = nodeScreens.GetAttribute("preloadNextScene").Value; if (!String.IsNullOrEmpty(preloadNextScene)) { sceneData.PreloadSceneName = convertSceneNameToID(preloadNextScene); } string designResolutionWidth = nodeScreens.GetAttribute("DesignResolutionWidth").Value; if (!String.IsNullOrEmpty(designResolutionWidth)) { sceneData.DesignResolutionWidth = Int32.Parse(designResolutionWidth); } string designResolutionHeight = nodeScreens.GetAttribute("DesignResolutionHeight").Value; if (!String.IsNullOrEmpty(designResolutionHeight)) { sceneData.DesignResolutionHeight = Int32.Parse(designResolutionHeight); } string designMatchWidthOrHeight = nodeScreens.GetAttribute("DesignMatchWidthOrHeight").Value; if (!String.IsNullOrEmpty(designMatchWidthOrHeight)) { sceneData.DesignMatchWidthOrHeight = float.Parse(designMatchWidthOrHeight); } if (nodeScreens.Name.Equals("screen")) { foreach (NanoXMLNode nodeScreensScreen in nodeScreens.SubNodes) { string formName = nodeScreensScreen.GetAttribute("name").Value.ToString(); UIConsts.FORM_ID formID = (UIConsts.FORM_ID)System.Enum.Parse(typeof(UIConsts.FORM_ID), formName); int formType = int.Parse(nodeScreensScreen.GetAttribute("type").Value); EFormCreationMethod creationMethod = EFormCreationMethod.Static; string path = UIConsts.DEFAULT_UI_PATH + formName; NanoXMLAttribute attrPath = nodeScreensScreen.GetAttribute("path"); if (attrPath != null) { path = attrPath.Value; } int faderType = 1; //show transparrent NanoXMLAttribute attrFader = nodeScreensScreen.GetAttribute("fader"); if (attrFader != null) { faderType = int.Parse(attrFader.Value); } NanoXMLAttribute attr = nodeScreensScreen.GetAttribute("creation"); if (attr != null) { if (!string.IsNullOrEmpty(attr.Value)) { if (attr.Value.ToLower() == "static") { creationMethod = EFormCreationMethod.Static; } else if (attr.Value.ToLower() == "dynamic") { creationMethod = EFormCreationMethod.Dynamic; } } } FormData formData = new FormData(formType, formID, path, faderType, creationMethod); sceneData.Forms.Add(formData); if (formType == 1) { sceneData.Menu = formID; } } } _scenesData.Add(sceneName, sceneData); } } } }
public void OnDestroyWindow(UIConsts.FORM_ID formID) { _uiCreator.RemoveWindowsFromList(formID); }
public bool WindowExists(UIConsts.FORM_ID formID) { return(_uiList.ContainsKey(formID)); }