296 lines
8.9 KiB
C#
296 lines
8.9 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using Games.Item;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.ChatHistory;
|
|||
|
using GCGame;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using Module.Log;
|
|||
|
|
|||
|
public class FriendChatItem : UIItemSelect
|
|||
|
{
|
|||
|
private static Material _ImageGrayMaterial;
|
|||
|
public static Material ImageGrayMaterial
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_ImageGrayMaterial == null)
|
|||
|
_ImageGrayMaterial = CommonUtility.LoadSharedMaterial(GlobeVar.grayMaterialName);
|
|||
|
return _ImageGrayMaterial;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public Text _Name;
|
|||
|
public Image _Icon;
|
|||
|
public Text _Level;
|
|||
|
public Text _OutLineTime;
|
|||
|
public Text _SwornRelationTip;
|
|||
|
public GameObject _BtnInfo;
|
|||
|
|
|||
|
public GameObject _SpriteHelpMessage;
|
|||
|
|
|||
|
Relation _Relation;
|
|||
|
FriendChat _FriendChat;
|
|||
|
|
|||
|
// 返回当前数据的GUID
|
|||
|
public ulong ChaterGuid
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if(_Relation != null)
|
|||
|
{
|
|||
|
return _Relation.Guid;
|
|||
|
}
|
|||
|
else if(_FriendChat != null)
|
|||
|
{
|
|||
|
return _FriendChat.ChatGuid;
|
|||
|
}
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void Show(Hashtable hash)
|
|||
|
{
|
|||
|
base.Show();
|
|||
|
|
|||
|
if (hash["InitObj"] is Relation)
|
|||
|
{
|
|||
|
_Relation = (Relation)hash["InitObj"];
|
|||
|
InitRelation();
|
|||
|
_SpriteHelpMessage.SetActive(_Relation.Guid == 1);
|
|||
|
}
|
|||
|
else if (hash["InitObj"] is FriendChat)
|
|||
|
{
|
|||
|
_FriendChat = (FriendChat)hash["InitObj"];
|
|||
|
InitFriendChat();
|
|||
|
_SpriteHelpMessage.SetActive(_FriendChat.ChatGuid == 1);
|
|||
|
}
|
|||
|
|
|||
|
UpdateChatTips();
|
|||
|
}
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
base.Refresh();
|
|||
|
UpdateChatTips();
|
|||
|
}
|
|||
|
|
|||
|
private void InitRelation()
|
|||
|
{
|
|||
|
_Name.text = _Relation.Name;
|
|||
|
if (_Relation.Guid == GlobeVar.SYSFRIEND_GUID)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_Icon, Utils.GetSysIconName(Utils.SysIconType.Sys));
|
|||
|
}
|
|||
|
else if (_Relation.Guid == GlobeVar.HELPFRIEND_GUID)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_Icon, Utils.GetSysIconName(Utils.SysIconType.AI));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
string spriteName = Utils.GetProfessionSpriteName(_Relation.Profession);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_Icon, spriteName);
|
|||
|
}
|
|||
|
if (_Relation.Level > 0)
|
|||
|
{
|
|||
|
_Level.text = _Relation.Level.ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Level.text = "";
|
|||
|
}
|
|||
|
if (_Relation.Guid == 0 || _Relation.Guid == 1)
|
|||
|
{
|
|||
|
_BtnInfo.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_BtnInfo.SetActive(true);
|
|||
|
}
|
|||
|
//_OutLineTime.text = _Relation
|
|||
|
|
|||
|
if (GameManager.gameManager.PlayerDataPool.LoverGUID == _Relation.Guid
|
|||
|
&& GameManager.gameManager.PlayerDataPool.IsMarried)
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(true);
|
|||
|
_SwornRelationTip.text = StrDictionary.GetClientDictionaryString("#{7319}");
|
|||
|
}
|
|||
|
else if (GameManager.gameManager.PlayerDataPool._SwornBrother.IsMySwornBro(_Relation.Guid))
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(true);
|
|||
|
_SwornRelationTip.text = GameManager.gameManager.PlayerDataPool._SwornBrother.GetSwornCalling(_Relation.Guid);
|
|||
|
}
|
|||
|
else if (GameManager.gameManager.PlayerDataPool.m_MasterInfo.IsGuidisMaster(_Relation.Guid)) //师傅
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(true);
|
|||
|
_SwornRelationTip.text = StrDictionary.GetClientDictionaryString("#{7300}");
|
|||
|
}
|
|||
|
else if (GameManager.gameManager.PlayerDataPool.m_MasterInfo.IsGuidisApprentice(_Relation.Guid)) //徒弟
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(true);
|
|||
|
_SwornRelationTip.text = StrDictionary.GetClientDictionaryString("#{7301}");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
LogModule.DebugLog("UIPlayer:" + _Relation.Name + ", onlineState:" + (CharacterDefine.RELATION_TYPE)_Relation.State);
|
|||
|
if (_Relation.State == (int)CharacterDefine.RELATION_TYPE.OFFLINE)
|
|||
|
{
|
|||
|
_Icon.material = ImageGrayMaterial;
|
|||
|
_OutLineTime.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Icon.material = null;
|
|||
|
_OutLineTime.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void InitFriendChat()
|
|||
|
{
|
|||
|
_Name.text = _FriendChat.ChatName;
|
|||
|
if (_FriendChat.ChatGuid == GlobeVar.SYSFRIEND_GUID)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_Icon, Utils.GetSysIconName(Utils.SysIconType.Sys));
|
|||
|
}
|
|||
|
else if (_FriendChat.ChatGuid == GlobeVar.HELPFRIEND_GUID)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_Icon, Utils.GetSysIconName(Utils.SysIconType.AI));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
string spriteName = _FriendChat.ChatIcon;
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_Icon, spriteName);
|
|||
|
}
|
|||
|
|
|||
|
if (_FriendChat.ChatLevel > 0)
|
|||
|
{
|
|||
|
_Level.text = _FriendChat.ChatLevel.ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Level.text = "";
|
|||
|
}
|
|||
|
if (_FriendChat.ChatGuid == 0 || _FriendChat.ChatGuid == 1)
|
|||
|
{
|
|||
|
_BtnInfo.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_BtnInfo.SetActive(true);
|
|||
|
}
|
|||
|
|
|||
|
if (GameManager.gameManager.PlayerDataPool.LoverGUID == _FriendChat.ChatGuid
|
|||
|
&& GameManager.gameManager.PlayerDataPool.IsMarried)
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(true);
|
|||
|
_SwornRelationTip.text = StrDictionary.GetClientDictionaryString("#{7319}"); //配偶
|
|||
|
}
|
|||
|
else if (GameManager.gameManager.PlayerDataPool._SwornBrother.IsMySwornBro(_FriendChat.ChatGuid))
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(true);
|
|||
|
_SwornRelationTip.text = GameManager.gameManager.PlayerDataPool._SwornBrother.GetSwornCalling(_FriendChat.ChatGuid);
|
|||
|
}
|
|||
|
else if (GameManager.gameManager.PlayerDataPool.m_MasterInfo.IsGuidisMaster(_FriendChat.ChatGuid)) //师傅
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(true);
|
|||
|
_SwornRelationTip.text = StrDictionary.GetClientDictionaryString("#{7300}");
|
|||
|
}
|
|||
|
else if (GameManager.gameManager.PlayerDataPool.m_MasterInfo.IsGuidisApprentice(_FriendChat.ChatGuid)) //徒弟
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(true);
|
|||
|
_SwornRelationTip.text = StrDictionary.GetClientDictionaryString("#{7301}");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_SwornRelationTip.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
//_Level.text = _FriendChat.Level.ToString();
|
|||
|
//_OutLineTime.text = _Relation
|
|||
|
if (GameManager.gameManager.PlayerDataPool.FriendList.RelationDataList.ContainsKey(_FriendChat.ChatGuid))
|
|||
|
{
|
|||
|
_Relation = GameManager.gameManager.PlayerDataPool.FriendList.RelationDataList[_FriendChat.ChatGuid];
|
|||
|
}
|
|||
|
|
|||
|
if (_Relation != null)
|
|||
|
{
|
|||
|
_InitInfo = _Relation;
|
|||
|
}
|
|||
|
|
|||
|
// 有bug,只要对方不是好友,都不会显示在线。
|
|||
|
if (_FriendChat.OnlineState == (int)CharacterDefine.RELATION_TYPE.OFFLINE)
|
|||
|
{
|
|||
|
_Icon.material = ImageGrayMaterial;
|
|||
|
_OutLineTime.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Icon.material = null;
|
|||
|
_OutLineTime.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void ShowPlayerTooltip()
|
|||
|
{
|
|||
|
if (_FriendChat != null)
|
|||
|
{
|
|||
|
PlayerTooltipsLogic.ShowPlayerTooltip(_FriendChat.ChatGuid, _FriendChat.ChatName, _FriendChat.ChatIcon, _FriendChat.ChatLevel, -1, _FriendChat.ChatCombat, Vector3.zero, 1);
|
|||
|
}
|
|||
|
else if(_Relation != null)
|
|||
|
{
|
|||
|
PlayerTooltipsLogic.ShowPlayerTooltip(_Relation.Guid, _Relation.Name, Utils.GetProfessionSpriteName(_Relation.Profession), _Relation.Level, -1, _Relation.CombatNum, Vector3.zero);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void OnItemClick()
|
|||
|
{
|
|||
|
base.OnItemClick();
|
|||
|
|
|||
|
SetChatChecked();
|
|||
|
}
|
|||
|
|
|||
|
#region friend chat tips
|
|||
|
|
|||
|
public GameObject _RedDotTips;
|
|||
|
|
|||
|
public void UpdateChatTips()
|
|||
|
{
|
|||
|
if (_FriendChat != null)
|
|||
|
{
|
|||
|
if (_FriendChat.NewRecordChecked)
|
|||
|
{
|
|||
|
_RedDotTips.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_RedDotTips.SetActive(true);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_RedDotTips.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SetChatChecked()
|
|||
|
{
|
|||
|
if (_FriendChat != null)
|
|||
|
{
|
|||
|
_FriendChat.SetNewRecordChecked(true);
|
|||
|
}
|
|||
|
|
|||
|
UpdateChatTips();
|
|||
|
FriendAndMailRoot.Instance().UpdateRedCheck();
|
|||
|
FriendAndMailRoot.Instance()._FriendRootLogic.UpdateCheckTip();
|
|||
|
ChatFrameLogic.Instance().UpdateRedDotTip();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|