324 lines
10 KiB
C#
324 lines
10 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
|
|||
|
public class GuildBossCopy : MonoBehaviour {
|
|||
|
|
|||
|
public struct BossState
|
|||
|
{
|
|||
|
public int dataid;
|
|||
|
public int state;
|
|||
|
public float PosX;
|
|||
|
public float PosZ;
|
|||
|
}
|
|||
|
|
|||
|
public GameObject BossInfoObj;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.GuildFBBoss, FreshBossInfo);
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.GuildFBBoss, FreshBossInfo);
|
|||
|
}
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
//if (MissionDialogAndLeftTabsLogic.Instance() != null)
|
|||
|
// MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(false);
|
|||
|
//MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.GuildBossCopy);
|
|||
|
Tab_Fuben fuben = TableManager.GetFubenByID(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID, 0);
|
|||
|
if (fuben == null)
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.GuildBossCopy);
|
|||
|
return;
|
|||
|
}
|
|||
|
int job = GameManager.gameManager.PlayerDataPool.GuildInfo.GetMemberJob(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid);
|
|||
|
if (job != (int)Games.GlobeDefine.GameDefine_Globe.GUILD_JOB.CHIEF && job != (int)Games.GlobeDefine.GameDefine_Globe.GUILD_JOB.VICE_CHIEF)
|
|||
|
{
|
|||
|
ApplyMemberWnd.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
OnBtnShow();
|
|||
|
}
|
|||
|
|
|||
|
public void FreshBossInfo(object argc)
|
|||
|
{
|
|||
|
List<GameObject> Caches = new List<GameObject>();
|
|||
|
int index = 0;
|
|||
|
SynGuildBossFBInfo binaryMsg = (SynGuildBossFBInfo)argc;
|
|||
|
if (binaryMsg == null)
|
|||
|
return;
|
|||
|
for (int i = 0; i < BossItemOBjs.Count; i++)
|
|||
|
BossItemOBjs[i].SetActive(false);
|
|||
|
Tab_GuildBossConfig guildBoss = null;
|
|||
|
var guildBosss = TableManager.GetGuildBossConfig().Values;
|
|||
|
foreach (var boss in guildBosss)
|
|||
|
{
|
|||
|
if (boss.FunbenID == GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID)
|
|||
|
guildBoss = boss;
|
|||
|
}
|
|||
|
|
|||
|
if(guildBoss==null)
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.GuildBossCopy);
|
|||
|
return;
|
|||
|
}
|
|||
|
m_CurrBossLevelId = guildBoss.Id;
|
|||
|
int stateIndex = -1;
|
|||
|
for (int i = 0; i < binaryMsg.info.Count; i++)
|
|||
|
{
|
|||
|
GuildBossFBInfo info = binaryMsg.info[i];
|
|||
|
if (info.state == 2)
|
|||
|
{
|
|||
|
stateIndex = i;
|
|||
|
}
|
|||
|
}
|
|||
|
SendMsg(100, MovieEventSend.EventType.HideGameObj);
|
|||
|
stateIndex++;
|
|||
|
for (; index < guildBoss.getBossInfoCount(); index++)
|
|||
|
{
|
|||
|
string bossStr = guildBoss.GetBossInfobyIndex(index);
|
|||
|
if (bossStr.Contains(":") == false)
|
|||
|
continue;
|
|||
|
string[] bossInfos = bossStr.Split(':');
|
|||
|
if (bossInfos.Length < 3)
|
|||
|
continue;
|
|||
|
BossState boss;
|
|||
|
int.TryParse(bossInfos[0], out boss.dataid);
|
|||
|
float.TryParse(bossInfos[1], out boss.PosX);
|
|||
|
float.TryParse(bossInfos[2], out boss.PosZ);
|
|||
|
if (boss.dataid == 0)
|
|||
|
continue;
|
|||
|
boss.state = 0;
|
|||
|
if (index < stateIndex)
|
|||
|
boss.state = 2;
|
|||
|
if(index == stateIndex)
|
|||
|
boss.state = 1;
|
|||
|
if(index > stateIndex)
|
|||
|
boss.state = 0;
|
|||
|
if (BossItemOBjs.Count > index)
|
|||
|
CreateOneBOSS(BossItemOBjs[index], boss);
|
|||
|
else
|
|||
|
{
|
|||
|
GameObject newObj = CreateOneBOSS(null, boss);
|
|||
|
if (newObj != null)
|
|||
|
BossItemOBjs.Add(newObj);
|
|||
|
}
|
|||
|
}
|
|||
|
for (; index < BossItemOBjs.Count; index++)
|
|||
|
{
|
|||
|
BossItemOBjs[index].SetActive(false);
|
|||
|
}
|
|||
|
if(stateIndex <= 0)
|
|||
|
{
|
|||
|
SendMsg(101, MovieEventSend.EventType.AddMesh);
|
|||
|
}
|
|||
|
if(stateIndex <= 1)
|
|||
|
{
|
|||
|
SendMsg(102, MovieEventSend.EventType.AddMesh);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void SendMsg(int envenID,MovieEventSend.EventType eventType)
|
|||
|
{
|
|||
|
EventSenderInfo info = new EventSenderInfo();
|
|||
|
info._SendID = gameObject.GetInstanceID();
|
|||
|
info._State = true;
|
|||
|
MovieEventSend.EventInfo even = new MovieEventSend.EventInfo();
|
|||
|
even.EveneID = envenID;
|
|||
|
even.EventType = eventType;
|
|||
|
info.Events.Add(even);
|
|||
|
|
|||
|
Games.Events.EventDispatcher.Instance.Dispatch(Games.Events.EventId.MovieEvent, info);
|
|||
|
}
|
|||
|
|
|||
|
List<GameObject> BossItemOBjs = new List<GameObject>();
|
|||
|
public GameObject CreateOneBOSS(GameObject cloneObj, BossState info)
|
|||
|
{
|
|||
|
GameObject BossItem = cloneObj;
|
|||
|
if(BossItem==null)
|
|||
|
BossItem = GameObject.Instantiate(BossInfoObj);
|
|||
|
if (BossItem == null)
|
|||
|
return null;
|
|||
|
BossItem.transform.SetParent(BossInfoObj.transform.parent);
|
|||
|
BossItem.transform.localPosition = Vector3.zero;
|
|||
|
BossItem.transform.localScale = Vector3.one;
|
|||
|
BossItem.SetActive(true);
|
|||
|
Transform killed = BossItem.transform.Find("Killed");
|
|||
|
if(killed!=null)
|
|||
|
{
|
|||
|
killed.gameObject.SetActive(info.state == 2);
|
|||
|
}
|
|||
|
|
|||
|
Transform Tip = BossItem.transform.Find("Tip");
|
|||
|
if (Tip != null)
|
|||
|
{
|
|||
|
Tip.gameObject.SetActive(info.state == 0);
|
|||
|
Text TipText = Tip.GetComponent<Text>();
|
|||
|
if (TipText != null)
|
|||
|
{
|
|||
|
TipText.text = StrDictionary.GetClientDictionaryString("#{24985}");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
Transform Name = BossItem.transform.Find("Name");
|
|||
|
if (Name != null)
|
|||
|
{
|
|||
|
Text NameText = Name.GetComponent<Text>();
|
|||
|
if(NameText!=null)
|
|||
|
{
|
|||
|
string numStr = string.Format(" {0}/1", (info.state == 2 ? 1 : 0));
|
|||
|
Tab_RoleBaseAttr role = TableManager.GetRoleBaseAttrByID(info.dataid, 0);
|
|||
|
if (role != null)
|
|||
|
NameText.text = role.Name + numStr;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
Button btn = BossItem.GetComponentInChildren<Button>(true);
|
|||
|
if (btn != null)
|
|||
|
{
|
|||
|
btn.gameObject.SetActive(info.state == 1);
|
|||
|
btn.onClick.AddListener(delegate ()
|
|||
|
{
|
|||
|
AutoSearchPoint point = new AutoSearchPoint(GameManager.gameManager.RunningScene, info.PosX , info.PosZ);
|
|||
|
GameManager.gameManager.AutoSearch.BuildPath(point, false);
|
|||
|
});
|
|||
|
}
|
|||
|
return BossItem;
|
|||
|
}
|
|||
|
|
|||
|
public void Click_LeaveCopy()
|
|||
|
{
|
|||
|
if (Singleton<ObjManager>.Instance.MainPlayer != null)
|
|||
|
{
|
|||
|
Singleton<ObjManager>.Instance.MainPlayer.AskLeaveCopy();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OpenMissionLeftTab()
|
|||
|
{
|
|||
|
if(MissionDialogAndLeftTabsLogic.Instance()==null)
|
|||
|
{
|
|||
|
UIManager.ShowUI(UIInfo.MissionInfoController,delegate(bool bSuccess, object param)
|
|||
|
{
|
|||
|
if (bSuccess == false)
|
|||
|
return;
|
|||
|
MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.GuildBossCopy);
|
|||
|
MissionDialogAndLeftTabsLogic.Instance().SetSwitchBtn();
|
|||
|
UIManager.CloseUI(UIInfo.GuildBossCopy);
|
|||
|
});
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(true);
|
|||
|
MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.GuildBossCopy);
|
|||
|
MissionDialogAndLeftTabsLogic.Instance().SetSwitchBtn();
|
|||
|
UIManager.CloseUI(UIInfo.GuildBossCopy);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//招募
|
|||
|
public GameObject ApplyMemberWnd;
|
|||
|
public Button ApplyMemberBtn;
|
|||
|
public Text ApplyMemText;
|
|||
|
private float TimeDown;
|
|||
|
private int m_CurrBossLevelId;
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (TimeDown < 0)
|
|||
|
{
|
|||
|
ApplyMemberBtn.gameObject.SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
if (TimeDown > 0)
|
|||
|
{
|
|||
|
int job = GameManager.gameManager.PlayerDataPool.GuildInfo.GetMemberJob(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid);
|
|||
|
if(job == (int)Games.GlobeDefine.GameDefine_Globe.GUILD_JOB.CHIEF || job == (int)Games.GlobeDefine.GameDefine_Globe.GUILD_JOB.VICE_CHIEF)
|
|||
|
{
|
|||
|
ApplyMemberWnd.SetActive(true);
|
|||
|
ApplyMemberBtn.gameObject.SetActive(true);
|
|||
|
ApplyMemText.text = string.Format("{0}({1}s)", StrDictionary.GetClientDictionaryString("#{24997}"), Mathf.FloorToInt(TimeDown));
|
|||
|
}
|
|||
|
}
|
|||
|
TimeDown -= Time.deltaTime;
|
|||
|
}
|
|||
|
|
|||
|
public void ApplyDisable()
|
|||
|
{
|
|||
|
GUIData.AddNotifyData("#{24983}");
|
|||
|
}
|
|||
|
|
|||
|
public void ApplyMember()
|
|||
|
{
|
|||
|
CG_REQ_GUILDBOSS_OPERATE send = (CG_REQ_GUILDBOSS_OPERATE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_GUILDBOSS_OPERATE);
|
|||
|
send.Operate = 2;
|
|||
|
send.Parm = m_CurrBossLevelId;
|
|||
|
send.SendPacket();
|
|||
|
TimeDown = 5;
|
|||
|
}
|
|||
|
|
|||
|
#region move
|
|||
|
public ObjectTween _MoveTo;
|
|||
|
public RectTransform _TitleBGRec;
|
|||
|
public GameObject _ShowBtn;
|
|||
|
public GameObject _HideBtn;
|
|||
|
public GameObject _InfoPanel;
|
|||
|
|
|||
|
private bool isShow = false;
|
|||
|
public void OnBtnShow()
|
|||
|
{
|
|||
|
ShowPanel();
|
|||
|
_ShowBtn.SetActive(false);
|
|||
|
_HideBtn.SetActive(true);
|
|||
|
isShow = true;
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnHide()
|
|||
|
{
|
|||
|
HidePanel();
|
|||
|
_ShowBtn.SetActive(true);
|
|||
|
_HideBtn.SetActive(false);
|
|||
|
isShow = false;
|
|||
|
}
|
|||
|
|
|||
|
public void OnTitleBtn()
|
|||
|
{
|
|||
|
if (isShow)
|
|||
|
{
|
|||
|
OnBtnHide();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OnBtnShow();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void ShowPanel()
|
|||
|
{
|
|||
|
_MoveTo.Reset();
|
|||
|
_MoveTo.destantPos = new Vector3(0, 0, 0);
|
|||
|
|
|||
|
GCGame.Utils.HideMainTopRightUI();
|
|||
|
_TitleBGRec.sizeDelta = new Vector2(300, _TitleBGRec.sizeDelta.y);
|
|||
|
_InfoPanel.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
|
|||
|
public void HidePanel()
|
|||
|
{
|
|||
|
_MoveTo.Reset();
|
|||
|
_MoveTo.destantPos = new Vector3(0, -192, 0);
|
|||
|
|
|||
|
GCGame.Utils.ShowMainTopRightUI();
|
|||
|
_TitleBGRec.sizeDelta = new Vector2(230, _TitleBGRec.sizeDelta.y);
|
|||
|
_InfoPanel.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|