Files
JJBB/Assets/Project/Script/GUI/Guanning/GuanningPointLogic.cs

164 lines
4.7 KiB
C#
Raw Permalink Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Games.Item;
using System.Collections.Generic;
using GCGame.Table;
using Games.GlobeDefine;
public class GuanningPointLogic : UIControllerBase<GuanningPointLogic>
{
#region
public static void ShowGuanningPoint(GC_BATTLE_FIELD_SETTLEMENT_BOARD packet)
{
UIManager.ShowUI(UIInfo.GuanningPointRoot, ShowGuanningPointOver, packet);
}
public static void ShowGuanningPointOver(bool bSuccess, object param)
{
if (!bSuccess)
{
return;
}
if (!GuanningPointLogic.Instance())
return;
GC_BATTLE_FIELD_SETTLEMENT_BOARD packet = param as GC_BATTLE_FIELD_SETTLEMENT_BOARD;
GuanningPointLogic.Instance().UpdatePoints(packet);
}
#endregion
void OnEnable ()
{
SetInstance(this);
}
void OnDisable()
{
SetInstance(null);
}
public void CloseWindow()
{
UIManager.CloseUI(UIInfo.GuanningPointRoot);
}
#region
public Text[] _TotleScore;
public Text[] _AreaScore;
public UIContainerBase[] _PlayerScore;
public GameObject _WinPanel;
public GameObject _FailPanel;
public GameObject _DrawPanel;
public Text _MyScore;
public Button _BtnDouble;
private int _BattleResult = -2;
public void UpdatePoints(GC_BATTLE_FIELD_SETTLEMENT_BOARD packet)
{
for (int i = 0; i < packet.resBoardCount; ++i)
{
_TotleScore[i].text = StrDictionary.GetClientDictionaryString("#{8101}", packet.GetResBoard(i).TotalScore.ToString()) ;
_AreaScore[i].text = StrDictionary.GetClientDictionaryString("#{8102}", packet.GetResBoard(i).HoldScore.ToString());
Hashtable hash = new Hashtable();
hash.Add("SettlementNum", i);
List<UserSettlement> memberScores = new List<UserSettlement>(packet.GetResBoard(i).memberBoardList);
memberScores.Sort((ele1, ele2) =>
{
if (ele1.TotalScore > ele2.TotalScore)
return -1;
else if (ele1.TotalScore < ele2.TotalScore)
return 1;
return 0;
});
_PlayerScore[i].InitContentItem(memberScores, null, hash);
for (int j = 0; j < packet.GetResBoard(i).memberBoardList.Count; ++j)
{
if (packet.GetResBoard(i).memberBoardList[j].UserName == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName)
{
//_MyScore.text = StrDictionary.GetClientDictionaryString("#{9218}", packet.GetResBoard(i).memberBoardList[j].TotalScore);
//_BtnDouble.interactable = true;
if (packet.GetResBoard(i).HasResult)
_BattleResult = packet.GetResBoard(i).Result;
else
_BattleResult = -2;
break;
}
}
}
if (_BattleResult >= -1 && _BattleResult <= 1)
{
_MyScore.gameObject.SetActive(true);
_BtnDouble.gameObject.SetActive(true);
_BtnDouble.interactable = packet.Candouble > 0;
UIManager.CloseUI(UIInfo.GuanningAreaRoot);
StartCoroutine(ShowResult());
}
else
{
_MyScore.gameObject.SetActive(false);
_BtnDouble.gameObject.SetActive(false);
}
if (packet.HasTureScore)
{
_MyScore.text = StrDictionary.GetClientDictionaryString("#{9218}", packet.TureScore, packet.ExpAdd);
}
else
{
_MyScore.text = "";
}
}
private IEnumerator ShowResult()
{
_WinPanel.SetActive(false);
_FailPanel.SetActive(false);
_DrawPanel.SetActive(false);
if (_BattleResult > 0)
{
_WinPanel.SetActive(true);
}
else if (_BattleResult < 0)
{
_FailPanel.SetActive(true);
}
else
{
_DrawPanel.SetActive(true);
}
yield return new WaitForSeconds(2.0f);
_WinPanel.SetActive(false);
_FailPanel.SetActive(false);
_DrawPanel.SetActive(false);
}
public void OnClickResult()
{
_WinPanel.SetActive(false);
_FailPanel.SetActive(false);
_DrawPanel.SetActive(false);
}
public void OnBtnDoubleAward()
{
CG_DOUBLE_BATTLE_SCORE_REQ packet = (CG_DOUBLE_BATTLE_SCORE_REQ)PacketDistributed.CreatePacket(MessageID.PACKET_CG_DOUBLE_BATTLE_SCORE_REQ);
packet.ActivityID = (int)ActivityDataManager.Activity_Type.ACTIVITY_FIGHTYARD;
packet.SendPacket();
_BtnDouble.interactable = false;
}
#endregion
}