using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace vnxbqy.UI { public class CommonDungeonSelectCell : CellView { [SerializeField] Image headIcon; [SerializeField] Text npcLVText; [SerializeField] List items; [SerializeField] Text todayCntText; [SerializeField] Button challengeBtn; [SerializeField] Text challengeText;//挑战/扫荡/xx仙玉扫荡 [SerializeField] Transform challengeObj; [SerializeField] Transform lockObj; [SerializeField] Text lockText; DungeonModel model { get { return ModelCenter.Instance.GetModel(); } } DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel(); } } CommonDungeonSelectModel commonDungeonSelectModel { get { return ModelCenter.Instance.GetModel(); } } int moneyType = 1; int money; public void Display(int lineID) { var dungeonInfo = FBGeneralTrainConfig.GetDungeonInfo(model.currentDungeon.mapId, lineID); if (dungeonInfo == null) { return; } var npcInfo = NPCConfig.Get(dungeonInfo.BossNPCID); headIcon.SetSprite(npcInfo.HeadPortrait); npcLVText.text = Language.Get("PlayerDetail_Level", npcInfo.NPCLV); for (int i = 0; i < items.Count; i++) { if (i < dungeonInfo.PassAwardItemList.Length) { items[i].SetActive(true); int itemID = dungeonInfo.PassAwardItemList[i][0]; items[i].Init(new ItemCellModel(itemID, false, (ulong)dungeonInfo.PassAwardItemList[i][1])); items[i].button.AddListener(() => { ItemTipUtility.Show(itemID); }); } else { items[i].SetActive(false); } } DungeonRecord dungeonRecord; if (!model.TryGetRecord(model.currentDungeon.mapId, out dungeonRecord)) { return; } DungeonOpenTimeConfig dungeonOpenTimeModel = DungeonOpenTimeConfig.Get(model.currentDungeon.mapId); var completedTimes = dailyQuestModel.GetDailyQuestCompletedTimes(commonDungeonSelectModel.selectDailyQuestType); var totalTimes = dailyQuestModel.GetDailyQuestTotalTimes(commonDungeonSelectModel.selectDailyQuestType); //1. 已通关 小于通关关卡的不显示按钮 //2. 通关的当前关卡 (相等) // a.当前显示扫荡(是否消费货币) //3. 未通关的当前关卡 // a.等级够且为下一层显示挑战按钮 // b.等级不够显示锁定 if (lineID < dungeonRecord.passLineID) { lockObj.SetActive(false); challengeObj.SetActive(false); } else if (lineID == dungeonRecord.passLineID) { ShowChallenge(1, dungeonRecord, lineID); } else { if (PlayerDatas.Instance.baseData.LV < dungeonInfo.LVLimit) { lockObj.SetActive(true); challengeObj.SetActive(false); lockText.text = Language.Get("StoreWin107", dungeonInfo.LVLimit); } else if (lineID == dungeonRecord.passLineID + 1) { ShowChallenge(2, dungeonRecord, lineID); } else { lockObj.SetActive(false); challengeObj.SetActive(true); challengeBtn.interactable = false; challengeBtn.SetColorful(null, false); challengeText.text = Language.Get("Multiple_Challenge"); todayCntText.text = UIHelper.AppendColor(TextColType.Red, Language.Get("TrialDungeonPreFloorLimit")); } } } void ShowChallenge(int type, DungeonRecord dungeonRecord, int lineID) { string key = type == 1 ? "RuneTower22" : "Multiple_Challenge"; DungeonOpenTimeConfig dungeonOpenTimeModel = DungeonOpenTimeConfig.Get(model.currentDungeon.mapId); var completedTimes = dailyQuestModel.GetDailyQuestCompletedTimes(commonDungeonSelectModel.selectDailyQuestType); var totalTimes = dailyQuestModel.GetDailyQuestTotalTimes(commonDungeonSelectModel.selectDailyQuestType, true); var totalTimesBuyYet = dailyQuestModel.GetDailyQuestTotalTimes(commonDungeonSelectModel.selectDailyQuestType, false); lockObj.SetActive(false); challengeObj.SetActive(true); challengeText.text = Language.Get(key); challengeBtn.interactable = true; challengeBtn.SetColorful(null, true); todayCntText.text = UIHelper.AppendColor(completedTimes >= totalTimes ? TextColType.Red : TextColType.Green, Language.Get("XBLimitCnt", (totalTimes - completedTimes).ToString(), totalTimes), true); Dungeon dungeon = model.currentDungeon; dungeon.lineId = lineID; challengeBtn.SetListener(() => { GotoDungeon(type, dungeon); }); //完成次数比较 if (completedTimes < dungeonOpenTimeModel.DayTimes) { challengeText.text = Language.Get(key); } else if (completedTimes < totalTimes) { string costFormula = string.Empty; if (completedTimes < totalTimesBuyYet) { challengeText.text = Language.Get(key); } else if (model.TryGetBuyCountCost(model.currentDungeon.mapId, out costFormula)) { if (ILGeneralDefine.fbBuyTimes.ContainsKey(model.currentDungeon.mapId)) { moneyType = ILGeneralDefine.fbBuyTimes[model.currentDungeon.mapId]; } Equation.Instance.Clear(); Equation.Instance.AddKeyValue("hasBuyCnt", dungeonRecord.buyTimes); money = Equation.Instance.Eval(costFormula); challengeText.text = StringUtility.Contact(money.ToString(), " ", Language.Get("MoneyType_" + moneyType), " ", Language.Get(key)); } } else { challengeText.text = Language.Get(key); challengeBtn.interactable = false; challengeBtn.SetColorful(null, false); } } void GotoDungeon(int type, Dungeon dungeon) { //不够次数的先发购买包,再发挑战/扫荡 var completedTimes = dailyQuestModel.GetDailyQuestCompletedTimes(commonDungeonSelectModel.selectDailyQuestType); var totalTimes = dailyQuestModel.GetDailyQuestTotalTimes(commonDungeonSelectModel.selectDailyQuestType, true); var totalTimesBuyYet = dailyQuestModel.GetDailyQuestTotalTimes(commonDungeonSelectModel.selectDailyQuestType, false); if (completedTimes < totalTimesBuyYet) { if (type == 1) { model.RequestSweep(dungeon); } else { model.currentDungeon = dungeon; ClientDungeonStageUtility.GotoNormalClientDungeon(dungeon.mapId, dungeon.mapId, dungeon.lineId); } } else { if (UIHelper.GetMoneyCnt(moneyType) >= (ulong)money) { if (!commonDungeonSelectModel.IsCheckBuy) { ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get(type == 1 ? "CommonDungeon2" : "CommonDungeon3", StringUtility.Contact(money, " ", Language.Get("MoneyType_" + moneyType))), Language.Get("ConfirmCancel102"), (bool isOk, bool isToggle) => { if (isOk) { model.RequestBuyEnterCount(model.currentDungeon.mapId); if (type == 1) { model.RequestSweep(dungeon); } else { model.currentDungeon = dungeon; ClientDungeonStageUtility.GotoNormalClientDungeon(dungeon.mapId, dungeon.mapId, dungeon.lineId); } } if (isToggle) { commonDungeonSelectModel.IsCheckBuy = true; } }); } else { model.RequestBuyEnterCount(model.currentDungeon.mapId); if (type == 1) { model.RequestSweep(dungeon); } else { model.currentDungeon = dungeon; ClientDungeonStageUtility.GotoNormalClientDungeon(dungeon.mapId, dungeon.mapId, dungeon.lineId); } } } else { SysNotifyMgr.Instance.ShowTip("LackMoney", moneyType); } } } } }