241 lines
6.5 KiB
C#
241 lines
6.5 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using Games.LogicObj;
|
||
using GCGame.Table;
|
||
using Games.GlobeDefine;
|
||
|
||
public class ActiveBtns : UIControllerBase<ActiveBtns>
|
||
{
|
||
public GameObject _BtnPanel;
|
||
public RectTransform Anchor;
|
||
|
||
public GameObject CloneBtnGameObj;
|
||
private List<ActivityBtn> m_btns = new List<ActivityBtn>();
|
||
|
||
public void RefreshBtns(int ActivityType)
|
||
{
|
||
for(int i=0;i< m_btns.Count;i++)
|
||
{
|
||
if (m_btns[i].Refresh(ActivityType))
|
||
return;
|
||
}
|
||
}
|
||
|
||
public void InitBtnInfo()
|
||
{
|
||
List<ActivityDataManager.ActivityData> activityDatas = ActivityDataManager.Instance.GetAllActivityData();
|
||
if (activityDatas == null)
|
||
return;
|
||
int Index = 0;
|
||
for (int i = 0; i < activityDatas.Count; i++)
|
||
{
|
||
if (activityDatas[i] == null
|
||
|| activityDatas[i].activityTab == null
|
||
|| activityDatas[i].activityTab.Icon == "-1"
|
||
|| activityDatas[i].activityState == ActivityDataManager.ActivityState.None
|
||
|| activityDatas[i].activityTab.Level > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level
|
||
|| activityDatas[i].BossLeaveCount == 0)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
if (m_btns.Count<= Index)
|
||
{
|
||
GameObject obj = GameObject.Instantiate(CloneBtnGameObj);
|
||
obj.transform.SetParent(CloneBtnGameObj.transform.parent);
|
||
obj.transform.localPosition = Vector3.zero;
|
||
obj.transform.localScale = Vector3.one;
|
||
m_btns.Add(obj.GetComponent<ActivityBtn>());
|
||
}
|
||
ActivityBtn btn = m_btns[Index];
|
||
if (btn == null)
|
||
continue;
|
||
Index++;
|
||
btn.gameObject.SetActive(true);
|
||
btn.Show(activityDatas[i]);
|
||
}
|
||
for(int i= Index; i< m_btns.Count;i++)
|
||
{
|
||
m_btns[i].gameObject.SetActive(false);
|
||
}
|
||
}
|
||
|
||
void Start()
|
||
{
|
||
// 强制将ActiveBtns做到一个低层级上,有层级管理底层之后再修改为稳定做法
|
||
transform.SetAsFirstSibling();
|
||
|
||
GCGame.Table.Tab_Fuben fuben = GCGame.Table.TableManager.GetFubenByID(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID, 0);
|
||
if (fuben != null)
|
||
{
|
||
if (fuben.IsShowAct != 0)
|
||
{
|
||
if (ActiveBtns.Instance())
|
||
{
|
||
ActiveBtns.Instance().ShowPanel();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (ActiveBtns.Instance())
|
||
{
|
||
ActiveBtns.Instance().HidePanel();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void OnEnable()
|
||
{
|
||
SetInstance(this);
|
||
}
|
||
|
||
void OnDisable()
|
||
{
|
||
SetInstance(null);
|
||
}
|
||
|
||
void Update()
|
||
{
|
||
//UpdateGuanningBtn();
|
||
|
||
if(_PanelStateChange)
|
||
{
|
||
AnimatorStateInfo info_BtnRot = _ShowAnimator.GetCurrentAnimatorStateInfo(0);
|
||
if (_ShowPanel)
|
||
{
|
||
if(_ShowAnimator.gameObject.activeSelf && !info_BtnRot.IsName("Show"))
|
||
_ShowAnimator.Play("Show", 0, 0);
|
||
}
|
||
else
|
||
{
|
||
if (_ShowAnimator.gameObject.activeSelf && !info_BtnRot.IsName("Hide"))
|
||
_ShowAnimator.Play("Hide", 0, 0);
|
||
}
|
||
|
||
RefreshBtnEffectState();
|
||
_PanelStateChange = false;
|
||
}
|
||
|
||
}
|
||
|
||
public void RefreshBtnEffectState()
|
||
{
|
||
for (int i = 0; i < m_btns.Count; i++)
|
||
{
|
||
m_btns[i].HideEffect(!_ShowPanel);
|
||
}
|
||
}
|
||
|
||
public Animator _ShowAnimator;
|
||
|
||
public bool _ShowPanel;
|
||
private bool _PanelStateChange;
|
||
public void ShowPanel()
|
||
{
|
||
GCGame.Table.Tab_Fuben fuben = GCGame.Table.TableManager.GetFubenByID(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID, 0);
|
||
if (fuben != null && fuben.IsShowAct == 0)
|
||
{
|
||
_BtnPanel.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
_BtnPanel.SetActive(true);
|
||
_ShowPanel = true;
|
||
_PanelStateChange = true;
|
||
}
|
||
}
|
||
|
||
public void HidePanel()
|
||
{
|
||
GCGame.Table.Tab_Fuben fuben = GCGame.Table.TableManager.GetFubenByID(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID, 0);
|
||
if (fuben != null && fuben.IsShowAct == 0)
|
||
{
|
||
_BtnPanel.SetActive(false);
|
||
return;
|
||
}
|
||
_ShowPanel = false;
|
||
_PanelStateChange = true;
|
||
}
|
||
|
||
#region red Packet
|
||
|
||
public GameObject _RedPacketBtn;
|
||
public GameObject[] _RedpacketBtnTypes;
|
||
|
||
private GC_GIVE_RED_PACKET_RET _RedPacket = null;
|
||
|
||
public void ShowRedPacket(GC_GIVE_RED_PACKET_RET packet)
|
||
{
|
||
_RedPacket = packet;
|
||
_RedPacketBtn.SetActive(true);
|
||
for (int i = 0; i < _RedpacketBtnTypes.Length; ++i)
|
||
{
|
||
if (i + 1 == (int)packet.Type)
|
||
{
|
||
_RedpacketBtnTypes[i].SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
_RedpacketBtnTypes[i].SetActive(false);
|
||
}
|
||
}
|
||
|
||
CancelInvoke();
|
||
Invoke("HideRedPacket", 10);
|
||
}
|
||
|
||
public void HideRedPacket()
|
||
{
|
||
_RedPacketBtn.SetActive(false);
|
||
|
||
ChatInfoLogic.ShowRedPacket(false);
|
||
}
|
||
|
||
public void OnRedPacketClick()
|
||
{
|
||
if(_RedPacket != null)
|
||
RedPacket.Instance.PickRedPacket(_RedPacket.RedPacketId, _RedPacket.Type);
|
||
|
||
HideRedPacket();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region VIP
|
||
|
||
public GameObject _VIPPacketBtn;
|
||
public GameObject _VipRedPoint;
|
||
|
||
public void VIPPacketBtn()
|
||
{
|
||
//_VIPPacketBtn.SetActive(GameManager.gameManager.PlayerDataPool.OPenServerDays <= 7);
|
||
//VipTipRedPoint();
|
||
}
|
||
|
||
public void VipTipRedPoint()
|
||
{
|
||
if (_VIPPacketBtn == null || _VIPPacketBtn.activeSelf == false)
|
||
return;
|
||
_VipRedPoint.SetActive(false);
|
||
int Count = GameManager.gameManager.PlayerDataPool.VipRewardStates.Count;
|
||
for(int i=0;i<Count;i++)
|
||
{
|
||
if(GameManager.gameManager.PlayerDataPool.VipRewardStates[i]>=1)
|
||
{
|
||
_VipRedPoint.SetActive(true);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
public void VipBtnClick()
|
||
{
|
||
UIManager.ShowUI(UIInfo.VipRoot);
|
||
}
|
||
|
||
#endregion
|
||
|
||
} |