using UnityEngine; using System.Collections; using System.Collections.Generic; using GCGame.Table; using Games.Mission; using Games.Events; using Games.LogicObj; using Module.Log; using GCGame; using Games.GlobeDefine; using UnityEngine.UI; public class MissionDialogAndLeftTabsLogic : MonoBehaviour { //private void Awake() //{ // var windowSign = this.gameObject.GetComponent(); // if (windowSign == null) // windowSign = this.gameObject.AddComponent(); // windowSign.Init((int)UIInfo.MissionDialogAndLeftTabsRoot.uiType); //} private static MissionDialogAndLeftTabsLogic m_Instance = null; public static MissionDialogAndLeftTabsLogic Instance() { return m_Instance; } public static UIPathData m_SwitchIndex = null; public static void SetSwitch(UIPathData data) { m_SwitchIndex = data; } public int CurGoingMissionType = -1; public GameObject m_Anchor; public void HideMissionDialog(bool state) { m_Anchor.SetActive(state); if (state) { ShowDefaultToggle(_IsShowFirst); GameManager.gameManager.MissionManager.NotifyMissionUI(-1, null); } } public bool _IsShowFirst = true; public void SetSwitchBtn(bool state = true) { GuildWarInfoBtn.gameObject.SetActive(state); if (!state) { _IsShowFirst = true; if (m_SwitchIndex != null) UIManager.CloseUI(m_SwitchIndex); m_SwitchIndex = null; HideMissionDialog(true); } else { _IsShowFirst = false; ShowDefaultToggle(_IsShowFirst); } } void OnEnable() { if (m_SwitchIndex != null) { HideMissionDialog(false); } else { HideMissionDialog(true); } m_Instance = this; GuildWarInfoBtn.gameObject.SetActive(false); StartCoroutine(InitMissionTips()); _BtnHide.SetActive(true); ShowFuncPreview(); ShowDefaultToggle(_IsShowFirst); ShowCaptainRewDot(GameManager.gameManager.PlayerDataPool.IsHaveCaptainWelfareRewCanGetted); ShowTeamRedIcon(false); //默认不显示 } public void ShowDefaultToggle(bool state = true) { _TagPanel._Tags[0].isOn = state; _TagPanel._Tags[1].isOn = (!state); } public void ShowFuncPreview() { if (FunctionPreviewCtr.Instance) { FunctionPreviewCtr.Instance.GetLastCompleteMainMissionId(); FunctionPreviewCtr.Instance.OnMissionComplteOver(); } } void OnDisable() { m_Instance = null; m_SwitchIndex = null; } void Start() { InitMissionFollow(); } private void Update() { //UpdateTeamFriendTip(); } public void Click_ShowGuildWar() { UIManager.ShowUI(m_SwitchIndex); } public void OnTagPage(int page) { if (page == 0) { _MissionLogBtn.SetActive(true); _TeamInfoBtn.SetActive(false); InitMissionFollow(); titleList[0].text = StrDictionary.GetClientDictionaryString("#{42506}"); //"任务"; titleList[1].text = StrDictionary.GetClientDictionaryString("#{42507}"); //"组队"; } else { _MissionLogBtn.SetActive(false); _TeamInfoBtn.SetActive(true); titleList[0].text = StrDictionary.GetClientDictionaryString("#{42508}"); //"任务"; titleList[1].text = StrDictionary.GetClientDictionaryString("#{42509}"); //"组队"; UpdateTeamInfo(); _TeamSpeakPanel.SetActive(false); } } private int CurGoingMissionId = -1; //用于指引 支线可以同时存在多个相同类型的任务 public void OnMissionItemClick(int missionId) { var missionBase = TableManager.GetMissionBaseByID(missionId, 0); if (missionBase == null) return; if(CurGoingMissionType == (int)MISSIONTYPE.MISSION_GUIDE) { CurGoingMissionId = missionId; }else { CurGoingMissionType = missionBase.MissionType; //点击的时候记录一次当前正在进行的类型,在切换场景之后可以选中 } _MissionContainer.ForeachActiveItem(missionItem => { missionItem.ShowEffect(missionItem.MissionID == missionId); }); } #region mission public GameObject GuildWarInfoBtn; public UITagPanel _TagPanel; public GameObject _MissionLogBtn; public GameObject _TeamInfoBtn; public List titleList; public UIContainerBase _MissionContainer; // 更新所有任务UI public void InitMissionFollow() { //UIManager.LoadItem(UIInfo.MissionItem, OnLoadMissionItem); if (_MissionContainer.gameObject.activeInHierarchy) { //特殊场景:关宁 if (GameManager.gameManager.RunningScene == (int)GameDefine_Globe.SCENE_DEFINE.SCENE_GUANNING) { RefreshMissionInBattleField(); } else { RefreshMissionOther(); } } } public void RefreshMissionInBattleField() { var missionItems = GameManager.gameManager.MissionManager.GetClassifyMission(); if (missionItems.ContainsKey(MISSIONTYPE.MISSION_BATTLE)) { _MissionContainer.InitContentItem(missionItems[MISSIONTYPE.MISSION_BATTLE]); } else { _MissionContainer.InitContentItem(null); } } public void ClickOneMissionItem(int missionId) { _MissionContainer.ForeachActiveItem(item => { item.ClickItem(item.MissionID == missionId); }); } public void RefreshMissionOther() { //InitMissionFollow(); var missionList = GameManager.gameManager.MissionManager.GetAllMissionID(); List initMissionList = new List(); for (int i = 0; i < missionList.Count; ++i) { var missionTab = TableManager.GetMissionBaseByID(missionList[i], 0); if (missionTab.MissionType == (int)MISSIONTYPE.MISSION_BATTLE) continue; initMissionList.Add(missionList[i]); } _MissionContainer.InitContentItem(initMissionList); if (CurGoingMissionId != -1) { _MissionContainer.ForeachActiveItem(item => { item.ShowEffect(item.MissionID == CurGoingMissionId); }); } else if (CurGoingMissionType != -1 && CurGoingMissionType != (int)MISSIONTYPE.MISSION_GUIDE && CurGoingMissionType != (int)MISSIONTYPE.MISSION_BRANCH) { _MissionContainer.ForeachActiveItem(item => { var missionBase = TableManager.GetMissionBaseByID(item.MissionID, 0); if (missionBase == null) { item.ShowEffect(false); } else { item.ShowEffect(missionBase.MissionType == CurGoingMissionType && missionBase.MissionType != (int)MISSIONTYPE.MISSION_GUIDE); } }); } else { _MissionContainer.ForeachActiveItem(item => { item.ShowEffect(false); }); } //ID只属于那种支线任务,刷新的时候不跑特效也可以 CurGoingMissionId = -1; //Id要置空 } bool UpdateMissionItem(int nMissionID) { InitMissionFollow(); return true; } // 更新任务信息UI操作 public void UpDateMissionFollow(int nMissionID, string strOpt) { InitMissionFollow(); } public void CloseMissionInfoRoot() { UIManager.CloseUI(UIInfo.MissionInfoController); } public void PlayTween(bool isIn) { gameObject.SetActive(!isIn); } public void OnBtnMissionLog() { UIManager.ShowUI(UIInfo.MissionLogRoot); } public void DisableMissionTag() { _TagPanel.ShowPage(1); _TagPanel._Tags[0].interactable = false; } public void EnableMissionTag() { _TagPanel._Tags[0].interactable = true; } #endregion #region Hide anim private static Vector2 _ShowPos = new Vector2(0, 0); private static Vector2 _HidePos = new Vector2(-335, 0); public RectTransform _AnimPanel; public GameObject _BtnHide; //和帮战联赛的界面互斥 public void OpenGuildWar_Click() { UIManager.CloseUI(UIInfo.MissionDialogAndLeftTabsRoot); UIManager.ShowUI(UIInfo.GuildWarLeftTab); } public void Init() { ShowPanel(); } public Animator _ShowPanelAnim; public Animator _ShowBtnAnim; private bool _IsShowPanel = true; public bool IsShowPanel { get { return _IsShowPanel; } } public void OnBtnShow() { if (_IsShowPanel) { HidePanel(); } else { ShowPanel(); } } public void ShowPanel() { _ShowPanelAnim.Play("Show"); _ShowBtnAnim.Play("Show"); _IsShowPanel = true; } public void HidePanel() { _ShowPanelAnim.Play("Hide"); _ShowBtnAnim.Play("Hide"); _IsShowPanel = false; } #endregion #region team public GameObject m_TeamButton; public GameObject _AutoTeamTip; public GameObject _TeamLeaderBtns; public GameObject _TeamMemberBtns; public GameObject _TeamMemberEnterFollow; public GameObject _TeamMemberLeaveFollow; public GameObject _TeamTarButtons; public GameObject _TeamSpeakPanel; public GameObject _TeamBtnAuto; public GameObject _TeamBtnCancelAuto; public void OnBtnTeamInfo() { if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID >= 0) { UIManager.ShowUI(UIInfo.TeamInfoRoot); } else { UIManager.ShowUI(UIInfo.TeamCreateRoot); } } public void BtnCreateTeam() { if (false == GameManager.gameManager.PlayerDataPool.IsHaveTeam() && null != Singleton.GetInstance().MainPlayer) { GameManager.gameManager.PlayerDataPool.TeamInfo.CreaetTeam(-1, -1, -1); UIManager.ShowUI(UIInfo.TeamInfoRoot); } } public void OpenTeamWindow() { //RelationLogic.OpenTeamWindow(RelationTeamWindow.TeamTab.TeamTab_NearPlayer); UIManager.ShowUI(UIInfo.TeamCreateRoot); } public void UpdateTeamInfo() { _TeamTarButtons.SetActive(false); if (m_TeamButton != null) { if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID >= 0) { m_TeamButton.SetActive(false); if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain()) { _TeamLeaderBtns.SetActive(true); _TeamMemberBtns.SetActive(false); if (GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount() != GlobeVar.MAX_TEAM_MEMBER) { _TeamTarButtons.SetActive(true); //if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsAutoTeam) //{ // _TeamBtnAuto.gameObject.SetActive(false); // _TeamBtnCancelAuto.gameObject.SetActive(true); //} //else //{ // _TeamBtnAuto.gameObject.SetActive(true); // _TeamBtnCancelAuto.gameObject.SetActive(false); //} } } else { _TeamLeaderBtns.SetActive(false); _TeamMemberBtns.SetActive(true); if (GameManager.gameManager.PlayerDataPool.IsFollowTeam) { _TeamMemberEnterFollow.SetActive(false); _TeamMemberLeaveFollow.SetActive(true); } else { _TeamMemberEnterFollow.SetActive(true); _TeamMemberLeaveFollow.SetActive(false); } } } else { m_TeamButton.SetActive(true); _TeamLeaderBtns.SetActive(false); _TeamMemberBtns.SetActive(false); } } UpdateAutoTip(); } public void UpdateAutoTip() { if (Singleton.GetInstance().MainPlayer == null) return; if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsAutoTeam) { _AutoTeamTip.SetActive(true); _TeamBtnAuto.gameObject.SetActive(false); _TeamBtnCancelAuto.gameObject.SetActive(true); } else { _AutoTeamTip.SetActive(false); _TeamBtnAuto.gameObject.SetActive(true); _TeamBtnCancelAuto.gameObject.SetActive(false); } } void LeaveTeamOnClick() { MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{3181}"), "", LeaveTeamOK); } void LeaveTeamOK() { if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID != GlobeVar.INVALID_ID) { if (null != Singleton.GetInstance().MainPlayer) { Singleton.GetInstance().MainPlayer.ReqLeaveTeam(); } } } public void BtnShowTeamInfo() { UIManager.ShowUI(UIInfo.TeamInfoRoot); } public void HandleSyncTeamInfo() { if (m_TeamButton != null) { if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID >= 0) { m_TeamButton.SetActive(false); UpdateTeamInfo(); } else { m_TeamButton.SetActive(true); _TeamLeaderBtns.SetActive(false); _TeamMemberBtns.SetActive(false); } } } public void BtnEnterTeamFollow() { Singleton.GetInstance().MainPlayer.EnterTeamFollow(); } public void BtnLeaveTeamFollow() { Singleton.GetInstance().MainPlayer.LeaveTeamFollow(); } public void OnBtnShowSpeakPanel() { if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID < 0) return; if (GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamDest > 0) { var teamTarget = TableManager.GetTeamTargetByID(GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamDest, 0); if (teamTarget == null) { Debug.LogError("teamTarget IS NULL ID : " + GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamDest); return; } if (teamTarget.TalkType == 2) { if (!GameManager.gameManager.PlayerDataPool.IsHaveGuild()) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{2941}")); return; } GameManager.gameManager.PlayerDataPool.TeamInfo.SendTeamChat(GC_CHAT.CHATTYPE.CHAT_TYPE_GUILD); return; } GameManager.gameManager.PlayerDataPool.TeamInfo.SendTeamChat(GC_CHAT.CHATTYPE.CHAT_TYPE_TEAM_INVITE); } else { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{5147}")); UIManager.ShowUI(UIInfo.TeamInfoRoot, (sucessed, param) => { TeamInfoWindow.Instance().OnBtnModifyTarget(); }); return; } } public void OnHideShowSpeakPanel() { _TeamSpeakPanel.SetActive(false); } public void OnBtnSpeakGuide() { if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{2941}")); return; } GameManager.gameManager.PlayerDataPool.TeamInfo.SendTeamChat(GC_CHAT.CHATTYPE.CHAT_TYPE_GUILD); OnHideShowSpeakPanel(); } public void OnBtnSpeakWorld() { GameManager.gameManager.PlayerDataPool.TeamInfo.SendTeamChat(GC_CHAT.CHATTYPE.CHAT_TYPE_WORLD); OnHideShowSpeakPanel(); } public void OnBtnAuto() { if (GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamDest > 0) { GameManager.gameManager.PlayerDataPool.TeamInfo.SetAutoTeam(true); } else { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{5147}")); UIManager.ShowUI(UIInfo.TeamInfoRoot, (sucessed, param) => { TeamInfoWindow.Instance().OnBtnModifyTarget(); }); return; } //_TeamBtnAuto.gameObject.SetActive(false); //_TeamBtnCancelAuto.gameObject.SetActive(true); } public void OnBtnCancelAuto() { GameManager.gameManager.PlayerDataPool.TeamInfo.SetAutoTeam(false); //_TeamBtnAuto.gameObject.SetActive(true); //_TeamBtnCancelAuto.gameObject.SetActive(false); } //申请队长 public void OnBtnApplyLeader() { if (null == Singleton.GetInstance().MainPlayer) { return; } CG_REQ_BECOME_TEAM_LEADER packet = (CG_REQ_BECOME_TEAM_LEADER)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_BECOME_TEAM_LEADER); packet.Nilparam = 1; packet.SendPacket(); } #region captainwelfare public Image _captainRewDot; public void OnBtnCaptainWelfare() { UIManager.ShowUI(UIInfo.CaptainWelfare); } public void ShowCaptainRewDot(bool isShow) { _captainRewDot.gameObject.SetActive(false); } #endregion #region team leader friend public static int _TipSec = 300; public float _StartTipCount; public int _TipLastSec = -1; public void UpdateTeamFriendTip() { if (Singleton.Instance.MainPlayer == null) return; if (_StartTipCount > 0) { var lastTime = Time.time - _StartTipCount; if (lastTime > _TipSec) { ShowAddFriendTip(); } } else { ShowAddFriendTip(); } } public void ShowAddFriendTip() { if (GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID < 0) return; if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain()) return; if (GameManager.gameManager.PlayerDataPool.FriendList.IsExist(GameManager.gameManager.PlayerDataPool.TeamInfo.teamMember[0].Guid)) return; string tips = GCGame.Table.StrDictionary.GetClientDictionaryString("#{5157}", GameManager.gameManager.PlayerDataPool.TeamInfo.teamMember[0].MemberName); _StartTipCount = Time.time; object[] param = new object[] { GameManager.gameManager.PlayerDataPool.TeamInfo.teamMember[0].Guid }; MessageTips.OpenOKCancelBox((int)MessageTips.MsgType.Team, tips,true, delegate (object[] objParam) { if (Singleton.Instance.MainPlayer == null) { return; } AgreeFriend(objParam); }, delegate (object[] objParam) { DisagreeFriend(objParam); } , delegate (object[] objParam) { DisagreeFriend(objParam); } , param); } public void AgreeFriend(object[] objParam) { if (objParam.Length < 1) return; Singleton.Instance.MainPlayer.ReqAddFriend((ulong)objParam[0]); //_StartTipCount = -1; } public void TimeOutFriend(object[] objParam) { } public void DisagreeFriend(object[] objParam) { } #endregion #endregion #region mission check tips public GameObject _RedDotTips; public void UpdateRedDotTips() { _RedDotTips.SetActive(false); //if (!GameManager.gameManager.MissionManager.IsMissionChecked()) //{ // _RedDotTips.SetActive(true); //} //else //{ // _RedDotTips.SetActive(false); //} } public IEnumerator InitMissionTips() { yield return new WaitForSeconds(5); GameManager.gameManager.MissionManager.GetClassifyCanAcceptMission(); UpdateRedDotTips(); } #endregion #region 队伍申请状态、福利状态 public GameObject _teamRedIcon; public void ShowTeamRedIcon(bool isShow) { _teamRedIcon.SetActive(isShow); } #endregion }