private void StartConstruct() { if (!CurrentPreview) { return; } if (CurrentPreview.StartConstruct()) { ProgressBar.Instance.New(CurrentPreview.Data.currentStage.BuildTime, delegate { return(CurrentPreview.Data.currentStage.BuildTime - CurrentPreview.Data.leftBuildTime); }, delegate { return(CurrentPreview == null || CurrentPreview.Data == null || !CurrentPreview.Data.IsBuilding); }, delegate { if (CurrentPreview) { CurrentPreview.PauseConstruct(); } }, "施工中"); } ZetanUtility.SetActive(morePanel, false); }
private void Awake() { #if UNITY_STANDALONE EnableJoyStick(false); ZetanUtility.SetActive(JoyStick.gameObject, false); ZetanUtility.SetActive(JoyStick.KnobBackground.gameObject, false); #elif UNITY_ANDROID ZetanUtility.SetActive(JoyStick.gameObject, true); #endif ZetanUtility.SetActive(InteractionButton.gameObject, false); questButton.onClick.AddListener(QuestManager.Instance.OpenCloseWindow); backpackButton.onClick.AddListener(BackpackManager.Instance.OpenCloseWindow); calendarButton.onClick.AddListener(CalendarManager.Instance.OpenCloseWindow); buildingButton.onClick.AddListener(BuildingManager.Instance.OpenCloseWindow); settingButton.onClick.AddListener(EscapeMenuManager.Instance.OpenCloseWindow); if (!dontDestroyOnLoadOnce) { DontDestroyOnLoad(this); dontDestroyOnLoadOnce = true; } else { DestroyImmediate(gameObject); } }
public void Mark(bool mark = true) { if (this.mark) { ZetanUtility.SetActive(this.mark, !IsEmpty && mark); } }
public void UpdateInfo() { totalDays.text = MCrop.totalGrowthDays.ToString(); ZetanUtility.SetActive(dryIcon.gameObject, MCrop.Dry); ZetanUtility.SetActive(pestIcon.gameObject, MCrop.Pest); ZetanUtility.SetActive(matureIcon.gameObject, MCrop.currentStage.HarvestAble); }
public void OptionPageDown() { if (Page >= MaxPage || !IsUIOpen || IsPausing) { return; } int leftLineCount = UI.lineAmount - (int)(UI.wordsText.preferredHeight / UI.textLineHeight); if (Page < Mathf.CeilToInt(optionAgents.Count * 1.0f / (leftLineCount * 1.0f))) { for (int i = 0; i < leftLineCount; i++) { if ((Page - 1) * leftLineCount + i < optionAgents.Count && (Page - 1) * leftLineCount + i >= 0) { ZetanUtility.SetActive(optionAgents[(Page - 1) * leftLineCount + i].gameObject, false); } if (Page * leftLineCount + i >= 0 && Page * leftLineCount + i < optionAgents.Count) { ZetanUtility.SetActive(optionAgents[Page * leftLineCount + i].gameObject, true); } } Page++; } if (Page >= MaxPage && MaxPage > 1) { SetPageArea(true, false, true); } else if (Page < MaxPage && MaxPage > 1) { SetPageArea(true, true, true); } UI.pageText.text = Page.ToString() + "/" + MaxPage.ToString(); }
public void OptionPageUp() { if (Page <= 1 || !IsUIOpen || IsPausing) { return; } int leftLineCount = UI.lineAmount - (int)(UI.wordsText.preferredHeight / UI.textLineHeight); if (Page > 0) { Page--; for (int i = 0; i < leftLineCount; i++) { if ((Page - 1) * leftLineCount + i < optionAgents.Count && (Page - 1) * leftLineCount + i >= 0) { ZetanUtility.SetActive(optionAgents[(Page - 1) * leftLineCount + i].gameObject, true); } if (Page * leftLineCount + i >= 0 && Page * leftLineCount + i < optionAgents.Count) { ZetanUtility.SetActive(optionAgents[Page * leftLineCount + i].gameObject, false); } } } if (Page <= 1 && MaxPage > 1) { SetPageArea(false, true, true); } else if (Page > 1 && MaxPage > 1) { SetPageArea(true, true, true); } UI.pageText.text = Page.ToString() + "/" + MaxPage.ToString(); }
/// <summary> /// 生成分支对话选项 /// </summary> private void MakeNormalOption() { if (wordsToSay.Count < 1 || wordsToSay.Peek().Options.Count < 1) { return; } DialogueWords currentWords = wordsToSay.Peek(); dialogueDatas.TryGetValue(currentDialog.ID, out DialogueData dialogDataFound); if (CurrentType == DialogueType.Normal) { ClearOptions(OptionType.Quest, OptionType.Objective); } else { ClearOptions(); } bool isLastWords = currentDialog.IndexOfWords(wordsToSay.Peek()) == currentDialog.Words.Count - 1; foreach (WordsOption option in currentWords.Options) { if (option.OptionType == WordsOptionType.Choice && dialogDataFound != null) { DialogueWordsData wordsDataFound = dialogDataFound.wordsDatas.Find(x => x.wordsIndex == currentDialog.IndexOfWords(currentWords)); //这个选择型分支是否完成了 if (isLastWords || wordsDataFound != null && wordsDataFound.IsOptionCmplt(currentWords.IndexOfOption(option))) { continue;//是最后一句话或者选项完成则跳过创建 } } if (option.IsValid) { if (option.OptionType == WordsOptionType.OnlyGet && (option.ShowOnlyWhenNotHave && BackpackManager.Instance.HasItemWithID(option.ItemCanGet.ItemID) || option.OnlyForQuest && option.BindedQuest && !QuestManager.Instance.HasOngoingQuestWithID(option.BindedQuest.ID))) { continue;//若已持有当前选项给的道具,或者需任务驱动但任务未接取,则跳过创建 } else if (option.OptionType == WordsOptionType.SubmitAndGet && option.OnlyForQuest && option.BindedQuest && !QuestManager.Instance.HasOngoingQuestWithID(option.BindedQuest.ID)) { continue;//若需当前选项需任务驱动但任务未接取,则跳过创建 } OptionAgent oa = ObjectPool.Get(UI.optionPrefab, UI.optionsParent, false).GetComponent <OptionAgent>(); oa.Init(option.Title, option); optionAgents.Add(oa); } } //把第一页以外的选项隐藏 for (int i = UI.lineAmount - (int)(UI.wordsText.preferredHeight / UI.textLineHeight); i < optionAgents.Count; i++) { ZetanUtility.SetActive(optionAgents[i].gameObject, false); } if (optionAgents.Count < 1) { MakeContinueOption();//如果所有选择型分支都完成了,则可以进行下一句对话 } CheckPages(); //Debug.Log("make"); //Debug.Log(optionAgents.Count); }
public void ResetIcon() { Current = null; onEndDrag = null; raycastResults.Clear(); ZetanUtility.SetActive(icon.gameObject, false); }
public void ShowDescription(ItemBase item) { if (!item) { return; } currentItem = item; List <string> info = BackpackManager.Instance.GetMaterialsInfo(currentItem.Materials).ToList(); StringBuilder materials = new StringBuilder("<b>持有数量:</b>" + BackpackManager.Instance.GetItemAmount(item)); materials.Append("\n<b>制作材料:</b>"); materials.Append(BackpackManager.Instance.IsMaterialsEnough(item.Materials) ? "<color=green>(可制作)</color>\n" : "<color=red>(耗材不足)</color>\n"); for (int i = 0; i < info.Count; i++) { materials.Append(info[i] + (i == info.Count - 1 ? string.Empty : "\n")); } UI.description.text = materials.ToString(); int makeAmount = BackpackManager.Instance.GetAmountCanMake(currentItem.Materials); UI.icon.SetItem(new ItemInfo(currentItem, makeAmount)); UI.nameText.text = item.name; UI.makeButton.interactable = makeAmount > 0; UI.descriptionWindow.alpha = 1; UI.descriptionWindow.blocksRaycasts = true; ZetanUtility.SetActive(UI.loopToggle.gameObject, currentItem.DIYAble); }
public void StartOneWords(DialogueWords words, Dialogue dialogToGoBack = null, int indexToGoBack = -1) { if (!UI || !words.IsValid) { Debug.Log(words.Words); Debug.Log(words.TalkerType); Debug.Log(words.TalkerInfo); return; } IsTalking = true; wordsToSay.Clear(); wordsToSay.Enqueue(words); MakeContinueOption(true); ZetanUtility.SetActive(UI.wordsText.gameObject, true); SetPageArea(false, false, false); if (dialogToGoBack && indexToGoBack > -1) { if (waitToGoBackRoutine != null) { StopCoroutine(waitToGoBackRoutine); } currentDialog = dialogToGoBack; this.indexToGoBack = indexToGoBack; waitToGoBackRoutine = StartCoroutine(WaitToGoBack()); } }
private float cleanDelayTime = 600.0f;//池子东西放多放久了臭,要按时排掉 public static void Put(GameObject gameObject) { if (!gameObject) { return; } if (!Instance || Instance.pool.Count > Instance.capacity) { Destroy(gameObject); return; } if (Instance.putDelayCoroutines.TryGetValue(gameObject, out var c)) { Instance.StopCoroutine(c); } ZetanUtility.SetActive(gameObject, false); gameObject.transform.SetParent(Instance.poolRoot, false); string name = gameObject.name.EndsWith("(Clone)") ? gameObject.name : gameObject.name + "Clone"; Instance.pool.TryGetValue(name, out var oListFound); if (oListFound != null) { if (!oListFound.Contains(gameObject)) { oListFound.Add(gameObject); } } else { Instance.pool.Add(name, new HashSet <GameObject>() { gameObject }); } }
public static GameObject Get(GameObject prefab, Transform parent = null, bool worldPositionStays = false) { if (!Instance) { return(Instantiate(prefab, parent, worldPositionStays)); } string goName = prefab.name.EndsWith("(Clone)") ? prefab.name : prefab.name + "(Clone)"; if (Instance.pool.TryGetValue(goName, out var oListFound) && oListFound.Count > 0) { GameObject go = oListFound.ElementAt(0); oListFound.Remove(go); if (oListFound.Count < 1) { Instance.pool.Remove(goName); } go.transform.SetParent(parent, worldPositionStays); ZetanUtility.SetActive(go, true); if (Instance.putDelayCoroutines.TryGetValue(go, out var c)) { Instance.StopCoroutine(c); Instance.putDelayCoroutines.Remove(go); } return(go); } else { return(Instantiate(prefab, parent, worldPositionStays)); } }
public void New(float seconds, Func <float> getTime, Func <bool> cancelCondition, Action cancelAction, string actionName = null) { targetTime = seconds; this.getTime = getTime; if (progressCoroutine != null) { StopCoroutine(progressCoroutine); progressCoroutine = null; } isProgressing = true; if (actionText) { if (string.IsNullOrEmpty(actionName)) { ZetanUtility.SetActive(actionText.gameObject, false); } else { actionText.text = actionName; ZetanUtility.SetActive(actionText.gameObject, true); } } if (cancelCondition != null) { shouldCancel = cancelCondition; } else { shouldCancel = () => { return(true); } }; onCancel = cancelAction; ZetanUtility.SetActive(bar, true); ZetanUtility.SetActive(cancel, true); progressCoroutine = StartCoroutine(ProgressCustom()); }
public MapIcon CreateMapIcon(Sprite iconSprite, Vector2 size, Vector3 worldPosition, bool keepOnMap, float rangeSize, MapIconType iconType, bool removeAble, string textToDisplay = "") { if (!UI || !UI.gameObject || !iconSprite) { return(null); } MapIcon icon = ObjectPool.Get(UI.iconPrefab.gameObject, SelectParent(iconType)).GetComponent <MapIcon>(); InitIcon(); IconsWithoutHolder.Add(icon, new MapIconWithoutHolder(worldPosition, icon, keepOnMap, removeAble, textToDisplay)); return(icon); void InitIcon() { icon.iconImage.rectTransform.pivot = new Vector2(0.5f, 0.5f); icon.iconImage.overrideSprite = iconSprite; icon.iconImage.rectTransform.sizeDelta = size; icon.iconType = iconType; if (rangeSize > 0) { icon.iconRange = ObjectPool.Get(UI.rangePrefab.gameObject, UI.rangesParent).GetComponent <MapIconRange>(); ZetanUtility.SetActive(icon.iconRange.gameObject, true); icon.iconRange.rectTransform.sizeDelta = new Vector2(rangeSize, rangeSize); } icon.RemoveAble = removeAble; icon.TextToDisplay = textToDisplay; } }
public void RefreshDescription() { title.text = selectedQuest.Model.Title; giver.text = $"[委托人:{selectedQuest.originalQuestHolder.TalkerName}]"; descriptionText.text = selectedQuest.Model.Description; StringBuilder objectives = new StringBuilder(); var displayObjectives = selectedQuest.Objectives.Where(x => x.Model.Display).ToArray(); int lineCount = displayObjectives.Length - 1; for (int i = 0; i < displayObjectives.Length; i++) { string endLine = i == lineCount ? string.Empty : "\n"; if (selectedQuest.IsFinished) { objectives.AppendFormat("-{0}{1}", displayObjectives[i].Model.DisplayName, endLine); } else { objectives.AppendFormat("-{0}{1}{2}", displayObjectives[i], displayObjectives[i].IsComplete ? "\t(达成)" : string.Empty, endLine); } } objectiveText.text = objectives.ToString(); rewardList.Refresh(ItemSlotData.Convert(selectedQuest.Model.RewardItems, maxRewardCount)); ZetanUtility.SetActive(abandonButton.gameObject, !selectedQuest.IsFinished && selectedQuest.Model.Abandonable); ZetanUtility.SetActive(traceButton.gameObject, !selectedQuest.IsFinished); RefreshTraceText(); }
private void ShowAll() { foreach (var sa in SeedAgents) { ZetanUtility.SetActive(sa.gameObject, true); } }
protected override bool OnOpen(params object[] args) { if (args.Length < 4) { return(false); } var par = (position : (Vector2)args[0], text : args[1] as string, duration : (float)args[2], closeBtn : (bool)args[3]); tipBackground.position = par.position; ZetanUtility.SetActive(tipBackground.gameObject, true); ZetanUtility.SetActive(tipsContent.gameObject, true); tipsContent.text = par.text; if (hideNameCoroutine != null) { StopCoroutine(hideNameCoroutine); } if (par.duration > 0) { hideNameCoroutine = StartCoroutine(HideTextDelay(par.duration)); } if (par.closeBtn) { MakeButton("关闭", Hide); } return(true); }
public void Defocus() { Quest = null; titleText.text = string.Empty; objectiveText.text = string.Empty; ZetanUtility.SetActive(gameObject, false); }
public void Refresh() { if (!Quest || Quest.IsFinished) { Defocus(); return; } ZetanUtility.SetActive(gameObject, true); titleText.text = $"{(Quest.IsComplete ? "[完成]" : string.Empty)}{Quest.Model.Title}"; StringBuilder objectives = new StringBuilder(); if (Quest.IsComplete) { objectiveText.text = string.Empty; } else { var displayObjectives = Quest.Objectives.Where(x => x.Model.Display).ToArray(); int lineCount = displayObjectives.Length - 1; for (int i = 0; i < displayObjectives.Length; i++) { var objective = displayObjectives[i]; if (!objective.IsComplete && (!objective.Model.InOrder || objective.AllPrevComplete)) { string endLine = i == lineCount ? string.Empty : "\n"; objectives.AppendFormat("-{0}{1}", objective, endLine); } } } objectiveText.text = objectives.ToString(); }
public void ShowIcon(float zoom) { if (forceHided) { return; } if (iconInstance) { iconInstance.Show(showRange); if (iconInstance.iconRange) { if (showRange) { if (iconInstance.iconRange) { if (iconInstance.iconRange.Color != rangeColor) { iconInstance.iconRange.Color = rangeColor; } iconInstance.iconRange.rectTransform.sizeDelta = new Vector2(rangeSize * 2, rangeSize * 2) * zoom; } } else { ZetanUtility.SetActive(iconInstance.iconRange.gameObject, false); } } } }
private void Awake() { if (preview.layer != LayerMask.NameToLayer("StructurePreview")) { preview.layer = LayerMask.NameToLayer("StructurePreview"); } ZetanUtility.SetActive(preview, true); ZetanUtility.SetActive(structure, false); renderers = GetComponentsInChildren <MeshRenderer>(); renderers = renderers.Concat(GetComponentsInChildren <SpriteRenderer>()).ToArray(); foreach (Renderer renderer in renderers) { if (renderer.gameObject.activeSelf) { oriColors.Add(renderer, renderer.material.color); redColors.Add(renderer, renderer.material.color * Color.red); } } Collider2D[] collider2Ds = preview.GetComponentsInChildren <Collider2D>(); foreach (Collider2D collider2D in collider2Ds) { collider2D.isTrigger = true; } }
protected override bool OnClose(params object[] args) { if (!IsOpen) { return(true); } foreach (var kvp in copySlots) { caches.Put(kvp.Value); } copySlots.Clear(); selectedItems.Clear(); SourceContainer.DarkIf(null); SourceContainer.MarkIf(null); SourceContainer = null; SourceHandler = null; ZetanUtility.SetActive(tips, true); dialog = string.Empty; SelectionType = ItemSelectionType.SelectNum; canSelect = null; onConfirm = null; if (!confirm) { onCancel?.Invoke(); } onCancel = null; WindowsManager.CloseWindow <ItemWindow>(); return(true); }
/// <summary> /// 生成任务列表的选项 /// </summary> private void MakeTalkerQuestOption() { if (CurrentTalker.QuestInstances.Count < 1) { return; } ClearOptions(); foreach (Quest quest in CurrentTalker.QuestInstances) { if (!QuestManager.Instance.HasCompleteQuest(quest) && QuestManager.Instance.IsQuestAcceptable(quest) && QuestManager.IsQuestValid(quest)) { OptionAgent oa = ObjectPool.Get(UI.optionPrefab, UI.optionsParent, false).GetComponent <OptionAgent>(); oa.Init(quest.Title + (quest.IsComplete ? "(完成)" : quest.InProgress ? "(进行中)" : string.Empty), quest); if (quest.IsComplete) { //保证完成的任务优先显示,方便玩家提交完成的任务 oa.transform.SetAsFirstSibling(); optionAgents.Insert(0, oa); } else { optionAgents.Add(oa); } } } //保证进行中的任务最后显示,方便玩家接取未接取的任务 for (int i = optionAgents.Count - 1; i >= 0; i--) { OptionAgent oa = optionAgents[i]; //若当前选项关联的任务在进行中 if (oa.MQuest.InProgress && !oa.MQuest.IsComplete) { //则从后向前找一个新位置以放置该选项 for (int j = optionAgents.Count - 1; j > i; j--) { //若找到了合适的位置 if (!optionAgents[j].MQuest.InProgress && !optionAgents[j].MQuest.IsComplete) { //则从该位置开始到选项的原位置,逐个前移一位,填充(覆盖)选项的原位置并空出新位置 for (int k = i; k < j; k++) { //在k指向目标位置之前,逐个前移 optionAgents[k] = optionAgents[k + 1]; } //把选项放入新位置,此时选项的原位置即OptionAgents[i]已被填充(覆盖) optionAgents[j] = oa; oa.transform.SetSiblingIndex(j); break; } } } } //把第一页以外的选项隐藏 for (int i = UI.lineAmount - (int)(UI.wordsText.preferredHeight / UI.textLineHeight); i < optionAgents.Count; i++) { ZetanUtility.SetActive(optionAgents[i].gameObject, false); } CheckPages(); }
public void Show(string name, UnityAction clickAction) { ZetanUtility.SetActive(gameObject, true); buttonName.text = name; button.onClick.RemoveAllListeners(); button.onClick.AddListener(clickAction); IsHiding = false; }
private void ShowButtons(bool gift, bool shop, bool warehouse, bool quest, bool back = true) { ZetanUtility.SetActive(giftButton.gameObject, gift); ZetanUtility.SetActive(shopButton.gameObject, shop); ZetanUtility.SetActive(warehouseButton.gameObject, warehouse); ZetanUtility.SetActive(questButton.gameObject, quest); ZetanUtility.SetActive(backButton.gameObject, back); }
public void LocationGoBack() { ZetanUtility.SetActive(UI.locationGoBackBtn, false); CameraMovement2D.Instance.Stop(); WindowsManager.Instance.PauseAll(false); IsLocating = false; LocatingBuilding = null; }
public void Hide() { ZetanUtility.SetActive(iconImage.gameObject, false); if (iconRange) { ZetanUtility.SetActive(iconRange.gameObject, false); } }
public override void Refresh() { totalDays.text = Data.Data.growthDays.ToString(); nameText.text = Data.Data.Info.Name; ZetanUtility.SetActive(dryIcon.gameObject, Data.Dry); ZetanUtility.SetActive(pestIcon.gameObject, Data.Pest); ZetanUtility.SetActive(matureIcon.gameObject, Data.Data.HarvestAble); }
public void Hide(bool clear = false) { if (clear) { Clear(); } ZetanUtility.SetActive(gameObject, false); }
public void LocateBuilding(Building building) { ZetanUtility.SetActive(UI.locationGoBackBtn, true); CameraMovement2D.Instance.MoveTo(building.transform.position); WindowsManager.Instance.PauseAll(true); IsLocating = true; LocatingBuilding = building; }