168 lines
4.8 KiB
C#
168 lines
4.8 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using System;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using Games.ChatHistory;
|
|||
|
using GCGame;
|
|||
|
|
|||
|
public class SwornFriendRoot : MonoBehaviour
|
|||
|
{
|
|||
|
void Awake()
|
|||
|
{
|
|||
|
InitSwornTips();
|
|||
|
}
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool._SwornBrother._MyBrothers.Count > 0)
|
|||
|
{
|
|||
|
_EmptyGO.SetActive(false);
|
|||
|
_RelationGO.SetActive(true);
|
|||
|
InitSwornItems();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_EmptyGO.SetActive(true);
|
|||
|
_RelationGO.SetActive(false);
|
|||
|
}
|
|||
|
UpdateFriend();
|
|||
|
}
|
|||
|
|
|||
|
void OnDisable()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void Close()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.FriendAndMail);
|
|||
|
}
|
|||
|
|
|||
|
#region friend List
|
|||
|
|
|||
|
public UIContainerSelect _FriendContainer;
|
|||
|
public Text _SwornTips;
|
|||
|
public GameObject _EmptyGO;
|
|||
|
public GameObject _RelationGO;
|
|||
|
public Vector3 _PlayerTooltipPos;
|
|||
|
public Text _EmptyTips;
|
|||
|
|
|||
|
public void InitSwornTips()
|
|||
|
{
|
|||
|
_SwornTips.text = StrDictionary.GetClientDictionaryString("#{5222}");
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateFriend()
|
|||
|
{
|
|||
|
|
|||
|
//先排在线的
|
|||
|
GameManager.gameManager.PlayerDataPool.FriendList.SortByRelationState((int)CharacterDefine.RELATION_TYPE.ONLINE);
|
|||
|
|
|||
|
List<Relation> _FriendList = new List<Relation>();
|
|||
|
foreach (KeyValuePair<UInt64, Relation> _relation in GameManager.gameManager.PlayerDataPool.FriendList.RelationDataList)
|
|||
|
{
|
|||
|
if(_relation.Value.Guid != GlobeVar.INVALID_GUID
|
|||
|
&& _relation.Value.Guid != GlobeVar.HELPFRIEND_GUID
|
|||
|
&& _relation.Value.Guid != GlobeVar.SYSFRIEND_GUID)
|
|||
|
_FriendList.Add(_relation.Value);
|
|||
|
}
|
|||
|
if (_FriendList.Count > 0)
|
|||
|
{
|
|||
|
_FriendList.Sort((relationA, relationB) =>
|
|||
|
{
|
|||
|
if (relationA.FriendPoint > relationB.FriendPoint)
|
|||
|
return -1;
|
|||
|
else if (relationA.FriendPoint < relationB.FriendPoint)
|
|||
|
return 1;
|
|||
|
return 0;
|
|||
|
});
|
|||
|
_EmptyTips.text = "";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_EmptyTips.text = StrDictionary.GetClientDictionaryString("#{5224}");
|
|||
|
}
|
|||
|
_FriendContainer.InitSelectContent(_FriendList, null, ShowPlayerTooltip);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void ShowPlayerTooltip(object relationObj)
|
|||
|
{
|
|||
|
Relation relation = relationObj as Relation;
|
|||
|
if (relation != null)
|
|||
|
{
|
|||
|
PlayerTooltipsLogic.ShowPlayerTooltip(relation.Guid, relation.Name, Utils.GetProfessionSpriteName(relation.Profession), relation.Level, -1, relation.CombatNum, _PlayerTooltipPos);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region relation
|
|||
|
|
|||
|
public MasterRelationInfo _MyInfo;
|
|||
|
public MasterRelationInfo[] _SwornItems;
|
|||
|
public int _SwornSceneNPC = 518;
|
|||
|
public int _CopySceneID = 6304;
|
|||
|
|
|||
|
public void InitSwornItems()
|
|||
|
{
|
|||
|
for (int i = 0; i < _SwornItems.Length; ++i)
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool._SwornBrother._MyBrothers.Count <= i)
|
|||
|
{
|
|||
|
_SwornItems[i].gameObject.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_SwornItems[i].gameObject.SetActive(true);
|
|||
|
_SwornItems[i].SetSwornBrother(GameManager.gameManager.PlayerDataPool._SwornBrother._MyBrothers[i]);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
_MyInfo.SetMyInfo();
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnSworn()
|
|||
|
{
|
|||
|
var sceneNpcs = TableManager.GetSceneNpc().Values;
|
|||
|
Tab_SceneNpc targetNpc = null;
|
|||
|
foreach (var sceneNpc in sceneNpcs)
|
|||
|
{
|
|||
|
if (sceneNpc.DataID == _SwornSceneNPC)
|
|||
|
{
|
|||
|
targetNpc = sceneNpc;
|
|||
|
}
|
|||
|
}
|
|||
|
if (targetNpc == null)
|
|||
|
return;
|
|||
|
|
|||
|
AutoSearchPoint point = new AutoSearchPoint(targetNpc.SceneID, targetNpc.PosX, targetNpc.PosZ, -1, AutoSearchPoint.ChangeMap_Type.WORLDMAP);
|
|||
|
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
|||
|
{
|
|||
|
GameManager.gameManager.AutoSearch.BuildPath(point);
|
|||
|
Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(targetNpc.DataID, 0);
|
|||
|
if (null != RoleBase && null != GameManager.gameManager.AutoSearch.Path)
|
|||
|
{
|
|||
|
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = RoleBase.Name;
|
|||
|
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = RoleBase.DialogRadius;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
Close();
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnCopyScene()
|
|||
|
{
|
|||
|
CG_REQ_ENTER_COPY packet = (CG_REQ_ENTER_COPY)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ENTER_COPY);
|
|||
|
packet.Copyid = _CopySceneID;
|
|||
|
|
|||
|
packet.SendPacket();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|