310 lines
9.0 KiB
C#
310 lines
9.0 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.Item;
|
|||
|
|
|||
|
// 试炼副本专用结算界面
|
|||
|
public class FinishTestingCopyResultPanel : MonoBehaviour {
|
|||
|
|
|||
|
private static FinishTestingCopyResultPanel instance;
|
|||
|
public static FinishTestingCopyResultPanel Instance
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return instance;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
if (instance == null)
|
|||
|
{
|
|||
|
instance = this;
|
|||
|
continueBtn_Win.onClick.AddListener(OnContinueBtnClick_Win);
|
|||
|
exitBtn_Win.onClick.AddListener(OnExitBtnClick);
|
|||
|
retryBtn_Loss.onClick.AddListener(OnRetryBtnClick_Lose);
|
|||
|
exitBtn_Loss.onClick.AddListener(OnExitBtnClick);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private int curFubenID = -1; // 副本ID
|
|||
|
private int curDiffcultType = -1; // 挑战类型
|
|||
|
private int freshTime = -1; // 刷怪剩余时间
|
|||
|
|
|||
|
public GameObject winPanel;
|
|||
|
public Button continueBtn_Win;
|
|||
|
public Text continueBtnDesc_Win;
|
|||
|
public Button exitBtn_Win;
|
|||
|
public Text exitBtnDesc_Win;
|
|||
|
public GameObject rewItemPrefab;
|
|||
|
public Transform rewItemPrefabParent;
|
|||
|
private List<GameObject> rewItemList = new List<GameObject>();
|
|||
|
|
|||
|
public GameObject losePanel;
|
|||
|
public GameObject loseTextGO;
|
|||
|
public Text loseText;
|
|||
|
public Button retryBtn_Loss;
|
|||
|
public Text retryBtnDesc_Loss;
|
|||
|
public Button exitBtn_Loss;
|
|||
|
public Text exitBtnDesc_Loss;
|
|||
|
|
|||
|
public void OnReceivePacket(RetFinishCopyInfo packet) //副本通用逻辑(newcopybase中存在的才会弹奖励)
|
|||
|
{
|
|||
|
curFubenID = packet._CopyId;
|
|||
|
curDiffcultType = packet._Difficult;
|
|||
|
freshTime = packet._PerTime;
|
|||
|
|
|||
|
if (packet._Success == 1)
|
|||
|
{
|
|||
|
ShowWinPanel(packet);
|
|||
|
}
|
|||
|
else if(packet._Success == 0)
|
|||
|
{
|
|||
|
ShowLosePanel(packet);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void ShowWinPanel(RetFinishCopyInfo packet)
|
|||
|
{
|
|||
|
winPanel.SetActive(true);
|
|||
|
losePanel.SetActive(false);
|
|||
|
|
|||
|
StartCoroutine(CreateitemPrefabCoroutine(packet));
|
|||
|
|
|||
|
if(packet._UIType == 1)
|
|||
|
{
|
|||
|
exitBtn_Win.gameObject.SetActive(true);
|
|||
|
exitBtnDesc_Win.text = StrDictionary.GetClientDictionaryString("#{6743}");
|
|||
|
continueBtn_Win.gameObject.SetActive(false);
|
|||
|
StartCoroutine("WinCountDonw_Exit");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
exitBtn_Win.gameObject.SetActive(true);
|
|||
|
exitBtnDesc_Win.text = StrDictionary.GetClientDictionaryString("#{6743}");
|
|||
|
continueBtn_Win.gameObject.SetActive(true);
|
|||
|
continueBtnDesc_Win.text = StrDictionary.GetClientDictionaryString("#{6744}");
|
|||
|
StartCoroutine("WinCountDonw_Continue");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private IEnumerator WinCountDonw_Continue()
|
|||
|
{
|
|||
|
if (TestingCopyInfoCtr.Instance == null)
|
|||
|
{
|
|||
|
Close();
|
|||
|
yield break;
|
|||
|
}
|
|||
|
|
|||
|
int delay = freshTime;
|
|||
|
for (int i = delay; i > 0; --i)
|
|||
|
{
|
|||
|
continueBtnDesc_Win.text = StrDictionary.GetClientDictionaryString("#{6744}") + "(" + i + ")";
|
|||
|
|
|||
|
for (float f = 0.0f; f < 1.0f; f += Time.deltaTime)
|
|||
|
{
|
|||
|
yield return 0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
Close();
|
|||
|
}
|
|||
|
|
|||
|
private IEnumerator WinCountDonw_Exit()
|
|||
|
{
|
|||
|
Tab_Fuben tab = TableManager.GetFubenByID(curFubenID, 0);
|
|||
|
if (tab == null)
|
|||
|
{
|
|||
|
Close();
|
|||
|
yield break;
|
|||
|
}
|
|||
|
|
|||
|
int delay = tab.LeaveDelay;
|
|||
|
for (int i = delay; i >= 0; --i)
|
|||
|
{
|
|||
|
for (float f = 0.0f; f < 1.0f; f += Time.deltaTime)
|
|||
|
{
|
|||
|
yield return 0;
|
|||
|
}
|
|||
|
|
|||
|
exitBtnDesc_Win.text = StrDictionary.GetClientDictionaryString("#{6743}") + "(" + i + ")";
|
|||
|
}
|
|||
|
|
|||
|
OnExitBtnClick();
|
|||
|
}
|
|||
|
|
|||
|
private void OnContinueBtnClick_Win()
|
|||
|
{
|
|||
|
ContinueNextLayer req = new ContinueNextLayer();
|
|||
|
// 仅占位,无效
|
|||
|
req.flags = 1;
|
|||
|
req.SendMsg();
|
|||
|
|
|||
|
Close();
|
|||
|
}
|
|||
|
|
|||
|
#region 失败界面
|
|||
|
|
|||
|
private void ShowLosePanel(RetFinishCopyInfo packet)
|
|||
|
{
|
|||
|
winPanel.SetActive(false);
|
|||
|
losePanel.SetActive(true);
|
|||
|
|
|||
|
if (packet._UIType == 1)
|
|||
|
{
|
|||
|
loseTextGO.SetActive(false);
|
|||
|
exitBtn_Loss.gameObject.SetActive(true);
|
|||
|
exitBtnDesc_Loss.text = StrDictionary.GetClientDictionaryString("#{6743}");
|
|||
|
retryBtn_Loss.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
loseTextGO.SetActive(true);
|
|||
|
loseText.text = StrDictionary.GetClientDictionaryString("#{6742}", packet._ChallengeLayer);
|
|||
|
exitBtn_Loss.gameObject.SetActive(true);
|
|||
|
exitBtnDesc_Loss.text = StrDictionary.GetClientDictionaryString("#{6743}");
|
|||
|
retryBtn_Loss.gameObject.SetActive(true);
|
|||
|
retryBtnDesc_Loss.text = StrDictionary.GetClientDictionaryString("#{6745}");
|
|||
|
}
|
|||
|
|
|||
|
StartCoroutine("LoseCountDown");
|
|||
|
}
|
|||
|
|
|||
|
// 失败后的倒计时
|
|||
|
private IEnumerator LoseCountDown()
|
|||
|
{
|
|||
|
Tab_Fuben tab = TableManager.GetFubenByID(curFubenID, 0);
|
|||
|
if (tab == null)
|
|||
|
{
|
|||
|
Close();
|
|||
|
yield break;
|
|||
|
}
|
|||
|
|
|||
|
int delay = tab.LeaveDelay;
|
|||
|
for (int i = delay; i > 0; --i)
|
|||
|
{
|
|||
|
exitBtnDesc_Loss.text = StrDictionary.GetClientDictionaryString("#{6743}") + "(" + i + ")";
|
|||
|
|
|||
|
for (float f = 0.0f; f < 1.0f; f += Time.deltaTime)
|
|||
|
{
|
|||
|
yield return 0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
OnExitBtnClick();
|
|||
|
}
|
|||
|
|
|||
|
private void Close()
|
|||
|
{
|
|||
|
StopAllCoroutines();
|
|||
|
UIManager.CloseUI(UIInfo.FinishTestingCopyResultPanel);
|
|||
|
}
|
|||
|
|
|||
|
private void OnRetryBtnClick_Lose()
|
|||
|
{
|
|||
|
CG_REQ_ENTER_COPY req = (CG_REQ_ENTER_COPY)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ENTER_COPY);
|
|||
|
req.SetCopyid(curFubenID);
|
|||
|
req.SetDeffcultyType(curDiffcultType);
|
|||
|
req.SetChallengeType(0);
|
|||
|
req.SendPacket();
|
|||
|
|
|||
|
Close();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
private void OnExitBtnClick()
|
|||
|
{
|
|||
|
CG_LEAVE_COPYSCENE send = (CG_LEAVE_COPYSCENE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_LEAVE_COPYSCENE);
|
|||
|
send.NoParam = 1;
|
|||
|
send.SendPacket();
|
|||
|
|
|||
|
// 一夫当关副本
|
|||
|
if (TestingCopyBuffInfoCtr.Instance != null)
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.BuffsStateInfo);
|
|||
|
}
|
|||
|
|
|||
|
Close();
|
|||
|
}
|
|||
|
|
|||
|
#region 胜利界面奖励
|
|||
|
|
|||
|
IEnumerator CreateitemPrefabCoroutine(RetFinishCopyInfo packet)
|
|||
|
{
|
|||
|
ClearAllRew();
|
|||
|
|
|||
|
//按照品质排序
|
|||
|
Dictionary<int, int> _RewItemDataDic = new Dictionary<int, int>();
|
|||
|
List<int> _ItemDataIdList = new List<int>();
|
|||
|
for (int index = 0; index < packet._items.Count; index++)
|
|||
|
{
|
|||
|
Tab_CommonItem tab = TableManager.GetCommonItemByID(packet._items[index].itemId, 0);
|
|||
|
if (tab == null)
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
if (tab.ClassID == (int)ItemClass.EQUIP && tab.Quality < (int)ItemQuality.QUALITY_BLUE)
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
if (!_ItemDataIdList.Contains(packet._items[index].itemId))
|
|||
|
{
|
|||
|
_ItemDataIdList.Add(packet._items[index].itemId);
|
|||
|
}
|
|||
|
if (_RewItemDataDic.ContainsKey(packet._items[index].itemId))
|
|||
|
{
|
|||
|
_RewItemDataDic[packet._items[index].itemId] += packet._items[index].itemNum;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_RewItemDataDic.Add(packet._items[index].itemId, packet._items[index].itemNum);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
_ItemDataIdList.Sort(delegate (int idA, int idB) {
|
|||
|
Tab_CommonItem commonItemA = TableManager.GetCommonItemByID(idA, 0);
|
|||
|
Tab_CommonItem commonItemB = TableManager.GetCommonItemByID(idB, 0);
|
|||
|
if (commonItemA == null || commonItemB == null)
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
if (commonItemA.Quality == commonItemB.Quality)
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
return commonItemA.Quality > commonItemB.Quality ? -1 : 1;
|
|||
|
});
|
|||
|
|
|||
|
for (int index = 0; index < _ItemDataIdList.Count; index++)
|
|||
|
{
|
|||
|
GameObject item = GameObject.Instantiate(rewItemPrefab);
|
|||
|
|
|||
|
item.transform.SetParent(rewItemPrefabParent);
|
|||
|
item.transform.localPosition = Vector3.zero;
|
|||
|
item.transform.localScale = Vector3.one;
|
|||
|
item.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
|||
|
|
|||
|
rewItemList.Add(item);
|
|||
|
item.GetComponent<CopyFinishRewItem>().InitItem(_ItemDataIdList[index], _RewItemDataDic.ContainsKey(_ItemDataIdList[index]) ? _RewItemDataDic[_ItemDataIdList[index]] : 1);
|
|||
|
}
|
|||
|
|
|||
|
yield break;
|
|||
|
}
|
|||
|
|
|||
|
public void ClearAllRew()
|
|||
|
{
|
|||
|
for (int index = 0; index < rewItemList.Count; index++)
|
|||
|
{
|
|||
|
GameObject.Destroy(rewItemList[index].gameObject);
|
|||
|
}
|
|||
|
rewItemList.Clear();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|