445 lines
14 KiB
C#
445 lines
14 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using System;
|
|
|
|
public class FactionAdvancePanelCtr : MonoBehaviour {
|
|
#region
|
|
|
|
#endregion
|
|
|
|
public List<Sprite> _BGSpriteList;
|
|
public UIContainerBase _MenuItemContainer;
|
|
public Image _BGSprite;
|
|
public Text _CopyName;
|
|
public Text _BestPassedPlayerName;
|
|
public Text _BasePassedTime;
|
|
public UIContainerBase _RankRewContainer;
|
|
public UIContainerBase _PassedRewContainer;
|
|
public Text _RemainTimes;
|
|
public GameObject _NoPassedInfo; //没有人通关的时候显示
|
|
|
|
public GameObject _FactionAdvanceRankPanel;
|
|
|
|
public static FactionAdvancePanelCtr Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
StartCoroutine(InitMenuItemContainer());
|
|
InitMacthInfo();
|
|
ShowDefaultFirst();
|
|
}
|
|
|
|
private List<int> _AllFacionAdvanceCopyList = new List<int>();
|
|
public void ShowDefaultFirst()
|
|
{
|
|
if (_CurSelectId != -1)
|
|
{
|
|
OnFactionAdvanceCopyItemClick(_CurSelectId);
|
|
}
|
|
else
|
|
{
|
|
OnFactionAdvanceCopyItemClick(1);
|
|
}
|
|
}
|
|
|
|
private int _CurSelectId = -1;
|
|
private Tab_FactionAdvanceCopy _CurSelectFactionAdvanceCopyTab;
|
|
public void OnFactionAdvanceCopyItemClick(int id)
|
|
{
|
|
_CurSelectId = id;
|
|
_CurSelectFactionAdvanceCopyTab = TableManager.GetFactionAdvanceCopyByID(id, 0);
|
|
_MenuItemContainer.ForeachActiveItem<FactionAdvanceCopyItem>(item => {
|
|
item.ShowMarkIcon(item.tabId == _CurSelectId);
|
|
});
|
|
|
|
if (_CurSelectFactionAdvanceCopyTab != null && GameManager.gameManager.PlayerDataPool.IsHaveTeam())
|
|
GameManager.gameManager.PlayerDataPool.TeamInfo.ChangeTeamDest(_CurSelectFactionAdvanceCopyTab.TeamTargetId, -1, -1);
|
|
StartCoroutine(InitCurSelectCopyPageInfo());
|
|
|
|
}
|
|
|
|
public void ReqCopyInfo()
|
|
{
|
|
CG_REQ_PROF_PASS_LAYER req = (CG_REQ_PROF_PASS_LAYER)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_PROF_PASS_LAYER);
|
|
req.Type = (int)CG_REQ_PROF_PASS_LAYER.REQ_PASS_LAYER_TYPE.FB_INFO;
|
|
req.Param = _CurSelectFactionAdvanceCopyTab.LocalServerFBId; //这边用本地
|
|
req.SendPacket();
|
|
}
|
|
|
|
public void OnPacket(GC_PROF_PASS_LAYER_FB packet)
|
|
{
|
|
var fbInfo = packet.GetFbinfo(0); //只取第一个
|
|
SetRemainTimes(fbInfo.Count);
|
|
|
|
if(fbInfo.Leastpasstime == 0)
|
|
{
|
|
_NoPassedInfo.gameObject.SetActive(true);
|
|
_BestPassedPlayerName.gameObject.SetActive(false);
|
|
_BasePassedTime.gameObject.SetActive(false);
|
|
}else
|
|
{
|
|
_NoPassedInfo.gameObject.SetActive(false);
|
|
SetBestPassedTime(fbInfo.Name, fbInfo.Leastpasstime);
|
|
}
|
|
}
|
|
|
|
public void SetBestPassedTime(string roleName, int passedTime)
|
|
{
|
|
_BestPassedPlayerName.gameObject.SetActive(true);
|
|
_BasePassedTime.gameObject.SetActive(true);
|
|
|
|
_BestPassedPlayerName.text = roleName;
|
|
var minute = passedTime / 60;
|
|
var sec = passedTime % 60;
|
|
_BasePassedTime.text = minute + ":" + sec;
|
|
}
|
|
|
|
private int _CurSelectedFBRemainTime = 0;
|
|
public void SetRemainTimes(int times) //同步的是已完成的次数
|
|
{
|
|
var fuben = TableManager.GetFubenByID(_CurSelectFactionAdvanceCopyTab.LocalServerFBId, 0);
|
|
if (fuben == null)
|
|
{
|
|
_RemainTimes.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
_RemainTimes.gameObject.SetActive(true);
|
|
if (fuben.ChallengeTimes == -1)
|
|
_RemainTimes.text = StrDictionary.GetClientDictionaryString("#{42756}");
|
|
else
|
|
{
|
|
_CurSelectedFBRemainTime = fuben.ChallengeTimes - times < 0 ? 0 : fuben.ChallengeTimes - times;
|
|
_RemainTimes.text = _CurSelectedFBRemainTime.ToString();
|
|
}
|
|
|
|
}
|
|
|
|
IEnumerator InitCurSelectCopyPageInfo()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
if(_CurSelectFactionAdvanceCopyTab == null)
|
|
{
|
|
yield break;
|
|
}
|
|
|
|
ReqCopyInfo();
|
|
_BGSprite.overrideSprite = _BGSpriteList[_CurSelectFactionAdvanceCopyTab.RawImageIndex];
|
|
List<int> _RankRewList = new List<int>();
|
|
bool isShowRew = false;
|
|
for(int index = 0; index < _CurSelectFactionAdvanceCopyTab.getRankRewIdCount(); index++)
|
|
{
|
|
if (_CurSelectFactionAdvanceCopyTab.GetRankRewIdbyIndex(index) != -1)
|
|
{
|
|
_RankRewList.Add(_CurSelectFactionAdvanceCopyTab.GetRankRewIdbyIndex(index));
|
|
isShowRew = true;
|
|
}
|
|
}
|
|
|
|
if(isShowRew)
|
|
{
|
|
_RankRewContainer.gameObject.SetActive(true);
|
|
_RankRewContainer.InitContentItem(_RankRewList);
|
|
}
|
|
else
|
|
{
|
|
_RankRewContainer.gameObject.SetActive(false);
|
|
}
|
|
|
|
List<int> _PassedRewList = new List<int>();
|
|
for(int index = 0; index < _CurSelectFactionAdvanceCopyTab.getPassedRewCount(); index++)
|
|
{
|
|
if (_CurSelectFactionAdvanceCopyTab.GetPassedRewbyIndex(index) != -1)
|
|
_PassedRewList.Add(_CurSelectFactionAdvanceCopyTab.GetPassedRewbyIndex(index));
|
|
}
|
|
_PassedRewContainer.InitContentItem(_PassedRewList);
|
|
_CopyName.text = _CurSelectFactionAdvanceCopyTab.MenuItemName;
|
|
yield break;
|
|
}
|
|
|
|
|
|
IEnumerator InitMenuItemContainer()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
if(_AllFacionAdvanceCopyList.Count == 0)
|
|
{
|
|
foreach (var factionCopy in TableManager.GetFactionAdvanceCopy())
|
|
{
|
|
_AllFacionAdvanceCopyList.Add(factionCopy.Key);
|
|
}
|
|
}
|
|
_MenuItemContainer.SetShowItemFinishCallFun(ShowDefaultFirst);
|
|
_MenuItemContainer.InitContentItem(_AllFacionAdvanceCopyList);
|
|
yield break;
|
|
}
|
|
|
|
public void OnRankBtnClick()
|
|
{
|
|
_FactionAdvanceRankPanel.SetActive(true);
|
|
}
|
|
|
|
public void OnHelpBtnClick()
|
|
{
|
|
MessageHelpLogic.ShowHelpMessage(38);
|
|
}
|
|
|
|
public void OnCloseBtnClick()
|
|
{
|
|
UIManager.CloseUI(UIInfo.FactionAdvancePanel);
|
|
}
|
|
|
|
#region 匹配相关
|
|
private List<int> _TeamTargetIdList;
|
|
public List<GameObject> _DotTextObjList;
|
|
public List<FactionAdvanceMatchItem> _RoleItemList;
|
|
public GameObject _ChallengePanel;
|
|
public GameObject _MatchPanel;
|
|
public GameObject _EnterBtn;
|
|
|
|
void InitMacthInfo()
|
|
{
|
|
if(IsInAutoTeamState())
|
|
{
|
|
SwitchToAutoTeamPanel(true);
|
|
RefreshTeamMemberInfo();
|
|
}
|
|
else
|
|
{
|
|
SwitchToAutoTeamPanel(false);
|
|
}
|
|
}
|
|
|
|
private bool isInAutoMatchPanel = false;
|
|
void SwitchToAutoTeamPanel(bool isShowAutoTeam)
|
|
{
|
|
isInAutoMatchPanel = isShowAutoTeam;
|
|
_ChallengePanel.SetActive(!isShowAutoTeam);
|
|
_MatchPanel.SetActive(isShowAutoTeam);
|
|
StopCoroutine(ChangeDotText());
|
|
if (_MatchPanel.gameObject.activeInHierarchy && isShowAutoTeam)
|
|
{
|
|
StartCoroutine(ChangeDotText());
|
|
RefreshTeamMemberInfo();
|
|
}
|
|
|
|
JudgeShowEnterBtn();
|
|
}
|
|
|
|
void JudgeShowEnterBtn()
|
|
{
|
|
_EnterBtn.SetActive(GameManager.gameManager.PlayerDataPool.IsHaveTeam()
|
|
&& GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount() >= 3);
|
|
}
|
|
|
|
public void RefreshAutoMatchState()
|
|
{
|
|
if(IsInAutoTeamState())
|
|
{
|
|
if (!isInAutoMatchPanel)
|
|
SwitchToAutoTeamPanel(true);
|
|
}
|
|
else
|
|
{
|
|
SwitchToAutoTeamPanel(false);
|
|
}
|
|
}
|
|
|
|
private int _Count = 0;
|
|
IEnumerator ChangeDotText()
|
|
{
|
|
while(true)
|
|
{
|
|
yield return new WaitForSeconds(0.5f);
|
|
_Count = ++_Count % 3;
|
|
for (int index = 0; index < _DotTextObjList.Count; index++)
|
|
_DotTextObjList[index].SetActive(index == _Count);
|
|
}
|
|
}
|
|
|
|
bool IsInAutoTeamState()
|
|
{
|
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsAutoTeam
|
|
&& IsFactionAdvanceCopyAutoTeam())
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
bool IsFactionAdvanceCopyAutoTeam()
|
|
{
|
|
if (_TeamTargetIdList == null)
|
|
{
|
|
_TeamTargetIdList = new List<int>();
|
|
foreach(var tab in TableManager.GetFactionAdvanceCopy())
|
|
{
|
|
if (!_TeamTargetIdList.Contains(tab.Value.TeamTargetId))
|
|
_TeamTargetIdList.Add(tab.Value.TeamTargetId);
|
|
}
|
|
}
|
|
|
|
if (_TeamTargetIdList.Contains(GameManager.gameManager.PlayerDataPool.TeamInfo.AutoTeamTargetDest))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
lastTeamMemberCout = -1;
|
|
isShowMessageBox = true;
|
|
}
|
|
|
|
private int lastTeamMemberCout = -1;
|
|
private bool isShowMessageBox = true;
|
|
public void RefreshTeamMemberInfo()
|
|
{
|
|
Debug.LogError("RefreshTeamMemberInfo");
|
|
var teamMemberCount = GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount();
|
|
if (lastTeamMemberCout != teamMemberCount)
|
|
{
|
|
isShowMessageBox = GameManager.gameManager.PlayerDataPool.TeamInfo.IsAutoTeam;
|
|
lastTeamMemberCout = teamMemberCount;
|
|
}else
|
|
{
|
|
isShowMessageBox = false;
|
|
return; //队员任何信息变化都是引起这边的刷新,这边应该改为只对人数变化敏感.
|
|
}
|
|
|
|
|
|
for (int index = 0; index < teamMemberCount; index++)
|
|
{
|
|
var memberInfo = GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(index);
|
|
_RoleItemList[index].InitItem(memberInfo.Profession, memberInfo.MemberName);
|
|
}
|
|
for (int index = teamMemberCount; index < _RoleItemList.Count; index++)
|
|
{
|
|
_RoleItemList[index].InitItem();
|
|
}
|
|
|
|
JudgeShowEnterBtn();
|
|
var isCaptain = GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain();
|
|
if (!isCaptain)
|
|
return;
|
|
|
|
if (teamMemberCount >= 5)
|
|
{
|
|
ReqEnterCopy();
|
|
}else if(teamMemberCount >= 3 && isShowMessageBox)
|
|
{
|
|
//弹窗提示是否直接进入或者继续匹配
|
|
MessageBoxLogic.OpenOKCancelBoxWithBtnName(StrDictionary.GetClientDictionaryString("#{48010}"), "",
|
|
StrDictionary.GetClientDictionaryString("#{48012}"), StrDictionary.GetClientDictionaryString("#{48011}"), delegate ()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
}, delegate ()
|
|
{
|
|
ReqEnterCopy();
|
|
});
|
|
}
|
|
}
|
|
|
|
public void OnTeamChallengeBtn()
|
|
{
|
|
if(GameManager.gameManager.PlayerDataPool.IsHaveTeam())
|
|
{
|
|
if(!GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1356}"));
|
|
return;
|
|
}
|
|
var memberCount = GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount();
|
|
if (memberCount < 5)
|
|
{
|
|
ReqEnterAutoMatchState();
|
|
}else
|
|
{
|
|
ReqEnterCopy();
|
|
}
|
|
}else
|
|
{
|
|
//需要创建队伍
|
|
GameManager.gameManager.PlayerDataPool.TeamInfo.CreaetTeam(_CurSelectFactionAdvanceCopyTab.TeamTargetId, -1, -1);
|
|
ReqEnterAutoMatchState();
|
|
}
|
|
}
|
|
|
|
public void OnAutoMatchBtn()
|
|
{
|
|
if (GameManager.gameManager.PlayerDataPool.IsHaveTeam())
|
|
{
|
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount() < 5)
|
|
{
|
|
ReqEnterAutoMatchState();
|
|
return;
|
|
}
|
|
|
|
ReqEnterCopy();
|
|
return;
|
|
}else
|
|
{
|
|
ReqEnterAutoMatchState();
|
|
}
|
|
}
|
|
|
|
public void OnCancelMatchBtn()
|
|
{
|
|
if (GameManager.gameManager.PlayerDataPool.IsHaveTeam()
|
|
&& !GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1356}"));
|
|
return;
|
|
}
|
|
|
|
CG_ASK_UN_AUTOTEAM packet = (CG_ASK_UN_AUTOTEAM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_UN_AUTOTEAM);
|
|
packet.None = 0;
|
|
packet.SendPacket();
|
|
|
|
StopAllCoroutines();
|
|
SwitchToAutoTeamPanel(false);
|
|
}
|
|
|
|
void ReqEnterAutoMatchState()
|
|
{
|
|
//if (!GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
|
|
//{
|
|
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1356}"));
|
|
// return;
|
|
//}
|
|
|
|
if (!GameManager.gameManager.PlayerDataPool.TeamInfo.IsAutoTeam)
|
|
{
|
|
CG_ASK_AUTOTEAM req = (CG_ASK_AUTOTEAM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_AUTOTEAM);
|
|
req.Desid = _CurSelectFactionAdvanceCopyTab.TeamTargetId;
|
|
req.SendPacket();
|
|
|
|
GameManager.gameManager.PlayerDataPool.TeamInfo.AutoTeamTargetDest = _CurSelectFactionAdvanceCopyTab.TeamTargetId;
|
|
}
|
|
}
|
|
|
|
public void ReqEnterCopy()
|
|
{
|
|
if(!GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1356}"));
|
|
return;
|
|
}
|
|
|
|
CG_REQ_ENTER_COPY req = (CG_REQ_ENTER_COPY)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ENTER_COPY);
|
|
req.Copyid = GameManager.gameManager.PlayerDataPool.TeamInfo.IsCrossServerTeam
|
|
? _CurSelectFactionAdvanceCopyTab.CrossServerFBId : _CurSelectFactionAdvanceCopyTab.LocalServerFBId;
|
|
req.SendPacket();
|
|
}
|
|
|
|
#endregion
|
|
}
|