160 lines
5.0 KiB
C#
160 lines
5.0 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System.Collections.Generic;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
public class GetGiftBtnPosEvent
|
|
{
|
|
public Vector3 Pos;
|
|
public float width;
|
|
}
|
|
/// <summary>
|
|
/// 其他礼包
|
|
/// </summary>
|
|
public class HomeGiftBtnPanel : MonoBehaviour
|
|
{
|
|
GameObject btn_gift_piggybank;
|
|
GameObject btn_gift_bargain;
|
|
GameObject btn_gift9;
|
|
GameObject btn_gift10;
|
|
GameObject btn_gift11;
|
|
Tables _tables;
|
|
FishingEventData fishingEventData;
|
|
protected CompositeDisposable disposables = new CompositeDisposable();
|
|
|
|
private void Awake()
|
|
{
|
|
GContext.OnEvent<TargetEvent>()
|
|
.Where(_ => (_.type == 3 && _.subType == 11) || _.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_gift1of3").gameObject;
|
|
btn_gift10 = transform.Find("btn_gift1+1").gameObject;
|
|
btn_gift11 = transform.Find("btn_gift1+2").gameObject;
|
|
btn_gift_piggybank = transform.Find("btn_gift_piggybank").gameObject;
|
|
btn_gift_bargain = transform.Find("btn_gift_bargain").gameObject;
|
|
|
|
_tables = GContext.container.Resolve<Tables>();
|
|
int eventID38 = fishingEventData.GetEvent(3, 11);
|
|
Show1A1(eventID38);
|
|
int eventID6 = fishingEventData.GetEvent(6, 1);
|
|
Show1A2(eventID6);
|
|
SetPiggyBankShow();
|
|
SetBarginPackShow();
|
|
}
|
|
|
|
#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;
|
|
// [REMOVED] PiggyBankPackData deleted
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
#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);
|
|
}
|
|
|
|
#endregion
|
|
void OnDestroy()
|
|
{
|
|
disposables?.Dispose();
|
|
disposables = null;
|
|
}
|
|
}
|