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; using Games.Events; public class GuildWarAndLeftTabsRoot : MonoBehaviour { private static GuildWarAndLeftTabsRoot m_Instance = null; public static GuildWarAndLeftTabsRoot Instance() { return m_Instance; } public TimeDownText NewBuffTimeDown; public GameObject FirstWnd; public GameObject SecondWnd; public GameObject EnemyWnd; public GameObject Tags; public UITagPanel TagPanel; public Slider MainBuild; public Slider UpBuild; public Slider CenterBuild; public Slider DownBuild; public Slider Drogon; public Slider Tigris; public Slider GodBrid; public Slider Tortois; public Slider SecondDrogon; public Slider SecondTigris; public Slider SecondGodBrid; public Slider SecondTortois; public GameObject UpHadDesroy; public GameObject CenterHadDesroy; public GameObject DownHadDesroy; public Text UpBuildLeave; public Text CenterBuildLeave; public Text DownBuildLeave; public GameObject DrogonText1; public GameObject TigrisText1; public GameObject GodBridText1; public GameObject TortoisText1; public GameObject DrogonText2; public GameObject TigrisText2; public GameObject GodBridText2; public GameObject TortoisText2; public GameObject SecondDrogonText; public GameObject SecondTigrisText; public GameObject SecondGodBridText; public GameObject SecondTortoisText; public GameObject SelfBtn; public GameObject eamyBtn; public DisableGameObj MainEffectObj; public DisableGameObj UpEffectObj; public DisableGameObj CenterEffectObj; public DisableGameObj DownEffectObj; float MainTowerAllPower = 0; float UpTowerAllPower = 0; float CenterTowerAllPower = 0; float DownTowerAllPower = 0; int m_Relation = -1; void Awake() { Hashtable calbackMoveparam6 = new Hashtable(); calbackMoveparam6["name"] = "GuildWarAndLeftTabsRoot"; MessageEventCallBack fun6 = OnBossInfoFresh; calbackMoveparam6.Add("callFun", fun6); Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.OnServerPointFresh, calbackMoveparam6); Hashtable calbackMoveparam8 = new Hashtable(); calbackMoveparam8["name"] = "GuildWarAndLeftTabsRoot"; MessageEventCallBack fun8 = OnMainPlayerForceChange; calbackMoveparam8.Add("callFun", fun8); Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.OnMainPlayerForecChange, calbackMoveparam8); } void OnDestroy() { Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.OnServerPointFresh, "GuildWarAndLeftTabsRoot"); Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.OnMainPlayerForecChange, "GuildWarAndLeftTabsRoot"); } void Start() { InvokeRepeating("AskBossInfo", 1, 1); MainOrSceond(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID == (int)GameDefine_Globe.SCENE_DEFINE.SCENE_GUILDWARMAIN); } void OnEnable() { Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.OnChangeSceneOver, OnChangeScene); m_Instance = this; InvokeRepeating("AskBossInfo", 1, 1); if (MissionDialogAndLeftTabsLogic.Instance() != null) { MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(false); MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.GuildWarLeftTab); } } void OnDisable() { Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.OnChangeSceneOver, OnChangeScene); m_Instance = null; CancelInvoke("AskBossInfo"); if (MissionDialogAndLeftTabsLogic.Instance() != null) MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(true); } public void OnChangeScene(object param) { MainOrSceond(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID == (int)GameDefine_Globe.SCENE_DEFINE.SCENE_GUILDWARMAIN); if(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID == (int)GameDefine_Globe.SCENE_DEFINE.SCENE_GUILDWARMAIN) { TagPanel.ShowPage(0); } if (MissionDialogAndLeftTabsLogic.Instance() != null) { MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(false); MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.GuildWarLeftTab); } } public void BroadcastBuff(int time) { NewBuffTimeDown.gameObject.SetActive(true); NewBuffTimeDown.Init("", Time.realtimeSinceStartup + time, 0, 29043, delegate (Hashtable table) { NewBuffTimeDown.gameObject.SetActive(false); }, TimeDownText.TimeFormat.number, 1); } public void OnMainPlayerForceChange(Hashtable addparam, Hashtable sendparam) { MainOrSceond(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID == (int)GameDefine_Globe.SCENE_DEFINE.SCENE_GUILDWARMAIN); } public void OnBossInfoFresh(Hashtable addparam, Hashtable sendparam) { if (sendparam.ContainsKey("data") == false) return; GC_SCENE_MONSTER_INFO packet = (GC_SCENE_MONSTER_INFO)sendparam["data"]; if(packet.Param ==11 || packet.Param == 12) { BuildInfo(packet); } else { BossInfo(packet); } } MonsterInfo m_Main = null; MonsterInfo m_UP = null; MonsterInfo m_Center = null; MonsterInfo m_Down = null; MonsterInfo m_Drogon; MonsterInfo m_Tigris; MonsterInfo m_GodBrid; MonsterInfo m_Tortois; public void OnTagPage(int page) { Tab_Relation tabRelation = TableManager.GetRelationByID(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force, 0); if (tabRelation == null) return; if (page == 0) { m_Relation = 11; int relation = tabRelation.GetRelationbyIndex(m_Relation); if (relation == 2) m_Relation = 12; } else { m_Relation = 13; int relation = tabRelation.GetRelationbyIndex(m_Relation); if (relation == 2) m_Relation = 14; CG_GUILD_UNION_MATCH_REQ send = (CG_GUILD_UNION_MATCH_REQ)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_UNION_MATCH_REQ); send.SetType((int)CG_GUILD_UNION_MATCH_REQ.UNION_MATCH_REQ.CAMP_NPC_INFO); send.Param = -1; send.SendPacket(); } } public void BuildInfo(GC_SCENE_MONSTER_INFO packet) { int MainLeave = 0; int UPLeave = 0; int CenterLeave = 0; int DownLeave = 0; m_Main = null; m_UP = null; m_Center = null; m_Down = null; float maintowerblood = 0; float uptowerblood = 0; float centertowerblood = 0; float downtowerblood = 0; for (int i=0;i 0) MainLeave++; m_Main = info; maintowerblood += info.MonsterHP; } if (info.MonsterParam >0 && info.MonsterParam<=10) { if (info.MonsterHP > 0) UPLeave++; if (m_UP == null) m_UP = info; else { if(info.MonsterHP>0 && info.MonsterParam>m_UP.MonsterParam) m_UP = info; } uptowerblood += info.MonsterHP; } if (info.MonsterParam > 10 && info.MonsterParam <= 20) { if (info.MonsterHP > 0) CenterLeave++; if (m_Center == null) m_Center = info; else { if (info.MonsterHP > 0 && info.MonsterParam > m_Center.MonsterParam) m_Center = info; } centertowerblood += info.MonsterHP; } if (info.MonsterParam > 20 && info.MonsterParam <= 30) { if (info.MonsterHP > 0) DownLeave++; if (m_Down == null) m_Down = info; else { if (info.MonsterHP > 0 && info.MonsterParam > m_Down.MonsterParam) m_Down = info; } downtowerblood += info.MonsterHP; } } if(m_Main!=null) { if(EnemyWnd.activeSelf == false) { if(maintowerblood < MainTowerAllPower) { MainEffectObj.gameObject.SetActive(true); MainEffectObj.ReEnable(); } MainTowerAllPower = maintowerblood; } } if(m_UP!=null) { UpBuild.value = m_UP.MonsterHP*1.0f / m_UP.MonsterMaxHP; UpBuildLeave.text = string.Format("{0}/{1}", UPLeave, 2); UpHadDesroy.SetActive(UPLeave == 0); if(EnemyWnd.activeSelf==false) { if(uptowerblood < UpTowerAllPower) { UpEffectObj.gameObject.SetActive(true); UpEffectObj.ReEnable(); } UpTowerAllPower = uptowerblood; } } else { UpBuildLeave.text = string.Format("{0}/{1}", 0, 2); UpBuild.value = 0; UpHadDesroy.SetActive(true); } if (m_Down != null) { DownBuild.value = m_Down.MonsterHP * 1.0f / m_Down.MonsterMaxHP; DownBuildLeave.text = string.Format("{0}/{1}", DownLeave, 2); DownHadDesroy.SetActive(DownLeave == 0); if (EnemyWnd.activeSelf == false) { if (downtowerblood < DownTowerAllPower) { DownEffectObj.gameObject.SetActive(true); DownEffectObj.ReEnable(); } DownTowerAllPower = downtowerblood; } } else { DownBuildLeave.text = string.Format("{0}/{1}", 0, 2); DownBuild.value = 0; DownHadDesroy.SetActive(true); } } public void BossInfo(GC_SCENE_MONSTER_INFO packet) { if (FirstWnd.activeSelf) { if (packet.Param == -1) { m_Drogon = null; m_Tigris = null; m_GodBrid = null; m_Tortois = null; Drogon.gameObject.SetActive(false); Tigris.gameObject.SetActive(false); GodBrid.gameObject.SetActive(false); Tortois.gameObject.SetActive(false); DrogonText1.gameObject.SetActive(true); TigrisText1.gameObject.SetActive(true); GodBridText1.gameObject.SetActive(true); TortoisText1.gameObject.SetActive(true); DrogonText2.gameObject.SetActive(false); TigrisText2.gameObject.SetActive(false); GodBridText2.gameObject.SetActive(false); TortoisText2.gameObject.SetActive(false); for (int i = 0; i < packet.InfoCount; i++) { MonsterInfo info = packet.GetInfo(i); if (info.MonsterId == 2250) { m_Drogon = info; DrogonText1.gameObject.SetActive(false); DrogonText2.gameObject.SetActive(true); } if (info.MonsterId == 2251) { m_Tigris = info; TigrisText1.gameObject.SetActive(false); TigrisText2.gameObject.SetActive(true); } if (info.MonsterId == 2252) { m_GodBrid = info; GodBridText1.gameObject.SetActive(false); GodBridText2.gameObject.SetActive(true); } if (info.MonsterId == 2253) { m_Tortois = info; TortoisText1.gameObject.SetActive(false); TortoisText2.gameObject.SetActive(true); } } } else { for (int i = 0; i < packet.InfoCount; i++) { MonsterInfo info = packet.GetInfo(i); if (info.MonsterId == 2246) { m_Drogon = info; DrogonText1.gameObject.SetActive(false); DrogonText2.gameObject.SetActive(false); Drogon.gameObject.SetActive(true); Drogon.value = info.MonsterHP * 1.0f / info.MonsterMaxHP; } if (info.MonsterId == 2247) { m_Tigris = info; TigrisText1.gameObject.SetActive(false); TigrisText2.gameObject.SetActive(false); Tigris.gameObject.SetActive(true); Tigris.value = info.MonsterHP * 1.0f / info.MonsterMaxHP; } if (info.MonsterId == 2248) { m_GodBrid = info; GodBridText1.gameObject.SetActive(false); GodBridText2.gameObject.SetActive(false); GodBrid.gameObject.SetActive(true); GodBrid.value = info.MonsterHP * 1.0f / info.MonsterMaxHP; } if (info.MonsterId == 2249) { m_Tortois = info; TortoisText1.gameObject.SetActive(false); TortoisText2.gameObject.SetActive(false); Tortois.gameObject.SetActive(true); Tortois.value = info.MonsterHP * 1.0f / info.MonsterMaxHP; } } } } if(SecondWnd.activeSelf) { SecondDrogon.gameObject.SetActive(false); SecondTigris.gameObject.SetActive(false); SecondGodBrid.gameObject.SetActive(false); SecondTortois.gameObject.SetActive(false); SecondDrogonText.SetActive(true); SecondTigrisText.SetActive(true); SecondGodBridText.SetActive(true); SecondTortoisText.SetActive(true); for (int i = 0; i < packet.InfoCount; i++) { MonsterInfo info = packet.GetInfo(i); if (info.MonsterId == 2240) { m_Drogon = info; SecondDrogon.gameObject.SetActive(true); SecondDrogonText.SetActive(false); SecondDrogon.value = info.MonsterHP * 1.0f / info.MonsterMaxHP; } if (info.MonsterId == 2241) { m_Tigris = info; SecondTigris.gameObject.SetActive(true); SecondTigrisText.SetActive(false); SecondTigris.value = info.MonsterHP * 1.0f / info.MonsterMaxHP; } if (info.MonsterId == 2242) { m_GodBrid = info; SecondGodBrid.gameObject.SetActive(true); SecondGodBridText.SetActive(false); SecondGodBrid.value = info.MonsterHP * 1.0f / info.MonsterMaxHP; } if (info.MonsterId == 2243) { m_Tortois = info; SecondTortois.gameObject.SetActive(true); SecondTortoisText.SetActive(false); SecondTortois.value = info.MonsterHP * 1.0f / info.MonsterMaxHP; } } } } public void AskBossInfo() { if(FirstWnd.activeSelf) { CG_GUILD_UNION_MATCH_REQ send = (CG_GUILD_UNION_MATCH_REQ)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_UNION_MATCH_REQ); send.SetType((int)CG_GUILD_UNION_MATCH_REQ.UNION_MATCH_REQ.CAMP_NPC_INFO); send.Param = m_Relation; send.SendPacket(); } if (SecondWnd.activeSelf) { CG_GUILD_UNION_MATCH_REQ req = (CG_GUILD_UNION_MATCH_REQ)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_UNION_MATCH_REQ); req.SetParam(0); req.SetType((int)CG_GUILD_UNION_MATCH_REQ.UNION_MATCH_REQ.MONSTER_INFO); req.SendPacket(); } } public void EnemyInfo() { FirstWnd.SetActive(true); SecondWnd.SetActive(false); TagPanel.ShowPage(0); Tab_Relation tabRelation = TableManager.GetRelationByID(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force, 0); if (tabRelation == null) return; m_Relation = 11; int relation = tabRelation.GetRelationbyIndex(m_Relation); if (relation != 2) m_Relation = 12; } public void MainOrSceond(bool state) { FirstWnd.SetActive(state); SecondWnd.SetActive(!state); Tags.SetActive(state); EnemyWnd.SetActive(false); Tab_Relation tabRelation = TableManager.GetRelationByID(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force, 0); if (tabRelation == null) return; if (state) { m_Relation = 11; int relation = tabRelation.GetRelationbyIndex(m_Relation); if (relation == 2) m_Relation = 12; } else { m_Relation = 13; int relation = tabRelation.GetRelationbyIndex(m_Relation); if (relation == 2) m_Relation = 14; CG_GUILD_UNION_MATCH_REQ send = (CG_GUILD_UNION_MATCH_REQ)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_UNION_MATCH_REQ); send.Param = -1; send.SetType((int)CG_GUILD_UNION_MATCH_REQ.UNION_MATCH_REQ.CAMP_NPC_INFO); send.SendPacket(); } } public void Click_OpenWarInfo() { UIManager.ShowUI(UIInfo.GuildWarInfo, null, null); } public void ShowSelf() { eamyBtn.SetActive(true); SelfBtn.SetActive(false); Tags.SetActive(true); EnemyWnd.SetActive(false); MainOrSceond(true); } public void ShowEamy() { eamyBtn.SetActive(false); SelfBtn.SetActive(true); Tags.SetActive(false); EnemyWnd.SetActive(true); UpEffectObj.gameObject.SetActive(false); CenterEffectObj.gameObject.SetActive(false); DownEffectObj.gameObject.SetActive(false); MainEffectObj.gameObject.SetActive(false); EnemyInfo(); } public void Click_Descript() { PlayHelpMessageRoot.ShowHelpMessage(2); } public void OpenMissionLeftTab() { if (MissionDialogAndLeftTabsLogic.Instance() == null) { UIManager.ShowUI(UIInfo.MissionInfoController, delegate (bool bSuccess, object param) { if (bSuccess == false) return; MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.GuildWarLeftTab); MissionDialogAndLeftTabsLogic.Instance().SetSwitchBtn(); UIManager.CloseUI(UIInfo.GuildWarLeftTab); }); } else { MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(true); MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.GuildWarLeftTab); MissionDialogAndLeftTabsLogic.Instance().SetSwitchBtn(); UIManager.CloseUI(UIInfo.GuildWarLeftTab); } } public void AutoTo(int roleBase,float x,float z,float stopRange = 0.5f) { if (GameManager.gameManager && GameManager.gameManager.AutoSearch) { AutoSearchPoint point = new AutoSearchPoint(GameManager.gameManager.RunningScene, x, z, SceneData.SceneInst); GameManager.gameManager.AutoSearch.BuildPath(point); GameManager.gameManager.AutoSearch.Path.autoSearchRadius = stopRange; Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(roleBase, 0); if (null != RoleBase && null != GameManager.gameManager.AutoSearch.Path) { GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = RoleBase.Name; GameManager.gameManager.AutoSearch.Path.autoSearchRadius = RoleBase.DialogRadius; } } } public void ToTower(int index) { float x = -1; float y = -1; if (index == 1 && m_UP != null) { x = m_UP.MonsterPosX / 100; y = m_UP.MonsterPosY / 100; } if (index == 2 && m_Center != null) { x = m_Center.MonsterPosX / 100; y = m_Center.MonsterPosY / 100; } if (index == 3 && m_Down != null) { x = m_Down.MonsterPosX / 100; y = m_Down.MonsterPosY / 100; } if(x==-1&&y==-1) { return; } AutoTo(-1,x, y,2); } public void SecondToBoss(int index) { float x = -1; float y = -1; if (index == 0 && m_Drogon != null) { x = m_Drogon.MonsterPosX / 100; y = m_Drogon.MonsterPosY / 100; } if (index == 1 && m_Tigris != null) { x = m_Tigris.MonsterPosX / 100; y = m_Tigris.MonsterPosY / 100; } if (index == 2 && m_GodBrid != null) { x = m_GodBrid.MonsterPosX / 100; y = m_GodBrid.MonsterPosY / 100; } if (index == 3 && m_Tortois != null) { x = m_Tortois.MonsterPosX / 100; y = m_Tortois.MonsterPosY / 100; } if (x == -1 && y == -1) { return; } AutoTo(-1,x, y,1); } public void CallBoss(int index) { float x = -1; float y = -1; int roleBaseId = -1; if(index==0) { roleBaseId = 2250; if (m_Drogon!=null) { if(m_Drogon.MonsterId == 2246) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("{#29031}")); return; } x = m_Drogon.MonsterPosX / 100; y = m_Drogon.MonsterPosY / 100; } } if (index == 1) { roleBaseId = 2251; if (m_Tigris != null) { if (m_Tigris.MonsterId == 2247) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("{#29031}")); return; } x = m_Tigris.MonsterPosX / 100; y = m_Tigris.MonsterPosY / 100; } } if (index == 2) { roleBaseId = 2252; if (m_GodBrid != null) { if (m_GodBrid.MonsterId == 2248) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("{#29031}")); return; } x = m_GodBrid.MonsterPosX / 100; y = m_GodBrid.MonsterPosY / 100; } } if (index == 3) { roleBaseId = 2253; if (m_Tortois != null) { if (m_Tortois.MonsterId == 2249) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("{#29031}")); return; } x = m_Tortois.MonsterPosX / 100; y = m_Tortois.MonsterPosY / 100; } } if(x==-1 && y==-1) { Tab_RoleBaseAttr baseRole = TableManager.GetRoleBaseAttrByID(roleBaseId, 0); if(baseRole!=null) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("{#29030}", baseRole.Name)); } } else { AutoTo(roleBaseId,x, y); } } public void GotoMainScene() { int sysParamId = -1; if(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID == (int)GameDefine_Globe.SCENE_DEFINE.SCENE_GUILDWARMAIN) { if(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force == (int)GameDefine_Globe.FORCETYPE.PVP1) { sysParamId = 10; } if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force == (int)GameDefine_Globe.FORCETYPE.PVP2) { sysParamId = 11; } } else { if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force == (int)GameDefine_Globe.FORCETYPE.PVP1) { sysParamId = 12; } if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force == (int)GameDefine_Globe.FORCETYPE.PVP2) { sysParamId = 13; } } string param = SystemParam.GetSystemParam_STRING(sysParamId); if (string.IsNullOrEmpty(param)) return; string[] ids = param.Split(','); if (ids.Length >= 3) { int roleId = -1; float x = -1; float y = -1; int.TryParse(ids[0], out roleId); float.TryParse(ids[1], out x); float.TryParse(ids[2], out y); if (roleId != -1 && roleId != 0) { AutoTo(roleId, x, y); } } } #region Hide anim private static Vector2 _ShowPos = new Vector2(0, 0); private static Vector2 _HidePos = new Vector2(-355, 0); public RectTransform _AnimPanel; public GameObject _BtnHide; public GameObject _BtnShow; public void Init() { ShowPanel(); } public void ShowPanel() { _AnimPanel.anchoredPosition = _ShowPos; _BtnShow.SetActive(false); _BtnHide.SetActive(true); } public void HidePanel() { _AnimPanel.anchoredPosition = _HidePos; _BtnShow.SetActive(true); _BtnHide.SetActive(false); } #endregion }