Files
JJBB/Assets/Project/Script/GUI/PVP/PvpSceneInfo.cs
2024-08-23 15:49:34 +08:00

259 lines
7.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GCGame.Table;
using Module.Log;
public class PvpSceneInfo : MonoBehaviour {
public static PvpSceneInfo Instance;
private void Awake()
{
Instance = this;
}
private void OnDestroy()
{
Instance = null;
}
public List<Sprite> _NumSpriteList;
public Image _SegmentIcon;
public Image _SegmentDescIcon;
public Image _SegmentNumIcon;
public GameObject _SementLevelDescPanel;
public Text _SegmentLevelDesc;
public Text _MatchRemainTime;
public Text _RemainTimeText;
public Text _Desc;
private void OnEnable()
{
OnBtnShow();
ReqPvpInfo();
if (FunctionButtonLogic.Instance())
{
FunctionButtonLogic.Instance().IsCanShwoBaseBtns = true;
}
if (MissionInfoController.Instance() && MissionInfoController.Instance().isActiveAndEnabled)
{
UIManager.CloseUI(UIInfo.MissionInfoController);
}
UIManager.CloseUI(UIInfo.MissionDialogAndLeftTabsRoot);
_Desc.text = StrDictionary.GetClientDictionaryString("#{81025}");
var remainTime = GetActEndTime();
_RemainTimeText.text = StrDictionary.GetClientDictionaryString("#{81027}", (remainTime / 60).ToString().PadLeft(2, '0'), (remainTime % 60).ToString().PadLeft(2, '0'));
StopAllCoroutines();
StartCoroutine(CountRemainTime());
//StartCoroutine(CountMatchRemainTimeSyc());
ReqRewInfo();
}
public void InitSegmentInfo()
{
var _MySelfPvpInfo = GameManager.gameManager.PlayerDataPool.pvpIfo; //必做刷新
var honorTab = TableManager.GetHonorBattlefieldSegmentByID(_MySelfPvpInfo.PvpSegmentLevel, 0);
if (honorTab == null)
{
return;
}
LoadAssetBundle.Instance.SetImageSprite(_SegmentIcon, honorTab.SegmentIcon);
LoadAssetBundle.Instance.SetImageSprite(_SegmentDescIcon, honorTab.SegmentDescIcon);
_SegmentNumIcon.overrideSprite = _NumSpriteList[honorTab.SegmentNumDescIconIndex];
if(_MySelfPvpInfo.IsMaxLevel())
{
_SementLevelDescPanel.SetActive(false);
}
else
{
_SementLevelDescPanel.SetActive(true);
_SegmentLevelDesc.text = _MySelfPvpInfo.SelfPvpScore + "/" + _MySelfPvpInfo.GetNextLevelNeedScore();
}
}
void ReqRewInfo()
{
ReqHonorBattlefieldPlayerInfo req = new ReqHonorBattlefieldPlayerInfo();
req.Flag = 1;
req.SendMsg();
}
IEnumerator CountMatchRemainTimeSyc()
{
while (true)
{
yield return new WaitForSeconds(1.0f);
var remainTime = GameManager.gameManager.PlayerDataPool.pvpIfo._RoomMatchRemainTime - GlobalData.ServerAnsiTime;
if (remainTime <= 0)
{
_MatchRemainTime.text = StrDictionary.GetClientDictionaryString("#{81026}", 0);
yield break;
}
_MatchRemainTime.text = StrDictionary.GetClientDictionaryString("#{81026}", remainTime);
}
}
public int GetActEndTime()
{
var actTab = ActivityDataManager.Instance.GetActivityTabByServerType(ActivityDataManager.Activity_Type.ACTIVITY_TYPE_PVP);
List<int> EndTimeList = new List<int>();
for(int index = 0; index < actTab.getTimeCount(); index++)
{
if(!actTab.GetTimebyIndex(index).Equals("-1"))
{
EndTimeList.Add(int.Parse(actTab.GetTimebyIndex(index).Split('|')[1]));
}
}
var curTime = GCGame.Utils.GetServerDateTime().Hour * 100 + GCGame.Utils.GetServerDateTime().Minute;
for(int index = 0; index < EndTimeList.Count; index++)
{
if(curTime < EndTimeList[index])
{
var val = ((EndTimeList[index] / 100 - curTime / 100) * 60 + (EndTimeList[index] % 100 - curTime % 100)) * 60 - GCGame.Utils.GetServerDateTime().Second;
return val > 0 ? val : 0;
}
}
return 0;
}
IEnumerator CountRemainTime()
{
while(true)
{
yield return new WaitForSeconds(1.0f);
var remainTime = GetActEndTime();
if (remainTime < 0)
{
_RemainTimeText.text = StrDictionary.GetClientDictionaryString("#{81027}", "00", "00");
yield break;
}
_RemainTimeText.text = StrDictionary.GetClientDictionaryString("#{81027}", (remainTime / 60).ToString().PadLeft(2, '0'), (remainTime % 60).ToString().PadLeft(2, '0'));
}
}
public void OnOpenRoomBtn()
{
UIManager.ShowUI(UIInfo.PvpRoomListPanel);
}
public void OnRoomInfoBtn()
{
UIManager.ShowUI(UIInfo.PvpRoomPanel, delegate(bool bSucess, object param) {
if(bSucess)
{
PvpRoomPanel.Instance.OnShowBtn();
}
});
}
public void OnInvateBtn()
{
UIManager.ShowUI(UIInfo.PvpInvateRoot);
}
public void OnExitBtn()
{
CG_LEAVE_COPYSCENE send = (CG_LEAVE_COPYSCENE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_LEAVE_COPYSCENE);
send.NoParam = 1;
send.SendPacket();
UIManager.CloseUI(UIInfo.PvpSceneInfo);
}
#region move
public ObjectTween _MoveTo;
public RectTransform _TitleBGRec;
public GameObject _ShowBtn;
public GameObject _HideBtn;
public GameObject _InfoPanel;
public GameObject _RedIcon;
private bool isShow = false;
public void OnBtnShow()
{
ShowPanel();
_ShowBtn.SetActive(false);
_HideBtn.SetActive(true);
isShow = true;
UIManager.CloseUI(UIInfo.MiniMapRoot);
}
public void OnBtnHide()
{
HidePanel();
_ShowBtn.SetActive(true);
_HideBtn.SetActive(false);
isShow = false;
}
public void OnTitleBtn()
{
if (isShow)
{
OnBtnHide();
}
else
{
OnBtnShow();
}
}
public void ShowPanel()
{
_MoveTo.Reset();
_MoveTo.destantPos = new Vector3(0, 0, 0);
GCGame.Utils.HideMainTopRightUI();
_TitleBGRec.sizeDelta = new Vector2(300, _TitleBGRec.sizeDelta.y);
_InfoPanel.gameObject.SetActive(true);
}
public void HidePanel()
{
_MoveTo.Reset();
_MoveTo.destantPos = new Vector3(0, -192, 0);
GCGame.Utils.ShowMainTopRightUI();
_TitleBGRec.sizeDelta = new Vector2(230, _TitleBGRec.sizeDelta.y);
_InfoPanel.gameObject.SetActive(false);
}
#endregion
public void OnRuleBtn()
{
PvpMatchRulePanel.OPenUI();
}
public void OnRewBtn()
{
UIManager.ShowUI(UIInfo.PvpRewPanel);
}
public void RefreshRewRedIconState()
{
_RedIcon.SetActive(GameManager.gameManager.PlayerDataPool.pvpIfo.IsHaveRew());
}
void ReqPvpInfo()
{
ReqHonorBattlefieldPlayerInfo req = new ReqHonorBattlefieldPlayerInfo();
req.Flag = 1;
req.SendMsg();
}
public void OnSwitchChannel()
{
CG_REQ_SCENE_SUB_LINE ask = (CG_REQ_SCENE_SUB_LINE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SCENE_SUB_LINE);
ask.NoParam = 1;
ask.SendPacket();
}
}