//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, November 27, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
|
namespace vnxbqy.UI
|
{
|
|
public class TreasureDungeonMissionHintWin : Window
|
{
|
[SerializeField] RectTransform m_ContainerDisplay;
|
[SerializeField] Text m_Title;
|
|
[SerializeField] Transform m_ContainerTreasureDungeon;
|
[SerializeField] Text m_Description;
|
[SerializeField] Transform m_ContainerTreasure;
|
[SerializeField] Image m_Icon;
|
[SerializeField] ScreenMoveTo m_ScreenMoveTo;
|
[SerializeField] Button m_ViewSkill;
|
|
[SerializeField] Transform m_ContainerDemonDungeon;
|
[SerializeField] PropertyBehaviour[] m_DemonPropertys;
|
|
bool demonTreasureDungeon = false;
|
int treasureId = 0;
|
|
Clock clock = null;
|
|
TreasureModel model { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_ViewSkill.AddListener(ViewSkill);
|
}
|
|
protected override void OnPreOpen()
|
{
|
m_ScreenMoveTo.SetActive(false);
|
BossNotify.OnNotifyStateEvent += OnNotifyStateEvent;
|
BossShowModel.Instance.bossShowCompletedEvent += BossShowCompletedEvent;
|
model.demonDungeonChallengeNext += ChallengeNextEvent;
|
|
if (ClientDungeonStageUtility.isClientDungeon
|
&& ClientDungeonStageUtility.clientMapId == 4000)
|
{
|
treasureId = 101;
|
}
|
else
|
{
|
var allConfigs = TreasureConfig.GetValues();
|
foreach (var value in allConfigs)
|
{
|
if (value.MapId == PlayerDatas.Instance.baseData.MapID && value.LineId == PlayerDatas.Instance.baseData.dungeonLineId)
|
{
|
treasureId = value.ID;
|
break;
|
}
|
}
|
}
|
|
Display();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
BossNotify.OnNotifyStateEvent -= OnNotifyStateEvent;
|
BossShowModel.Instance.bossShowCompletedEvent -= BossShowCompletedEvent;
|
model.demonDungeonChallengeNext -= ChallengeNextEvent;
|
m_ContainerDisplay.SetActive(true);
|
|
if (clock != null)
|
{
|
Clock.Stop(clock);
|
clock = null;
|
}
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
if (!BossShowModel.Instance.BossShowing && !demonTreasureDungeon)
|
{
|
Co_TreasureBehaviour();
|
}
|
}
|
|
#endregion
|
|
public void Display()
|
{
|
CheckDemonTreasureDungeon();
|
m_ContainerTreasureDungeon.SetActive(!demonTreasureDungeon);
|
m_ContainerDemonDungeon.SetActive(demonTreasureDungeon);
|
|
if (!demonTreasureDungeon)
|
{
|
DisplayNormalTreasureDungeon();
|
}
|
else
|
{
|
DisplayDemonTreasureDungeon();
|
}
|
}
|
|
private void BossShowCompletedEvent()
|
{
|
if (!demonTreasureDungeon)
|
{
|
Co_TreasureBehaviour();
|
}
|
}
|
|
void Co_TreasureBehaviour()
|
{
|
m_ScreenMoveTo.transform.SetParentEx(this.transform, Vector3.zero, Vector3.zero, Vector3.one);
|
m_ScreenMoveTo.SetActive(true);
|
m_ScreenMoveTo.enabled = false;
|
|
if (clock != null)
|
{
|
Clock.Stop(clock);
|
clock = null;
|
}
|
|
clock = Clock.AlarmAfter(1.5f, () =>
|
{
|
m_ScreenMoveTo.enabled = true;
|
m_ScreenMoveTo.transform.SetParent(m_ContainerTreasure);
|
m_ScreenMoveTo.destination = Vector2.zero;
|
m_ScreenMoveTo.Begin(false);
|
});
|
}
|
|
private void OnNotifyStateEvent(int _skillId, bool _state)
|
{
|
var _config = bossSkillTipsConfig.Get(_skillId);
|
if (_config != null && _config.mode == 2)
|
{
|
m_ContainerDisplay.SetActive(!_state);
|
}
|
}
|
|
private void ChallengeNextEvent()
|
{
|
Display();
|
if (PlayerDatas.Instance.hero != null)
|
{
|
PlayerDatas.Instance.hero.Behaviour.StartHandupAI();
|
}
|
}
|
|
void DisplayNormalTreasureDungeon()
|
{
|
var config = TreasureConfig.Get(treasureId);
|
var dungeonId = 0;
|
if (ClientDungeonStageUtility.isClientDungeon)
|
{
|
dungeonId = dungeonModel.GetDungeonId(4000, 0);
|
}
|
else
|
{
|
dungeonId = dungeonModel.GetDungeonId(config.MapId, config.LineId);
|
}
|
var dungeonConfig = DungeonConfig.Get(dungeonId);
|
m_Title.text = dungeonConfig.FBName;
|
m_Description.text = dungeonConfig.Description;
|
m_Icon.SetSprite(config.Icon);
|
}
|
|
private void ViewSkill()
|
{
|
HumanTreasureSkillDetailWin.treasureId = treasureId;
|
WindowCenter.Instance.Open<HumanTreasureSkillDetailWin>();
|
}
|
|
void DisplayDemonTreasureDungeon()
|
{
|
TreasureDungeon treasureDungeon;
|
Dictionary<int, int> propertyDict = null;
|
if (model.TryGetTreasureDungeon(treasureId, out treasureDungeon))
|
{
|
propertyDict = treasureDungeon.GetUpperProperty(treasureDungeon.currentLevel + 1);
|
var dungeonInfo = treasureDungeon.Get(treasureDungeon.currentLevel + 1);
|
if (!dungeonInfo.Equals(default(TreasureDungeonInfo)))
|
{
|
var config = TreasureDungeonConfig.Get(dungeonInfo.key);
|
if (config != null)
|
{
|
m_Title.text = Language.Get("DemonTreasureDungeonHintTitle", config.bossName);
|
}
|
}
|
}
|
var index = 0;
|
if (propertyDict != null)
|
{
|
foreach (var key in propertyDict.Keys)
|
{
|
if (index < m_DemonPropertys.Length)
|
{
|
m_DemonPropertys[index].SetActive(true);
|
m_DemonPropertys[index].DisplayUpper(key, propertyDict[key]);
|
index++;
|
}
|
}
|
}
|
for (int i = index; i < m_DemonPropertys.Length; i++)
|
{
|
m_DemonPropertys[i].SetActive(false);
|
}
|
}
|
|
private void CheckDemonTreasureDungeon()
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var lineId = PlayerDatas.Instance.baseData.dungeonLineId;
|
demonTreasureDungeon = false;
|
if (mapId == 41110)
|
{
|
TreasureDungeon treasureDungeon;
|
if (model.TryGetTreasureDungeon(mapId, lineId, out treasureDungeon))
|
{
|
if (treasureDungeon.currentLevel < treasureDungeon.maxLevel - 1)
|
{
|
demonTreasureDungeon = true;
|
}
|
}
|
}
|
}
|
}
|
|
}
|
|
|
|
|