309 lines
8.6 KiB
C#
309 lines
8.6 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame;
|
|||
|
using Module.Log;
|
|||
|
using GCGame.Table;
|
|||
|
using System;
|
|||
|
using Games.Events;
|
|||
|
|
|||
|
public class TeamCreateWindow : MonoBehaviour
|
|||
|
{
|
|||
|
public static TeamCreateWindow Instance;
|
|||
|
public void Awake()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
InitSubMenu();
|
|||
|
}
|
|||
|
|
|||
|
public void Start()
|
|||
|
{
|
|||
|
//InitSubMenu();
|
|||
|
}
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash["name"] = "TeamCreateWindow";
|
|||
|
MessageEventCallBack fun = SelectBtn;
|
|||
|
hash["callFun"] = fun;
|
|||
|
EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.SELECTTEAMCREATEWNDITEM, hash);
|
|||
|
|
|||
|
GUIData.delNearbyTeampUpdate += UpdateNearbyTeam;
|
|||
|
GUIData.delTeamDataUpdate += UpdateTeamInfo;
|
|||
|
ReqNearbyTeam(_SelectDestIdx);
|
|||
|
ShowCaptainWelfareMarkIcon(GameManager.gameManager.PlayerDataPool.IsHaveCaptainWelfareRewCanGetted);
|
|||
|
|
|||
|
GuideLogic.OnOpenUIStatic(UIInfo.TeamCreateRoot.name);
|
|||
|
|
|||
|
UpdateAuto();
|
|||
|
}
|
|||
|
|
|||
|
public void SelectBtn(Hashtable addparam, Hashtable Sendparam)
|
|||
|
{
|
|||
|
int index = (int)Sendparam["index"];
|
|||
|
var targetTab = TableManager.GetTeamTargetByID(index, 0);
|
|||
|
if (targetTab != null)
|
|||
|
{
|
|||
|
if(_SubMenu!=null)
|
|||
|
{
|
|||
|
_SubMenu.ShowMenu(targetTab, true);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void OnDisable()
|
|||
|
{
|
|||
|
Instance = null;
|
|||
|
GUIData.delNearbyTeampUpdate -= UpdateNearbyTeam;
|
|||
|
GUIData.delTeamDataUpdate -= UpdateTeamInfo;
|
|||
|
EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.SELECTTEAMCREATEWNDITEM, "TeamCreateWindow");
|
|||
|
}
|
|||
|
|
|||
|
#region menu
|
|||
|
public UISubScollMenu _SubMenu;
|
|||
|
public UIContainerBase _TeamContainer;
|
|||
|
public Button _BtnAuto;
|
|||
|
public Button _BtnCancelAuto;
|
|||
|
public UIButtonTime _BtnRefresh;
|
|||
|
|
|||
|
private List<TeamInfo> _TeamList;
|
|||
|
public List<TeamInfo> TeamList
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _TeamList;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private int _SelectDestIdx = 0;
|
|||
|
|
|||
|
public void UpdateTeamInfo()
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID != GlobeVar.INVALID_ID)
|
|||
|
{
|
|||
|
BtnClose();
|
|||
|
UIManager.ShowUI(UIInfo.TeamInfoRoot);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void InitSubMenu()
|
|||
|
{
|
|||
|
//GameManager.gameManager.PlayerDataPool.TeamInfo.AutoTeamTargetDest = -1;
|
|||
|
_SelectDestIdx = -1;
|
|||
|
var targetTabs = TableManager.GetTeamTarget().Values;
|
|||
|
Dictionary<string, List<Tab_TeamTarget>> menuDict = new Dictionary<string, List<Tab_TeamTarget>>();
|
|||
|
foreach (var targetTab in targetTabs)
|
|||
|
{
|
|||
|
if (!menuDict.ContainsKey(targetTab.ClassName))
|
|||
|
{
|
|||
|
menuDict.Add(targetTab.ClassName, new List<Tab_TeamTarget>());
|
|||
|
}
|
|||
|
menuDict[targetTab.ClassName].Add(targetTab);
|
|||
|
}
|
|||
|
|
|||
|
_SubMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4070}"));
|
|||
|
foreach (var menu in menuDict)
|
|||
|
{
|
|||
|
if (menu.Value.Count == 1)
|
|||
|
{
|
|||
|
_SubMenu.PushMenu(menu.Value[0]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_SubMenu.PushMenu(menu.Key, menu.Value.ToArray());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
_SubMenu.ShowDefaultFirst();
|
|||
|
}
|
|||
|
|
|||
|
public void BtnMenu(object menuObj)
|
|||
|
{
|
|||
|
if (menuObj is string)
|
|||
|
{
|
|||
|
if ((menuObj as string) == StrDictionary.GetClientDictionaryString("#{4070}"))
|
|||
|
{
|
|||
|
ReqNearbyTeam(0);
|
|||
|
}
|
|||
|
_SelectDestIdx = -1;
|
|||
|
//_BtnAuto.interactable = false;
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Tab_TeamTarget menuStr = menuObj as Tab_TeamTarget;
|
|||
|
|
|||
|
LogModule.DebugLog("BtnMenu:" + menuStr);
|
|||
|
_SelectDestIdx = menuStr.Id;
|
|||
|
|
|||
|
if (_SelectDestIdx > 0)
|
|||
|
{
|
|||
|
_BtnAuto.interactable = true;
|
|||
|
}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// _BtnAuto.interactable = false;
|
|||
|
//}
|
|||
|
|
|||
|
if(_SelectDestIdx >= 0)
|
|||
|
ReqNearbyTeam(_SelectDestIdx);
|
|||
|
}
|
|||
|
|
|||
|
public void BtnClose()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.TeamCreateRoot);
|
|||
|
}
|
|||
|
|
|||
|
public void BtnRefresh()
|
|||
|
{
|
|||
|
LogModule.DebugLog("SelectID:" + _SelectDestIdx);
|
|||
|
ReqNearbyTeam(_SelectDestIdx);
|
|||
|
_BtnRefresh.SetBtnDisableTime(2);
|
|||
|
}
|
|||
|
|
|||
|
public void BtnCreateTeam()
|
|||
|
{
|
|||
|
if (false == GameManager.gameManager.PlayerDataPool.IsHaveTeam() &&
|
|||
|
null != Singleton<ObjManager>.GetInstance().MainPlayer)
|
|||
|
{
|
|||
|
var playerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
|||
|
//GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamLevelMin = Mathf.Max(playerLevel - 5, 0);
|
|||
|
//GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamLevelMax = playerLevel;
|
|||
|
TeamTargetRoot.SetDefaultLevel(_SelectDestIdx, playerLevel);
|
|||
|
GameManager.gameManager.PlayerDataPool.TeamInfo.CreaetTeam(GameManager.gameManager.PlayerDataPool.TeamInfo.AutoTeamTargetDest, GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamLevelMin, GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamLevelMax);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void BtnAuto()
|
|||
|
{
|
|||
|
if (_SelectDestIdx > 0)
|
|||
|
{
|
|||
|
CG_ASK_AUTOTEAM packet = (CG_ASK_AUTOTEAM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_AUTOTEAM);
|
|||
|
packet.Desid = _SelectDestIdx;
|
|||
|
packet.SendPacket();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
GUIData.AddNotifyData("#{7183}");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
GameManager.gameManager.PlayerDataPool.TeamInfo.AutoTeamTargetDest = _SelectDestIdx;
|
|||
|
|
|||
|
_SubMenu.Refresh();
|
|||
|
_BtnAuto.gameObject.SetActive(false);
|
|||
|
_BtnCancelAuto.gameObject.SetActive(true);
|
|||
|
|
|||
|
if (MissionDialogAndLeftTabsLogic.Instance())
|
|||
|
{
|
|||
|
MissionDialogAndLeftTabsLogic.Instance().UpdateAutoTip();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnCancelAuto()
|
|||
|
{
|
|||
|
GameManager.gameManager.PlayerDataPool.TeamInfo.AutoTeamTargetDest = -1;
|
|||
|
_SubMenu.Refresh();
|
|||
|
|
|||
|
CG_ASK_UN_AUTOTEAM packet = (CG_ASK_UN_AUTOTEAM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_UN_AUTOTEAM);
|
|||
|
packet.None = 0;
|
|||
|
packet.SendPacket();
|
|||
|
|
|||
|
_BtnAuto.gameObject.SetActive(true);
|
|||
|
_BtnCancelAuto.gameObject.SetActive(false);
|
|||
|
|
|||
|
if (MissionDialogAndLeftTabsLogic.Instance())
|
|||
|
{
|
|||
|
MissionDialogAndLeftTabsLogic.Instance().UpdateAutoTip();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateAuto()
|
|||
|
{
|
|||
|
_SubMenu.Refresh();
|
|||
|
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsAutoTeam)
|
|||
|
{
|
|||
|
_BtnAuto.gameObject.SetActive(false);
|
|||
|
_BtnCancelAuto.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_BtnAuto.gameObject.SetActive(true);
|
|||
|
_BtnCancelAuto.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region TeamInfo
|
|||
|
|
|||
|
//请求附近队伍
|
|||
|
void ReqNearbyTeam(int destID)
|
|||
|
{
|
|||
|
//发送给服务器请求
|
|||
|
CG_REQ_NEAR_LIST packet = (CG_REQ_NEAR_LIST)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_NEAR_LIST);
|
|||
|
if (destID > 0)
|
|||
|
{
|
|||
|
packet.IsNearPlayerList = 0;
|
|||
|
packet.Desid = destID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
packet.IsNearPlayerList = 0;
|
|||
|
packet.Desid = -1;
|
|||
|
}
|
|||
|
packet.SendPacket();
|
|||
|
|
|||
|
_TeamContainer.InitContentItem(null);
|
|||
|
}
|
|||
|
|
|||
|
//更新附近队伍
|
|||
|
public void UpdateNearbyTeam(GC_NEAR_TEAMLIST packet)
|
|||
|
{
|
|||
|
LogModule.DebugLog("Update UpdateNearbyTeam");
|
|||
|
if (null == packet)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
_TeamList = new List<TeamInfo>();
|
|||
|
int idCount = packet.GuidCount;
|
|||
|
for (int i = 0; i < idCount; i++)
|
|||
|
{
|
|||
|
TeamInfo team = new TeamInfo();
|
|||
|
team.Guid = packet.GetGuid(i);
|
|||
|
team.Name = packet.GetName(i);
|
|||
|
team.Level = packet.GetLevel(i);
|
|||
|
team.Profession = packet.GetProf(i);
|
|||
|
team.CombatNum = packet.GetCombatNum(i);
|
|||
|
team.TeamID = packet.GetTeamID(i);
|
|||
|
team.DesID = packet.GetDesID(i);
|
|||
|
team.MemberNum = packet.GetMemberNum(i);
|
|||
|
|
|||
|
_TeamList.Add(team);
|
|||
|
}
|
|||
|
|
|||
|
_TeamContainer.InitContentItem(_TeamList);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region captainWelfare
|
|||
|
public UnityEngine.UI.Image _redIcon;
|
|||
|
public void OnCaptainWelfareBtn()
|
|||
|
{
|
|||
|
UIManager.ShowUI(UIInfo.CaptainWelfare);
|
|||
|
}
|
|||
|
public void ShowCaptainWelfareMarkIcon(bool isShow)
|
|||
|
{
|
|||
|
if(_redIcon != null)
|
|||
|
_redIcon.gameObject.SetActive(isShow);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|