224 lines
7.2 KiB
C#
224 lines
7.2 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
public class GetGiftBtnPosEvent
|
|
{
|
|
public Vector3 Pos;
|
|
public float width;
|
|
}
|
|
/// <summary>
|
|
/// 其他礼包
|
|
/// </summary>
|
|
public class HomeGiftBtnPanel : MonoBehaviour
|
|
{
|
|
GiftButton ct_giftButton;
|
|
GameObject btn_gift_piggybank;
|
|
GameObject btn_gift_bargain;
|
|
GameObject btn_gift9;
|
|
GameObject btn_gift10;
|
|
GameObject btn_gift11;
|
|
Transform _minibp;
|
|
Tables _tables;
|
|
bool CollectingTarget = false;
|
|
FishingEventData fishingEventData;
|
|
protected CompositeDisposable disposables = new CompositeDisposable();
|
|
|
|
private void Awake()
|
|
{
|
|
GContext.OnEvent<TargetEvent>()
|
|
.Where(_ => (_.type == 3 && _.subType == 8) || _.type == 9 || _.type == 6)
|
|
.Subscribe(FishingEvent).AddTo(disposables);
|
|
|
|
GContext.OnEvent<HideHomePanelEvent>().Subscribe(OnHideHomePanelEvent).AddTo(disposables);
|
|
|
|
}
|
|
private void OnHideHomePanelEvent(HideHomePanelEvent e)
|
|
{
|
|
Destroy(this);
|
|
}
|
|
public void Init()
|
|
{
|
|
fishingEventData = GContext.container.Resolve<FishingEventData>();
|
|
btn_gift9 = transform.Find("btn_gift9").gameObject;
|
|
btn_gift10 = transform.Find("btn_gift10").gameObject;
|
|
btn_gift11 = transform.Find("btn_gift11").gameObject;
|
|
btn_gift_piggybank = transform.Find("btn_gift_piggybank").gameObject;
|
|
btn_gift_bargain = transform.Find("btn_gift_bargain").gameObject;
|
|
|
|
_minibp = transform.Find("MiniBPGroup");
|
|
_tables = GContext.container.Resolve<Tables>();
|
|
ct_giftButton = transform.Find("btn_gift7").GetComponent<GiftButton>();
|
|
ct_giftButton.gameObject.SetActive(false);
|
|
int eventID38 = fishingEventData.GetEvent(3, 8);
|
|
Show1A1(eventID38);
|
|
int eventID6 = fishingEventData.GetEvent(6, 1);
|
|
Show1A2(eventID6);
|
|
SetPiggyBankShow();
|
|
SetBarginPackShow();
|
|
}
|
|
|
|
#region 目标奖励活动礼包 GiftPopupPanel_7
|
|
public void InitCollectingTarget()
|
|
{
|
|
var pack = GContext.container.Resolve<FishingEventData>().IsShowCTGift();
|
|
CollectingTarget = pack != null;
|
|
if (CollectingTarget)
|
|
{
|
|
ct_giftButton.Init(UITypes.GiftPopupPanel_7, GContext.container.Resolve<FishingEventData>().collectingTargetInit.GiftIcon);
|
|
}
|
|
else
|
|
{
|
|
ct_giftButton.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
public void SetCollectingTargetTime(string timeStr)
|
|
{
|
|
if (CollectingTarget && ct_giftButton != null)
|
|
{
|
|
ct_giftButton.SetTime(timeStr);
|
|
}
|
|
}
|
|
public void HideTarget()
|
|
{
|
|
if (ct_giftButton != null)
|
|
{
|
|
ct_giftButton.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region
|
|
//猪猪银行活动礼包
|
|
async void SetPiggyBankShow()
|
|
{
|
|
var fishingData = GContext.container.Resolve<FishingData>();
|
|
if (fishingData.isAddPiggyBank)
|
|
{
|
|
CanvasGroup canvasGroup = btn_gift_piggybank.GetComponent<CanvasGroup>();
|
|
canvasGroup.alpha = 0;
|
|
await Awaiters.Until(() => fishingData.isShowTargetPanel);
|
|
fishingData.isShowTargetPanel = false;
|
|
fishingData.isAddPiggyBank = false;
|
|
if (GContext.container.Resolve<PiggyBankPackData>().IsPackActivated)
|
|
{
|
|
Transform Ani_Container = btn_gift_piggybank.transform.Find("icon");
|
|
GetGiftBtnPosEvent getBuffPosEvent = new GetGiftBtnPosEvent();
|
|
getBuffPosEvent.Pos = Ani_Container.position;
|
|
getBuffPosEvent.width = Ani_Container.GetComponent<RectTransform>().rect.width;
|
|
await Awaiters.Seconds(2f);
|
|
GContext.Publish(getBuffPosEvent);
|
|
await Awaiters.Seconds(0.66f);
|
|
canvasGroup.alpha = 1;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region
|
|
//砍价礼包活动礼包
|
|
public async void SetBarginPackShow()
|
|
{
|
|
var fishingData = GContext.container.Resolve<FishingData>();
|
|
if (fishingData.isAddBarginPack)
|
|
{
|
|
CanvasGroup canvasGroup = btn_gift_bargain.GetComponent<CanvasGroup>();
|
|
canvasGroup.alpha = 0;
|
|
await Awaiters.Until(() => fishingData.isShowTargetPanel);
|
|
fishingData.isShowTargetPanel = false;
|
|
fishingData.isAddBarginPack = false;
|
|
//if (GContext.container.Resolve<BarginPackData>().IsPackActivated)
|
|
{
|
|
Transform Ani_Container = btn_gift_bargain.transform.Find("icon");
|
|
GetGiftBtnPosEvent getBuffPosEvent = new GetGiftBtnPosEvent();
|
|
getBuffPosEvent.Pos = Ani_Container.position;
|
|
getBuffPosEvent.width = Ani_Container.GetComponent<RectTransform>().rect.width;
|
|
await Awaiters.Seconds(2f);
|
|
GContext.Publish(getBuffPosEvent);
|
|
await Awaiters.Seconds(0.66f);
|
|
canvasGroup.alpha = 1;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
void FishingEvent(TargetEvent targetEvent)
|
|
{
|
|
if (targetEvent.type == 3)
|
|
{
|
|
Show1A1(targetEvent.id);
|
|
}
|
|
else if (targetEvent.type == 6)
|
|
{
|
|
switch (targetEvent.subType)
|
|
{
|
|
case 1:
|
|
Show1A2(targetEvent.id);
|
|
break;
|
|
}
|
|
}
|
|
else if (targetEvent.type == 9)
|
|
{
|
|
ShowMiniBP(targetEvent.subType);
|
|
}
|
|
}
|
|
#region 1+1活动礼包
|
|
void Show1A1(int eventid)
|
|
{
|
|
if (fishingEventData.Pack1A1Data != null && fishingEventData.Pack1A1Data.lastID == eventid && fishingEventData.Pack1A1Data.index < 2)
|
|
{
|
|
btn_gift10.SetActive(true);
|
|
return;
|
|
}
|
|
btn_gift10.SetActive(false);
|
|
var _epd = GContext.container.Resolve<EventPackData>();
|
|
if (_epd != null && _epd.CurrentEventID == eventid)
|
|
{
|
|
btn_gift9.SetActive(true);
|
|
return;
|
|
}
|
|
btn_gift9.SetActive(false);
|
|
}
|
|
#endregion
|
|
#region 1+2活动礼包
|
|
void Show1A2(int eventid)
|
|
{
|
|
Pack1A2Data Pack1A2Data = fishingEventData.Pack1A2Data;
|
|
if (fishingEventData.Pack1A2Data == null || Pack1A2Data.lastID != eventid)
|
|
{
|
|
btn_gift11.SetActive(false);
|
|
return;
|
|
}
|
|
EventPackManager eventPackManager = fishingEventData.Get1A2EventPackManager();
|
|
List<int> packIDs = eventPackManager.VIPPackList[Pack1A2Data.vipLevel];
|
|
if (packIDs.Count <= Pack1A2Data.index)
|
|
{
|
|
btn_gift11.SetActive(false);
|
|
return;
|
|
}
|
|
btn_gift11.SetActive(true);
|
|
}
|
|
#region 小战令
|
|
void ShowMiniBP(int subType)
|
|
{
|
|
int count = _minibp.childCount;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
HomeBtnMiniBP homeBtnMiniBP = _minibp.GetChild(i).GetComponent<HomeBtnMiniBP>();
|
|
if (homeBtnMiniBP != null&& homeBtnMiniBP.Type == (MiniBattlePassType)subType)
|
|
{
|
|
homeBtnMiniBP.SetShow();
|
|
}
|
|
}
|
|
}
|
|
#endregion 小战令
|
|
|
|
#endregion
|
|
void OnDestroy()
|
|
{
|
|
disposables?.Dispose();
|
|
disposables = null;
|
|
}
|
|
}
|