using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
using vnxbqy.UI;
|
|
//对战结束后,胜利或失败的提示
|
public class ArenaSettlementWin : ILWindow
|
{
|
Transform m_Container1;
|
Transform m_Container2;
|
Transform m_Container3;
|
Transform Container_Rewards;
|
|
ButtonEx m_Exit;
|
Text m_ExitTimer;
|
|
Transform m_BackWin;
|
Transform m_BackFail;
|
ItemBehaviour m_SpecialItemCollect;
|
DungeonRewardItem[] passRewardBehaviours = new DungeonRewardItem[5];
|
ScaleTween[] m_RewardTweens = new ScaleTween[6];
|
List<Item> items = new List<Item>();
|
private bool bShow = false;
|
protected DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
protected float timer = 0f;
|
protected float LimitTimer = 5f;
|
protected List<int> m_RewardIndexs = new List<int>();
|
private List<ServerItem> m_RewardSorts = new List<ServerItem>();
|
#region Built-in
|
|
protected override void BindController()
|
{
|
m_BackFail = proxy.GetWidgtEx<Transform>("Back_Failure");
|
m_Container1 = proxy.GetWidgtEx<Transform>("Container_1");
|
m_Container2 = proxy.GetWidgtEx<Transform>("Container_2");
|
m_Container3 = proxy.GetWidgtEx<Transform>("Container_3");
|
m_Exit = proxy.GetWidgtEx<ButtonEx>("Btn_Exit");
|
m_ExitTimer = proxy.GetWidgtEx<Text>("Txt_ExitTimer");
|
|
Container_Rewards = proxy.GetWidgtEx<Transform>("Container_Rewards");
|
m_BackWin = proxy.GetWidgtEx<Transform>("Back_Win");
|
m_SpecialItemCollect = proxy.GetWidgtEx<ItemBehaviour>("Reward_Special");
|
passRewardBehaviours[0] = proxy.GetWidgtEx<DungeonRewardItem>("Reward_0");
|
passRewardBehaviours[1] = proxy.GetWidgtEx<DungeonRewardItem>("Reward_1");
|
passRewardBehaviours[2] = proxy.GetWidgtEx<DungeonRewardItem>("Reward_2");
|
passRewardBehaviours[3] = proxy.GetWidgtEx<DungeonRewardItem>("Reward_3");
|
passRewardBehaviours[4] = proxy.GetWidgtEx<DungeonRewardItem>("Reward_4");
|
m_RewardTweens[0] = proxy.GetWidgtEx<ScaleTween>("Reward_Special");
|
m_RewardTweens[1] = proxy.GetWidgtEx<ScaleTween>("Reward_0");
|
m_RewardTweens[2] = proxy.GetWidgtEx<ScaleTween>("Reward_1");
|
m_RewardTweens[3] = proxy.GetWidgtEx<ScaleTween>("Reward_2");
|
m_RewardTweens[4] = proxy.GetWidgtEx<ScaleTween>("Reward_3");
|
m_RewardTweens[5] = proxy.GetWidgtEx<ScaleTween>("Reward_4");
|
|
m_Container1.transform.Find("Txt_PassTimeStatic").GetComponent<Text>().text = StringUtility.Contact(Language.Get("ArenaSetMentle_Time"), ":");
|
m_Container2.transform.Find("Txt_ScoreStatic").GetComponent<Text>().text = StringUtility.Contact(Language.Get("ArenaSetMentle_Score"),":");
|
m_Container3.transform.Find("Txt_NumberStatic").GetComponent<Text>().text = StringUtility.Contact(Language.Get("ArenaSetMentle_Blackboard"), ":");
|
if(ArenaManagerModel.Instance.s_StepTimes != null)
|
LimitTimer = ArenaManagerModel.Instance.s_StepTimes[2] + 1;
|
}
|
|
protected override void AddListeners()
|
{
|
if(m_Exit != null)
|
{
|
m_Exit.AddListener(ExitDungeon);
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
timer = 0f;
|
|
if (dungeonModel.dungeonResult.isPass == 0)
|
{
|
m_BackWin.SetActiveIL(false);
|
m_BackFail.SetActiveIL(true);
|
}
|
else
|
{
|
m_BackWin.SetActiveIL(true);
|
m_BackFail.SetActiveIL(false);
|
}
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
bShow = false;
|
}
|
|
protected override void OnAfterClose()
|
{
|
ArenaManager.isArenaClient = false;
|
}
|
protected override void OnActived()
|
{
|
base.OnActived();
|
timer = 0;
|
Display();
|
bShow = true;
|
}
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
if (m_ExitTimer != null && !m_ExitTimer.gameObject.activeInHierarchy)
|
{
|
m_ExitTimer.SetActiveIL(true);
|
}
|
if (!bShow)
|
return;
|
timer = timer + Time.deltaTime;
|
float now = LimitTimer - timer;
|
if (now >= 0)
|
{
|
DrawExitTimer((int)now);
|
}
|
else
|
{
|
now = 0;
|
if (ArenaModel.Instance.isSkipFightChoose)
|
{
|
WindowCenter.Instance.CloseIL<ArenaSettlementWin>();
|
}
|
else
|
{
|
ArenaModel.Instance.StopClientArena();
|
}
|
}
|
}
|
|
#endregion
|
void ExitDungeon()
|
{
|
if (ArenaModel.Instance.isSkipFightChoose)
|
{
|
WindowCenter.Instance.CloseIL<ArenaSettlementWin>();
|
}
|
else
|
{
|
ArenaModel.Instance.StopClientArena();
|
}
|
}
|
|
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 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].SetActiveIL(true);
|
m_RewardTweens[_index].Play(() =>
|
{
|
_playIndex += 1;
|
PlayRewardTween(_playIndex);
|
});
|
}
|
}
|
}
|
|
//增加积分
|
protected void DrawPassTime()
|
{
|
var surplus = ArenaManagerModel.Instance.dungeonEndTime - TimeUtility.ServerNow;
|
int EndTime = ArenaManagerModel.Instance.s_StepTimes[0] - Mathf.CeilToInt((float)surplus.TotalSeconds);
|
|
m_Container1.transform.Find("Txt_PassTime").GetComponent<Text>().text = StringUtility.Contact(EndTime < 0 ? 0: EndTime, Language.Get("RealmWin_Bewrite_35"));
|
//积分变化
|
m_Container2.transform.Find("Txt_Score").GetComponent<Text>().text = dungeonModel.dungeonResult.updScore.ToString();
|
m_Container2.transform.Find("Txt_ScoreAdd").GetComponent<Text>().text = dungeonModel.dungeonResult.addScore.ToString();
|
if (dungeonModel.dungeonResult.addScore > 0)
|
{
|
m_Container2.transform.Find("Up").SetActiveIL(true);
|
m_Container2.transform.Find("Down").SetActiveIL(false);
|
m_Container2.transform.Find("Txt_ScoreAdd").SetActiveIL(true);
|
|
}
|
else if(dungeonModel.dungeonResult.addScore == 0)
|
{
|
m_Container2.transform.Find("Up").SetActiveIL(false);
|
m_Container2.transform.Find("Down").SetActiveIL(false);
|
m_Container2.transform.Find("Txt_ScoreAdd").SetActiveIL(false);
|
}
|
else
|
{
|
m_Container2.transform.Find("Up").SetActiveIL(false);
|
m_Container2.transform.Find("Down").SetActiveIL(true);
|
m_Container2.transform.Find("Txt_ScoreAdd").SetActiveIL(true);
|
}
|
|
//排名变化
|
m_Container3.transform.Find("Txt_Number").GetComponent<Text>().text = dungeonModel.dungeonResult.updOrder.ToString();
|
int addOrder = 0;
|
if(dungeonModel.dungeonResult.curOrder <= 0)
|
{
|
addOrder = 0;
|
}
|
else
|
{
|
addOrder = dungeonModel.dungeonResult.updOrder - dungeonModel.dungeonResult.curOrder;
|
}
|
|
|
if (addOrder < 0)
|
{
|
m_Container3.transform.Find("Up").SetActiveIL(true);
|
m_Container3.transform.Find("Down").SetActiveIL(false);
|
m_Container3.transform.Find("Txt_NumberAdd").SetActiveIL(true);
|
}
|
else if(addOrder == 0 )
|
{
|
m_Container3.transform.Find("Up").SetActiveIL(false);
|
m_Container3.transform.Find("Down").SetActiveIL(false);
|
m_Container3.transform.Find("Txt_NumberAdd").SetActiveIL(false);
|
}
|
else
|
{
|
m_Container3.transform.Find("Up").SetActiveIL(false);
|
m_Container3.transform.Find("Down").SetActiveIL(true);
|
m_Container3.transform.Find("Txt_NumberAdd").SetActiveIL(true);
|
}
|
|
m_Container3.transform.Find("Txt_NumberAdd").GetComponent<Text>().text = Math.Abs(addOrder).ToString();
|
if (dungeonModel.dungeonResult.updOrder <= 0)
|
{
|
m_Container3.transform.Find("Txt_Number").GetComponent<Text>().text = Language.Get("DemonJar13");
|
}
|
}
|
|
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;
|
}
|
void Display()
|
{
|
DrawPassTime();
|
|
var result = dungeonModel.dungeonResult;
|
|
items.Clear();
|
|
if (result.totalExp > 0)
|
{
|
items.Add(new Item()
|
{
|
itemId = GeneralDefine.expDisplayId,
|
count = result.totalExp,
|
});
|
}
|
|
if (result.money != null && result.money.Length > 0)
|
{
|
for (int i = 0; i < result.money.Length; i++)
|
{
|
var moneyType = result.money[i].moneyType;
|
if (GeneralDefine.moneyDisplayIds.ContainsKey(moneyType))
|
{
|
items.Add(new Item()
|
{
|
itemId = GeneralDefine.moneyDisplayIds[moneyType],
|
count = result.money[i].moneyValue,
|
});
|
}
|
}
|
}
|
|
if (result.itemInfo != null && result.itemInfo.Length > 0)
|
{
|
for (int i = 0; i < result.itemInfo.Length; i++)
|
{
|
items.Add(new Item()
|
{
|
itemId = result.itemInfo[i].ItemID,
|
count = result.itemInfo[i].Count,
|
});
|
}
|
}
|
else
|
{
|
Container_Rewards.SetActiveIL(false);
|
return;
|
}
|
if(result.itemInfo.Length == 0)
|
{
|
|
}
|
else
|
{
|
Container_Rewards.SetActiveIL(true);
|
DrawItemRewards();
|
}
|
|
|
}
|
|
void DrawItemRewards()
|
{
|
var merged = false;
|
var hasReward = items.Count > 0;
|
|
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 (items.Count > 0)
|
{
|
var itemModels = new List<ItemCellModel>();
|
for (int i = 0; i < items.Count; i++)
|
{
|
if (!merged && items[i].itemId == dungeonModel.specialItemCollectRecord.id)
|
{
|
itemModels.Add(new ItemCellModel(items[i].itemId, false,
|
(ulong)items[i].count + (ulong)dungeonModel.specialItemCollectRecord.count));
|
merged = true;
|
}
|
else
|
{
|
itemModels.Add(new ItemCellModel(items[i].itemId, false, (ulong)items[i].count));
|
}
|
}
|
|
for (int i = 0; i < passRewardBehaviours.Length; i++)
|
{
|
var behaviour = passRewardBehaviours[i];
|
if (i < itemModels.Count)
|
{
|
behaviour.transform.parent.SetActiveIL(true);
|
behaviour.SetActiveIL(false);
|
behaviour.Init(itemModels[i]);
|
m_RewardIndexs.Add(m_SpecialItemCollect == null ? i : i + 1);
|
}
|
else
|
{
|
behaviour.transform.parent.SetActiveIL(false);
|
behaviour.SetActiveIL(false);
|
}
|
}
|
|
if (m_SpecialItemCollect != null)
|
{
|
if (!merged && dungeonModel.specialItemCollectRecord.count > 0)
|
{
|
m_SpecialItemCollect.transform.parent.SetActiveIL(true);
|
m_SpecialItemCollect.SetActiveIL(false);
|
m_SpecialItemCollect.SetItem(dungeonModel.specialItemCollectRecord);
|
m_RewardIndexs.Insert(0, 0);
|
}
|
else
|
{
|
m_SpecialItemCollect.transform.parent.SetActiveIL(false);
|
m_SpecialItemCollect.SetActiveIL(false);
|
}
|
}
|
|
}
|
if (m_RewardIndexs.Count > 0 && m_RewardTweens != null && m_RewardTweens.Length > 0)
|
{
|
PlayRewardTween(0);
|
}
|
}
|
|
public struct Item
|
{
|
public int itemId;
|
public long count;
|
}
|
}
|