//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, September 18, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using DG.Tweening;
|
using TableConfig;
|
|
namespace Snxxz.UI
|
{
|
|
public class DungeonFightWin : Window
|
{
|
[SerializeField] Button m_ExitDungeon;
|
[SerializeField] RectTransform m_ExitContainer;
|
[SerializeField] Text m_ExitCoolDown;
|
[SerializeField] DungeonInspireBehaviour m_Inspire;
|
[SerializeField] DungeonLiquidBehaviour m_Liquid;
|
[SerializeField] RectTransform m_ContainerFuncUp;
|
[SerializeField] RectTransform m_ContainerFuncBottom;
|
[SerializeField] RectTransform m_ContainerFuncBtn;
|
[SerializeField] RectTransform m_ContainerResPoint;
|
[SerializeField] RectTransform m_ContainerAncient;
|
[SerializeField] Button m_AncientBtn;
|
[SerializeField] DungeonItemCollect m_ItemCollect;
|
[SerializeField] DungeonGuardSkyBehaviour m_GuardSky;
|
[SerializeField] DungeonBossBriefInfoContainer m_BossInfosContainer;
|
[SerializeField] GameObject m_Container_WHYJ;
|
[SerializeField] DungenWHYJ m_DungenWHYJ;
|
bool excutedAutoExit = false;
|
float timer = 0f;
|
DateTime endTime = DateTime.Now;
|
float existSurplusTime = 10f;
|
|
int collectItem = 0;
|
|
int ruinsTranscriptMapId = 0;
|
DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
PlayerMainDate main { get { return ModelCenter.Instance.GetModel<PlayerMainDate>(); } }
|
RuneTowerModel runeTowerModel { get { return ModelCenter.Instance.GetModel<RuneTowerModel>(); } }
|
BossHomeModel bossHomeModel { get { return ModelCenter.Instance.GetModel<BossHomeModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
ruinsTranscriptMapId = int.Parse(Config.Instance.Get<FuncConfigConfig>("SpRewardMapID").Numerical1);
|
}
|
|
protected override void AddListeners()
|
{
|
m_ExitDungeon.AddListener(ExitDungeon);
|
m_AncientBtn.onClick.AddListener(OnAncientBtn);
|
}
|
|
protected override void OnPreOpen()
|
{
|
timer = 1f;
|
excutedAutoExit = false;
|
existSurplusTime = (float)(model.GetCoolDownEndTime(DungeonCoolDownType.LeaveMap) - DateTime.Now).TotalSeconds;
|
|
ShowItemCollect();
|
ShowResPoint();
|
|
m_Inspire.gameObject.SetActive(false);
|
m_Liquid.gameObject.SetActive(false);
|
var dataMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
m_ExitDungeon.gameObject.SetActive(dataMapId != DemonJarModel.DEMONJAR_MAPID);
|
m_ContainerAncient.gameObject.SetActive(dataMapId == 31160);
|
m_BossInfosContainer.gameObject.SetActive(dataMapId == ElderGodAreaModel.ELDERGODAREA_MAPID || dataMapId == BossHomeModel.BOSSHOME_MAPID);
|
switch (dataMapId)
|
{
|
case 31080:
|
m_Inspire.gameObject.SetActive(true);
|
m_Liquid.gameObject.SetActive(true);
|
break;
|
case DemonJarModel.DEMONJAR_MAPID:
|
var _bossId = ModelCenter.Instance.GetModel<DemonJarModel>().GetBossIdByLine(model.currentDungeon.lineId);
|
var _cfg = Config.Instance.Get<DemonJarConfig>(_bossId);
|
m_Inspire.gameObject.SetActive(_cfg != null && _cfg.CanEnterTimes == 0);
|
break;
|
case 31190:
|
DropItemManager.pickUpCallBack += OnPickItem;
|
break;
|
case ElderGodAreaModel.ELDERGODAREA_MAPID:
|
case BossHomeModel.BOSSHOME_MAPID:
|
m_BossInfosContainer.Display(dataMapId);
|
break;
|
default:
|
break;
|
}
|
m_GuardSky.gameObject.SetActive(dataMapId == 31170);
|
m_ContainerFuncBtn.localPosition = MainInterfaceWin.recordPositionBool ? m_ContainerFuncBottom.localPosition : m_ContainerFuncUp.localPosition;
|
|
model.dungeonCoolDownEvent += OnLeaveMapTimeEvent;
|
MainInterfaceWin.Event_Duplicates += OnChangeFuncBtnPosEvent;
|
if (WHYJBool())
|
{
|
m_Container_WHYJ.SetActive(true);
|
m_DungenWHYJ.Init();
|
}
|
else
|
{
|
m_Container_WHYJ.SetActive(false);
|
}
|
}
|
|
protected override void OnAfterOpen()
|
{
|
var dataMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
switch (dataMapId)
|
{
|
case 31080:
|
if (!NewBieCenter.Instance.completeGuidesBuf.Contains(GeneralConfig.Instance.fairyLandGuideId))
|
{
|
NewBieCenter.Instance.StartNewBieGuide(GeneralConfig.Instance.fairyLandGuideId);
|
}
|
break;
|
}
|
}
|
|
protected override void OnPreClose()
|
{
|
m_BossInfosContainer.Dispose();
|
DropItemManager.pickUpCallBack -= OnPickItem;
|
MainInterfaceWin.Event_Duplicates -= OnChangeFuncBtnPosEvent;
|
model.dungeonCoolDownEvent -= OnLeaveMapTimeEvent;
|
|
try
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var mapConfig = Config.Instance.Get<MapConfig>(mapId);
|
if (mapConfig != null && mapConfig.MapFBType != (int)MapType.OpenCountry)
|
{
|
throw new NullReferenceException();
|
}
|
}
|
catch (Exception ex)
|
{
|
Debug.Log(ex.Message);
|
ExceptionCatcher.ReportException("副本战斗界面异常关闭", ex.Message);
|
}
|
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
UpdateDungeonExitTime();
|
}
|
#endregion
|
|
|
private void OnLeaveMapTimeEvent(DungeonCoolDownType _type)
|
{
|
if (_type != DungeonCoolDownType.LeaveMap)
|
{
|
return;
|
}
|
|
excutedAutoExit = false;
|
existSurplusTime = (float)(model.GetCoolDownEndTime(DungeonCoolDownType.LeaveMap) - DateTime.Now).TotalSeconds;
|
}
|
|
private void ExitDungeon()
|
{
|
var dataMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
var config = Config.Instance.Get<DungeonOpenTimeConfig>(dataMapId);
|
string language = string.Empty;
|
if (dataMapId == GeneralConfig.Instance.ruinsTranscriptMapId)
|
{
|
language = Language.Get(model.mission.lineID > main.LayerNumberNow ? "WHMJ_Quit2" : "WHMJ_Quit1");
|
}
|
else if (dataMapId == BossHomeModel.BOSSHOME_MAPID)
|
{
|
var vipLevel = PlayerDatas.Instance.baseData.VIPLv;
|
var vipNeed = bossHomeModel.GetFloorVipRequirement(PlayerDatas.Instance.baseData.dungeonLineId + 1);
|
var dungeonId = model.GetDungeonId(dataMapId, PlayerDatas.Instance.baseData.dungeonLineId);
|
var dungeonConfig = Config.Instance.Get<DungeonConfig>(dungeonId);
|
|
if (vipLevel < vipNeed)
|
{
|
var moneyNeed = bossHomeModel.GetVipLackCost(PlayerDatas.Instance.baseData.dungeonLineId + 1);
|
language = Language.Get("QuitRemindBossHome", dungeonConfig.FBName, vipNeed, moneyNeed);
|
}
|
else
|
{
|
language = Language.Get(config.ExitDescription);
|
}
|
}
|
else
|
{
|
language = Language.Get(config.ExitDescription);
|
}
|
|
ConfirmCancel.ShowPopConfirm(
|
Language.Get("Mail101"),
|
language,
|
(bool _ok) =>
|
{
|
if (_ok)
|
{
|
model.ExitCurrentDungeon();
|
}
|
}
|
);
|
}
|
|
private void ShowItemCollect()
|
{
|
if (PlayerDatas.Instance.baseData.MapID == 31190)
|
{
|
m_ItemCollect.gameObject.SetActive(true);
|
collectItem = GeneralConfig.Instance.kylinHomeCollectItems[model.currentDungeon.lineId];
|
m_ItemCollect.Init(collectItem);
|
}
|
else
|
{
|
collectItem = 0;
|
m_ItemCollect.gameObject.SetActive(false);
|
}
|
}
|
|
private void ShowResPoint()
|
{
|
m_ContainerResPoint.gameObject.SetActive(PlayerDatas.Instance.baseData.MapID == FairyLeagueModel.FAIRY_LEAGUE_DUNGEON);
|
}
|
|
private void OnPickItem(int _pickInstanceId)
|
{
|
var itemId = 0;
|
DropItemManager.TryGetItemIdFromInstanceId(_pickInstanceId, out itemId);
|
if (collectItem == itemId)
|
{
|
var flyObject = DungeonItemCollectFlyObjectPool.Require();
|
flyObject.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
Vector3 position;
|
if (DropItemManager.TryGetDropPositionFromInstanceId(_pickInstanceId, out position))
|
{
|
var uiPosition = CameraUtility.ConvertToUIPosition(CameraManager.sceneCamera, position);
|
flyObject.Begin(uiPosition, DungeonItemCollect.Instance.transform.position, ItemCollectFlyEnd);
|
}
|
|
model.specialItemCollectRecord = new Item(collectItem, model.specialItemCollectRecord.count + 1);
|
}
|
}
|
|
private void ItemCollectFlyEnd()
|
{
|
m_ItemCollect.OnCollect();
|
}
|
|
private void OnChangeFuncBtnPosEvent(bool open, float speed)
|
{
|
m_ContainerFuncBtn.DOLocalMoveY(open ? m_ContainerFuncUp.localPosition.y : m_ContainerFuncBottom.localPosition.y, speed);
|
}
|
|
private void ProcessDungeonEndCoolDown()
|
{
|
var dataMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
switch (dataMapId)
|
{
|
case RuneTowerModel.RUNETOWER_MAPID:
|
if (!runeTowerModel.allTowerCompleted)
|
{
|
var config = Config.Instance.Get<RuneTowerFloorConfig>(runeTowerModel.currentFloor);
|
var lastFloor = (int)ModelCenter.Instance.GetModel<RuneModel>().RuneTowerOpenLV;
|
var lastFloorConfig = Config.Instance.Get<RuneTowerFloorConfig>(lastFloor);
|
if (model.dungeonResult.isPass == 1 && config.TowerId == lastFloorConfig.TowerId && lastFloorConfig.AutoExit == 0)
|
{
|
var runeTowerStage = StageManager.Instance.CurrentStage as RuneTowerDungeonStage;
|
runeTowerStage.PerformChallengeNextLevel();
|
model.UpdateCoolDown(DungeonCoolDownType.LeaveMap, 0);
|
model.UpdateCoolDown(DungeonCoolDownType.TowerTake, 0);
|
WindowCenter.Instance.Close<DungeonRuneTowerVictoryWin>();
|
}
|
else
|
{
|
model.ExitCurrentDungeon();
|
}
|
}
|
else
|
{
|
model.ExitCurrentDungeon();
|
}
|
break;
|
case RealmModel.REALM_DUNGEON_ID:
|
var realmLv = ModelCenter.Instance.GetModel<RealmModel>().cacheRealmLv;
|
var realmConfig = Config.Instance.Get<RealmConfig>(realmLv);
|
if (model.dungeonResult.leaderID != PlayerDatas.Instance.baseData.PlayerID
|
|| realmConfig == null || realmConfig.IsBigRealm != 1)
|
{
|
model.ExitCurrentDungeon();
|
}
|
break;
|
default:
|
model.ExitCurrentDungeon();
|
break;
|
}
|
}
|
|
private void OnAncientBtn()
|
{
|
if (WindowCenter.Instance.CheckOpen<DungeonAncientAchieveWin>())
|
{
|
WindowCenter.Instance.CloseImmediately<DungeonAncientAchieveWin>();
|
}
|
else
|
{
|
WindowCenter.Instance.Open<DungeonAncientAchieveWin>();
|
}
|
}
|
|
private void UpdateDungeonExitTime()
|
{
|
if (existSurplusTime > 0f)
|
{
|
timer += Time.deltaTime;
|
existSurplusTime -= Time.deltaTime;
|
var dataMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
|
if (timer > 1f)
|
{
|
timer = 0f;
|
switch (dataMapId)
|
{
|
case PersonalBossModel.PERSONALBOSS_MAPID:
|
m_ExitCoolDown.text = Language.Get("QuitCountDownPersonalBoss", (int)existSurplusTime);
|
break;
|
case 31210:
|
m_ExitCoolDown.text = Language.Get("QuitCountDownUnionBoss", (int)existSurplusTime);
|
break;
|
default:
|
break;
|
}
|
}
|
|
if (dataMapId == PersonalBossModel.PERSONALBOSS_MAPID || dataMapId == 31210)
|
{
|
if (!m_ExitContainer.gameObject.activeInHierarchy)
|
{
|
m_ExitContainer.gameObject.SetActive(true);
|
}
|
}
|
else
|
{
|
if (m_ExitContainer.gameObject.activeInHierarchy)
|
{
|
m_ExitContainer.gameObject.SetActive(false);
|
}
|
}
|
|
if (existSurplusTime < 1f && !excutedAutoExit)
|
{
|
excutedAutoExit = true;
|
ProcessDungeonEndCoolDown();
|
}
|
}
|
else
|
{
|
if (m_ExitContainer.gameObject.activeInHierarchy)
|
{
|
m_ExitContainer.gameObject.SetActive(false);
|
}
|
}
|
|
}
|
|
private bool WHYJBool()//判断是否在娲皇遗迹副本
|
{
|
var dataMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
if (dataMapId == GeneralConfig.Instance.ruinsTranscriptMapId)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
}
|
|
}
|
|
|
|
|