104 lines
3.4 KiB
C#
104 lines
3.4 KiB
C#
using Games.LogicObj;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using GCGame;
|
|
using Module.Log;
|
|
using Games.GlobeDefine;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using GCGame.Table;
|
|
|
|
public class AskFriendJoinGuild : MonoBehaviour
|
|
{
|
|
public GameObject FriendListObjClone;
|
|
|
|
List<GameObject> clones = new List<GameObject>();
|
|
static int _ReqFriendGuildIdx = 0;
|
|
void OnEnable()
|
|
{
|
|
Hashtable add = new Hashtable();
|
|
add["name"] = "AddAskFriends";
|
|
Games.Events.MessageEventCallBack call = AddAskFriends;
|
|
add["callFun"] = call;
|
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.FriendInfo, add);
|
|
|
|
++_ReqFriendGuildIdx;
|
|
CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM packet = (CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM);
|
|
packet.Ophandle = _ReqFriendGuildIdx;
|
|
packet.HandleType = (int)CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM.HANDLE_TYPE.GuildInfo;
|
|
packet.SendPacket();
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.FriendInfo, "AddAskFriends");
|
|
for(int i=0;i<clones.Count;i++)
|
|
{
|
|
clones[i].SetActive(false);
|
|
clones[i].transform.SetParent(null);
|
|
GameObject.Destroy(clones[i]);
|
|
}
|
|
clones.Clear();
|
|
}
|
|
|
|
public void Cloes()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public void AddAskFriends(Hashtable addParam, Hashtable sendParam)
|
|
{
|
|
if (sendParam == null || sendParam.ContainsKey("packet")==false)
|
|
return;
|
|
GC_ACK_FRIEND_INFO_WHO_IS_NOT_IN_TEAM packet = (GC_ACK_FRIEND_INFO_WHO_IS_NOT_IN_TEAM)sendParam["packet"];
|
|
|
|
if (packet.Ophandle != _ReqFriendGuildIdx)
|
|
return;
|
|
if (FriendListObjClone == null)
|
|
return;
|
|
GameObject newObj = GameObject.Instantiate(FriendListObjClone);
|
|
if (newObj == null)
|
|
return;
|
|
newObj.SetActive(true);
|
|
newObj.transform.SetParent(FriendListObjClone.transform.parent);
|
|
newObj.transform.localScale = FriendListObjClone.transform.localScale;
|
|
clones.Add(newObj);
|
|
Transform iconTran = newObj.transform.Find("professionIcon");
|
|
if (iconTran != null)
|
|
{
|
|
Image icon = iconTran.GetComponent<Image>();
|
|
if (icon != null)
|
|
{
|
|
LoadAssetBundle.Instance.SetImageSprite(icon, Utils.GetProfessionSpriteName(packet.Prof));
|
|
}
|
|
}
|
|
Transform nameTran = newObj.transform.Find("name");
|
|
if (nameTran != null)
|
|
{
|
|
Text name = nameTran.GetComponent<Text>();
|
|
if (name != null)
|
|
{
|
|
name.text = packet.Name;
|
|
}
|
|
}
|
|
Transform levelTran = newObj.transform.Find("level");
|
|
if (levelTran != null)
|
|
{
|
|
Text level = levelTran.GetComponent<Text>();
|
|
if (level != null)
|
|
{
|
|
level.text = packet.Level.ToString();
|
|
}
|
|
}
|
|
Button btn = newObj.GetComponentInChildren<Button>();
|
|
if (btn != null)
|
|
{
|
|
btn.onClick.AddListener(delegate ()
|
|
{
|
|
Singleton<ObjManager>.GetInstance().MainPlayer.ReqInviteGuild(packet.Guid);
|
|
});
|
|
}
|
|
|
|
}
|
|
} |