Files
JJBB/Assets/Project/Script/GUI/FriendAndMail/FriendAndMailRoot.cs

163 lines
4.0 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GCGame.Table;
using System;
using UnityEngine.UI;
public class FriendAndMailRoot : MonoBehaviour
{
private static FriendAndMailRoot m_Instance = null;
public static FriendAndMailRoot Instance()
{
return m_Instance;
}
void OnEnable()
{
m_Instance = this;
UpdateRedCheck();
UpdateMailRedTip();
_TagPanel.ShowPage(0);
}
void OnDisable()
{
m_Instance = null;
}
public void CloseWindow()
{
UIManager.CloseUI(UIInfo.FriendAndMail);
}
#region static function
public static void ShowFriendChat(UInt64 guid, string name, string icon = "", int level = 0)
{
Hashtable hash = new Hashtable();
hash.Add("FuncName", "FriendSendMessage");
hash.Add("GUID", guid);
hash.Add("Name", name);
hash.Add("Icon", icon);
hash.Add("Level", level);
ShowFriendAndMailRoot(hash);
}
public static void ShowFriendAndMailRoot(Hashtable funParams)
{
UIManager.ShowUI(UIInfo.FriendAndMail, FriendAndMailRoot.ShowUIOver, funParams);
}
static void ShowUIOver(bool bSuccess, object param)
{
if (bSuccess)
{
Hashtable initParams = param as Hashtable;
if (FriendAndMailRoot.Instance() != null && initParams != null && initParams.Count > 1)
{
FriendAndMailRoot.Instance().ShowFriendAndMail(initParams);
}
}
}
void ShowFriendAndMail(Hashtable hashParams)
{
string funName = (string)hashParams["FuncName"];
switch (funName)
{
case "FriendSendMessage":
FriendSendMessage(hashParams);
break;
}
}
#endregion
#region open friend
public UITagPanel _TagPanel;
public FriendRootLogic _FriendRootLogic;
public GameObject _FriendRedCheckTips;
public Text _FriendAllUnCheckedCountText;
void FriendSendMessage(Hashtable hashParams)
{
_TagPanel.ShowPage(0);
var friendGuid = (UInt64)hashParams["GUID"];
var friendName = (string)hashParams["Name"];
string icon = "";
int level = 0;
if (hashParams.ContainsKey("Icon"))
{
icon = (string)hashParams["Icon"];
}
if (hashParams.ContainsKey("level"))
{
level = (int)hashParams["Level"];
}
_FriendRootLogic.ShowUIChat(friendGuid, friendName, icon, level);
}
public void OnReceiveChat()
{
_FriendRootLogic.OnReceiveChat();
UpdateRedCheck();
}
public void UpdateRedCheck()
{
if (GameManager.gameManager.PlayerDataPool.ChatHistory.IsHaveUnCheckChat())
{
_FriendRedCheckTips.SetActive(true);
}else if (GameManager.gameManager.PlayerDataPool.NewApplyCheck
&& GameManager.gameManager.PlayerDataPool.GetNewApplyListCount() > 0)
{
_FriendRedCheckTips.SetActive(true);
}else
{
_FriendRedCheckTips.SetActive(false);
return;
}
var count = GameManager.gameManager.PlayerDataPool.ChatHistory.GetAllUnCheckedChatCount() + GameManager.gameManager.PlayerDataPool.GetNewApplyListCount();
_FriendAllUnCheckedCountText.text = (count >= 99 ? 99 : count).ToString();
}
#endregion
#region mail
public GameObject _MailRedCheckTips;
public Text _UnCheckedMailCountText;
public GameObject _MailFullMark;
public void UpdateMailRedTip()
{
_MailFullMark.SetActive(MailData.GetAllMailCount() >= 100);
if (MailData.IsHaveUpReadMail())
{
_MailRedCheckTips.SetActive(true);
var count = MailData.GetAllUnLoadMainCount();
_UnCheckedMailCountText.text = (count >= 99 ? 99 : count).ToString();
return;
}
_MailRedCheckTips.SetActive(false);
}
#endregion
}