//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, April 04, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class HazyRegionWin : Window
|
{
|
[SerializeField] HazyRegionEntrancePanel m_EntrancePanel;
|
[SerializeField] HazyRegionIncidentPanel m_IncidentPanel;
|
[SerializeField] ScaleTween m_BottomScaleTween;
|
[SerializeField] UIAlphaTween m_AlphaTween;
|
|
HazyRegionStage m_Stage = HazyRegionStage.Entrance;
|
HazyRegionStage stage
|
{
|
get { return m_Stage; }
|
set
|
{
|
if (m_Stage != value)
|
{
|
switch (m_Stage)
|
{
|
case HazyRegionStage.Entrance:
|
// CloseHazyRegionEntrance();
|
break;
|
case HazyRegionStage.Playing:
|
CloseHazyRegionIncident();
|
break;
|
}
|
|
m_Stage = value;
|
|
switch (m_Stage)
|
{
|
case HazyRegionStage.Entrance:
|
OpenHazyRegionEntrance();
|
break;
|
case HazyRegionStage.Playing:
|
StartEntranceAnimation();
|
break;
|
}
|
}
|
}
|
}
|
|
HazyRegionModel model { get { return ModelCenter.Instance.GetModel<HazyRegionModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
}
|
|
private void OnVipFuncClick()
|
{
|
WindowCenter.Instance.Open<HazyRegionAutoSettingWin>();
|
}
|
|
protected override void OnPreOpen()
|
{
|
var _hero = PlayerDatas.Instance.hero;
|
if (_hero != null)
|
{
|
_hero.LastChkCanAutoHazyRegionTime = 0;
|
_hero.hazyAutoWaitTime = 2;
|
}
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
|
Display();
|
|
model.onHazyRegionStateRefresh += OnHazyRegionStateRefresh;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
if (stage == HazyRegionStage.Playing)
|
{
|
StartCoroutine(Co_VerifyCompleteAllIncidents());
|
}
|
}
|
|
protected override void OnPreClose()
|
{
|
m_EntrancePanel.Dispose();
|
m_IncidentPanel.Dispose();
|
|
StopAllCoroutines();
|
|
m_BottomScaleTween.Stop();
|
m_BottomScaleTween.SetStartState();
|
m_AlphaTween.SetStartState();
|
|
model.onHazyRegionStateRefresh -= OnHazyRegionStateRefresh;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
void Display()
|
{
|
m_EntrancePanel.SetActive(false);
|
m_IncidentPanel.SetActive(false);
|
|
m_Stage = model.playing ? HazyRegionStage.Playing : HazyRegionStage.Entrance;
|
|
switch (stage)
|
{
|
case HazyRegionStage.Entrance:
|
OpenHazyRegionEntrance();
|
break;
|
case HazyRegionStage.Playing:
|
OpenHazyRegionIncident();
|
break;
|
}
|
}
|
|
void OpenHazyRegionEntrance()
|
{
|
m_IncidentPanel.SetActive(false);
|
m_EntrancePanel.SetActive(true);
|
m_BottomScaleTween.Stop();
|
m_BottomScaleTween.SetStartState();
|
m_AlphaTween.SetStartState();
|
m_EntrancePanel.Dispose();
|
m_EntrancePanel.Display();
|
}
|
|
|
void OpenHazyRegionIncident()
|
{
|
m_IncidentPanel.SetActive(true);
|
m_IncidentPanel.Dispose();
|
m_IncidentPanel.Display();
|
GetWidgt<Button>("Btn_Sweep").SetListener(()=> {
|
var dungeonConfig = DungeonConfig.Get(312800);
|
if (PlayerDatas.Instance.baseData.LV < dungeonConfig.SweepLVLimit)
|
{
|
SysNotifyMgr.Instance.ShowTip("IceCrystal_LV", dungeonConfig.SweepLVLimit);
|
return;
|
}
|
|
var dungeonModel = ModelCenter.Instance.GetModel<DungeonModel>();
|
bool isSweep = false;
|
foreach (var eventID in model.GetAllIncidents())
|
{
|
HazyRegionModel.Incident _incident;
|
if (!model.TryGetIncident(eventID, out _incident))
|
{
|
continue;
|
}
|
if (_incident.state == HazyRegionModel.IncidentState.Complete)
|
{
|
continue;
|
}
|
|
isSweep = true;
|
var hazyConfig = HazyRegionConfig.Get(eventID);
|
var fbID = dungeonModel.GetDungeonId(hazyConfig.dungeonId, hazyConfig.lineId);
|
if (fbID == 0)
|
{
|
//奇遇扫荡
|
var pak = new CA504_tagCMPlayerGetReward();
|
pak.RewardType = (byte)GotServerRewardType.Def_RewardType_FairyAdventuresAward;
|
pak.DataEx = (uint)eventID;
|
pak.DataExStr = "13";
|
pak.DataExStrLen = (byte)pak.DataExStr.Length;
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
else
|
{
|
var send = new CA505_tagCMBeginFBWipeOut();
|
send.MapID = (ushort)hazyConfig.dungeonId;
|
send.LineID = (ushort)hazyConfig.lineId;
|
send.Cnt = 1;
|
send.IsFinish = 1;
|
GameNetSystem.Instance.SendInfo(send);
|
}
|
}
|
|
if (isSweep)
|
{
|
WindowJumpMgr.Instance.WindowJumpToEx("HazyRegionSweepWin");
|
}
|
|
|
});
|
}
|
|
void CloseHazyRegionIncident()
|
{
|
m_IncidentPanel.Dispose();
|
}
|
|
void CloseHazyRegionEntrance()
|
{
|
m_EntrancePanel.Dispose();
|
m_EntrancePanel.SetActive(false);
|
}
|
|
void StartEntranceAnimation()
|
{
|
m_BottomScaleTween.Play();
|
m_AlphaTween.Play();
|
StartCoroutine(Co_EntranceAnimation());
|
}
|
|
IEnumerator Co_EntranceAnimation()
|
{
|
yield return WaitingForSecondConst.GetWaitForSeconds(m_AlphaTween.duration * 0.5f);
|
CloseHazyRegionEntrance();
|
yield return WaitingForSecondConst.GetWaitForSeconds(m_AlphaTween.duration * 0.2f);
|
model.requireIncidentAnimation = true;
|
OpenHazyRegionIncident();
|
}
|
|
private void OnHazyRegionStateRefresh(int state)
|
{
|
if (state == 2)
|
{
|
if ((model.playing && stage != HazyRegionStage.Playing) || (!model.playing && stage != HazyRegionStage.Entrance))
|
{
|
Display();
|
}
|
}
|
else
|
{
|
stage = state == 0 ? HazyRegionStage.Entrance : HazyRegionStage.Playing;
|
}
|
}
|
|
IEnumerator Co_VerifyCompleteAllIncidents()
|
{
|
yield return WaitingForSecondConst.WaitMS500;
|
|
var allComplete = true;
|
var incidents = model.GetAllIncidents();
|
if (incidents != null)
|
{
|
foreach (var id in incidents)
|
{
|
HazyRegionModel.Incident incident;
|
if (model.TryGetIncident(id, out incident))
|
{
|
if (incident.state != HazyRegionModel.IncidentState.Complete)
|
{
|
allComplete = false;
|
}
|
}
|
}
|
}
|
|
if (allComplete)
|
{
|
WindowCenter.Instance.Open<HazyRegionCompleteWin>();
|
}
|
}
|
|
enum HazyRegionStage
|
{
|
Entrance,
|
Playing,
|
}
|
}
|
|
}
|
|
|
|
|