//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, September 12, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
namespace vnxbqy.UI
|
{
|
|
public class DungeonVictoryWin : Window
|
{
|
[SerializeField] protected Transform m_ContainerPoivt;
|
[SerializeField, Header("通关时间")] Transform m_ContainerPassTime;
|
[SerializeField] Text m_PassTime;
|
[SerializeField, Header("经验")] protected Transform m_ContainerExp;
|
[SerializeField] protected Text m_Experience;
|
[SerializeField, Header("金钱")] protected Transform m_ContainerMoney;
|
[SerializeField] Text m_Money;
|
[SerializeField, Header("精华")] protected Transform m_ContainerEssence;
|
[SerializeField] Text m_Essence;
|
[SerializeField, Header("魔晶")] protected Transform m_ContainerMagicEssence;
|
[SerializeField] Text m_MagicEssence;
|
[SerializeField, Header("仙缘币")] protected Transform m_ContainerXianyuanCoins;
|
[SerializeField] Text m_XianyuanCoins;
|
[SerializeField, Header("退出按钮")] protected ButtonEx m_Exit;
|
[SerializeField] protected Text m_ExitTimer;
|
[SerializeField, Header("评级")] GameObject m_GradeBottom;
|
[SerializeField] Image m_Grade;
|
[SerializeField] Text m_GradeScore;
|
[SerializeField, Header("杀怪数量")] protected Transform m_ContainerKillMonster;
|
[SerializeField] Text m_KillMonsterCnt;
|
[SerializeField, Header("新记录")] protected Transform m_ContainerNewRecord;
|
[SerializeField] Text m_Record;
|
[SerializeField, Header("Sp")] protected Transform m_ContainerSP;
|
[SerializeField] Text m_SP;
|
[SerializeField, Header("物品奖励")] protected Transform m_ContainerReward;
|
[SerializeField] protected ItemBehaviour m_SpecialItemCollect;
|
[SerializeField] protected DungeonRewardItem[] passRewardBehaviours;
|
[SerializeField] protected ScaleTween[] m_RewardTweens;
|
|
protected DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
protected float timer = 0f;
|
|
protected List<int> m_RewardIndexs = new List<int>();
|
|
private List<ServerItem> m_RewardSorts = new List<ServerItem>();
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
if (m_Exit != null)
|
{
|
m_Exit.AddListener(ExitDungeon);
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
timer = 0f;
|
if (m_ContainerMagicEssence != null)
|
{
|
m_ContainerMagicEssence.SetActive(false);
|
}
|
if (m_ContainerEssence != null)
|
{
|
m_ContainerEssence.SetActive(false);
|
}
|
if (m_ContainerMoney != null)
|
{
|
m_ContainerMoney.SetActive(false);
|
}
|
if (m_ContainerReward != null)
|
{
|
m_ContainerReward.SetActive(false);
|
}
|
if (m_ContainerNewRecord != null)
|
{
|
m_ContainerNewRecord.SetActive(false);
|
}
|
if (m_ContainerKillMonster != null)
|
{
|
m_ContainerKillMonster.SetActive(false);
|
}
|
if (m_ContainerPoivt != null)
|
{
|
m_ContainerPoivt.SetActive(false);
|
}
|
}
|
|
protected override void OnAfterOpen()
|
{
|
if (PlayerDatas.Instance.baseData.MapID == IceCrystalVeinModel.ICECRYSTALVEIN_MAPID)
|
{
|
var iceCrystalVeinModel = ModelCenter.Instance.GetModel<IceCrystalVeinModel>();
|
iceCrystalVeinModel.IsIceCrystalVein_Copy = true;
|
}
|
}
|
|
protected override void OnPreClose()
|
{
|
|
}
|
|
protected override void OnAfterClose()
|
{
|
var iceCrystalVeinModel = ModelCenter.Instance.GetModel<IceCrystalVeinModel>();
|
|
if (iceCrystalVeinModel.IsIceCrystalVein_Copy)
|
{
|
iceCrystalVeinModel.IsIceCrystalVein_Copy = false;
|
PopupWindowsProcessor.Instance.Add("IceCrystalVeinWin");
|
}
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
var config = DungeonOpenTimeConfig.Get(dungeonModel.dungeonResult.dataMapID);
|
StartCoroutine(Co_DelayDisplay(config.DelayTime * 0.001f));
|
}
|
#endregion
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
if (m_ExitTimer != null && !m_ExitTimer.gameObject.activeInHierarchy)
|
{
|
m_ExitTimer.SetActive(true);
|
}
|
|
timer -= Time.deltaTime;
|
if (timer < 0f)
|
{
|
timer += 0.5f;
|
var endTime = dungeonModel.GetCoolDownEndTime(DungeonCoolDownType.LeaveMap);
|
var seconds = (endTime - TimeUtility.ServerNow).TotalSeconds;
|
DrawExitTimer((int)seconds);
|
}
|
}
|
|
protected virtual void ExitDungeon()
|
{
|
if (ClientDungeonStageUtility.isClientDungeon)
|
{
|
switch (ClientDungeonStageUtility.clientMapId)
|
{
|
case HazyDemonKingModel.CLIENTDATAMAP:
|
case HazyGrassModel.REIKI_CLIENTDATAMAP:
|
case HazyGrassModel.FAIRY_CLIENTDATAMAP:
|
case HazyRegionModel.PRECIOUS_CLIENTDATAMAP:
|
case PersonalBossModel.PERSONALBOSS_MAPID:
|
case ClientGuardDungeon.DATAMAPID:
|
case CommonDungeonSelectModel.CommonDungenMapID1:
|
case CommonDungeonSelectModel.CommonDungenMapID2:
|
case CommonDungeonSelectModel.CommonDungenMapID3:
|
case CommonDungeonSelectModel.CommonDungenMapID4:
|
case CommonDungeonSelectModel.CommonDungenMapID5:
|
ClientDungeonStageUtility.ExitNormalClientDungeon();
|
return;
|
}
|
}
|
dungeonModel.ExitCurrentDungeon();
|
}
|
|
protected virtual void DrawExitTimer(int seconds)
|
{
|
if (m_ExitTimer != null)
|
{
|
m_ExitTimer.text = Language.Get("DungeonVictoryWin_Btn_Exit_1", Mathf.Clamp(seconds, 0, int.MaxValue));
|
}
|
}
|
|
protected virtual void DrawItemRewards()
|
{
|
var merged = false;
|
var serveritems = dungeonModel.dungeonResult.itemInfo;
|
var hasReward = (serveritems != null && serveritems.Length > 0) || dungeonModel.specialItemCollectRecord.count > 0;
|
|
m_ContainerReward.SetActive(hasReward);
|
|
m_RewardSorts.Clear();
|
if (serveritems != null)
|
{
|
m_RewardSorts.AddRange(serveritems);
|
int _mapid = dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
switch (_mapid)
|
{
|
case 31130:
|
case 60010:
|
m_RewardSorts.Sort(CompareTrialItemIndex);
|
break;
|
case 31240:
|
m_RewardSorts.Sort(CompareItemColor);
|
break;
|
}
|
}
|
|
m_RewardIndexs.Clear();
|
if (m_RewardTweens != null && m_RewardTweens.Length > 0)
|
{
|
for (int i = 0; i < m_RewardTweens.Length; i++)
|
{
|
m_RewardTweens[i].SetEndState();
|
}
|
}
|
if (m_RewardSorts.Count > 0)
|
{
|
var items = new List<ItemModel>();
|
for (int i = 0; i < m_RewardSorts.Count; i++)
|
{
|
var serverItem = m_RewardSorts[i];
|
|
var itemInfo = new ItemInfo();
|
itemInfo.itemId = serverItem.ItemID;
|
itemInfo.userData = serverItem.UserData;
|
if (!merged && itemInfo.itemId == dungeonModel.specialItemCollectRecord.id)
|
{
|
itemInfo.count = serverItem.Count + dungeonModel.specialItemCollectRecord.count;
|
merged = true;
|
}
|
else
|
{
|
itemInfo.count = serverItem.Count;
|
}
|
|
items.Add(new ItemModel(PackType.Item, itemInfo));
|
}
|
|
for (int i = 0; i < passRewardBehaviours.Length; i++)
|
{
|
var behaviour = passRewardBehaviours[i];
|
if (i < items.Count)
|
{
|
behaviour.transform.parent.SetActive(true);
|
behaviour.SetActive(false);
|
behaviour.serverItem = m_RewardSorts[i];
|
behaviour.Init(items[i]);
|
m_RewardIndexs.Add(m_SpecialItemCollect == null ? i : i + 1);
|
}
|
else
|
{
|
behaviour.transform.parent.SetActive(false);
|
behaviour.SetActive(false);
|
}
|
}
|
|
if (m_SpecialItemCollect != null)
|
{
|
if (!merged && dungeonModel.specialItemCollectRecord.count > 0)
|
{
|
m_SpecialItemCollect.transform.parent.SetActive(true);
|
m_SpecialItemCollect.SetActive(false);
|
m_SpecialItemCollect.SetItem(dungeonModel.specialItemCollectRecord);
|
m_RewardIndexs.Insert(0, 0);
|
}
|
else
|
{
|
m_SpecialItemCollect.transform.parent.SetActive(false);
|
m_SpecialItemCollect.SetActive(false);
|
}
|
}
|
|
}
|
if (m_RewardIndexs.Count > 0 && m_RewardTweens != null && m_RewardTweens.Length > 0)
|
{
|
PlayRewardTween(0);
|
}
|
}
|
|
protected virtual void PlayRewardTween(int _playIndex)
|
{
|
if (_playIndex < m_RewardIndexs.Count)
|
{
|
var _index = m_RewardIndexs[_playIndex];
|
if (_index < m_RewardTweens.Length)
|
{
|
m_RewardTweens[_index].SetStartState();
|
m_RewardTweens[_index].SetActive(true);
|
m_RewardTweens[_index].Play(() =>
|
{
|
_playIndex += 1;
|
PlayRewardTween(_playIndex);
|
});
|
}
|
}
|
}
|
|
protected virtual void DrawPassGrade()
|
{
|
if (m_Grade != null)
|
{
|
var grade = dungeonModel.dungeonResult.grade;
|
if (grade > 0)
|
{
|
m_GradeBottom.SetActive(true);
|
switch (grade)
|
{
|
case 5:
|
m_Grade.SetSprite("Remark_S");
|
m_Grade.SetNativeSize();
|
break;
|
case 4:
|
m_Grade.SetSprite("Remark_A");
|
m_Grade.SetNativeSize();
|
break;
|
case 3:
|
m_Grade.SetSprite("Remark_B");
|
m_Grade.SetNativeSize();
|
break;
|
case 2:
|
m_Grade.SetSprite("Remark_C");
|
m_Grade.SetNativeSize();
|
break;
|
case 1:
|
m_Grade.SetSprite("Remark_D");
|
m_Grade.SetNativeSize();
|
break;
|
default:
|
break;
|
}
|
m_Grade.SetNativeSize();
|
if (m_GradeScore != null)
|
{
|
m_GradeScore.text = string.Empty;
|
if (PlayerDatas.Instance.baseData.MapID == PersonalBossModel.PERSONALBOSS_MAPID)
|
{
|
int rate = 0;
|
if (dungeonModel.GetRewardRateWithGrade(PersonalBossModel.PERSONALBOSS_MAPID, grade, out rate))
|
{
|
m_GradeScore.SetActive(true);
|
m_GradeScore.text = Language.Get("PersonalBossGrade", rate);
|
}
|
}
|
else
|
{
|
m_GradeScore.SetActive(false);
|
}
|
}
|
}
|
else
|
{
|
m_GradeBottom.SetActive(false);
|
if (m_GradeScore != null)
|
{
|
m_GradeScore.text = string.Empty;
|
}
|
}
|
}
|
|
}
|
|
protected virtual void DrawNewRecord()
|
{
|
if (dungeonModel.dungeonResult.upPer > 0)
|
{
|
m_ContainerNewRecord.SetActive(true);
|
m_Record.text = Language.Get("FairyLand_Func26", dungeonModel.dungeonResult.upPer);
|
}
|
else
|
{
|
m_ContainerNewRecord.SetActive(false);
|
}
|
}
|
|
protected virtual void DrawKillMonster()
|
{
|
if (dungeonModel.dungeonResult.npcTotal > 0)
|
{
|
m_ContainerKillMonster.SetActive(true);
|
m_KillMonsterCnt.text = dungeonModel.dungeonResult.npcTotal.ToString();
|
}
|
else
|
{
|
m_ContainerKillMonster.SetActive(false);
|
}
|
|
}
|
|
protected virtual void DrawGetExp(bool _force = false)
|
{
|
if (m_ContainerExp != null)
|
{
|
if (dungeonModel.dungeonResult.totalExp > 0 || _force)
|
{
|
m_ContainerExp.SetActive(true);
|
m_Experience.text = UIHelper.ReplaceLargeNum((ulong)dungeonModel.dungeonResult.totalExp);
|
}
|
else
|
{
|
m_ContainerExp.SetActive(false);
|
}
|
}
|
|
}
|
|
protected virtual void DrawPassTime()
|
{
|
m_ContainerPassTime.SetActive(dungeonModel.dungeonResult.costTime > 0);
|
m_PassTime.text = StringUtility.Contact((int)(dungeonModel.dungeonResult.costTime * 0.001f), Language.Get("RealmWin_Bewrite_35"));
|
}
|
|
protected virtual void DrawGetXianYuanCoins()
|
{
|
if (m_ContainerXianyuanCoins == null)
|
{
|
return;
|
}
|
|
var dungeonResult = dungeonModel.dungeonResult;
|
var results = dungeonResult.xianyuanCoin;
|
bool isShow = true;
|
|
if (results == null || results.Length == 0)
|
{
|
isShow = false;
|
}
|
|
m_ContainerXianyuanCoins.SetActive(isShow);
|
|
if (!isShow)
|
{
|
return;
|
}
|
|
int getCoins = 0;
|
int reason = 0;
|
if (results != null && results.Length > 1)
|
{
|
getCoins = results[0];
|
reason = results[1];
|
}
|
|
if (getCoins > 0 && reason == 0)
|
{
|
m_XianyuanCoins.text = UIHelper.ReplaceLargeNum((ulong)getCoins);
|
}
|
else
|
{
|
switch (reason)
|
{
|
case 1:
|
m_XianyuanCoins.text = UIHelper.AppendColor(TextColType.Red, Language.Get("DungeonAssist145"));
|
break;
|
case 2:
|
m_XianyuanCoins.text = UIHelper.AppendColor(TextColType.Red, Language.Get("DungeonAssist144"));
|
break;
|
default:
|
if (dungeonResult.dataMapID == 51010)
|
{
|
m_ContainerXianyuanCoins.SetActive(false);
|
}
|
break;
|
}
|
}
|
}
|
|
protected virtual void DrawGetMoney()
|
{
|
if (m_ContainerMoney != null)
|
{
|
m_ContainerMoney.SetActive(false);
|
}
|
|
if (m_ContainerMagicEssence != null)
|
{
|
m_ContainerMagicEssence.SetActive(false);
|
}
|
|
if (m_ContainerEssence != null)
|
{
|
m_ContainerEssence.SetActive(false);
|
}
|
|
if (dungeonModel.dungeonResult.money != null && dungeonModel.dungeonResult.money.Length > 0)
|
{
|
var dungeonMoney = dungeonModel.dungeonResult.money;
|
for (int i = 0; i < dungeonMoney.Length; i++)
|
{
|
var money = dungeonMoney[i];
|
switch (money.moneyType)
|
{
|
case 3:
|
if (m_ContainerMoney != null && money.moneyValue > 0)
|
{
|
m_ContainerMoney.SetActive(true);
|
m_Money.text = UIHelper.ReplaceLargeNum((ulong)money.moneyValue);
|
}
|
break;
|
case 14:
|
if (m_ContainerMagicEssence != null && money.moneyValue > 0)
|
{
|
m_ContainerMagicEssence.SetActive(true);
|
m_MagicEssence.text = UIHelper.ReplaceLargeNum((ulong)money.moneyValue);
|
}
|
break;
|
case 23:
|
if (m_ContainerEssence != null && money.moneyValue > 0)
|
{
|
m_ContainerEssence.SetActive(true);
|
m_Essence.text = UIHelper.ReplaceLargeNum((ulong)money.moneyValue);
|
}
|
break;
|
}
|
}
|
}
|
|
}
|
|
protected virtual void DrawSP()
|
{
|
var mapId = dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
if (dungeonModel.dungeonResult.sp > 0)
|
{
|
m_ContainerSP.SetActive(true);
|
m_SP.text = dungeonModel.dungeonResult.sp.ToString();
|
}
|
else
|
{
|
m_ContainerSP.SetActive(false);
|
}
|
}
|
|
IEnumerator Co_DelayDisplay(float _delay)
|
{
|
yield return new WaitForSeconds(_delay);
|
Display();
|
}
|
|
protected virtual void RequireDungeonExit()
|
{
|
if (m_Exit != null)
|
{
|
m_Exit.SetActive(true);
|
}
|
var endTime = dungeonModel.GetCoolDownEndTime(DungeonCoolDownType.LeaveMap);
|
var seconds = (endTime - TimeUtility.ServerNow).TotalSeconds;
|
timer = (float)seconds - (int)seconds;
|
|
DrawExitTimer((int)seconds);
|
}
|
|
protected virtual void Display()
|
{
|
m_ContainerPoivt.SetActive(true);
|
RequireDungeonExit();
|
DrawPassTime();
|
DrawGetExp();
|
DrawGetMoney();
|
DrawItemRewards();
|
DrawPassGrade();
|
DrawSP();
|
DrawKillMonster();
|
DrawNewRecord();
|
DrawGetXianYuanCoins();
|
}
|
|
protected int CompareTrialItemIndex(ServerItem x, ServerItem y)
|
{
|
var config_x = ItemConfig.Get(x.ItemID);
|
var config_y = ItemConfig.Get(y.ItemID);
|
bool equip_x = config_x.Type >= 101 && config_x.Type <= 109;
|
bool equip_y = config_y.Type >= 101 && config_y.Type <= 109;
|
if (equip_x.CompareTo(equip_y) != 0)
|
{
|
return equip_x.CompareTo(equip_y);
|
}
|
if (!equip_x && !equip_y)
|
{
|
bool type_13_x = config_x.Type == 13;
|
bool type_13_y = config_y.Type == 13;
|
if (type_13_x.CompareTo(type_13_y) != 0)
|
{
|
return -type_13_x.CompareTo(type_13_y);
|
}
|
if (config_x.ItemColor.CompareTo(config_y.ItemColor) != 0)
|
{
|
return -config_x.ItemColor.CompareTo(config_y.ItemColor);
|
}
|
return x.ItemID.CompareTo(y.ItemID);
|
}
|
else
|
{
|
bool type_108109_x = config_x.Type >= 108;
|
bool type_108109_y = config_y.Type >= 108;
|
if (type_108109_x || type_108109_y)
|
{
|
if (config_x.Type.CompareTo(config_y.Type) != 0)
|
{
|
return -config_x.Type.CompareTo(config_y.Type);
|
}
|
}
|
if (config_x.ItemColor.CompareTo(config_y.ItemColor) != 0)
|
{
|
return -config_x.ItemColor.CompareTo(config_y.ItemColor);
|
}
|
if (config_x.StarLevel.CompareTo(config_y.StarLevel) != 0)
|
{
|
return -config_x.StarLevel.CompareTo(config_y.StarLevel);
|
}
|
if (config_x.LV.CompareTo(config_y.LV) != 0)
|
{
|
return -config_x.LV.CompareTo(config_y.LV);
|
}
|
return x.ItemID.CompareTo(y.ItemID);
|
}
|
}
|
|
protected int CompareItemColor(ServerItem x, ServerItem y)
|
{
|
var config_x = ItemConfig.Get(x.ItemID);
|
var config_y = ItemConfig.Get(y.ItemID);
|
if (config_x.ItemColor != config_y.ItemColor)
|
{
|
return -config_x.ItemColor.CompareTo(config_y.ItemColor);
|
}
|
return 0;
|
}
|
}
|
}
|
|
|
|
|