void createLoading() { if (queuePushDialogData.Count == 0 || loadingContainerClone != null) { canSrollToBottom = false; fastForwardBtn.gameObject.SetActive(false); return; } fastForwardBtn.gameObject.SetActive(true); if (loadingContainerObj == null) { loadingContainerObj = Statics.GetPrefab("Prefabs/UI/GridItems/TaskDetailDialogs/TaskDetailDialogLoadingContainer"); } if (loadingContainerClone != null) { Destroy(loadingContainerClone); loadingContainerClone = null; } loadingContainerClone = Statics.GetPrefabClone(loadingContainerObj); loadingContainerClone.name = "loadingContainer"; pushItemToGrid(loadingContainerClone.transform); taskDetailDialogLoadingContainer = loadingContainerClone.GetComponent <TaskDetailDialogLoadingContainer>(); taskDetailDialogLoadingContainer.UpdateData(() => { canPushDialog = true; loadingContainerClone = null; taskDetailDialogLoadingContainer = null; }); }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/RoleOfWinShopContainer"); } GameObject itemPrefab; RoleData role; RoleOfWinShopContainer container; for (int i = 0; i < rolesData.Count; i++) { role = rolesData[i]; if (roleContainers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <RoleOfWinShopContainer>(); roleContainers.Add(container); } else { container = roleContainers[i]; } container.UpdateData(role); container.RefreshView(); } // RectTransform trans = grid.GetComponent<RectTransform>(); // float y = (grid.cellSize.y + grid.spacing.y) * Mathf.Ceil(roleContainers.Count / 3) - grid.spacing.y; // y = y < 0 ? 0 : y; // trans.sizeDelta = new Vector2(trans.sizeDelta.x, y); }
public override void RefreshView() { for (int i = 0; i < taskContainers.Count; i++) { Destroy(taskContainers[i].gameObject); } taskContainers.Clear(); if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/TaskItemContainer"); } GameObject itemPrefab; TaskData task; TaskItemContainer container; for (int i = 0; i < taskList.Count; i++) { task = taskList[i]; itemPrefab = Statics.GetPrefabClone(prefabObj); itemPrefab.name = i.ToString(); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <TaskItemContainer>(); container.UpdateData(task); container.RefreshView(); taskContainers.Add(container); } grid.GetComponent <RectTransform>().sizeDelta = new Vector2(grid.cellSize.x, (grid.cellSize.y + grid.spacing.y) * taskContainers.Count - grid.spacing.y); }
public override void RefreshView() { refreshEnemy(); refreshTeamBlood(); refreshLimePowder(); DrugInBattleItemContainer drugContainer; for (int i = 0, len = drugsData.Count; i < len; i++) { drugContainer = Statics.GetPrefabClone(drugPrefab).GetComponent <DrugInBattleItemContainer>(); MakeToParent(drugsGrid.transform, drugContainer.transform); drugContainer.UpdateData(drugsData[i]); drugContainer.RefreshView(); drugInBattleItemContainers.Add(drugContainer); } TeamInBattleItemContainer teamContainer; for (int i = 0, len = teamsData.Count; i < len; i++) { teamContainer = Statics.GetPrefabClone(teamPrefab).GetComponent <TeamInBattleItemContainer>(); MakeToParent(teamsGrid.transform, teamContainer.transform); teamContainer.UpdateData(teamsData[i]); teamContainer.RefreshView(); teamInBattleItemContainers.Add(teamContainer); } //绝学视图 if (teamsData.Count > 0) { teamInBattleLostKnowledgeContainer.UpdateData(teamsData[0], true); teamInBattleLostKnowledgeContainer.RefreshView(); } SoundManager.GetInstance().PlayBGM("bgm0004"); }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/StoreItemContainer"); } GameObject itemPrefab; ItemData item; StoreItemContainer container; for (int i = 0; i < itemsData.Count; i++) { item = itemsData[i]; if (itemContainers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <StoreItemContainer>(); itemContainers.Add(container); } else { container = itemContainers[i]; } container.UpdateData(item); container.RefreshView(); } RectTransform trans = grid.GetComponent <RectTransform>(); float y = (grid.cellSize.y + grid.spacing.y) * Mathf.Ceil(itemContainers.Count / 2) - grid.spacing.y; y = y < 0 ? 0 : y; trans.sizeDelta = new Vector2(trans.sizeDelta.x, y); RefreshSilverNumView(); // bankBtn.gameObject.SetActive(UserModel.CurrentUserData.CurrentCitySceneId != "00001" && UserModel.CurrentUserData.CurrentCitySceneId != "0001"); }
public void RefreshWeaponBreakingView() { weaponNunText.text = string.Format("兵器匣:{0}/{1}", weaponBreakings.Count, DbManager.Instance.MaxWeaponNum); if (prefabBreakWeaponObj == null) { prefabBreakWeaponObj = Statics.GetPrefab("Prefabs/UI/GridItems/WorkshopWeaponBreakingContainer"); } GameObject itemPrefab; WorkshopWeaponBreakingContainer container; WeaponData weapon; for (int i = 0; i < weaponBreakings.Count; i++) { weapon = weaponBreakings[i]; if (weaponBreakingContainers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabBreakWeaponObj); MakeToParent(weaponBreakingGrid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <WorkshopWeaponBreakingContainer>(); weaponBreakingContainers.Add(container); } else { container = weaponBreakingContainers[i]; } container.UpdateData(weapon); container.RefreshView(); } RectTransform trans = weaponBreakingGrid.GetComponent <RectTransform>(); trans.sizeDelta = new Vector2(trans.sizeDelta.x, (weaponBreakingGrid.cellSize.y + weaponBreakingGrid.spacing.y) * Mathf.Ceil(weaponBreakingContainers.Count * 0.5f) - weaponBreakingGrid.spacing.y); }
/// <summary> /// Creates the user interface prefab. /// </summary> /// <returns>The user interface prefab.</returns> /// <param name="parent">Parent.</param> /// <param name="path">Path.</param> /// <param name="offsetWidth">Offset width.</param> /// <param name="offsetHeight">Offset height.</param> protected static GameObject CreateUIPrefab(Transform parent, string path, float offsetWidth = 0, float offsetHeight = 0) { GameObject winObj = Statics.GetPrefabClone(path); if (winObj != null) { RectTransform rectTrans = winObj.GetComponent <RectTransform>(); Vector2 offsetMin; Vector2 offsetMax; Vector2 sizeDelta = rectTrans.sizeDelta; if (offsetWidth == 0 && offsetHeight == 0) { offsetMin = rectTrans.offsetMin; offsetMax = rectTrans.offsetMax; } else { offsetMin = new Vector2(offsetWidth, offsetHeight); offsetMax = new Vector2(offsetWidth, offsetHeight); } winObj.transform.SetParent(parent); rectTrans.localScale = Vector3.one; rectTrans.offsetMin = offsetMin; rectTrans.offsetMax = offsetMax; rectTrans.sizeDelta = sizeDelta; rectTrans.localPosition = new Vector3(rectTrans.localPosition.x, rectTrans.localPosition.y, 0); rectTrans = null; return(winObj); } return(null); }
public override void RefreshView() { RefreshResultResourcesView(); if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/WorkshopResourceContainer"); } GameObject itemPrefab; WorkshopResourceContainer container; ResourceData resource; for (int i = 0; i < resources.Count; i++) { resource = resources[i]; if (resourceContainers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(resourceGrid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <WorkshopResourceContainer>(); resourceContainers.Add(container); } else { container = resourceContainers[i]; } container.UpdateData(resource); container.RefreshView(); } RectTransform trans = resourceGrid.GetComponent <RectTransform>(); trans.sizeDelta = new Vector2(trans.sizeDelta.x, (resourceGrid.cellSize.y + resourceGrid.spacing.y) * Mathf.Ceil(resourceContainers.Count * 0.5f) - resourceGrid.spacing.y); Messenger.Broadcast(NotifyTypes.ModifyResources); }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/SellItemContainer"); } GameObject itemPrefab; ItemData item; SellItemContainer container; for (int i = 0; i < itemsData.Count; i++) { item = itemsData[i]; if (itemContainers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <SellItemContainer>(); itemContainers.Add(container); } else { container = itemContainers[i]; } container.UpdateData(item); container.RefreshView(); } RectTransform trans = grid.GetComponent <RectTransform>(); float y = (grid.cellSize.y + grid.spacing.y) * Mathf.Ceil(itemContainers.Count / 5) - grid.spacing.y; y = y < 0 ? 0 : y; trans.sizeDelta = new Vector2(trans.sizeDelta.x, y); MakeSelectedItem(); }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/BagItemContainer"); } for (int i = 0; i < itemContainers.Count; i++) { if (itemContainers[i].gameObject != null) { Destroy(itemContainers[i].gameObject); } } itemContainers.Clear(); GameObject itemPrefab; ItemData item; BagItemContainer container; for (int i = 0; i < itemsData.Count; i++) { item = itemsData[i]; itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <BagItemContainer>(); itemContainers.Add(container); container.UpdateData(item); container.RefreshView(); } // RectTransform trans = grid.GetComponent<RectTransform>(); // float y = (grid.cellSize.y + grid.spacing.y) * Mathf.Ceil(itemContainers.Count / 2) - grid.spacing.y; // y = y < 0 ? 0 : y; // trans.sizeDelta = new Vector2(trans.sizeDelta.x, y); silverText.text = silverNum.ToString(); totalText.text = string.Format("{0}/{1}", itemsData.Count, DbManager.Instance.MaxItemNumOfBag); }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/RecordItemContainer"); } if (recordsData.Count > 0) { JArray record; GameObject itemPrefab; RecordItemContainer container; for (int i = 0; i < recordsData.Count; i++) { record = recordsData[i]; if (recordContainers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <RecordItemContainer>(); recordContainers.Add(container); } else { container = recordContainers[i]; } container.UpdateData(record); container.RefreshView(); } RectTransform trans = grid.GetComponent <RectTransform>(); trans.sizeDelta = new Vector2(trans.sizeDelta.x, (grid.cellSize.y + grid.spacing.y) * recordContainers.Count - grid.spacing.y); } }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/BookOfForbiddenAreaContainer"); } GameObject itemPrefab; BookData book; BookOfForbiddenAreaContainer container; for (int i = 0; i < booksData.Count; i++) { book = booksData[i]; book.MakeJsonToModel(); if (bookContainers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <BookOfForbiddenAreaContainer>(); bookContainers.Add(container); } else { container = bookContainers[i]; } container.UpdateData(book, hostRoleData); container.RefreshView(); } RectTransform trans = grid.GetComponent <RectTransform>(); float y = (grid.cellSize.y + grid.spacing.y) * Mathf.Ceil(bookContainers.Count / 3) - grid.spacing.y; y = y < 0 ? 0 : y; trans.sizeDelta = new Vector2(trans.sizeDelta.x, y); }
/// <summary> /// 拿起兵器 /// </summary> /// <param name="weaponId">Weapon identifier.</param> public void PickUpWeapon(string weaponId) { PickDownWeapon(); GameObject weapon = Statics.GetPrefabClone("Prefabs/Avatars/Weapon/" + weaponId); RightHand.enabled = false; weapon.transform.SetParent(RightHand.transform); weapon.transform.localPosition = Vector3.zero; weapon.transform.localScale = Vector3.one; weapon.transform.localEulerAngles = Vector3.zero; }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/WeaponItemContainer"); } if (weaponsData.Count > 0) { WeaponData weapon = weaponsData[0]; if (weapon != null) { hostWeaponItemContainer.gameObject.SetActive(true); hostWeaponItemContainer.UpdateData(weapon, weapon, hostRoleData); hostWeaponItemContainer.RefreshView(); } else { hostWeaponItemContainer.gameObject.SetActive(false); } if (weaponsData.Count > 0) { GameObject itemPrefab; WeaponItemContainer container; for (int i = 1; i < weaponsData.Count; i++) { weapon = weaponsData[i]; if (weaponContainers.Count <= (i - 1)) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <WeaponItemContainer>(); weaponContainers.Add(container); } else { container = weaponContainers[i - 1]; } container.UpdateData(weapon, weaponsData[0], hostRoleData); container.RefreshView(); } //移除多余的container if (weaponContainers.Count > weaponsData.Count - 1) { for (int i = weaponContainers.Count - 1; i >= weaponsData.Count - 1; i--) { Destroy(weaponContainers[i].gameObject); weaponContainers.RemoveAt(i); } } RectTransform trans = grid.GetComponent <RectTransform>(); trans.sizeDelta = new Vector2(trans.sizeDelta.x, (grid.cellSize.y + grid.spacing.y) * weaponContainers.Count - grid.spacing.y); } } }
void createNpcContainer(NpcData npc) { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/NpcItemContainer"); } GameObject itemPrefab = Statics.GetPrefabClone(prefabObj); itemPrefab.name = npc.Id; MakeToParent(npcsGrid.transform, itemPrefab.transform); NpcContainer container = itemPrefab.GetComponent <NpcContainer>(); container.SetNpcData(npc); npcContainersMapping.Add(npc.Id, container); }
void Update() { if (queue.Count > 0) { if (Time.fixedTime - date > 0.1f) { date = Time.fixedTime; string popContext = queue.Dequeue(); contexts.Add(popContext); FreeHeightText freeHeightText = Statics.GetPrefabClone(prefab).GetComponent <FreeHeightText>(); MakeToParent(transform, freeHeightText.transform); freeHeightText.Text.rectTransform.anchoredPosition = new Vector2(0, -Height); freeHeightText.SetValue(popContext); freeHeightTexts.Add(freeHeightText); StartCoroutine(refresh()); } } }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/BookItemContainer"); } if (booksData.Count > 0) { emptyImage.gameObject.SetActive(false); BookData book; GameObject itemPrefab; BookItemContainer container; for (int i = 0; i < booksData.Count; i++) { book = booksData[i]; if (bookContainers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <BookItemContainer>(); bookContainers.Add(container); } else { container = bookContainers[i]; } container.Index = i; container.UpdateData(book); container.RefreshView(); } RectTransform trans = grid.GetComponent <RectTransform>(); trans.sizeDelta = new Vector2(trans.sizeDelta.x, (grid.cellSize.y + grid.spacing.y) * bookContainers.Count - grid.spacing.y); scroll.verticalNormalizedPosition = 1; } else { emptyImage.gameObject.SetActive(true); } refreshRedPoints(); }
public override void RefreshView() { iconImage.sprite = Statics.GetIconSprite(bookData.IconId); nameText.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(bookData.Quality), bookData.Name); descText.text = string.Format("{0}{1}描述:\n{2}", bookData.LimitWeaponType != WeaponType.None ? string.Format("兵器限制:{0}\n", Statics.GetEnmuDesc <WeaponType>(bookData.LimitWeaponType)) : "", info != "" ? string.Format("附加属性:\n<color=\"#00FF00\">{0}</color>", info) : "", bookData.Desc); if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/SkillItemContainer"); } if (bookData.Skills.Count > 0) { emptyImage.gameObject.SetActive(false); SkillData skill; GameObject itemPrefab; SkillItemContainer container; for (int i = 0; i < bookData.Skills.Count; i++) { skill = bookData.Skills[i]; if (containers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(gridTrans.transform, itemPrefab.transform); container = itemPrefab.GetComponent <SkillItemContainer>(); containers.Add(container); } else { container = containers[i]; } container.UpdateData(skill, i != bookData.Skills.Count - 1); container.RefreshView(); } } else { emptyImage.gameObject.SetActive(true); } }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/RoleOfHospitalContainer"); } GameObject itemPrefab; RoleData role; RoleOfHospitalContainer container; bool hasBeenInjury = false; for (int i = 0; i < rolesData.Count; i++) { role = rolesData[i]; if (roleContainers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <RoleOfHospitalContainer>(); roleContainers.Add(container); } else { container = roleContainers[i]; } container.UpdateData(role); container.RefreshView(); if (role.Injury != InjuryType.None) { hasBeenInjury = true; } } RectTransform trans = grid.GetComponent <RectTransform>(); float y = (grid.cellSize.y + grid.spacing.y) * Mathf.Ceil(roleContainers.Count / 3) - grid.spacing.y; y = y < 0 ? 0 : y; trans.sizeDelta = new Vector2(trans.sizeDelta.x, y); cameraBtn.gameObject.SetActive(hasBeenInjury); }
public override void RefreshView() { if (rolesData.Count > 0) { hostRoleContainer.UpdateData(rolesData[0]); hostRoleContainer.RefreshView(); if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/ReadyToTraveRoleContainer"); } GameObject itemPrefab; RoleData role; ReadyToTraveRoleContainer container; for (int i = 1; i < rolesData.Count; i++) { role = rolesData[i]; if (roleContainers.Count <= (i - 1)) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <ReadyToTraveRoleContainer>(); roleContainers.Add(container); } else { container = roleContainers[i - 1]; } container.UpdateData(role); container.RefreshView(); } RectTransform trans = grid.GetComponent <RectTransform>(); float y = (grid.cellSize.y + grid.spacing.y) * roleContainers.Count - grid.spacing.y; y = y < 0 ? 0 : y; trans.sizeDelta = new Vector2(trans.sizeDelta.x, y); } foodIcon.sprite = Statics.GetIconSprite("600000"); foodNumText.text = string.Format("{0}/{1}", foodData.Num, foodData.MaxNum); RefreshSelectedRolesView(); }
void popDialog(JArray dialogData, bool willDuring = false) { if (dialogData == null) { return; } string dialogId = dialogData[0].ToString(); TaskDialogType dialogType = (TaskDialogType)((short)dialogData[1]); switch (dialogType) { case TaskDialogType.Choice: TaskDetailDialogChoiceContainer choiceContainer; if (!containersMapping.ContainsKey(dialogId)) { if (choiceContainerObj == null) { choiceContainerObj = Statics.GetPrefab("Prefabs/UI/GridItems/TaskDetailDialogs/TaskDetailDialogChoiceContainer"); } choiceContainer = Statics.GetPrefabClone(choiceContainerObj).GetComponent <TaskDetailDialogChoiceContainer> (); pushItemToGrid(choiceContainer.transform); containersMapping.Add(dialogId, choiceContainer); } choiceContainer = (TaskDetailDialogChoiceContainer)containersMapping[dialogId]; choiceContainer.UpdateData(taskId, dialogData, willDuring); choiceContainer.RefreshView(); break; case TaskDialogType.JustTalk: TaskDetailDialogTalkContainer talkContainer; if (!containersMapping.ContainsKey(dialogId)) { if (dialogData[4].ToString() == "{0}") { if (talkRightContainerObj == null) { talkRightContainerObj = Statics.GetPrefab("Prefabs/UI/GridItems/TaskDetailDialogs/TaskDetailDialogTalkRightContainer"); } talkContainer = Statics.GetPrefabClone(talkRightContainerObj).GetComponent <TaskDetailDialogTalkContainer>(); } else { if (talkLeftContainerObj == null) { talkLeftContainerObj = Statics.GetPrefab("Prefabs/UI/GridItems/TaskDetailDialogs/TaskDetailDialogTalkLeftContainer"); } talkContainer = Statics.GetPrefabClone(talkLeftContainerObj).GetComponent <TaskDetailDialogTalkContainer>(); } pushItemToGrid(talkContainer.transform); containersMapping.Add(dialogId, talkContainer); } talkContainer = (TaskDetailDialogTalkContainer)containersMapping[dialogId]; talkContainer.UpdateData(taskId, dialogData, willDuring); talkContainer.RefreshView(); break; case TaskDialogType.FightWined: TaskDetailDialogFightContainer fightContainer; if (!containersMapping.ContainsKey(dialogId)) { if (fightContainerObj == null) { fightContainerObj = Statics.GetPrefab("Prefabs/UI/GridItems/TaskDetailDialogs/TaskDetailDialogFightContainer"); } fightContainer = Statics.GetPrefabClone(fightContainerObj).GetComponent <TaskDetailDialogFightContainer> (); pushItemToGrid(fightContainer.transform); containersMapping.Add(dialogId, fightContainer); } fightContainer = (TaskDetailDialogFightContainer)containersMapping[dialogId]; fightContainer.UpdateData(taskId, dialogData, willDuring); fightContainer.RefreshView(); break; default: TaskDetailDialogNoticeContainer noticeContainer; if (!containersMapping.ContainsKey(dialogId)) { if (noticeContainerObj == null) { noticeContainerObj = Statics.GetPrefab("Prefabs/UI/GridItems/TaskDetailDialogs/TaskDetailDialogNoticeContainer"); } noticeContainer = Statics.GetPrefabClone(noticeContainerObj).GetComponent <TaskDetailDialogNoticeContainer>(); pushItemToGrid(noticeContainer.transform); containersMapping.Add(dialogId, noticeContainer); } noticeContainer = (TaskDetailDialogNoticeContainer)containersMapping[dialogId]; noticeContainer.UpdateData(taskId, dialogData, willDuring); noticeContainer.RefreshView(); break; } }