using System.Collections.Generic; using UnityEngine; public class BoneFieldWin : UIBase { [SerializeField] TextEx txtDifficulty; [SerializeField] TextEx txtBossName; [SerializeField] TextEx txtTodaySweepCount; [SerializeField] TextEx txtTodayAdsCount; [SerializeField] TextEx txtFirstFree; [SerializeField] TextEx txtFightPower; [SerializeField] ImageEx imgMaxLineID; [SerializeField] Transform transChallengeItemCells; [SerializeField] List challengeItemCells1; [SerializeField] List challengeItemCells2; [SerializeField] List sweepItemCells; [SerializeField] List skillWords; [SerializeField] ButtonEx btnClose; [SerializeField] Transform transNoChallenge; [SerializeField] Transform transHasChallenge; [SerializeField] BoneFieldChallengeButton btnChallenge1; [SerializeField] BoneFieldChallengeButton btnChallenge2; [SerializeField] ButtonEx btnSweep; [SerializeField] ImageEx imgSweepNo; [SerializeField] ButtonEx btnAds; [SerializeField] ImageEx imgSweepRed; bool isHasNextLineID; int adID; int showSweepMaxCount; int showrealRemainSweepCount; protected override void InitComponent() { base.InitComponent(); btnClose.SetListener(OnClickClose); btnSweep.SetListener(OnClickSweep); btnAds.SetListener(OnClickAds); } protected override void OnPreOpen() { base.OnPreOpen(); DungeonManager.Instance.UpdateFBInfoChangeEvent += OnUpdateFBInfoChangeEvent; AdsManager.Instance.OnAdsInfoListUpdateEvent += OnAdsInfoListUpdateEvent; TimeMgr.Instance.OnDayEvent += OnDayEvent; Display(); } protected override void OnPreClose() { base.OnPreClose(); DungeonManager.Instance.UpdateFBInfoChangeEvent -= OnUpdateFBInfoChangeEvent; AdsManager.Instance.OnAdsInfoListUpdateEvent -= OnAdsInfoListUpdateEvent; TimeMgr.Instance.OnDayEvent -= OnDayEvent; } private void OnUpdateFBInfoChangeEvent(int mapID, bool isADAddCntChange, bool isBuyAddCntChange, bool isItemAddCntChange) { int dataMapID = BoneFieldManager.Instance.DataMapID; if (mapID != dataMapID) return; if (!ADAwardConfig.TryGetADIDByADMapID(BoneFieldManager.Instance.DataMapID, out adID) || !ADAwardConfig.HasKey(adID)) return; ADAwardConfig aDAwardConfig = ADAwardConfig.Get(adID); if (isADAddCntChange) { DisplayAdsButton(aDAwardConfig); } else { Display(); } } private void OnAdsInfoListUpdateEvent(int id, int mapId) { if (mapId != BoneFieldManager.Instance.DataMapID) return; if (!ADAwardConfig.TryGetADIDByADMapID(BoneFieldManager.Instance.DataMapID, out adID) || !ADAwardConfig.HasKey(adID)) return; ADAwardConfig aDAwardConfig = ADAwardConfig.Get(adID); DisplayAdsButton(aDAwardConfig); } private void OnDayEvent() { Display(); } private void OnClickClose() { UIManager.Instance.CloseWindow(); } private void OnClickSweep() { int dataMapID = BoneFieldManager.Instance.DataMapID; if (!DungeonManager.Instance.TryGetFBInfoByMapID(dataMapID, out var fbInfo)) return; if (!DungeonOpenTimeConfig.HasKey(dataMapID)) return; DungeonOpenTimeConfig config = DungeonOpenTimeConfig.Get(dataMapID); if (showrealRemainSweepCount == showSweepMaxCount) { BoneFieldManager.Instance.SendBBeginFBWipeOut(dataMapID, (int)fbInfo.PassLineID); return; } int index = Mathf.Min(Mathf.Max(0, showSweepMaxCount - showrealRemainSweepCount - 1), config.PayMoneyValues.Length - 1); int payMoneyValue = config.PayMoneyValues[index]; int payMoneyType = config.PayMoneyType; ConfirmCancel.MoneyIconToggleConfirmByType(ToggleCheckType.BoneField, payMoneyValue, payMoneyType, Language.Get("BoneField11", UIHelper.GetIconNameWithMoneyType(payMoneyType), payMoneyValue), () => { if (!UIHelper.CheckMoneyCount(payMoneyType, payMoneyValue, 2)) return; BoneFieldManager.Instance.SendBuyEnterCount(dataMapID); BoneFieldManager.Instance.SendBBeginFBWipeOut(dataMapID, (int)fbInfo.PassLineID); }); } private void OnClickAds() { AdsManager.Instance.PlayAds(adID); } public void Display() { int dataMapID = BoneFieldManager.Instance.DataMapID; if (!DungeonManager.Instance.TryGetFBInfoByMapID(dataMapID, out var fbInfo)) return; int nowPassLineID = BoneFieldManager.Instance.GetNowPassLineID(fbInfo); isHasNextLineID = BoneFieldManager.Instance.IsHasNextLineID(fbInfo); DungeonConfig.TryGetDungeonID(dataMapID, nowPassLineID, out int dungeonID); if (!DungeonConfig.HasKey(dungeonID)) return; DungeonConfig dungeonConfig = DungeonConfig.Get(dungeonID); int[] lineupIDList = dungeonConfig.LineupIDList; if (lineupIDList.IsNullOrEmpty()) return; int LineupID = lineupIDList[0]; if (!NPCLineupConfig.HasKey(LineupID)) return; NPCLineupConfig lineupConfig = NPCLineupConfig.Get(LineupID); int bossId = lineupConfig.BossID; if (bossId == 0 || !NPCConfig.HasKey(bossId)) return; NPCConfig nPCConfig = NPCConfig.Get(bossId); if (!ADAwardConfig.TryGetADIDByADMapID(dataMapID, out adID) || !ADAwardConfig.HasKey(adID)) return; ADAwardConfig aDAwardConfig = ADAwardConfig.Get(adID); DisplayFBInfo(nPCConfig, dungeonConfig, nowPassLineID); DisplayChallengeButton(dungeonConfig, fbInfo); DisplaySweepButton(dungeonConfig); DisplayAdsButton(aDAwardConfig); DisplaySkillWordsList(lineupConfig); DisplayItemCellList(challengeItemCells1, dungeonConfig.PassAwardList); DisplayItemCellList(challengeItemCells2, dungeonConfig.PassAwardList); if (fbInfo.PassLineID > 0) { DungeonConfig.TryGetDungeonID(dataMapID, (int)fbInfo.PassLineID, out int sweepDungeonID); if (!DungeonConfig.HasKey(dungeonID)) return; DungeonConfig sweepDungeonConfig = DungeonConfig.Get(sweepDungeonID); DisplayItemCellList(sweepItemCells, sweepDungeonConfig.SweepAwardList); } } public void DisplayFBInfo(NPCConfig nPCConfig, DungeonConfig dungeonConfig, int nowPassLineID) { imgMaxLineID.SetActive(!isHasNextLineID); transChallengeItemCells.SetActive(isHasNextLineID); txtBossName.text = nPCConfig.NPCName; txtDifficulty.text = nowPassLineID.ToString(); txtFightPower.text = UIHelper.ReplaceLargeArtNum(dungeonConfig.FightPower); } public void DisplayChallengeButton(DungeonConfig dungeonConfig, FBInfo fBInfo) { transNoChallenge.SetActive(fBInfo.PassLineID <= 0); transHasChallenge.SetActive(fBInfo.PassLineID > 0); btnChallenge1.Display(dungeonConfig.LVLimitMin, isHasNextLineID, dungeonConfig.FightPower); btnChallenge2.Display(dungeonConfig.LVLimitMin, isHasNextLineID, dungeonConfig.FightPower); } public void DisplaySweepButton(DungeonConfig dungeonConfig) { if (!BoneFieldManager.Instance.TryGetShowSweepCount(out showSweepMaxCount, out showrealRemainSweepCount)) return; bool isSweepCountOk = showrealRemainSweepCount > 0; imgSweepNo.SetActive(!isSweepCountOk); btnSweep.interactable = isSweepCountOk; long myFightPower = PlayerDatas.Instance.baseData.FightPower; imgSweepRed.SetActive(isSweepCountOk && myFightPower < dungeonConfig.FightPower); txtFirstFree.SetActive(showSweepMaxCount == showrealRemainSweepCount); txtTodaySweepCount.SetActive(showSweepMaxCount > showrealRemainSweepCount); txtTodaySweepCount.text = UIHelper.AppendColor(isSweepCountOk ? TextColType.Green : TextColType.Red, Language.Get("BoneField08", showrealRemainSweepCount, showSweepMaxCount)); } public void DisplayAdsButton(ADAwardConfig aDAwardConfig) { int adsCnt = AdsManager.Instance.GetADCntByADID(adID); bool isShowAds = adsCnt < aDAwardConfig.ADCntMax; int remainAdsCount = aDAwardConfig.ADCntMax - adsCnt; btnAds.SetActive(isShowAds); txtTodayAdsCount.text = UIHelper.AppendColor(isShowAds ? TextColType.Green : TextColType.Red, Language.Get("BoneField09", remainAdsCount, aDAwardConfig.ADCntMax)); ; } public void DisplayItemCellList(List itemCells, int[][] items) { if (itemCells.IsNullOrEmpty() || items.IsNullOrEmpty()) return; for (int i = 0; i < itemCells.Count; i++) { if (i < items.Length) { int index = i; itemCells[i].SetActive(true); itemCells[i].Init(new ItemCellModel(items[i][0], true, items[i][1])); itemCells[i].button.SetListener(() => { ItemTipUtility.Show(items[index][0], true); }); } else { itemCells[i].SetActive(false); } } } public void DisplaySkillWordsList(NPCLineupConfig lineUPConfig) { if (skillWords.IsNullOrEmpty()) return; for (int i = 0; i < skillWords.Count; i++) { if (i < lineUPConfig.SkillIDExList.Length) { skillWords[i].SetActive(true); int skillID = lineUPConfig.SkillIDExList[i]; skillWords[i].Init(skillID, () => { SmallTipWin.showText = Language.Get("SmallTipFomat", SkillConfig.Get(skillID)?.SkillName, SkillConfig.Get(skillID)?.Description); SmallTipWin.worldPos = CameraManager.uiCamera.ScreenToWorldPoint(Input.mousePosition); SmallTipWin.isDownShow = true; UIManager.Instance.OpenWindow(); }); } else { skillWords[i].SetActive(false); } } } }