98 lines
3.4 KiB
C#
98 lines
3.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using Module.Log;
|
|
using Games.LogicObj;
|
|
using Games.Events;
|
|
|
|
public class ChangeChannelController : MonoBehaviour {
|
|
|
|
public UIContainerBase _LineContainer;
|
|
public Text m_CurLineLable;
|
|
// Use this for initialization
|
|
void Start ()
|
|
{
|
|
FreshChannel(null,null);
|
|
}
|
|
public void FreshChannel(Hashtable table1,Hashtable table2)
|
|
{
|
|
_LineContainer.InitContentItem(SceneData.SceneInstInfoList, OnChangeChannel);
|
|
}
|
|
|
|
public void OnChangeChannel(object item)
|
|
{
|
|
|
|
SceneData.InstInfo channelInfo = item as SceneData.InstInfo;
|
|
if(channelInfo != null)
|
|
{
|
|
if (channelInfo.curplayercount >= SceneData.SceneMaxPlayerCoutn)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{3907}"));
|
|
return;
|
|
}
|
|
|
|
if(GameManager.gameManager.PlayerDataPool.IsHaveTeam())
|
|
{
|
|
if(GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain()==false)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1874}"));
|
|
return;
|
|
}
|
|
|
|
if(channelInfo.curplayercount + GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount() > SceneData.SceneMaxPlayerCoutn)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{3907}"));
|
|
return;
|
|
}
|
|
if (Singleton<ObjManager>.Instance.MainPlayer.IsInPaoShang())
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("{#3937}"));
|
|
return;
|
|
}
|
|
var mainPlayer = ObjManager.Instance.MainPlayer;
|
|
if (mainPlayer != null)
|
|
{
|
|
mainPlayer.TeamChangeInstFollow(GameManager.gameManager.RunningScene, channelInfo.instId);
|
|
}
|
|
}
|
|
|
|
if (channelInfo.instId != SceneData.SceneInst && SceneData.SceneInstList.Contains(channelInfo.instId))
|
|
{
|
|
CG_SCENE_CHANGEINST packet = (CG_SCENE_CHANGEINST)PacketDistributed.CreatePacket(MessageID.PACKET_CG_SCENE_CHANGEINST);
|
|
packet.SetSceneInst(channelInfo.instId);
|
|
packet.SendPacket();
|
|
}
|
|
}
|
|
|
|
UIManager.CloseUI(UIInfo.ChannelChange);
|
|
}
|
|
|
|
public void OnEnable()
|
|
{
|
|
Hashtable calbackMoveparam = new Hashtable();
|
|
calbackMoveparam["name"] = "FreshChannel";
|
|
MessageEventCallBack fun = FreshChannel;
|
|
calbackMoveparam.Add("callFun", fun);
|
|
EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.UpdatePlayerChannel, calbackMoveparam);
|
|
FreshChannel(null,null);
|
|
}
|
|
|
|
public void OnDisable()
|
|
{
|
|
EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.UpdatePlayerChannel, "FreshChannel");
|
|
}
|
|
|
|
public void OnCloseClick()
|
|
{
|
|
UIManager.CloseUI(UIInfo.ChannelChange);
|
|
|
|
if (MainUILogic.Instance() != null && SceneMapFix.Instance() != null && SceneMapFix.Instance().CurrSceneName == UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)
|
|
{
|
|
UIManager.ShowUI(UIInfo.SceneMapRoot);
|
|
}
|
|
}
|
|
|
|
}
|