Files
JJBB/Assets/Project/Script/GUI/Other/FunctionButtonLogic.cs
2024-08-23 15:49:34 +08:00

558 lines
14 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using Games.Events;
using GCGame;
using GCGame.Table;
using Module.Log;
using UnityEngine;
using UnityEngine.AI;
public class FunctionButtonLogic : UIControllerBase<FunctionButtonLogic>
{
public static bool _IsShowInit = true;
protected override void Init()
{
base.Init();
SetInstance(this);
//注册任务完成显示Image事件
//MissionManager.m_completeMission += showCompleteImage;
// 开启新手指引
UIManager.ShowUI(UIInfo.GuideRoot);
InitGMBtn();
}
private void OnEnable()
{
//自己刷新一遍
if (copyBtnFunc)
copyBtnFunc.ShowRemainTimeStateIcon();
//活动红点刷新
ActivityRedStateCtr.Instance.RefreshActState();
}
public void Start()
{
ShowUIInit();
}
public void ShowUIInit()
{
if (_IsShowInit)
ShowBaseBtns();
else
HideBaseBtns();
}
#region
public void InitButtonActive()
{
}
public void LevelUpButtonActive()
{
}
public void UpdateButtonAwardTips()
{
}
public void OpenFunction(int type)
{
}
public void UpdateAutoFightBtnState()
{
}
public void UpdateActionButtonTip()
{
}
#endregion
#region //隐藏部分窗口
public GameObject Anchor_RightTop;
public GameObject Anchor_LeftBottom;
public void HideWndPart(int part)
{
Anchor_RightTop.SetActive((part & 1) != 0);
Anchor_LeftBottom.SetActive((part & 2) != 0);
}
#endregion
#region event
public GameObject ShowOrHideBtn;
public BtnInteraction interactionBtn;
public BtnFunc copyBtnFunc; //这个要特殊处理
public GameObject _BaseBtn;
public GameObject _TopShowBtn;
public GameObject _TopHideBtn;
public Animator _BtnShowAnimator;
public Animator _BtnRotAnimator;
private readonly List<GameObject> _TempSwitchPanels = new List<GameObject>(); // 临时需要切换显示的面板,某些副本需要右上位置显示信息。
public List<GameObject> TempSwitchPanels
{
get { return _TempSwitchPanels; }
}
private bool _IsShowBtn;
public bool IsShowBtn
{
get { return _IsShowBtn; }
private set { }
}
public void OnBtnShow()
{
if (!_IsShowBtn)
Utils.ShowMainTopRightUI();
else
Utils.HideMainTopRightUI(false);
ShowOrHideBtn.SetActive(true);
}
//用于某些特定的场景屏蔽ShowBaseBtn入口
public bool IsCanShwoBaseBtns = true;
private bool _BaseBtnStateChange;
public bool ShowBaseBtns()
{
if (!IsCanShwoBaseBtns)
return false;
if (FirstShowScene.Instance() != null) return false;
if (_TempSwitchPanels.Count > 0)
for (var i = 0; i < _TempSwitchPanels.Count; ++i)
if (_TempSwitchPanels[i] != null)
_TempSwitchPanels[i].SetActive(false);
_BaseBtnStateChange = true;
_IsShowBtn = true;
EventDispatcher.Instance.Dispatch(EventId.FunctionChangeBaseBtnActive, true);
return true;
}
private void Update()
{
if (_BaseBtnStateChange && _BtnShowAnimator.gameObject.activeSelf)
{
var info_BtnShow = _BtnShowAnimator.GetCurrentAnimatorStateInfo(0);
var info_BtnRot = _BtnShowAnimator.GetCurrentAnimatorStateInfo(0);
if (_IsShowBtn)
{
if (!info_BtnShow.IsName("Show")) _BtnShowAnimator.Play("Show", 0, 0);
if (!info_BtnRot.IsName("Show")) _BtnRotAnimator.Play("Show", 0, 0);
}
else
{
if (!info_BtnShow.IsName("Hide")) _BtnShowAnimator.Play("Hide", 0, 0);
if (!info_BtnRot.IsName("Hide")) _BtnRotAnimator.Play("Hide", 0, 0);
}
_BaseBtnStateChange = false;
}
DoueldMountBtnShow();
}
public void HideBaseBtns()
{
if (_TempSwitchPanels.Count > 0)
for (var i = 0; i < _TempSwitchPanels.Count; ++i)
if (_TempSwitchPanels[i] != null)
_TempSwitchPanels[i].SetActive(true);
_BaseBtnStateChange = true;
_IsShowBtn = false;
EventDispatcher.Instance.Dispatch(EventId.FunctionChangeBaseBtnActive, false);
}
public void OnClickPrecious()
{
UIManager.ShowUI(UIInfo.Activity);
}
public void OnClickWar()
{
LogModule.DebugLog("C# OnClickWar");
//ActivityController.SetStartTab("Tab11");
//UIManager.ShowUI(UIInfo.Activity);
}
public void OnBackPackClick()
{
UIManager.ShowUI(UIInfo.BackPackRoot);
}
public void OnRankClick()
{
UIManager.ShowUI(UIInfo.RankRoot);
}
public void OnBossClick()
{
UIManager.ShowUI(UIInfo.Boss);
}
public void OnSports()
{
UIManager.ShowUI(UIInfo.SportsPanel);
}
public void OnPetClick()
{
UIManager.ShowUI(UIInfo.PetMainWndPath, delegate(bool bSuccess, object param)
{
if (bSuccess && PetMainWnd.Instance != null) PetMainWnd.Instance.ShowPage(0, 0);
});
}
public void OnMagicClick()
{
UIManager.ShowUI(UIInfo.MagicWndPath);
}
public void OnSettingClick()
{
UIManager.ShowUI(UIInfo.SystemAndAutoFight);
}
public void OnSkillClick()
{
UIManager.ShowUI(UIInfo.SkillInfo);
}
public void OnAdvanceBtnClick(int type)
{
UIManager.ShowUI(UIInfo.AdvanceMountPanel, delegate(bool bSucess, object param)
{
if (bSucess) AdvanceMountPanelCtr.Instance.SetAdvanceType(type);
});
}
public void OnGodWeaponClick()
{
UIManager.ShowUI(UIInfo.AdvanceMountPanel, delegate(bool bSucess, object param)
{
if (bSucess) AdvanceMountPanelCtr.Instance.SetAdvanceType((int) AdvanceBase.AdvanceType.Piano);
});
}
//打开帮会窗口
public void OnGuildClick()
{
if (GameManager.gameManager.PlayerDataPool.IsHaveGuild())
UIManager.ShowUI(UIInfo.GuildMainInfoWnd);
else
UIManager.ShowUI(UIInfo.GuildMainWnd);
}
public void OnActivityCick()
{
UIManager.ShowUI(UIInfo.Activity);
}
public void OnEquipClick()
{
UIManager.ShowUI(UIInfo.EquipEnhance);
}
public void OnGMClick()
{
UIManager.ShowUI(UIInfo.GMWnd);
}
public void OnCameraClick()
{
UIManager.ShowUI(UIInfo.CameraTest);
}
public void OnShopClick()
{
UIManager.ShowUI(UIInfo.YuanBaoShop);
}
public void OnMarketClick()
{
//UIManager.ShowUI(UIInfo.MarketRoot);
Market.ShowSysMarket(3, 2);
}
public void OnWelfareClick()
{
UIManager.ShowUI(UIInfo.WelfareRoot);
}
public void OnMountRide()
{
if (GameManager.gameManager.PlayerDataPool.IsInWeddingCar)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{26013}"));
return;
}
if (GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId < 0) //当前骑乘ID
Singleton<ObjManager>.GetInstance().MainPlayer.AskRideMount();
else
Singleton<ObjManager>.GetInstance().MainPlayer.AskUnMount();
}
#region /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary>
/// 骑乘者身份0为正常1为司机2为乘客
/// </summary>
public int DoubleState;
/// <summary>
/// 坐骑身份0为单人坐骑1为双人
/// </summary>
public int MountType = -1;
/// <summary>
/// 乘客guid
/// </summary>
public ulong _linkId;
/// <summary>
/// 按钮背景
/// </summary>
public GameObject DoubleMountBtnBg;
/// <summary>
/// 司机的按钮
/// </summary>
public GameObject driverBtn;
/// <summary>
/// 乘客的按钮
/// </summary>
public GameObject passengerBtn;
/// <summary>
/// 点击双人骑乘按钮
/// </summary>
public void OnClickDriverBtn()
{
UIManager.ShowUI(UIInfo.DoubleMountInvitePanel);
}
/// <summary>
/// 邀请者ID
/// </summary>
private ulong _InviterId;
private string _InviterName;
/// <summary>
/// 获取骑乘数据
/// </summary>
/// <param name="data"></param>
public void GetMountData(GC_MOUNT_DATA data)
{
var zuoQiID = GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId;
if (data == null) return;
_linkId = data.LinkId;
DoubleState = data.State; //...状态类型0为正常1为司机2为乘客
if (DoubleState == 2)
{
DoubleMountBtnBg.gameObject.SetActive(true);
passengerBtn.gameObject.SetActive(true);
}
else
{
passengerBtn.gameObject.SetActive(false);
}
}
/// <summary>
/// 被邀请乘坐双人坐骑
/// </summary>
public void InviteData(GC_DOUBLEMOUNT_INVITE packet)
{
//需要弹出提示框
if (packet == null)
return;
_InviterId = packet.InviterId;
_InviterName = packet.InviterName;
if (GameManager.gameManager.PlayerDataPool.LoverGUID == _InviterId)
//当A和B为夫妻关系时A邀请B进行双人乘骑B无需确认直接双人乘骑成功。
DoubleMountInviteOk();
else
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{48212}", packet.InviterName),
null, DoubleMountInviteOk);
}
/// <summary>
/// 同意邀请
/// </summary>
public void DoubleMountInviteOk()
{
var pak = (CG_DOUBLEMOUNT_INVITE_ACCEPT) PacketDistributed.CreatePacket(MessageID
.PACKET_CG_DOUBLEMOUNT_INVITE_ACCEPT);
pak.InviterId = _InviterId;
pak.SendPacket();
}
/// <summary>
/// 乘客取消骑乘
/// </summary>
public void PassengersCancel()
{
var pak = (CG_DOUBLEMOUNT_PASSENGER_UNMOUNT) PacketDistributed.CreatePacket(MessageID
.PACKET_CG_DOUBLEMOUNT_PASSENGER_UNMOUNT);
pak.Flag = 1;
pak.SendPacket();
var _ModelNav = GameObject.Find("MainPlayer").GetComponent<NavMeshAgent>();
_ModelNav.transform.SetParent(null);
_ModelNav.enabled = true;
}
/// <summary>
/// 拒绝邀请
/// </summary>
public void DoubleMountInviteNo()
{
}
public void DoueldMountBtnShow()
{
var advanceFashion =
TableManager.GetAdvanceFashionByID(GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId);
if (advanceFashion != null)
{
var mountBase = TableManager.GetMountBaseByID(advanceFashion.ModelId);
if (DoubleMountBtnBg)
if (mountBase != null)
if (mountBase.DoubleRiding == 1 && DoubleMountBtnBg.activeInHierarchy == false)
{
DoubleMountBtnBg.gameObject.SetActive(true); //判断双人坐骑
passengerBtn.gameObject.SetActive(false);
}
}
else if (DoubleMountBtnBg.activeInHierarchy)
{
if (DoubleState != 2) DoubleMountBtnBg.gameObject.SetActive(false);
}
}
public void GetNewScenepassengerData()
{
DoubleMountBtnBg.gameObject.SetActive(false);
}
#endregion////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void OnShoucongClick()
{
UIManager.ShowUI(UIInfo.FirstPayPanel);
}
public void ShowUI(UIPathData uipath)
{
UIManager.ShowUI(uipath);
}
public void OnOpenSeverClick()
{
UIManager.ShowUI(UIInfo.OpenServerSevenDayPanel);
}
public void OnRedPacketClick()
{
UIManager.ShowUI(UIInfo.RedPacketRebeatPanel);
}
public void OnInvestClick()
{
UIManager.ShowUI(UIInfo.InvestMentPanel);
}
public void OnRebateClick()
{
UIManager.ShowUI(UIInfo.HundredTimesRebeatPanel);
}
public void OnCommunity()
{
CommunityLogic.ShowMyCommunityRoot();
}
public void OnCopyBtnClick()
{
UIManager.ShowUI(UIInfo.CopyScenePanelCtr);
}
public void OnBtnIneraction()
{
UIManager.ShowUI(UIInfo.InteractionPanel);
}
public void OnBtnLevelCombat()
{
UIManager.ShowUI(UIInfo.LevelCombatTipRoot);
}
//福利大厅红点
public GameObject _WelfareRedDot_Effect;
public GameObject _WelfareRedDot;
//福利大厅界面状态
public void ShowWelfareState(bool isShow)
{
_WelfareRedDot.SetActive(isShow);
_WelfareRedDot_Effect.SetActive(isShow);
//redIconsList[0].gameObject.SetActive(isShow);
}
#endregion
#region
public GameObject _RedIcon;
public void ShowActivityRedIcon(bool isShow)
{
_RedIcon.SetActive(isShow);
}
#endregion
#region GM
public GameObject _BtnGM;
public void InitGMBtn()
{
var useGm = SdkControl.instance.useGm;
_BtnGM.SetActive(useGm);
//#if UNITY_EDITOR
// _BtnGM.SetActive(true);
//#else
// _BtnGM.SetActive(false);
//#endif
}
#endregion
}