//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Saturday, September 16, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
namespace Snxxz.UI
|
{
|
|
public class DailyQuestWin : Window
|
{
|
[SerializeField] FunctionButtonGroup m_FunctionGroup;
|
[SerializeField] FunctionButton m_EveryDaily;
|
[SerializeField] FunctionButton m_TimeLimit;
|
[SerializeField] FunctionButton m_ResourcesBack;
|
[SerializeField] Button m_Left;
|
[SerializeField] Button m_Right;
|
[SerializeField] ButtonEx m_CloseButton;
|
|
[SerializeField] RectTransform m_DailyQuestContainer;
|
[SerializeField] CyclicScroll m_QuestScroll;
|
[SerializeField] Button m_Calendar;
|
[SerializeField] DailyQuestHangTimeBehaviour m_HangTimeBehaviour;
|
[SerializeField] DailyQuestActiveSlider m_DailyQuestActiveSlider;
|
|
[SerializeField] RectTransform m_ResourcesBackContainer;
|
|
DailyQuestModel model { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
TaskModel taskModel { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
|
MapModel mapModel { get { return ModelCenter.Instance.GetModel<MapModel>(); } }
|
|
public int guidingDailyQuestId = 0;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_CloseButton.AddListener(CloseClick);
|
m_Calendar.AddListener(ShowCalendar);
|
m_EveryDaily.AddListener(ShowEveryDayQuests);
|
m_TimeLimit.AddListener(ShowTimeLimit);
|
m_ResourcesBack.AddListener(ShowResourcesBack);
|
m_Left.AddListener(ShowLastFunction);
|
m_Right.AddListener(ShowNextFunction);
|
}
|
|
protected override void OnPreOpen()
|
{
|
guidingDailyQuestId = model.currentDailyQuest;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
model.currentActiveValueUpdateEvent += OnUpdateCurrentActive;
|
}
|
|
protected override void OnPreClose()
|
{
|
guidingDailyQuestId = 0;
|
model.currentDailyQuest = 0;
|
m_HangTimeBehaviour.Dispose();
|
m_QuestScroll.Dispose();
|
|
model.currentActiveValueUpdateEvent -= OnUpdateCurrentActive;
|
}
|
|
protected override void OnAfterClose()
|
{
|
if (!WindowJumpMgr.Instance.IsJumpState)
|
{
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
|
if (guidingDailyQuestId != 0)
|
{
|
var preferTimeLimit = false;
|
var dailyQuests = model.GetDailyQuests();
|
foreach (var quest in dailyQuests)
|
{
|
var dailyQuestState = model.GetQuestState(quest);
|
DailyQuestOpenTime openTime;
|
if (model.TryGetOpenTime(quest, out openTime) && !openTime.always)
|
{
|
var completedTimes = model.GetDailyQuestCompletedTimes(quest);
|
var totalTimes = model.GetDailyQuestTotalTimes(quest);
|
if ((dailyQuestState == DailyQuestModel.DailyQuestState.Normal && completedTimes < totalTimes))
|
{
|
preferTimeLimit = true;
|
}
|
break;
|
}
|
}
|
|
if (preferTimeLimit)
|
{
|
functionOrder = 1;
|
}
|
}
|
|
m_FunctionGroup.TriggerByOrder(functionOrder);
|
}
|
|
#endregion
|
|
private void ShowEveryDayQuests()
|
{
|
var dailyQuests = model.GetDailyQuests(DailyQuestModel.DailyQuestCategory.EveryDay);
|
m_DailyQuestContainer.gameObject.SetActive(true);
|
m_ResourcesBackContainer.gameObject.SetActive(false);
|
ShowQuestGroups(dailyQuests);
|
functionOrder = m_EveryDaily.order;
|
}
|
|
private void ShowTimeLimit()
|
{
|
var dailyQuests = model.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit);
|
m_DailyQuestContainer.gameObject.SetActive(true);
|
m_ResourcesBackContainer.gameObject.SetActive(false);
|
ShowQuestGroups(dailyQuests);
|
functionOrder = m_TimeLimit.order;
|
}
|
|
private void ShowResourcesBack()
|
{
|
m_DailyQuestContainer.gameObject.SetActive(false);
|
m_ResourcesBackContainer.gameObject.SetActive(true);
|
|
functionOrder = m_ResourcesBack.order;
|
}
|
|
private void ShowLastFunction()
|
{
|
m_FunctionGroup.TriggerLast();
|
}
|
|
private void ShowNextFunction()
|
{
|
m_FunctionGroup.TriggerNext();
|
}
|
|
private void ShowQuestGroups(List<int> _quests)
|
{
|
m_HangTimeBehaviour.Display();
|
m_DailyQuestActiveSlider.Initialize();
|
m_DailyQuestActiveSlider.UpdateCurrentActiveValue(model.currentActiveValue, model.dailyQuestTotalActiveValue);
|
var groupDatas = new List<DailyQuestGroup.GroupData>();
|
var max = _quests.Count;
|
for (int i = 0; i < max; i++, i++)
|
{
|
DailyQuestData data1 = null;
|
model.TryGetDailyQuest(_quests[i], out data1);
|
DailyQuestData data2 = null;
|
if (i + 1 < max)
|
{
|
model.TryGetDailyQuest(_quests[i + 1], out data2);
|
}
|
groupDatas.Add(new DailyQuestGroup.GroupData(data1, data2, this));
|
}
|
|
m_QuestScroll.Init(groupDatas);
|
|
var currentQuestIndex = _quests.IndexOf(model.currentDailyQuest);
|
if (currentQuestIndex != -1)
|
{
|
m_QuestScroll.MoveToCenter(currentQuestIndex / 2);
|
}
|
}
|
|
private void ShowCalendar()
|
{
|
WindowCenter.Instance.Open<DailyQuestCalendarWin>();
|
}
|
|
private void OnUpdateCurrentActive()
|
{
|
m_DailyQuestActiveSlider.UpdateCurrentActiveValue(model.currentActiveValue, model.dailyQuestTotalActiveValue);
|
}
|
|
public void GotoDailyQuest(int _id)
|
{
|
switch ((DailyQuestType)_id)
|
{
|
case DailyQuestType.FairyLand:
|
GotoNormalDungeon(_id);
|
break;
|
case DailyQuestType.IceCrystal:
|
WindowCenter.Instance.Open<IceCrystalVeinWin>();
|
break;
|
case DailyQuestType.GuardSky:
|
var _fairyModel = ModelCenter.Instance.GetModel<FairyModel>();
|
if (!_fairyModel.SatisfyGuardSkyFairyLv())
|
{
|
SysNotifyMgr.Instance.ShowTip("GuardSkyOpenLvError", _fairyModel.guardSkyOpenFairyLv);
|
break;
|
}
|
if (_fairyModel.completeGuardSky)
|
{
|
SysNotifyMgr.Instance.ShowTip("TheEmperor1");
|
break;
|
}
|
GotoNormalDungeon(_id);
|
break;
|
case DailyQuestType.Kirin:
|
GotoMultipleDifficultyDungeon(_id);
|
break;
|
case DailyQuestType.BountyMission:
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.BountyInterface);
|
break;
|
case DailyQuestType.Demon:
|
GotoChaosDemon(_id);
|
break;
|
case DailyQuestType.Trial:
|
GotoTrial();
|
break;
|
case DailyQuestType.BlastStove:
|
GotoBlastStove();
|
break;
|
case DailyQuestType.AncientBattleGround:
|
GotoNormalDungeon(_id, dungeonModel.GetBelongToLine(_id));
|
break;
|
case DailyQuestType.EmperorRelic:
|
GotoNuwa();
|
break;
|
case DailyQuestType.WyTaiChi:
|
GotoTaiChiDungeon(_id);
|
break;
|
case DailyQuestType.HeavenBattle:
|
GotoHeavenBattleDungeon(_id);
|
break;
|
case DailyQuestType.Prayer:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<WelfareWin>(false, 1);
|
WindowCenter.Instance.Close<MainInterfaceWin>();
|
break;
|
case DailyQuestType.WorldBoss:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<FindPreciousFrameWin>();
|
break;
|
case DailyQuestType.DemonJar:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<LootPreciousFrameWin>();
|
break;
|
case DailyQuestType.FairyTask:
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.UnionTask);
|
break;
|
case DailyQuestType.FairyLeague:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<UnionPanel>(false, 4);
|
break;
|
case DailyQuestType.FairyFeast:
|
if (CrossServerUtility.IsCrossServer())
|
{
|
SysNotifyMgr.Instance.ShowTip("CrossMap10");
|
break;
|
}
|
var config = DailyQuestConfig.Get(_id);
|
dungeonModel.SingleChallenge(config.RelatedID);
|
break;
|
case DailyQuestType.RuneTowerSweep:
|
RuneTowerWin.guideSweep = true;
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<TowerWin>(false, 0);
|
break;
|
case DailyQuestType.BossHome:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<FindPreciousFrameWin>(false, 1);
|
break;
|
case DailyQuestType.PersonalBoss:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<FindPreciousFrameWin>(false, 2);
|
break;
|
case DailyQuestType.ElderGodArea:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<FindPreciousFrameWin>(false, 3);
|
break;
|
case DailyQuestType.RuneTower:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<TowerWin>(false, 0);
|
break;
|
case DailyQuestType.TreasureCollectSoul:
|
GotoTreasureCollectSoul();
|
break;
|
case DailyQuestType.DungeonAssist:
|
WindowCenter.Instance.Open<DungeonAssistWin>();
|
break;
|
case DailyQuestType.FairyGrabBoss:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<LootPreciousFrameWin>(false, 1);
|
break;
|
case DailyQuestType.KillMonster:
|
var point = mapModel.GetRecommendHangPoint();
|
var mapEventConfig = MapEventPointConfig.Get(point);
|
mapModel.wannaLookLocalMap = mapEventConfig.MapID;
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<LocalMapWin>();
|
break;
|
case DailyQuestType.GatherSoulDungeon:
|
GotoNormalDungeon(_id, 0);
|
break;
|
case DailyQuestType.CrossServerPk:
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<CrossServerWin>();
|
break;
|
case DailyQuestType.AllianceBoss1:
|
GotoAllianceBoss(_id, 0);
|
break;
|
case DailyQuestType.AllianceBoss2:
|
GotoAllianceBoss(_id, 1);
|
break;
|
default:
|
CSharpCallLua.GotoLuaDailyQuest(_id);
|
break;
|
}
|
|
WindowJumpMgr.Instance.ClearJumpData();
|
}
|
|
private void GotoTaiChiDungeon(int _dailyQuestId, int _lineId = 0)
|
{
|
if (VersionConfig.Get().isBanShu)
|
{
|
return;
|
}
|
|
var config = DailyQuestConfig.Get(_dailyQuestId);
|
model.currentDailyQuest = config.ID;
|
dungeonModel.currentDungeon = new Dungeon(config.RelatedID, _lineId);
|
WindowCenter.Instance.Open<TaiChilDungeonEntranceWin>();
|
}
|
|
private void GotoHeavenBattleDungeon(int _dailyQuestId, int _lineId = 0)
|
{
|
var config = DailyQuestConfig.Get(_dailyQuestId);
|
dungeonModel.currentDungeon = new Dungeon(config.RelatedID, _lineId);
|
WindowCenter.Instance.Open<HeavenBattleWin>();
|
}
|
|
private void GotoNormalDungeon(int _dailyQuestId, int _lineId = 0)
|
{
|
var config = DailyQuestConfig.Get(_dailyQuestId);
|
dungeonModel.currentDungeon = new Dungeon(config.RelatedID, _lineId);
|
WindowCenter.Instance.Open<NormalDungeonEntranceWin>();
|
}
|
|
private void GotoMultipleDifficultyDungeon(int _dailyQuestId)
|
{
|
var config = DailyQuestConfig.Get(_dailyQuestId);
|
dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
|
dungeonModel.selectedKylinDungeon = default(Dungeon);
|
WindowCenter.Instance.Open<MultipleDifficultyDungeonWin>();
|
}
|
|
private void GotoChaosDemon(int _dailyQuestId)
|
{
|
var completedTimes = model.GetDailyQuestCompletedTimes(_dailyQuestId);
|
var totalTimes = model.GetDailyQuestTotalTimes(_dailyQuestId);
|
if (completedTimes >= totalTimes)
|
{
|
if (DayRemind.Instance.GetDayRemind(DayRemind.DUNGEON_DEMON_TIP))
|
{
|
GotoNormalDungeon(_dailyQuestId);
|
}
|
else
|
{
|
ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get("TodayDungeonComplete"), Language.Get("TodayNoNotify"), (bool isOk, bool isToggle) =>
|
{
|
if (isOk)
|
{
|
GotoNormalDungeon(_dailyQuestId);
|
}
|
if (isToggle)
|
{
|
DayRemind.Instance.SetDayRemind(DayRemind.DUNGEON_DEMON_TIP, true);
|
}
|
});
|
}
|
return;
|
}
|
|
GotoNormalDungeon(_dailyQuestId);
|
}
|
|
private void GotoNuwa()
|
{
|
var id = (int)DailyQuestType.EmperorRelic;
|
var completedTimes = model.GetDailyQuestCompletedTimes(id);
|
var totalTimes = model.GetDailyQuestTotalTimes(id);
|
if (completedTimes >= totalTimes)
|
{
|
if (DayRemind.Instance.GetDayRemind(DayRemind.DUNGEON_RELIC_TIP))
|
{
|
GotoNormalDungeon(id);
|
}
|
else
|
{
|
ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get("TodayDungeonComplete"), Language.Get("TodayNoNotify"), (bool isOk, bool isToggle) =>
|
{
|
if (isOk)
|
{
|
GotoNormalDungeon(id);
|
}
|
if (isToggle)
|
{
|
DayRemind.Instance.SetDayRemind(DayRemind.DUNGEON_RELIC_TIP, true);
|
}
|
});
|
}
|
return;
|
}
|
GotoNormalDungeon(id);
|
}
|
|
private void GotoTrial()
|
{
|
var id = (int)DailyQuestType.Trial;
|
var config = DailyQuestConfig.Get(id);
|
|
var completedTimes = model.GetDailyQuestCompletedTimes(id);
|
var totalTimes = model.GetDailyQuestTotalTimes(id);
|
|
if (completedTimes >= totalTimes)
|
{
|
if (DayRemind.Instance.GetDayRemind(DayRemind.DUNGEON_TRIAL_TIP))
|
{
|
dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
|
WindowCenter.Instance.Open<TrialDungeonSelectWin>();
|
}
|
else
|
{
|
ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get("TodayTrialComplete"), Language.Get("TodayNoNotify"), (bool isOk, bool isToggle) =>
|
{
|
if (isOk)
|
{
|
dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
|
WindowCenter.Instance.Open<TrialDungeonSelectWin>();
|
}
|
if (isToggle)
|
{
|
DayRemind.Instance.SetDayRemind(DayRemind.DUNGEON_TRIAL_TIP, true);
|
}
|
});
|
}
|
return;
|
}
|
|
dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
|
WindowCenter.Instance.Open<TrialDungeonSelectWin>();
|
}
|
|
private void GotoBlastStove()
|
{
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<BlastFurnaceWin>();
|
}
|
|
private void GotoBountyMission()
|
{
|
var inDungeon = IsDungeon();
|
if (inDungeon)
|
{
|
SysNotifyMgr.Instance.ShowTip("InDungeon_CantGo");
|
}
|
else
|
{
|
taskModel.DailyBountyMove();
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
}
|
|
private void GotoFairyTask()
|
{
|
var inDungeon = IsDungeon();
|
if (inDungeon)
|
{
|
SysNotifyMgr.Instance.ShowTip("InDungeon_CantGo");
|
}
|
else
|
{
|
taskModel.DailyFairyTaskMove();
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
}
|
|
private void GotoAllianceBoss(int id, int lineId)
|
{
|
dungeonModel.currentDungeon = new Dungeon(AllianceBossModel.DATAMAPID, lineId);
|
AllianceBossEntranceWin.dailyQuestId = id;
|
WindowCenter.Instance.Open<AllianceBossEntranceWin>();
|
}
|
|
private void GotoTreasureCollectSoul()
|
{
|
var treasureModel = ModelCenter.Instance.GetModel<TreasureModel>();
|
var treasures = treasureModel.GetTreasureCategory(TreasureCategory.Human);
|
var gotoTreasureId = 0;
|
for (int i = treasures.Count - 1; i >= 0; i--)
|
{
|
if (IsTreasureCollectSoul(treasures[i]))
|
{
|
gotoTreasureId = treasures[i];
|
break;
|
}
|
}
|
|
if (gotoTreasureId == 0)
|
{
|
for (int i = 0; i < treasures.Count; i++)
|
{
|
Treasure treasure;
|
if (treasureModel.TryGetTreasure(treasures[i], out treasure))
|
{
|
if (treasure != null
|
&& (treasure.state == TreasureState.Locked || treasure.state == TreasureState.Collecting))
|
{
|
gotoTreasureId = treasure.id;
|
break;
|
}
|
}
|
}
|
}
|
|
WindowCenter.Instance.Close<DailyQuestWin>();
|
|
if (gotoTreasureId == 0)
|
{
|
treasureModel.currentCategory = TreasureCategory.Human;
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.TreasureFunc1);
|
}
|
else
|
{
|
var config = TreasureConfig.Get(gotoTreasureId);
|
treasureModel.selectedTreasure = gotoTreasureId;
|
treasureModel.currentCategory = (TreasureCategory)config.Category;
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.TreasureCollectSoul);
|
}
|
}
|
|
private bool IsTreasureCollectSoul(int _treasureId)
|
{
|
return false;
|
}
|
|
private bool IsDungeon()//是否在副本中
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var mapConfig = MapConfig.Get(mapId);
|
return mapConfig != null && mapConfig.MapFBType != 0;
|
}
|
}
|
|
}
|
|
|
|
|