备份CatanBuilding瘦身独立工程
This commit is contained in:
103
Assets/Scripts/UI/Shop/AdsPackPanel.cs
Normal file
103
Assets/Scripts/UI/Shop/AdsPackPanel.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
|
||||
public class AdsPackPanel : GiftPopupPanel
|
||||
{
|
||||
protected int Type = 5;
|
||||
protected TriggerPackManager packManager;
|
||||
protected TriggerPackBuyData curTriggerPackState;
|
||||
|
||||
List<List<int>> VIPPackList;
|
||||
int allCount = 0;
|
||||
int buyCount = 0;
|
||||
|
||||
TMP_Text txt_packName;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
txt_packName = transform.Find("root/text_title").GetComponent<TMP_Text>();
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
SetData();
|
||||
base.Start();
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
SetTriggerPackTimer();
|
||||
}
|
||||
|
||||
public void SetData()
|
||||
{
|
||||
var triggerPackDic = GContext.container.Resolve<TriggerPackData>().GetTriggerPackList(Type);
|
||||
if (triggerPackDic.Count <= 0)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
curTriggerPackState = triggerPackDic[0];
|
||||
TimeSpan now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(curTriggerPackState);
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
int id = curTriggerPackState.ID;
|
||||
packManager = _tables.TbTriggerPackManager.GetOrDefault(id);
|
||||
int vipLevel = curTriggerPackState.vipLevel;
|
||||
List<int> VIPPackList = packManager.VIPPackList[vipLevel];
|
||||
pack = _tables.TbPack.GetOrDefault(VIPPackList[0]);
|
||||
iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID);
|
||||
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(pack.DropID);
|
||||
SetShowData();
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
text_buy.text = sKUDetailDataEvent.price;
|
||||
tag_more.SetActive(pack.Rebate > 0.01);
|
||||
text_best.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", (pack.Rebate * 100).ToString("F0"));
|
||||
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
//txt_packName.text = LocalizationMgr.GetText(pack.Title_l10n_key);
|
||||
}
|
||||
protected override ShopBuyTypeData GetShopBuyTypeData()
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.TriggerPack;
|
||||
shopBuyTypeData.ID = packManager.ID;
|
||||
return shopBuyTypeData;
|
||||
}
|
||||
protected override void OnSuccess()
|
||||
{
|
||||
GContext.container.Resolve<TriggerPackData>().AddTriggerPackCount(packManager.ID);
|
||||
OnClickClose();
|
||||
}
|
||||
protected override void OnBuySuccess()
|
||||
{
|
||||
OnClickClose();
|
||||
}
|
||||
|
||||
public async void SetTriggerPackTimer()
|
||||
{
|
||||
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
DateTime dateTime1 = dateTime.AddDays(1).Date;
|
||||
while (this != null && dateTime.Ticks < dateTime1.Ticks)
|
||||
{
|
||||
TimeSpan now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(curTriggerPackState);
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
await System.Threading.Tasks.Task.Delay(1000);
|
||||
dateTime.AddSeconds(1);
|
||||
}
|
||||
}
|
||||
protected void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.AdsPackPanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/AdsPackPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/AdsPackPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ede3da81a22493b4cb1733d67b5c3d0f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
99
Assets/Scripts/UI/Shop/AquariumGiftPopupPanel.cs
Normal file
99
Assets/Scripts/UI/Shop/AquariumGiftPopupPanel.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AquariumGiftPopupPanel : GiftPopupPanel
|
||||
{
|
||||
protected int Type = 6;
|
||||
protected TriggerPackManager packManager;
|
||||
protected TriggerPackBuyData curTriggerPackState;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
SetData();
|
||||
base.Start();
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
StartCoroutine(Countdown());
|
||||
}
|
||||
|
||||
public void SetData()
|
||||
{
|
||||
var triggerPackDic = GContext.container.Resolve<TriggerPackData>().GetTriggerPackList(Type);
|
||||
if (triggerPackDic.Count <= 0)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
curTriggerPackState = triggerPackDic[0];
|
||||
TimeSpan now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(curTriggerPackState);
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
int id = curTriggerPackState.ID;
|
||||
packManager = _tables.TbTriggerPackManager.GetOrDefault(id);
|
||||
int vipLevel = curTriggerPackState.vipLevel;
|
||||
List<int> VIPPackList = packManager.VIPPackList[vipLevel];
|
||||
pack = _tables.TbPack.GetOrDefault(VIPPackList[0]);
|
||||
iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID);
|
||||
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(pack.DropID, curTriggerPackState.mapID);
|
||||
SetShowData();
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
text_buy.text = sKUDetailDataEvent.price;
|
||||
tag_more.SetActive(pack.Rebate > 0.01);
|
||||
text_best.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", (pack.Rebate * 100).ToString("F0"));
|
||||
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
//txt_packName.text = LocalizationMgr.GetText(pack.Title_l10n_key);
|
||||
}
|
||||
protected override ShopBuyTypeData GetShopBuyTypeData()
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.TriggerPack;
|
||||
shopBuyTypeData.ID = packManager.ID;
|
||||
return shopBuyTypeData;
|
||||
}
|
||||
protected override void OnSuccess()
|
||||
{
|
||||
GContext.container.Resolve<TriggerPackData>().AddTriggerPackCount(packManager.ID);
|
||||
OnClickClose();
|
||||
}
|
||||
protected override void OnBuySuccess()
|
||||
{
|
||||
OnClickClose();
|
||||
}
|
||||
|
||||
|
||||
IEnumerator Countdown()
|
||||
{
|
||||
DateTime curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
DateTime endTime = GlobalUtils.TryParseDateTime(curTriggerPackState.time, curTime);
|
||||
TimeSpan now = endTime - curTime;
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
|
||||
while (endTime.Ticks > curTime.Ticks)
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
if (curTriggerPackState.index > 0)
|
||||
{
|
||||
OnClickClose();
|
||||
yield break;
|
||||
}
|
||||
curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
now = endTime - curTime;
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
}
|
||||
OnClickClose();
|
||||
}
|
||||
|
||||
protected void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.AquariumGiftPopupPanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/AquariumGiftPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/AquariumGiftPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3dcea0e9334e3a044ad3813e1d67ec8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
Assets/Scripts/UI/Shop/BlackFridayCouponBanner.cs
Normal file
61
Assets/Scripts/UI/Shop/BlackFridayCouponBanner.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BlackFridayCouponBanner : MonoBehaviour
|
||||
{
|
||||
private BlackFridayCouponData _data;
|
||||
[SerializeField] private TMP_Text textBanner, textTimer;
|
||||
[SerializeField] private DiamondShopSlot[] slots;
|
||||
[SerializeField] private Image bgBanner;
|
||||
private readonly IEventAggregator _eventAggregator = new EventAggregator();
|
||||
public void Awake()
|
||||
{
|
||||
_data = GContext.container.Resolve<PlayerShopData>().CouponData;
|
||||
if (_data is not { IsActive: true })
|
||||
{
|
||||
SetupBlackFriday(false, _eventAggregator);
|
||||
return;
|
||||
}
|
||||
SetupBlackFriday(true, _eventAggregator);
|
||||
textBanner.text = LocalizationMgr.GetFormatTextValue("UI_GiftPopupPanel_13_5", _data.Multiplier + "%");
|
||||
textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
ColorUtility.TryParseHtmlString(
|
||||
GContext.container.Resolve<Tables>().TbEventCoupon[_data.RedirectId].FontColorTime, out var c);
|
||||
textTimer.color = c;
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe(_ => {
|
||||
textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
if (!_data.IsActive)
|
||||
SetupBlackFriday(false, _eventAggregator);
|
||||
}).AddTo(this);
|
||||
_eventAggregator.GetEvent<EventTerminateBlackFriday>().Subscribe(_ => {
|
||||
// _data.SetStateBought();
|
||||
SetupBlackFriday(_data.IsActive, _eventAggregator);
|
||||
}).AddTo(this);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(bgBanner,
|
||||
GContext.container.Resolve<Tables>().TbEventCoupon[_data.RedirectId].LabelShop1);
|
||||
}
|
||||
|
||||
private void SetupBlackFriday(bool isOpen, IEventAggregator ea)
|
||||
{
|
||||
if (isOpen)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
foreach (var slot in slots)
|
||||
slot.SetUpBlackFriday(true, ea);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var slot in slots)
|
||||
slot.SetUpBlackFriday(false, ea);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
public class EventTerminateBlackFriday { }
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/BlackFridayCouponBanner.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/BlackFridayCouponBanner.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1968af781d290345985bb1c59bf25ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Assets/Scripts/UI/Shop/BlackFridayCouponData.cs
Normal file
87
Assets/Scripts/UI/Shop/BlackFridayCouponData.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
|
||||
public class BlackFridayCouponData
|
||||
{
|
||||
private readonly Tables _tables = GContext.container.Resolve<Tables>();
|
||||
private readonly TbEventCoupon _tableCoupon = GContext.container.Resolve<Tables>().TbEventCoupon;
|
||||
public DateTime ActivateTime = new DateTime(1996, 11, 28);
|
||||
public int EventId { get; private set; }
|
||||
public int RedirectId { get; private set; }
|
||||
public bool IsBought => _isBought;
|
||||
public bool DoesPop = true;
|
||||
private bool _isBought = false;
|
||||
public TimeSpan RemainingTime
|
||||
{
|
||||
get
|
||||
{
|
||||
var eventLimit = DateTime.Parse((_tables.TbFishingEvent[EventId].TimeDefinition as LimitedTime)?.EndTime);
|
||||
var activeLimit = ActivateTime + TimeSpan.FromSeconds(EventDuration);
|
||||
var limit = eventLimit < activeLimit ? eventLimit : activeLimit;
|
||||
return limit - ZZTimeHelper.UtcNow();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsWithinEventTime
|
||||
{
|
||||
get
|
||||
{
|
||||
var now = ZZTimeHelper.UtcNow();
|
||||
var fishingEvent = _tables.TbFishingEvent[EventId];
|
||||
return now >= DateTime.Parse((fishingEvent.TimeDefinition as LimitedTime)?.StartTime) &&
|
||||
now < DateTime.Parse((fishingEvent.TimeDefinition as LimitedTime)?.EndTime);
|
||||
}
|
||||
}
|
||||
public const string PlayFabDataKey = "BlackFridayCouponDate";
|
||||
|
||||
public bool IsActive => _tables.TbFishingEvent.DataMap.ContainsKey(EventId) &&
|
||||
_tableCoupon.DataMap.ContainsKey(RedirectId) && IsWithinEventTime &&
|
||||
ZZTimeHelper.UtcNow() <= ActivateTime + TimeSpan.FromSeconds(EventDuration) && !IsBought;
|
||||
public int Multiplier => GContext.container.Resolve<Tables>().TbEventCoupon[RedirectId].Multiple;
|
||||
public int EventDuration => GContext.container.Resolve<Tables>().TbEventCoupon[RedirectId].Time;
|
||||
public void LoadData(string s)
|
||||
{
|
||||
int[] tokens = s.Split(',').Select(int.Parse).ToArray();
|
||||
ActivateTime = new DateTime(tokens[0], tokens[1], tokens[2], tokens[3], tokens[4], tokens[5]);
|
||||
EventId = tokens[6];
|
||||
if (tokens.Length < 9)
|
||||
{
|
||||
_isBought = false;
|
||||
RedirectId = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
RedirectId = tokens[7];
|
||||
_isBought = tokens[8] == 1;
|
||||
}
|
||||
|
||||
// BlackFridayCouponPopupPanel.DebugWithColor("Debug Activated.");
|
||||
// EventId = 0;
|
||||
}
|
||||
|
||||
public void UploadData()
|
||||
{
|
||||
string s =
|
||||
$"{ActivateTime.Year},{ActivateTime.Month},{ActivateTime.Day},{ActivateTime.Hour},{ActivateTime.Minute},{ActivateTime.Second},{EventId},{RedirectId},{(IsBought ? 1 : 0)}";
|
||||
PlayFabMgr.Instance.UpdateUserDataValue(PlayFabDataKey, s);
|
||||
}
|
||||
public void UpdateData(FishingEvent e)
|
||||
{
|
||||
if (e.Type != 3 || e.SubType != 9 || e.ID == EventId)
|
||||
return ;
|
||||
EventId = e.ID;
|
||||
RedirectId = e.RedirectID;
|
||||
ActivateTime = ZZTimeHelper.UtcNow();
|
||||
_isBought = false;
|
||||
// Debug.Log($"<color=#23aaf2>Black Friday Activated @ {ActivateTime}</color>");
|
||||
UploadData();
|
||||
}
|
||||
|
||||
public void SetStateBought()
|
||||
{
|
||||
_isBought = true;
|
||||
UploadData();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/BlackFridayCouponData.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/BlackFridayCouponData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63d0fe667f96882459c535e1ad4f64ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Assets/Scripts/UI/Shop/BlackFridayCouponPopupPanel.cs
Normal file
56
Assets/Scripts/UI/Shop/BlackFridayCouponPopupPanel.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using cfg;
|
||||
|
||||
public class BlackFridayCouponPopupPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button btnClose, btnClaim;
|
||||
[SerializeField] private TMP_Text textTimer, textInfo, textTitle;
|
||||
[SerializeField] private Image bg;
|
||||
private BlackFridayCouponData _data;
|
||||
private void Start()
|
||||
{
|
||||
btnClose.onClick.AddListener(OnClickClose);
|
||||
_data = GContext.container.Resolve<PlayerShopData>().CouponData;
|
||||
if (_data is not {IsActive: true})
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel);
|
||||
}
|
||||
var couponUiData = GContext.container.Resolve<Tables>().TbEventCoupon[_data.RedirectId];
|
||||
textTitle.text = LocalizationMgr.GetText(couponUiData.Title_l10n_key);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(bg, couponUiData.BgBanner);
|
||||
textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
if (!_data.IsActive)
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel);
|
||||
}
|
||||
})
|
||||
.AddTo(this);
|
||||
textInfo.text = LocalizationMgr.GetFormatTextValue("UI_GiftPopupPanel_13_3", _data.Multiplier + "%");
|
||||
btnClaim.onClick.RemoveAllListeners();
|
||||
btnClaim.onClick.AddListener(OnClickBuy);
|
||||
}
|
||||
|
||||
private void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel);
|
||||
}
|
||||
|
||||
private async void OnClickBuy()
|
||||
{
|
||||
GContext.container.Resolve<IFaceUIService>().StopFaceUI();
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingShopPanel);
|
||||
GContext.Publish(new LackOfResourceConfirmEvent() { state = 1 });
|
||||
UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel);
|
||||
GContext.Publish(new HideHomePanelEvent());
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/BlackFridayCouponPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/BlackFridayCouponPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc1db2591c4a516458bb9380d733fc3c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/Scripts/UI/Shop/BlackFridayEntranceButton.cs
Normal file
39
Assets/Scripts/UI/Shop/BlackFridayEntranceButton.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using UniRx;
|
||||
using TMPro;
|
||||
using System;
|
||||
using GameCore;
|
||||
using asap.core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using cfg;
|
||||
|
||||
public class BlackFridayEntranceButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text textTimer;
|
||||
[SerializeField] private Button btn;
|
||||
[SerializeField] private Image icon;
|
||||
private BlackFridayCouponData _data;
|
||||
private void Awake()
|
||||
{
|
||||
_data = GContext.container.Resolve<PlayerShopData>().CouponData;
|
||||
if (_data is not {IsActive:true})
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon,
|
||||
GContext.container.Resolve<Tables>().TbEventCoupon[_data.RedirectId].Icon);
|
||||
textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
if (_data.RemainingTime.TotalSeconds <= 0)
|
||||
gameObject.SetActive(false);
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f)).Subscribe(_ =>
|
||||
{
|
||||
textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
if (_data.RemainingTime.TotalSeconds <= 0)
|
||||
gameObject.SetActive(false);
|
||||
}).AddTo(this);
|
||||
btn.onClick.AddListener(() => _ = UIManager.Instance.ShowUILoad(UITypes.BlackFridayPopupPanel));
|
||||
// RedPointManager.Instance.SetRedPointState(RedPointKey, _data.IsActive);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/BlackFridayEntranceButton.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/BlackFridayEntranceButton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 347f692d6da05284183a9b4f06b2b029
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Scripts/UI/Shop/ChainPackWithProgressData.cs
Normal file
33
Assets/Scripts/UI/Shop/ChainPackWithProgressData.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
namespace GameCore
|
||||
{
|
||||
public partial class FishingEventData
|
||||
{
|
||||
public readonly ChainPackWithProgressMigrationData ChainPackWithProgressMigrationData = new ChainPackWithProgressMigrationData();
|
||||
}
|
||||
|
||||
}
|
||||
public class ChainPackWithProgressMigrationData : ThanksGivingPackData
|
||||
{
|
||||
public new const string Key = "ThanksGivingPackMigrationData";
|
||||
public override string RedPointKey => "thanks_giving";
|
||||
protected override string key => Key;
|
||||
public void UpdateData(int eventId, int packId)
|
||||
{
|
||||
// Debug.Log($"<color=#f18c0a>Updatedata {e.ID}, {e.RedirectID}, {TokenProgress}, {ChainProgress}</color>");
|
||||
if (eventId == 0 || packId == 0)
|
||||
return;
|
||||
var oldData = GContext.container.Resolve<FishingEventData>().ThanksGivingPackData;
|
||||
if (!GContext.container.Resolve<Tables>().TbFishingEvent.DataMap.ContainsKey(oldData.EventId)
|
||||
&& oldData.PackId == packId)
|
||||
{
|
||||
_data = new Data(eventId: eventId, redirectId: packId, tokenProgress: oldData.TokenProgress, chainProgress: oldData.ChainProgress);
|
||||
PlayFabMgr.Instance.UpdateUserDataValue(ThanksGivingPackData.Key, "");
|
||||
}
|
||||
else
|
||||
_data = new Data(eventId: eventId, redirectId: packId, tokenProgress: 0, chainProgress: 0);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/ChainPackWithProgressData.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/ChainPackWithProgressData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9649bf89c8bf24344b8721422fe276aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
199
Assets/Scripts/UI/Shop/CommerceNoviceGiftPopupPanel.cs
Normal file
199
Assets/Scripts/UI/Shop/CommerceNoviceGiftPopupPanel.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CommerceNoviceGiftPopupPanel : MonoBehaviour
|
||||
{
|
||||
public int rodID;
|
||||
public Rod rod;
|
||||
#region Field&&Property
|
||||
private RewardItemNew[] rewardItems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_Text
|
||||
//txt_detail,
|
||||
txt_title,
|
||||
txt_buy,
|
||||
txt_remainder,
|
||||
//txt_rebate,
|
||||
txt_timer;
|
||||
|
||||
[SerializeField]
|
||||
private Button
|
||||
btn_close,
|
||||
btn_buy;
|
||||
[SerializeField]
|
||||
private List<Perk> perkList = new List<Perk>();
|
||||
[SerializeField]
|
||||
List<Button> peark_btns = new List<Button>();
|
||||
|
||||
public IconRodRoot iconRod;
|
||||
public RawImage rawImageRod;
|
||||
private TriggerPackBuyData _noticeGift;
|
||||
private IAPItemList _iapItem;
|
||||
private Pack _pack;
|
||||
private List<ItemData> _itemDatas;
|
||||
#endregion
|
||||
RodData config;
|
||||
|
||||
#region Function
|
||||
protected void Start()
|
||||
{
|
||||
iconRod.SetRawImage(rawImageRod);
|
||||
rewardItems = transform.Find("root/reward").GetComponentsInChildren<RewardItemNew>();
|
||||
|
||||
btn_buy.onClick.AddListener(OnBuy);
|
||||
btn_close.onClick.AddListener(Close);
|
||||
RefreshView();
|
||||
SetRod();
|
||||
}
|
||||
void SetRod()
|
||||
{
|
||||
var tables = GContext.container.Resolve<Tables>();
|
||||
config = tables.TbRodData.GetOrDefault(rodID);
|
||||
RodSkinData skin = tables.TbRodSkinData.GetOrDefault(rodID);
|
||||
RodAscend curRodAscend = tables.TbRodAscend.GetOrDefault(config.AscendID);
|
||||
int perkIDListCount = curRodAscend.PerkIDList.Count;
|
||||
|
||||
for (int i = 0; i < perkList.Count; i++)
|
||||
{
|
||||
if (i < perkIDListCount)
|
||||
{
|
||||
perkList[i].gameObject.SetActive(true);
|
||||
perkList[i].SetData(curRodAscend.PerkIDList[i], 1, config.Quality);
|
||||
}
|
||||
else
|
||||
{
|
||||
perkList[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < peark_btns.Count; i++)
|
||||
{
|
||||
int index = i;
|
||||
peark_btns[i].onClick.AddListener(() =>
|
||||
{
|
||||
ShowPeark(index);
|
||||
});
|
||||
}
|
||||
//rod.transform.localPosition = new Vector3(skin.DisplayPosition[0], skin.DisplayPosition[1], skin.DisplayPosition[2]);
|
||||
rod.transform.localRotation = Quaternion.Euler(skin.DisplayRotation[0], skin.DisplayRotation[1], skin.DisplayRotation[2]);
|
||||
//rod.transform.localScale = Vector3.one * skin.DisplayScale;
|
||||
rod.rod.GetComponent<Animator>().Play("Show01");
|
||||
StartDoRotate();
|
||||
}
|
||||
async void ShowPeark(int index)
|
||||
{
|
||||
item_tips _item_tips = await item_tips.Show();
|
||||
if (_item_tips == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_item_tips.ShowPerk(config.ID, index, peark_btns[index].transform.position);
|
||||
}
|
||||
void RefreshView()
|
||||
{
|
||||
var triggerPackData = GContext.container.Resolve<TriggerPackData>();
|
||||
var noticeGifts = triggerPackData.GetTriggerPackList(2);
|
||||
if (noticeGifts == null || noticeGifts.Count == 0)
|
||||
{
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
_noticeGift = noticeGifts[0];
|
||||
var triggerPack = GContext.container.Resolve<Tables>().TbTriggerPackManager.GetOrDefault(_noticeGift.ID);
|
||||
int packID = triggerPack.VIPPackList[triggerPackData.GetVIPLevel(2)][_noticeGift.index];
|
||||
_pack = GContext.container.Resolve<Tables>().TbPack.DataMap[packID];
|
||||
//txt_rebate.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", _pack.Rebate * 100);
|
||||
_iapItem = GContext.container.Resolve<Tables>().TbIAPItemList.GetOrDefault(_pack.IAPID);
|
||||
_itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(_pack.DropID);
|
||||
txt_remainder.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1", 1, 1);
|
||||
|
||||
for (int i = 0; i < rewardItems.Length; i++)
|
||||
{
|
||||
if (i < _itemDatas.Count)
|
||||
{
|
||||
rewardItems[i].SetData(_itemDatas[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardItems[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
txt_title.text = LocalizationMgr.GetFormatTextValue(_pack.Title_l10n_key);
|
||||
//txt_detail.text = LocalizationMgr.GetFormatTextValue(_pack.Desc_l10n_key);
|
||||
// txt_rebate.text = LocalizationMgr.GetFormatTextValue("UI_CommerceWelfarePopupPanel_2", _pack.Value);
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(_iapItem);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
txt_buy.text = sKUDetailDataEvent.price;
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(SetTimer());
|
||||
}
|
||||
|
||||
async void OnBuy()
|
||||
{
|
||||
btn_buy.onClick.RemoveAllListeners();
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.TriggerPack;
|
||||
shopBuyTypeData.ID = _noticeGift.ID;
|
||||
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(_pack.DropID, shopBuyTypeData, _iapItem, _itemDatas);
|
||||
if (Result)
|
||||
{
|
||||
OnBuySuccess();
|
||||
Close();
|
||||
}
|
||||
|
||||
btn_buy.onClick.AddListener(OnBuy);
|
||||
}
|
||||
async void OnBuySuccess()
|
||||
{
|
||||
//GContext.container.Resolve<TriggerPackData>().AddTriggerPackCount(_noticeGift.ID);
|
||||
var triggerPackData = GContext.container.Resolve<TriggerPackData>();
|
||||
var noticeGifts = triggerPackData.GetTriggerPackList(2);
|
||||
if (noticeGifts == null || noticeGifts.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_noticeGift = noticeGifts[0];
|
||||
var triggerPack = GContext.container.Resolve<Tables>().TbTriggerPackManager.GetOrDefault(_noticeGift.ID);
|
||||
await new WaitForSeconds(1f);
|
||||
|
||||
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(triggerPack.ID, UITypes.CommerceNoviceGiftPopupPanel, triggerPack.PackType, true);
|
||||
GContext.Publish(new TriggerPackEvent());
|
||||
}
|
||||
void Close()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.CommerceNoviceGiftPopupPanel);
|
||||
}
|
||||
|
||||
IEnumerator SetTimer()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(_noticeGift);
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
RefreshView();
|
||||
yield break;
|
||||
}
|
||||
txt_timer.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
public Transform rotateTarget;
|
||||
void StartDoRotate()
|
||||
{
|
||||
var endRotation = rotateTarget.localRotation.eulerAngles + new Vector3(0, 360, 0);
|
||||
rotateTarget.DOKill();
|
||||
rotateTarget.DOLocalRotate(endRotation, 10f, DG.Tweening.RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/CommerceNoviceGiftPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/CommerceNoviceGiftPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fc3664af326e0f42a15d585ce103bb8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
159
Assets/Scripts/UI/Shop/DiamondShopSlot.cs
Normal file
159
Assets/Scripts/UI/Shop/DiamondShopSlot.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
public class DiamondShopSlot : MonoBehaviour
|
||||
{
|
||||
//public Button btn_buy;
|
||||
public Button btn_buy1;
|
||||
public Image bg;
|
||||
// public Image icon;
|
||||
public TMP_Text text_num;
|
||||
public GameObject tag_first;
|
||||
public TMP_Text text_first_num;
|
||||
public TMP_Text txt_cost;
|
||||
//价钱
|
||||
public TMP_Text text_price;
|
||||
Button btn_showItem;
|
||||
ShopToken shopToken;
|
||||
IAPItemList iAPItemList;
|
||||
/// <summary>
|
||||
/// Used to be just for BlackFriday Coupon, now it is used as a general coupon data.
|
||||
/// </summary>
|
||||
private BlackFridayCouponData _couponData;
|
||||
bool _isFirstPurchase = false;
|
||||
private GameObject _blackFridayGo;
|
||||
private TMP_Text _textDiscount, _textDiamondCount, _textDiamondCountOld;
|
||||
private IEventAggregator _eventAggregator;
|
||||
private Image _bgDiscountTag;
|
||||
private void Init()
|
||||
{
|
||||
btn_buy1 = transform.Find("position/btn_purchase/btn_green").GetComponent<Button>();
|
||||
// icon = transform.Find("position/icon").GetComponent<Image>();
|
||||
btn_showItem = transform.Find("position/reward").GetComponent<Button>();
|
||||
bg = transform.Find("position/bg").GetComponent<Image>();
|
||||
text_num = transform.Find("position/text_num").GetComponent<TMP_Text>();
|
||||
txt_cost = transform.Find("position/text_cost").GetComponent<TMP_Text>();
|
||||
|
||||
tag_first = transform.Find("position/tag_first").gameObject;
|
||||
text_first_num = transform.Find("position/tag_first/text_num").GetComponent<TMP_Text>();
|
||||
text_price = transform.Find("position/btn_purchase/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
|
||||
btn_buy1.onClick.AddListener(OnBuy);
|
||||
btn_showItem.onClick.AddListener(OnShowItemInfo);
|
||||
_couponData = GContext.container.Resolve<PlayerShopData>().CouponData;
|
||||
_blackFridayGo = transform.Find("position/friday").gameObject;
|
||||
_textDiscount = transform.Find("position/friday/text_cost").GetComponent<TMP_Text>();
|
||||
_textDiamondCount = transform.Find("position/friday/text_num1").GetComponent<TMP_Text>();
|
||||
_textDiamondCountOld = transform.Find("position/friday/text_num2").GetComponent<TMP_Text>();
|
||||
_bgDiscountTag = transform.Find("position/friday/bg").GetComponent<Image>();
|
||||
}
|
||||
public void SetData(cfg.ShopToken shopToken)
|
||||
{
|
||||
Init();
|
||||
this.shopToken = shopToken;
|
||||
iAPItemList = GContext.container.Resolve<Tables>().TbIAPItemList.GetOrDefault(shopToken.IAPID);
|
||||
RefreshUI();
|
||||
txt_cost.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", shopToken.ValueMore * 100);
|
||||
txt_cost.gameObject.SetActive(shopToken.ValueMore > 0);
|
||||
text_first_num.text = "+" + shopToken.FirstPurchaseGift;
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
|
||||
//Change!!!
|
||||
text_price.text = sKUDetailDataEvent.price;
|
||||
}
|
||||
public void RefreshUI()
|
||||
{
|
||||
int number = shopToken.Number;
|
||||
if (_couponData is { IsActive: true })
|
||||
{
|
||||
_textDiscount.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", _couponData.Multiplier);
|
||||
if (ColorUtility.TryParseHtmlString(
|
||||
GContext.container.Resolve<Tables>().TbEventCoupon[_couponData.RedirectId].FontColorPercent,
|
||||
out var c))
|
||||
_textDiscount.color = c;
|
||||
_textDiamondCountOld.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_23", number);
|
||||
number += shopToken.Number * _couponData.Multiplier / 100;
|
||||
_textDiamondCount.text = number.ToString();
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(_bgDiscountTag,
|
||||
GContext.container.Resolve<Tables>().TbEventCoupon[_couponData.RedirectId].LabelShop2);
|
||||
}
|
||||
text_num.text = number.ToString();
|
||||
|
||||
PlayerShopData playerShopData = GContext.container.Resolve<PlayerShopData>();
|
||||
|
||||
_isFirstPurchase = playerShopData.GiftBuyCount(shopToken.IAPID) == 0
|
||||
&& playerShopData.GiftBuyCount(shopToken.ID) == 0
|
||||
&& shopToken.FirstPurchaseGift > 0;
|
||||
|
||||
tag_first.SetActive(_isFirstPurchase);
|
||||
}
|
||||
async void OnBuy()
|
||||
{
|
||||
int number = shopToken.Number;
|
||||
if (_isFirstPurchase)
|
||||
{
|
||||
number += shopToken.FirstPurchaseGift;
|
||||
}
|
||||
if (_couponData.IsActive)
|
||||
number += (int)(shopToken.Number * _couponData.Multiplier / 100f);
|
||||
double curCount = GContext.container.Resolve<PlayerItemData>().GetItemCount(shopToken.TokenID);
|
||||
List<ItemData> itemData = new List<ItemData> {
|
||||
new ItemData {
|
||||
count = number,
|
||||
id = shopToken.TokenID,
|
||||
curCount = (ulong)curCount } };
|
||||
btn_buy1.enabled = false;
|
||||
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.ShopToken;
|
||||
shopBuyTypeData.ID = shopToken.ID;
|
||||
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(shopToken.TokenID, shopBuyTypeData, iAPItemList, itemData, game.RewardType.NormalOne);
|
||||
if (Result)
|
||||
{
|
||||
}
|
||||
OnBuySuccess();
|
||||
_eventAggregator.Publish(new BlackFridayCouponBanner.EventTerminateBlackFriday());
|
||||
btn_buy1.enabled = true;
|
||||
}
|
||||
|
||||
void OnBuySuccess()
|
||||
{
|
||||
RefreshUI();
|
||||
}
|
||||
|
||||
void OnShowItemInfo()
|
||||
{
|
||||
GContext.container.Resolve<PlayerItemData>().ShowItemTips(1005, btn_showItem.transform);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
btn_buy1.onClick.RemoveAllListeners();
|
||||
btn_showItem.onClick.RemoveAllListeners();
|
||||
}
|
||||
|
||||
public void SetUpBlackFriday(bool isOpen, IEventAggregator ea)
|
||||
{
|
||||
_eventAggregator = ea;
|
||||
if (isOpen)
|
||||
{
|
||||
text_num.gameObject.SetActive(false);
|
||||
txt_cost.gameObject.SetActive(false);
|
||||
_blackFridayGo.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
text_num.gameObject.SetActive(true);
|
||||
txt_cost.gameObject.SetActive(shopToken.ValueMore > 0);
|
||||
_blackFridayGo.SetActive(false);
|
||||
}
|
||||
RefreshUI();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/DiamondShopSlot.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/DiamondShopSlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f64e56e42e9cab940b9a4d4782b90141
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
196
Assets/Scripts/UI/Shop/DiamondsShopPanel.cs
Normal file
196
Assets/Scripts/UI/Shop/DiamondsShopPanel.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using tysdk;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DiamondsShopPanel : MonoBehaviour
|
||||
{
|
||||
protected CompositeDisposable disposables = new CompositeDisposable();
|
||||
#region Field&&Property
|
||||
Tables _tables;
|
||||
|
||||
Animation anim;
|
||||
[Space(10)]
|
||||
public PanelScroll panelScroll;
|
||||
public GameObject giftItem;
|
||||
public RectTransform giftContent;
|
||||
[Space(10)]
|
||||
public RectTransform shopScrollView;
|
||||
public GameObject shopItem;
|
||||
public Transform shopItemParent;
|
||||
float itemWidth;
|
||||
List<PackData> packItemDatas = new List<PackData>();
|
||||
List<GameObject> packItemSelects = new List<GameObject>();
|
||||
PackData curPackData;
|
||||
|
||||
[Space(10)] public GameObject imageItem;
|
||||
public Transform imageItemParent;
|
||||
private GameObject curSelect;
|
||||
private Image RedPoint;
|
||||
private Image RedPointFade;
|
||||
private Image RedPointSelect;
|
||||
PackItem curPackItem;
|
||||
|
||||
bool isTopOpen = false;
|
||||
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private DiamondShopSlot[] _diamondShopSlots;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Function
|
||||
private void Awake()
|
||||
{
|
||||
anim = transform.GetComponentInParent<Animation>();
|
||||
panelScroll = transform.Find("bg_gift/bg_gift").GetComponent<PanelScroll>();
|
||||
giftItem = transform.Find("bg_gift/bg_gift/Viewport/Content/item").gameObject;
|
||||
giftContent = transform.Find("bg_gift/bg_gift/Viewport/Content").GetComponent<RectTransform>();
|
||||
shopItem = transform.Find("ScrollView/Viewport/Content/Item").gameObject;
|
||||
shopItemParent = transform.Find("ScrollView/Viewport/Content").GetComponent<Transform>();
|
||||
shopScrollView = transform.Find("ScrollView").GetComponent<RectTransform>();
|
||||
imageItem = transform.Find("bg_gift/Sliding/ImageItem").gameObject;
|
||||
imageItemParent = transform.Find("bg_gift/Sliding").GetComponent<Transform>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("enter_shop")) { }
|
||||
#endif
|
||||
|
||||
|
||||
var shopTokens = GContext.container.Resolve<Tables>().TbShopToken.DataList;
|
||||
var diamondShopTokens = shopTokens.Where(x => x.Type == 3).ToArray();
|
||||
|
||||
for (int i = 0; i < diamondShopTokens.Length; i++)
|
||||
{
|
||||
if (i == _diamondShopSlots.Length)
|
||||
{
|
||||
Debug.LogError($"[DiamondsShopPanl::Awake]diamond Shop Slot Not Enough");
|
||||
break;
|
||||
}
|
||||
_diamondShopSlots[i].SetData(diamondShopTokens[i]);
|
||||
}
|
||||
}
|
||||
|
||||
protected void Start()
|
||||
{
|
||||
isTopOpen = GContext.container.Resolve<PlayerShopData>().IsShopTopOpen;
|
||||
panelScroll.transform.parent.gameObject.SetActive(isTopOpen);
|
||||
|
||||
shopScrollView.sizeDelta = isTopOpen ? new Vector2(0, -1156f) : new Vector2(0, -506f);
|
||||
itemWidth = giftItem.GetComponent<RectTransform>().rect.width;
|
||||
imageItem.SetActive(false);
|
||||
|
||||
InitGift();
|
||||
SetScroll();
|
||||
|
||||
GContext.OnEvent<RewardPanelClose>().Subscribe(RewardPanelClose).AddTo(disposables);
|
||||
|
||||
}
|
||||
|
||||
#region Old
|
||||
void RewardPanelClose(RewardPanelClose rewardPanelClose)
|
||||
{
|
||||
InitGift();
|
||||
//播动画
|
||||
SetScroll();
|
||||
anim.Play();
|
||||
}
|
||||
void InitGift()
|
||||
{
|
||||
GContext.container.Resolve<PlayerShopData>().InitShopPackData();
|
||||
//DayOfWeek week = ZZTimeHelper.UtcNow().UtcNowOffset().DayOfWeek;
|
||||
packItemDatas.Clear();
|
||||
var DailyGiftPackList = GContext.container.Resolve<PlayerData>().priceLevel.DailyPackList;
|
||||
for (int i = 0; i < DailyGiftPackList.Count; i++)
|
||||
{
|
||||
PackData data = GetPackData(DailyGiftPackList[i]);
|
||||
if (data == null) continue;
|
||||
packItemDatas.Add(data);
|
||||
}
|
||||
|
||||
for (int i = 0; i < packItemDatas.Count; i++)
|
||||
{
|
||||
PackData data = packItemDatas[i];
|
||||
if (i < packItemSelects.Count)
|
||||
{
|
||||
data.select = packItemSelects[i].transform.Find("Select").gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject go1 = Instantiate(imageItem, imageItemParent);
|
||||
go1.SetActive(true);
|
||||
packItemSelects.Add(go1);
|
||||
data.select = go1.transform.Find("Select").gameObject;
|
||||
}
|
||||
data.select.SetActive(false);
|
||||
}
|
||||
|
||||
RedPointSelect = packItemSelects[0].transform.Find("Select").GetComponent<Image>();
|
||||
RedPoint = packItemSelects[0].transform.GetComponent<Image>();
|
||||
RedPointFade = packItemSelects[0].transform.Find("RedPoint").GetComponent<Image>();
|
||||
}
|
||||
PackData GetPackData(int id)
|
||||
{
|
||||
ShopPackManager packM = GContext.container.Resolve<PlayerShopData>().TbPackManagerGetOrDefault(id);
|
||||
if (packM == null) return null;
|
||||
Pack pack = _tables.TbPack.GetOrDefault(packM.PackID[0]);
|
||||
if (pack == null) return null;
|
||||
return new PackData
|
||||
{
|
||||
packM = packM,
|
||||
pack = pack,
|
||||
num = GContext.container.Resolve<PlayerShopData>().GetShopPackBuyCount(packM.ID),
|
||||
OnCenter = SetPackData,
|
||||
};
|
||||
}
|
||||
void SetScroll()
|
||||
{
|
||||
if (isTopOpen)
|
||||
{
|
||||
SetPackData(packItemDatas[0]);
|
||||
panelScroll.loop = true;
|
||||
panelScroll.Init<PackItem, PackData>(itemWidth, giftItem, OnSelectGiftItem, packItemDatas, true, curPackItem == null ? 0 : curPackItem.index);
|
||||
panelScroll.enabled = packItemDatas.Count > 1;
|
||||
}
|
||||
}
|
||||
|
||||
void OnSelectGiftItem(PackItem item)
|
||||
{
|
||||
curPackItem = item;
|
||||
PackData data = item.data;
|
||||
|
||||
giftContent.DOAnchorPosX(-item.transform.localPosition.x, 0.2f).OnComplete(() => { SetPackData(data); });
|
||||
}
|
||||
|
||||
void SetPackData(PackData data)
|
||||
{
|
||||
curPackData?.select.SetActive(false);
|
||||
curPackData = data;
|
||||
if (curPackData != null)
|
||||
{
|
||||
curPackData.select.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnDestroy()
|
||||
{
|
||||
disposables?.Dispose();
|
||||
disposables = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/DiamondsShopPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/DiamondsShopPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 162b924fc0d43ec4e97e4ca45f78903b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Scripts/UI/Shop/EnergyShopPanel.cs
Normal file
38
Assets/Scripts/UI/Shop/EnergyShopPanel.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnergyShopPanel : MonoBehaviour
|
||||
{
|
||||
|
||||
#region Field&&Property
|
||||
[SerializeField]
|
||||
private EnergyShopSlot[] _diamondShopSlots;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Function
|
||||
private void Awake()
|
||||
{
|
||||
var shopTokens = GContext.container.Resolve<Tables>().TbResourceStore.DataList;
|
||||
var energyShopTokens = shopTokens.Where(x => x.ItemID== 1001).ToArray();
|
||||
|
||||
for ( int i = 0; i < energyShopTokens.Length; i++ )
|
||||
{
|
||||
if ( i == _diamondShopSlots.Length )
|
||||
{
|
||||
Debug.LogError($"[EnergyShopPanel::Awake]Energy Shop Slot Not Enough");
|
||||
break;
|
||||
}
|
||||
_diamondShopSlots[i].SetData(energyShopTokens[i]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/EnergyShopPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/EnergyShopPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d9b26dda4f997e429e73aa0e2847f80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
106
Assets/Scripts/UI/Shop/EnergyShopSlot.cs
Normal file
106
Assets/Scripts/UI/Shop/EnergyShopSlot.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using tysdk;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EnergyShopSlot : MonoBehaviour
|
||||
{
|
||||
//public Button btn_buy;
|
||||
public Button btn_buy1;
|
||||
public Image bg;
|
||||
// public Image icon;
|
||||
public TMP_Text text_num;
|
||||
public TMP_Text txt_value;
|
||||
public TMP_Text text_price;
|
||||
Button
|
||||
btn_showItem;
|
||||
// public GameObject tag_first;
|
||||
// public TMP_Text text_first_num;
|
||||
|
||||
ResourceStore _shopToken;
|
||||
|
||||
private void Init()
|
||||
{
|
||||
btn_buy1 = transform.Find("position/btn_purchase/btn_green").GetComponent<Button>();
|
||||
// icon = transform.Find("position/icon").GetComponent<Image>();
|
||||
bg = transform.Find("position/bg").GetComponent<Image>();
|
||||
text_num = transform.Find("position/text_num").GetComponent<TMP_Text>();
|
||||
txt_value = transform.Find("position/text_cost").GetComponent<TMP_Text>();
|
||||
btn_showItem = transform.Find("position/reward").GetComponent<Button>();
|
||||
|
||||
// tag_first = transform.Find("position/tag_first").gameObject;
|
||||
// text_first_num = transform.Find("position/tag_first/text_best").GetComponent<TMP_Text>();
|
||||
text_price = transform.Find("position/btn_purchase/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
|
||||
btn_buy1.onClick.AddListener(OnBuy);
|
||||
btn_showItem.onClick.AddListener(OnShowItemInfo);
|
||||
}
|
||||
public void SetData(cfg.ResourceStore data)
|
||||
{
|
||||
Init();
|
||||
_shopToken = data;
|
||||
|
||||
text_num.text = data.Number.ToString();
|
||||
if (data.Value == 0)
|
||||
txt_value.gameObject.SetActive(false);
|
||||
else
|
||||
txt_value.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", data.Value);
|
||||
|
||||
text_price.text = data.Price.ToString();
|
||||
|
||||
}
|
||||
void OnBuy()
|
||||
{
|
||||
var cost = _shopToken.Price;
|
||||
if (cost == 0)
|
||||
{
|
||||
//Free
|
||||
var itemData = new ItemData { id = _shopToken.ItemID, count = (_shopToken.Number) };
|
||||
// var itemData = new ItemData { id = _shopToken.ItemID, count = (_shopToken.AddNumber+_shopToken.Number)};
|
||||
itemData.curCount = (ulong)GContext.container.Resolve<PlayerItemData>().GetItemCount(_shopToken.ItemID);
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemData);
|
||||
GContext.Publish(new ShowData(itemData));
|
||||
GContext.Publish(new ShowData());
|
||||
}
|
||||
else
|
||||
{
|
||||
var curDiamond = GContext.container.Resolve<PlayerData>().diamond;
|
||||
//Not Free
|
||||
if (curDiamond >= cost)
|
||||
{
|
||||
// var itemData = new ItemData { id = _shopToken.ItemID, count = ( _shopToken.AddNumber + _shopToken.Number ) };
|
||||
var itemData = new ItemData { id = _shopToken.ItemID, count = (_shopToken.Number) };
|
||||
itemData.curCount = (ulong)GContext.container.Resolve<PlayerItemData>().GetItemCount(_shopToken.ItemID);
|
||||
GContext.container.Resolve<PlayerData>().AddDiamond(-cost);
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemData);
|
||||
GContext.Publish(new ShowData(new List<ItemData> { itemData }, RewardType.NormalOne));
|
||||
GContext.Publish(new ShowData());
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("resource_shop"))
|
||||
{
|
||||
e.AddContent("cost_diamond_count", cost)
|
||||
.AddContent("change_type", 1)
|
||||
.AddContent("change_num", _shopToken.Number)
|
||||
.AddContent("item_id", _shopToken.ItemID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_59"));
|
||||
_ = UIManager.Instance.ShowUI(UITypes.LackOfResourceConfirmPopupPanel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void OnShowItemInfo()
|
||||
{
|
||||
GContext.container.Resolve<PlayerItemData>().ShowItemTips(1001, btn_showItem.transform);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/EnergyShopSlot.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/EnergyShopSlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3420bcbfda53fab4db3b3700215aacba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Assets/Scripts/UI/Shop/FishCardMapSelectSlot.cs
Normal file
87
Assets/Scripts/UI/Shop/FishCardMapSelectSlot.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using PlayFab.Json;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishCardMapSelectSlot : MonoBehaviour
|
||||
{
|
||||
#region Field
|
||||
[SerializeField]
|
||||
GameObject
|
||||
go_selecting,
|
||||
go_lock;
|
||||
[SerializeField]
|
||||
Image img_bg;
|
||||
[SerializeField]
|
||||
TMP_Text
|
||||
txt_levelRequired,
|
||||
txt_mapSelectedName,
|
||||
txt_mapName;
|
||||
[SerializeField]
|
||||
Button btn_Select;
|
||||
|
||||
CompositeDisposable disposables = new CompositeDisposable();
|
||||
|
||||
private MapData
|
||||
_mapData;
|
||||
private bool _isSelecting;
|
||||
#endregion
|
||||
|
||||
|
||||
#region Func
|
||||
public void SetData(MapData mapData,int requiredLevel)
|
||||
{
|
||||
_isSelecting = false;
|
||||
_mapData = mapData;
|
||||
gameObject.SetActive(true);
|
||||
GContext.OnEvent<FishCardShopSlot.SChangeFishCardMapEvent>().Where(x=>x.MapData.ID==_mapData.ID||_isSelecting).Subscribe(OnMapSelected).AddTo(disposables);
|
||||
txt_mapName.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
|
||||
txt_mapSelectedName.text=LocalizationMgr.GetText(mapData.Name_l10n_key);
|
||||
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(img_bg, mapData.Bg);
|
||||
|
||||
if (GContext.container.Resolve<PlayerData>().lv>=requiredLevel)
|
||||
{
|
||||
go_lock.SetActive(false);
|
||||
btn_Select.OnClickAsObservable().Where(_=>!_isSelecting).Subscribe(_ => OnSelectMap()).AddTo(disposables);
|
||||
}
|
||||
else
|
||||
{
|
||||
go_lock.SetActive(true);
|
||||
txt_levelRequired.text = requiredLevel.ToString();
|
||||
btn_Select.OnClickAsObservable().Subscribe(_ => OnMapLock());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMapSelected(FishCardShopSlot.SChangeFishCardMapEvent data)
|
||||
{
|
||||
if(_isSelecting)
|
||||
{
|
||||
_isSelecting = false;
|
||||
go_selecting.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_isSelecting = true;
|
||||
go_selecting.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectMap()
|
||||
{
|
||||
GContext.Publish(new FishCardShopSlot.SChangeFishCardMapEvent { MapData = _mapData });
|
||||
}
|
||||
private void OnMapLock()
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_63"));
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposables.Dispose();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/FishCardMapSelectSlot.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/FishCardMapSelectSlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4d9a9b8a581a9146a882b141ff33bcb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
161
Assets/Scripts/UI/Shop/FishCardShopSlot.cs
Normal file
161
Assets/Scripts/UI/Shop/FishCardShopSlot.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using TMPro;
|
||||
using tysdk;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
public class FishCardShopSlot : MonoBehaviour
|
||||
{
|
||||
public struct SChangeFishCardMapEvent
|
||||
{
|
||||
public bool IsConfirm;
|
||||
public MapData MapData;
|
||||
}
|
||||
|
||||
//public Button btn_buy;
|
||||
public Button btn_buy1;
|
||||
public Image bg;
|
||||
// public Image icon;
|
||||
// public TMP_Text text_num;
|
||||
// public TMP_Text txt_value;
|
||||
public TMP_Text text_price;
|
||||
public TMP_Text txt_itemName;
|
||||
public TMP_Text txt_mapName;
|
||||
public RewardItemNew _rewardItem;
|
||||
public Transform tran_tag;
|
||||
private int _itemID;
|
||||
private int _mapID;
|
||||
// public GameObject tag_first;
|
||||
// public TMP_Text text_first_num;
|
||||
private CompositeDisposable _disposables = new();
|
||||
|
||||
ResourceStore _shopToken;
|
||||
|
||||
private void Init()
|
||||
{
|
||||
btn_buy1 = transform.Find("position/btn_purchase/btn_green").GetComponent<Button>();
|
||||
// icon = transform.Find("position/icon").GetComponent<Image>();
|
||||
bg = transform.Find("position/reward/mask_map/img_map").GetComponent<Image>();
|
||||
// text_num = transform.Find("position/price/text_num").GetComponent<TMP_Text>();
|
||||
// txt_value = transform.Find("position/text_cost").GetComponent<TMP_Text>();
|
||||
txt_itemName = transform.Find("position/reward/text_title").GetComponent<TMP_Text>();
|
||||
_rewardItem = transform.Find("position/reward").GetComponent<RewardItemNew>();
|
||||
txt_mapName = transform.Find("position/reward/text_map").GetComponent<TMP_Text>();
|
||||
tran_tag = transform.Find("position/tag");
|
||||
|
||||
|
||||
// tag_first = transform.Find("position/tag_first").gameObject;
|
||||
// text_first_num = transform.Find("position/tag_first/text_best").GetComponent<TMP_Text>();
|
||||
text_price = transform.Find("position/btn_purchase/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_buy1.onClick.AddListener(OnBuy);
|
||||
GContext.OnEvent<SChangeFishCardMapEvent>().Where(x => _mapID != x.MapData.ID && x.IsConfirm).Subscribe(x => OnChangeMapID(x)).AddTo(_disposables);
|
||||
}
|
||||
|
||||
public void SetData(cfg.ResourceStore data, int curMapID)
|
||||
{
|
||||
Init();
|
||||
_shopToken = data;
|
||||
|
||||
// text_num.text = data.Number.ToString();
|
||||
// txt_value.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", data.Value);
|
||||
//Discount
|
||||
var discount = data.Discount;
|
||||
if (discount > 0 && discount < 1)
|
||||
{
|
||||
var tagJudgeList = GContext.container.Resolve<Tables>().TbStoreConfig.Get(1).PriceTag;
|
||||
if (!Mathf.Approximately(discount, 1f))
|
||||
{
|
||||
var lastDiscount = 0f;
|
||||
var index = 0;
|
||||
foreach (var tagjudge in tagJudgeList)
|
||||
{
|
||||
if (discount * 10f > lastDiscount && discount * 10f <= tagjudge)
|
||||
{
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
lastDiscount = tagjudge;
|
||||
}
|
||||
if (tran_tag.childCount <= index)
|
||||
Debug.LogError($"[ItemShopSlot::RefreshView] tagJudge {index} exceeds tagsCount {tran_tag.childCount}");
|
||||
|
||||
tran_tag.gameObject.SetActive(true);
|
||||
var tag = tran_tag.GetChild(index);
|
||||
tag.gameObject.SetActive(true);
|
||||
tag.GetChild(0).GetComponent<TMP_Text>().text = ConvertTools.GetNumberString3(discount);
|
||||
|
||||
}
|
||||
text_price.text = (data.Price * data.Discount).ToString("F0"); ;
|
||||
}
|
||||
else
|
||||
{
|
||||
text_price.text = data.Price.ToString("F0"); ;
|
||||
}
|
||||
var mapData = GContext.container.Resolve<Tables>().TbMapData.Get(curMapID);
|
||||
OnChangeMapID(new SChangeFishCardMapEvent { MapData = mapData });
|
||||
}
|
||||
public void OnChangeMapID(SChangeFishCardMapEvent data)
|
||||
{
|
||||
|
||||
var itemID = GContext.container.Resolve<PlayerItemData>().GetFishCardItemIdByItemIDAndMapId(_shopToken.ItemID, data.MapData.ID);
|
||||
|
||||
_rewardItem.SetData(new ItemData
|
||||
{
|
||||
count = _shopToken.Number,
|
||||
id = itemID,
|
||||
});
|
||||
txt_mapName.text = LocalizationMgr.GetText(data.MapData.Name_l10n_key);
|
||||
_itemID = itemID;
|
||||
_mapID = data.MapData.ID;
|
||||
var imgUrl = data.MapData.Bg;
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(bg, imgUrl);
|
||||
}
|
||||
void OnBuy()
|
||||
{
|
||||
var discount = _shopToken.Discount == 0 ? 1 : _shopToken.Discount;
|
||||
var cost = _shopToken.Price * discount;
|
||||
var curDiamond = GContext.container.Resolve<PlayerData>().diamond;
|
||||
//Not Free
|
||||
if (curDiamond >= cost)
|
||||
{
|
||||
var itemData = new ItemData { id = _itemID, count = (_shopToken.Number) };
|
||||
GContext.container.Resolve<PlayerData>().AddDiamond(-(int)cost);
|
||||
GContext.Publish(new ShowData(new List<ItemData> { itemData }, RewardType.NormalOne));
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemData);
|
||||
GContext.Publish(new ShowData());
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("resource_shop"))
|
||||
{
|
||||
e.AddContent("cost_diamond_count", cost)
|
||||
.AddContent("change_type", 3)
|
||||
.AddContent("change_num", _shopToken.Number)
|
||||
.AddContent("item_id", _itemID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_59"));
|
||||
_ = UIManager.Instance.ShowUI(UITypes.LackOfResourceConfirmPopupPanel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
_disposables.Dispose();
|
||||
btn_buy1.onClick.RemoveAllListeners();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/FishCardShopSlot.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/FishCardShopSlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4635035c27862b40a0288e9c271b07a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
127
Assets/Scripts/UI/Shop/FishingShopPanel.cs
Normal file
127
Assets/Scripts/UI/Shop/FishingShopPanel.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishingShopPanel : BasePanel
|
||||
{
|
||||
public Button btn_close;
|
||||
|
||||
#region tabChange
|
||||
[SerializeField]
|
||||
GameObject
|
||||
tab_diamond,
|
||||
go_diamond,
|
||||
tab_items,
|
||||
go_items;
|
||||
|
||||
[SerializeField]
|
||||
Toggle
|
||||
tog_diamond,
|
||||
tog_item;
|
||||
|
||||
[SerializeField]
|
||||
TMP_Text
|
||||
txt_level,
|
||||
txt_energy,
|
||||
txt_diamond;
|
||||
int _curDiamond;
|
||||
int _curEnergy;
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
UIManager.Instance.panelStack.Push(UITypes.FishingShopPanel);
|
||||
|
||||
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("enter_shop")) { }
|
||||
#endif
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
GContext.OnEvent<LackOfResourceConfirmEvent>().Subscribe(x =>
|
||||
{
|
||||
OnSwitchTab(x.state);
|
||||
}).AddTo(disposables);
|
||||
GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1005).Subscribe(x =>
|
||||
{
|
||||
DiamondAddAnim();
|
||||
}).AddTo(disposables);
|
||||
GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1001).Subscribe(x =>
|
||||
{
|
||||
EnergyAddAnim();
|
||||
}).AddTo(disposables);
|
||||
oldPanelName = PanelName;
|
||||
base.Start();
|
||||
|
||||
btn_close.onClick.AddListener(async () =>
|
||||
{
|
||||
if (UIManager.Instance.panelStack.Count > 0)
|
||||
{
|
||||
UIManager.Instance.panelStack.Pop();
|
||||
}
|
||||
if (UIManager.Instance.panelStack.Count > 0)
|
||||
{
|
||||
UIType topUI = UIManager.Instance.panelStack.Pop();
|
||||
await UIManager.Instance.ShowUI(topUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
|
||||
GContext.Publish(restartShowHomeUIEvent);
|
||||
}
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingShopPanel);
|
||||
});
|
||||
|
||||
//New
|
||||
tog_item.OnValueChangedAsObservable().Where(x => x).Subscribe(_ => OnSwitchTab(0)).AddTo(disposables);
|
||||
tog_diamond.OnValueChangedAsObservable().Where(x => x).Subscribe(_ => OnSwitchTab(1)).AddTo(disposables);
|
||||
|
||||
var playerData = GContext.container.Resolve<PlayerData>();
|
||||
_curDiamond = playerData.diamond;
|
||||
_curEnergy = playerData.Energy;
|
||||
txt_diamond.text = ConvertTools.GetNumberString2(_curDiamond);
|
||||
txt_level.text = playerData.lv.ToString();
|
||||
txt_energy.text = ConvertTools.GetNumberString2(_curEnergy);
|
||||
}
|
||||
|
||||
|
||||
#region New
|
||||
void OnSwitchTab(int scope)
|
||||
{
|
||||
if (scope == 0)
|
||||
{
|
||||
go_diamond.SetActive(false);
|
||||
go_items.SetActive(true);
|
||||
tab_diamond.SetActive(false);
|
||||
tab_items.SetActive(true);
|
||||
}
|
||||
else if (scope == 1)
|
||||
{
|
||||
go_diamond.SetActive(true);
|
||||
go_items.SetActive(false);
|
||||
tab_diamond.SetActive(true);
|
||||
tab_items.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DiamondAddAnim()
|
||||
{
|
||||
_curDiamond = GContext.container.Resolve<PlayerData>().diamond;
|
||||
txt_diamond.text = ConvertTools.GetNumberString2(_curDiamond);
|
||||
}
|
||||
|
||||
void EnergyAddAnim()
|
||||
{
|
||||
_curEnergy = GContext.container.Resolve<PlayerData>().Energy;
|
||||
txt_energy.text = ConvertTools.GetNumberString2(_curEnergy);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
3
Assets/Scripts/UI/Shop/FishingShopPanel.cs.meta
Normal file
3
Assets/Scripts/UI/Shop/FishingShopPanel.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3be93599337431c93070b8f57d0484e
|
||||
timeCreated: 1691993942
|
||||
47
Assets/Scripts/UI/Shop/FishingShopSelectMapPopupPanel.cs
Normal file
47
Assets/Scripts/UI/Shop/FishingShopSelectMapPopupPanel.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishingShopSelectMapPopupPanel : MonoBehaviour
|
||||
{
|
||||
#region Field
|
||||
[SerializeField]
|
||||
Transform
|
||||
tran_mapParent;
|
||||
[SerializeField]
|
||||
GameObject
|
||||
go_mapSlot;
|
||||
[SerializeField]
|
||||
Button
|
||||
btn_confirm,
|
||||
btn_close;
|
||||
private int curMapID;
|
||||
#endregion
|
||||
|
||||
#region Func
|
||||
public void Init(int mapID)
|
||||
{
|
||||
curMapID = mapID;
|
||||
go_mapSlot.SetActive(false);
|
||||
var mapDatas = GContext.container.Resolve<Tables>().TbMapData.DataMap;
|
||||
btn_close.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.FishingShopSelectMapPopupPanel));
|
||||
int requireLevel = 0;
|
||||
foreach ( var mapData in mapDatas.Values )
|
||||
{
|
||||
Instantiate(go_mapSlot, tran_mapParent).GetComponent<FishCardMapSelectSlot>().SetData(mapData, requireLevel);
|
||||
requireLevel = mapData.LevelRequired;
|
||||
}
|
||||
GContext.Publish(new FishCardShopSlot.SChangeFishCardMapEvent { MapData = mapDatas[curMapID] });
|
||||
btn_confirm.onClick.AddListener(() => {
|
||||
GContext.Publish(new FishCardShopSlot.SChangeFishCardMapEvent { IsConfirm = true, MapData = mapDatas[curMapID] });
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingShopSelectMapPopupPanel);
|
||||
});
|
||||
GContext.OnEvent<FishCardShopSlot.SChangeFishCardMapEvent>().Where(x => !x.IsConfirm).Subscribe(x => curMapID = x.MapData.ID).AddTo(this);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 679293187e809384e9286566aaa566a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Scripts/UI/Shop/GiftBargainInfoPopupPanel.cs
Normal file
50
Assets/Scripts/UI/Shop/GiftBargainInfoPopupPanel.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using cfg;
|
||||
public class GiftBargainInfoPopupPanel : BasePanel
|
||||
{
|
||||
private List<Image> _itemIcons;
|
||||
private List<TMP_Text> _itemTexts;
|
||||
private Image _progressBar;
|
||||
private TMP_Text _textProgress, _textInfo, _textTagInfo;
|
||||
private IUIService _uiService;
|
||||
private BargainPackData _bpd;
|
||||
private Button _btnClose;
|
||||
private readonly Tables _tables = GContext.container.Resolve<Tables>();
|
||||
private void Awake()
|
||||
{
|
||||
_itemIcons = new List<Image>();
|
||||
_itemTexts = new List<TMP_Text>();
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
_itemIcons.Add(transform.Find($"root/info1/item/item{i}/icon_tag").GetComponent<Image>());
|
||||
_itemTexts.Add(transform.Find($"root/info1/item/item{i}/text_num").GetComponent<TMP_Text>());
|
||||
}
|
||||
_progressBar = transform.Find("root/info2/bg_bar/bar").GetComponent<Image>();
|
||||
_textProgress = transform.Find("root/info2/bg_bar/text_progress").GetComponent<TMP_Text>();
|
||||
_uiService = GContext.container.Resolve<IUIService>();
|
||||
_bpd = GContext.container.Resolve<BargainPackData>();
|
||||
_btnClose = transform.Find("btn_close").GetComponent<Button>();
|
||||
_textInfo = transform.Find("root/info3/text_num").GetComponent<TMP_Text>();
|
||||
_textTagInfo = transform.Find("root/info2/tag/tag_1/text_num").GetComponent<TMP_Text>();
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
_btnClose.onClick.AddListener(() =>
|
||||
{ UIManager.Instance.DestroyUI(UITypes.GiftBargainInfoPopupPanel); });
|
||||
for (int i = 0; i < _itemIcons.Count; i++)
|
||||
{
|
||||
_uiService.SetImageSprite(_itemIcons[i], $"icon_fish_rate_tag_{i + 3}");
|
||||
_itemTexts[i].text = "+" + _bpd.FishingScoreList[i + 2].ToString();
|
||||
}
|
||||
int target = _tables.TbSpecialPack[_tables.TbEventPackManager[_bpd.RedirectID].VIPPackList[0][0]].EventItemRequire[1];
|
||||
_textProgress.text = $"{target / 2}/{target}";
|
||||
_progressBar.fillAmount = 0.5f;
|
||||
_textInfo.text = $"{_tables.TbSpecialPack[_tables.TbEventPackManager[_bpd.RedirectID].VIPPackList[0][0]].DiscountList[^1]}%";
|
||||
_textTagInfo.text = $"{_tables.TbSpecialPack[_tables.TbEventPackManager[_bpd.RedirectID].VIPPackList[0][0]].DiscountList[2]}%";
|
||||
base.Start();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftBargainInfoPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftBargainInfoPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8227be5868bdd3a4c8fbd6e7f07d9cee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
317
Assets/Scripts/UI/Shop/GiftBargainPopupPanel.cs
Normal file
317
Assets/Scripts/UI/Shop/GiftBargainPopupPanel.cs
Normal file
@@ -0,0 +1,317 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine.UI;
|
||||
using cfg;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using game;
|
||||
using DG.Tweening;
|
||||
|
||||
public class GiftBargainPopupPanel : BasePanel
|
||||
{
|
||||
private TMP_Text _textTimer,
|
||||
_textBargainProgress,
|
||||
_textPrice,
|
||||
_textPriceDiscount,
|
||||
_textDiscountTag1,
|
||||
_textDiscountTag2,
|
||||
_textPriceOrigin,
|
||||
_textInfo,
|
||||
_textLastPriceDiscount,
|
||||
_textLastPriceOrigin;
|
||||
|
||||
private Image _bargainBar;
|
||||
private Tables _tables;
|
||||
private Button _btnBuy, _btnDiscount, _btnClose, _btnInfo, _btnLastDiscount;
|
||||
private GiftRewardAttached _reward4, _reward3;
|
||||
private BargainPackData _bpd;
|
||||
private GameObject _discountTag1, _discountTag2;
|
||||
private Spine.Unity.SkeletonGraphic _npc;
|
||||
private IAPItemList _iap;
|
||||
private System.Threading.CancellationTokenSource _cts;
|
||||
private Animation _rootAni;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
#region UI
|
||||
|
||||
_textTimer = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
||||
_bargainBar = transform.Find("root/bg_bar/bar").GetComponent<Image>();
|
||||
_textBargainProgress = transform.Find("root/bg_bar/text_progress").GetComponent<TMP_Text>();
|
||||
_btnBuy = transform.Find("root/btn_buy/btn_green").GetComponent<Button>();
|
||||
_textPrice = transform.Find("root/btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
_btnDiscount = transform.Find("root/btn_discount/btn_green").GetComponent<Button>();
|
||||
_textPriceDiscount =
|
||||
transform.Find("root/btn_discount/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
_textPriceOrigin = transform.Find("root/btn_discount/btn_green/Ani_Container/text_old")
|
||||
.GetComponent<TMP_Text>();
|
||||
_btnLastDiscount = transform.Find("root/btn_discount2/btn_green").GetComponent<Button>();
|
||||
_textLastPriceDiscount =
|
||||
transform.Find("root/btn_discount2/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
_textLastPriceOrigin = transform.Find("root/btn_discount2/btn_green/Ani_Container/text_old")
|
||||
.GetComponent<TMP_Text>();
|
||||
_reward3 = transform.Find("root/reward_3").GetComponent<GiftRewardAttached>();
|
||||
_reward4 = transform.Find("root/reward_4").GetComponent<GiftRewardAttached>();
|
||||
_btnClose = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
_btnInfo = transform.Find("root/btn_questionmark").GetComponent<Button>();
|
||||
_discountTag1 = transform.Find("root/tag/tag_1").gameObject;
|
||||
_discountTag2 = transform.Find("root/tag/tag_2").gameObject;
|
||||
_textDiscountTag1 = transform.Find("root/tag/tag_1/text_num").GetComponent<TMP_Text>();
|
||||
_textDiscountTag2 = transform.Find("root/tag/tag_2/text_num").GetComponent<TMP_Text>();
|
||||
_textInfo = transform.Find("root/bg_info/text_num").GetComponent<TMP_Text>();
|
||||
_npc = transform.Find("root/npc/mask/spine").GetComponent<Spine.Unity.SkeletonGraphic>();
|
||||
_rootAni = transform.Find("root/").GetComponent<Animation>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region config
|
||||
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_bpd = GContext.container.Resolve<BargainPackData>();
|
||||
|
||||
#endregion
|
||||
|
||||
if (!_bpd.IsPackActivated) gameObject.SetActive(false);
|
||||
_cts = new System.Threading.CancellationTokenSource();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
_btnClose.onClick.AddListener(() => ClosePanel());
|
||||
_btnInfo.onClick.AddListener(async () => await UIManager.Instance.ShowUI(UITypes.GiftBargainInfoPopupPanel));
|
||||
_textTimer.text = ConvertTools.ConvertTime2(_bpd.RemainingTime);
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe(_ => { _textTimer.text = ConvertTools.ConvertTime2(_bpd.RemainingTime); })
|
||||
.AddTo(this);
|
||||
_bargainBar.fillAmount = GetFillAmount(_bpd.VisualProgress, _bpd.NextVisualTarget);
|
||||
if (_bpd.IsFull)
|
||||
_textBargainProgress.text = LocalizationMgr.GetText("UI_FishingPanel_101007");
|
||||
else
|
||||
_textBargainProgress.text = $"{_bpd.VisualProgress}/{_bpd.NextVisualTarget}";
|
||||
_textDiscountTag1.text = $"{_bpd.NextVisualDiscount}%";
|
||||
_textInfo.text = $"{_tables.TbSpecialPack[_bpd.PackID].DiscountList[_bpd.DiscountLvlCount - 1]}%";
|
||||
_textPrice.text = GetPrice(0);
|
||||
_textPriceOrigin.text = GetPrice(0);
|
||||
_textLastPriceOrigin.text = GetPrice(0);
|
||||
if (_bpd.VisualDiscountLvl == 0)
|
||||
{
|
||||
_btnBuy.transform.parent.gameObject.SetActive(true);
|
||||
_btnDiscount.transform.parent.gameObject.SetActive(false);
|
||||
_btnLastDiscount.transform.parent.gameObject.SetActive(false);
|
||||
_textPrice.text = GetPrice(0);
|
||||
_btnBuy.onClick.AddListener(async () => { await OnClickBuy(); });
|
||||
}
|
||||
else
|
||||
{
|
||||
_btnBuy.transform.parent.gameObject.SetActive(false);
|
||||
_btnDiscount.transform.parent.gameObject.SetActive(true);
|
||||
_btnLastDiscount.transform.parent.gameObject.SetActive(false);
|
||||
_textPriceDiscount.text = GetPrice(_bpd.VisualDiscountLvl);
|
||||
_btnDiscount.onClick.AddListener(async () => { await OnClickBuy(); });
|
||||
}
|
||||
|
||||
int dropID = _tables.TbSpecialPack[_bpd.PackID].DropID[0];
|
||||
_reward4.SetData(GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(dropID));
|
||||
PlayCutSequence(_cts.Token);
|
||||
PlayNPCLoopSequence(_cts.Token);
|
||||
oldPanelName = panelName;
|
||||
base.Start();
|
||||
}
|
||||
|
||||
private string GetPrice(int discountLvl)
|
||||
{
|
||||
int IAPID = _tables
|
||||
.TbSpecialPack[_tables.TbEventPackManager[_bpd.RedirectID].VIPPackList[_bpd.VIPLvlWhenEventActivated][0]]
|
||||
.IAPID[discountLvl];
|
||||
_iap = _tables.TbIAPItemList.GetOrDefault(IAPID);
|
||||
//Debug.Log($"_iap: {_iap}");
|
||||
SKUDetailDataEvent sdde = new SKUDetailDataEvent(_iap);
|
||||
GContext.Publish(sdde);
|
||||
return sdde.price;
|
||||
}
|
||||
|
||||
[SerializeField] private float _judgeInterval = 4.6f, _switchChance = 0.2f;
|
||||
private float _countDown = 0;
|
||||
private bool _doPlayIdle2 = false;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_doPlayIdle2 || _npc.AnimationState.GetCurrent(0) == null
|
||||
|| _npc.AnimationState.GetCurrent(0).Animation.Name != "Idle01")
|
||||
return;
|
||||
_countDown += Time.deltaTime;
|
||||
if (_countDown >= _judgeInterval)
|
||||
{
|
||||
_countDown -= _judgeInterval;
|
||||
_doPlayIdle2 = (UnityEngine.Random.value < _switchChance);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] private float _barAnimationDuration = 0.5f;
|
||||
|
||||
private async System.Threading.Tasks.Task PlayCutSequence(System.Threading.CancellationToken token)
|
||||
{
|
||||
int p, dl, progressStart;
|
||||
if (_bpd.VisualDiscountLvl >= _bpd.DiscountLvlCount - 1 && _bpd.VisualProgress >= _bpd.NextVisualTarget)
|
||||
{
|
||||
_state = LumberJackState.Rest;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_bpd.VisualDiscountLvl >= _bpd.DiscountLvl) //discount lvl did not change
|
||||
{
|
||||
_bargainBar.DOFillAmount(GetFillAmount(_bpd.Progress, _bpd.NextTarget), _barAnimationDuration);
|
||||
p = _bpd.VisualProgress;
|
||||
DOTween.To(() => p, value => p = value, _bpd.Progress, _barAnimationDuration)
|
||||
.OnUpdate(() => _textBargainProgress.text = $"{p}/{_bpd.NextTarget}");
|
||||
await System.Threading.Tasks.Task.Delay((int)(_barAnimationDuration * 1000));
|
||||
}
|
||||
else //discount lvl change
|
||||
{
|
||||
dl = _bpd.VisualDiscountLvl;
|
||||
progressStart = _bpd.VisualProgress;
|
||||
_state = LumberJackState.Cut;
|
||||
p = progressStart;
|
||||
_bargainBar.fillAmount = GetFillAmount(_bpd.VisualProgress, _bpd.NextVisualTarget);
|
||||
_btnBuy.onClick.RemoveAllListeners();
|
||||
_btnDiscount.onClick.RemoveAllListeners();
|
||||
_btnLastDiscount.onClick.RemoveAllListeners();
|
||||
while (dl < _bpd.DiscountLvl)
|
||||
{
|
||||
_textDiscountTag1.text = $"{_bpd.GetNextDiscount(dl)}%";
|
||||
_bargainBar.DOFillAmount(1, _barAnimationDuration);
|
||||
DOTween.To(() => p, value => p = value, _bpd.GetNextDiscountTarget(dl), _barAnimationDuration)
|
||||
.OnUpdate(() => _textBargainProgress.text = $"{p}/{_bpd.GetNextDiscountTarget(dl)}");
|
||||
await System.Threading.Tasks.Task.Delay((int)(_barAnimationDuration * 1000));
|
||||
//Debug.Log($"DL: {dl}");
|
||||
//Debug.Log($"max lvl: {_bpd.DiscountLvlCount - 1}");
|
||||
if (dl == _bpd.DiscountLvlCount - 2 && _bpd.Progress >= _bpd.NextVisualTarget)
|
||||
{
|
||||
_textBargainProgress.text = LocalizationMgr.GetText("UI_FishingPanel_101007");
|
||||
}
|
||||
|
||||
_rootAni.Play("bargain_fillup");
|
||||
await System.Threading.Tasks.Task.Delay((int)(40.0f / 60.0f * 1000f));
|
||||
if (dl == 0)
|
||||
{
|
||||
_textPriceDiscount.text = GetPrice(dl + 1);
|
||||
_rootAni.Play("bargain_change1");
|
||||
//TODO:
|
||||
}
|
||||
else
|
||||
{
|
||||
_textLastPriceDiscount.text = GetPrice(dl);
|
||||
_textPriceDiscount.text = GetPrice(dl + 1);
|
||||
_rootAni.Play("bargain_change2");
|
||||
//TODO:
|
||||
}
|
||||
|
||||
await PlaySpine("Cut01", false);
|
||||
PlaySpine("Idle01", true);
|
||||
p = 0;
|
||||
_bargainBar.fillAmount = 0;
|
||||
dl++;
|
||||
}
|
||||
|
||||
_textDiscountTag1.text = $"{_bpd.GetNextDiscount(dl)}%";
|
||||
_bpd.RefreshVisualData();
|
||||
if (_bpd.VisualDiscountLvl >= _bpd.DiscountLvlCount - 1 && _bpd.VisualProgress >= _bpd.NextVisualTarget)
|
||||
{
|
||||
_bargainBar.fillAmount = 1;
|
||||
//_rootAni.Play("bargain_fillup");
|
||||
//await System.Threading.Tasks.Task.Delay((int) (40.0f / 60.0f * 1000f));
|
||||
_textPriceDiscount.text = GetPrice(dl);
|
||||
//_rootAni.Play("bargain_change2");
|
||||
//await PlaySpine("Cut01", false);
|
||||
_btnDiscount.onClick.AddListener(async () => await OnClickBuy());
|
||||
await PlaySpine("Idle04", false);
|
||||
_state = LumberJackState.Rest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_bargainBar.DOFillAmount(GetFillAmount(_bpd.Progress, _bpd.NextTarget), _barAnimationDuration);
|
||||
DOTween.To(() => p, value => p = value, _bpd.Progress, _barAnimationDuration)
|
||||
.OnUpdate(() => _textBargainProgress.text = $"{p}/{_bpd.NextTarget}");
|
||||
await System.Threading.Tasks.Task.Delay((int)(_barAnimationDuration * 1000));
|
||||
_btnDiscount.onClick.AddListener(async () => await OnClickBuy());
|
||||
_state = LumberJackState.Idle;
|
||||
}
|
||||
}
|
||||
//_rootAni.Play("");
|
||||
}
|
||||
|
||||
private enum LumberJackState
|
||||
{
|
||||
Idle,
|
||||
Cut,
|
||||
Rest
|
||||
}
|
||||
|
||||
private LumberJackState _state = LumberJackState.Idle;
|
||||
|
||||
private async System.Threading.Tasks.Task PlayNPCLoopSequence(System.Threading.CancellationToken token)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (token.IsCancellationRequested) return;
|
||||
if (_state == LumberJackState.Cut)
|
||||
{
|
||||
PlaySpine("Idle01", true);
|
||||
await new WaitUntil(() => _state != LumberJackState.Cut);
|
||||
}
|
||||
|
||||
if (_state == LumberJackState.Rest)
|
||||
{
|
||||
await PlaySpine("Idle03", false);
|
||||
continue;
|
||||
}
|
||||
|
||||
await PlaySpine("Idle01", false);
|
||||
if (_doPlayIdle2)
|
||||
{
|
||||
_doPlayIdle2 = false;
|
||||
await PlaySpine("Idle02", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task PlaySpine(string name, bool isLoop = false)
|
||||
{
|
||||
_npc.AnimationState.SetAnimation(0, name, isLoop);
|
||||
await System.Threading.Tasks.Task.Delay((int)(_npc.AnimationState.GetCurrent(0).Animation.Duration * 1000));
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task OnClickBuy()
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.EventPack;
|
||||
shopBuyTypeData.ID = _bpd.CurrentEventID;
|
||||
bool res = await GContext.container.Resolve<PlayerShopData>().OnBuy(_bpd.RewardDropID, shopBuyTypeData, _iap,
|
||||
GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(_bpd.RewardDropID));
|
||||
|
||||
if (res)
|
||||
{
|
||||
//_bpd.AddPurchase();
|
||||
ClosePanel();
|
||||
}
|
||||
}
|
||||
|
||||
private void ClosePanel()
|
||||
{
|
||||
_cts.Cancel();
|
||||
_bpd.RefreshVisualData();
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftBargainPopupPanel);
|
||||
}
|
||||
|
||||
private float GetFillAmount(int progress, int target)
|
||||
{
|
||||
return (float)progress / (float)target;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_cts?.Dispose();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftBargainPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftBargainPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80daa437887cd3140b007d4e48dc0a21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Assets/Scripts/UI/Shop/GiftNoticePanel.cs
Normal file
71
Assets/Scripts/UI/Shop/GiftNoticePanel.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.Notifications;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftNoticePanel : MonoBehaviour
|
||||
{
|
||||
Button btn_close;
|
||||
Button btn_mask;
|
||||
Button btn_watch1;
|
||||
Button btn_watch2;
|
||||
public RewardItemNew[] rewardItemNews;
|
||||
private Tables _tables;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_mask = transform.Find("mask").GetComponent<Button>();
|
||||
btn_watch1 = transform.Find("root/btn_watch1/btn_green").GetComponent<Button>();
|
||||
btn_watch2 = transform.Find("root/btn_watch2/btn_green").GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(OnClose);
|
||||
btn_mask.onClick.AddListener(OnClose);
|
||||
btn_watch1.onClick.AddListener(OnClickNO);
|
||||
btn_watch2.onClick.AddListener(OnClickYES);
|
||||
|
||||
int id = GContext.container.Resolve<PlayerData>().priceLevel.DailyGiftDisplay;
|
||||
Item item = _tables.TbItem.GetOrDefault(id);
|
||||
var itemDataGift = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(item.RedirectID);
|
||||
//ItemDropPackage itemDropPackage = _tables.TbItemDropPackage.GetOrDefault(item.RedirectID);
|
||||
//if (itemDropPackage.ItemDisplay.Count > 0)
|
||||
//{
|
||||
// List<string> CountDisplay = GContext.container.Resolve<PlayerItemData>().ShowItemDropPackage(id, itemDropPackage);
|
||||
for (int i = 0; i < rewardItemNews.Length; i++)
|
||||
{
|
||||
if (i < itemDataGift.Count)
|
||||
{
|
||||
rewardItemNews[i].SetData(itemDataGift[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardItemNews[i].transform.parent.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
void OnClickNO()
|
||||
{
|
||||
//不再显示此界面
|
||||
PlayerPrefs.SetInt("GiftNoticePanel", 1);
|
||||
OnClose();
|
||||
}
|
||||
void OnClickYES()
|
||||
{
|
||||
//开启通知
|
||||
OnClose();
|
||||
NotificationCenter.OpenNotificationSettings();
|
||||
}
|
||||
void OnClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftNoticePanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftNoticePanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftNoticePanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcac9d7fba385084eb571761ecd48d07
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
121
Assets/Scripts/UI/Shop/GiftOneAddTwoItem.cs
Normal file
121
Assets/Scripts/UI/Shop/GiftOneAddTwoItem.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftOneAddTwoItem : MonoBehaviour
|
||||
{
|
||||
Tables _tables;
|
||||
Transform rewardRoot;
|
||||
List<RewardItemNew> items = new List<RewardItemNew>();
|
||||
public List<ItemData> itemData;
|
||||
public IAPItemList iAPItemList;
|
||||
int dropID;
|
||||
public int dataIndex;
|
||||
Button btn_buy;
|
||||
TMP_Text text_buy;
|
||||
GameObject done;
|
||||
Action OnBuySuccess;
|
||||
GameObject lockGo;
|
||||
RectTransform rectTransform;
|
||||
int isDone;
|
||||
private void Awake()
|
||||
{
|
||||
rewardRoot = transform.Find("reward");
|
||||
int count = rewardRoot.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
items.Add(rewardRoot.GetChild(i).GetComponent<RewardItemNew>());
|
||||
}
|
||||
btn_buy = transform.Find("btn_buy/btn_green").GetComponent<Button>();
|
||||
text_buy = transform.Find("btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
done = transform.Find("done").gameObject;
|
||||
|
||||
lockGo = transform.Find("btn_buy/btn_green/Ani_Container/p_text/lock").gameObject;
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_buy.onClick.AddListener(OnBuy);
|
||||
}
|
||||
public void SetData(Action action, int dropID, int IAPID, int isDone, int dataIndex, List<ItemData> itemDatas)
|
||||
{
|
||||
this.dropID = dropID;
|
||||
this.dataIndex = dataIndex;
|
||||
itemData = itemDatas;
|
||||
done.SetActive(isDone == 0);
|
||||
btn_buy.gameObject.SetActive(isDone != 0);
|
||||
this.isDone = isDone;
|
||||
lockGo.SetActive(isDone == 2);
|
||||
iAPItemList = _tables.TbIAPItemList.GetOrDefault(IAPID);
|
||||
int itemCount = itemData.Count;
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
items[i].gameObject.SetActive(i < itemCount);
|
||||
if (i < itemCount)
|
||||
{
|
||||
items[i].SetData(itemData[i]);
|
||||
items[i].SetReceived(isDone == 0);
|
||||
}
|
||||
}
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
text_buy.text = sKUDetailDataEvent.price;
|
||||
this.OnBuySuccess = action;
|
||||
}
|
||||
public void SetReceived()
|
||||
{
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
items[i].SetReceived(true);
|
||||
}
|
||||
done.SetActive(true);
|
||||
btn_buy.gameObject.SetActive(false);
|
||||
}
|
||||
public void PlayMove()
|
||||
{
|
||||
rectTransform.DOKill();
|
||||
rectTransform.anchoredPosition = Vector3.right * rectTransform.rect.width;
|
||||
rectTransform.DOAnchorPosX(0, 0.5f).SetEase(Ease.Linear);
|
||||
}
|
||||
async void OnBuy()
|
||||
{
|
||||
if (isDone == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (isDone == 2)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_30"));
|
||||
return;
|
||||
}
|
||||
btn_buy.enabled = false;
|
||||
if (iAPItemList == null)
|
||||
{
|
||||
GContext.Publish(new ShowData(itemData, RewardType.Normal));
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemData);
|
||||
GContext.Publish(new ShowData());
|
||||
GContext.container.Resolve<FishingEventData>().SetPack1A2Index();
|
||||
OnBuySuccess?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.EventPack;
|
||||
shopBuyTypeData.ID = GContext.container.Resolve<FishingEventData>().Pack1A2Data.lastID;
|
||||
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(dropID, shopBuyTypeData, iAPItemList, itemData, RewardType.Normal);
|
||||
if (Result)
|
||||
{
|
||||
OnBuySuccess?.Invoke();
|
||||
}
|
||||
}
|
||||
btn_buy.enabled = true;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftOneAddTwoItem.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftOneAddTwoItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82841115d97c6c543b8c5fdf888d98a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Assets/Scripts/UI/Shop/GiftPiggyBankInfoPopupPanel.cs
Normal file
49
Assets/Scripts/UI/Shop/GiftPiggyBankInfoPopupPanel.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
public class GiftPiggyBankInfoPopupPanel : MonoBehaviour
|
||||
{
|
||||
List<Image> _itemIcons;
|
||||
List<TMP_Text> _itemTexts;
|
||||
Image _progressBar;
|
||||
TMP_Text _textEnd;
|
||||
TMP_Text _textMid;
|
||||
IUIService _uiService;
|
||||
PiggyBankPackData _pbpd;
|
||||
Button _btnClose;
|
||||
private void Awake()
|
||||
{
|
||||
_itemIcons = new List<Image>();
|
||||
_itemTexts = new List<TMP_Text>();
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
_itemIcons.Add(transform.Find($"root/info1/item/item{i}/icon_tag").GetComponent<Image>());
|
||||
_itemTexts.Add(transform.Find($"root/info1/item/item{i}/text_num").GetComponent<TMP_Text>());
|
||||
}
|
||||
_progressBar = transform.Find("root/info2/bg_bar/bar").GetComponent<Image>();
|
||||
_textEnd = transform.Find("root/info2/bg_bar/resin2/text_num").GetComponent<TMP_Text>();
|
||||
_textMid = transform.Find("root/info2/bg_bar/resin3/text_num").GetComponent<TMP_Text>();
|
||||
_uiService = GContext.container.Resolve<IUIService>();
|
||||
_pbpd = GContext.container.Resolve<PiggyBankPackData>();
|
||||
_btnClose = transform.Find("btn_close").GetComponent<Button>();
|
||||
//_progressText = transform.Find()
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
_btnClose.onClick.AddListener(() =>
|
||||
{ UIManager.Instance.DestroyUI(UITypes.GiftPiggyBankInfoPopupPanel); });
|
||||
for (int i = 0; i < _itemIcons.Count; i++)
|
||||
{
|
||||
_uiService.SetImageSprite(_itemIcons[i], $"icon_fish_rate_tag_{i + 3}");
|
||||
_itemTexts[i].text = "+" + _pbpd.FishingScoreList[i + 2].ToString();
|
||||
}
|
||||
_textEnd.text = _pbpd.Target.ToString();
|
||||
_textMid.text = _pbpd.CanBuyCount.ToString();
|
||||
_progressBar.fillAmount = 0.5f;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPiggyBankInfoPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPiggyBankInfoPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbb71ba3d31c24d4b8638197ae52be18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
102
Assets/Scripts/UI/Shop/GiftPiggyBankPopupPanel.cs
Normal file
102
Assets/Scripts/UI/Shop/GiftPiggyBankPopupPanel.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine.UI;
|
||||
using cfg;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using game;
|
||||
using System.Collections.Generic;
|
||||
public class GiftPiggyBankPopupPanel : BasePanel
|
||||
{
|
||||
private TMP_Text _textTimer, _textPrice, _textPriceGray,
|
||||
_textBubbleFull, _textBubbleNormal, _textBarEnd, _textBarMid;
|
||||
private Image _progressBar;
|
||||
private Tables _tables;
|
||||
private Button _btnBuy, _btnClose, _btnInfo, _btnBuyGray;
|
||||
private GameObject _bubbleNormal, _bubbleFull, _textContentNormal, _textContentFull, _tagFull, text_info;
|
||||
private PiggyBankPackData _pbpd;
|
||||
private IAPItemList _iap;
|
||||
private void Awake()
|
||||
{
|
||||
#region UI
|
||||
_textTimer = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
||||
_progressBar = transform.Find("root/bg_bar/bar").GetComponent<Image>();
|
||||
_btnBuy = transform.Find("root/btn_buy/btn_green").GetComponent<Button>();
|
||||
_btnBuyGray = transform.Find("root/btn_buy_gray/btn_green").GetComponent<Button>();
|
||||
_textPrice = transform.Find("root/btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
_textPriceGray = transform.Find("root/btn_buy_gray/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
_btnClose = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
_btnInfo = transform.Find("root/btn_questionmark").GetComponent<Button>();
|
||||
_tagFull = transform.Find("root/tag_full").gameObject;
|
||||
text_info = transform.Find("root/text_info").gameObject;
|
||||
_bubbleNormal = transform.Find("root/bubble_normal").gameObject;
|
||||
_bubbleFull = transform.Find("root/bubble_full").gameObject;
|
||||
_textBubbleNormal = transform.Find("root/bubble_normal/resin1/text_num").GetComponent<TMP_Text>();
|
||||
_textBubbleFull = transform.Find("root/bubble_full/resin1/text_num").GetComponent<TMP_Text>();
|
||||
_textContentNormal = transform.Find("root/text_content1").gameObject;
|
||||
_textContentFull = transform.Find("root/text_content2").gameObject;
|
||||
_textBarMid = transform.Find("root/bg_bar/reward2/text_num").GetComponent<TMP_Text>();
|
||||
_textBarEnd = transform.Find("root/bg_bar/reward3/text_num").GetComponent<TMP_Text>();
|
||||
#endregion
|
||||
#region config
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_pbpd = GContext.container.Resolve<PiggyBankPackData>();
|
||||
#endregion
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
_pbpd.DoNeedUpdate = false;
|
||||
_textTimer.text = ConvertTools.ConvertTime2(_pbpd.RemainingTime);
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe(_ => { _textTimer.text = ConvertTools.ConvertTime2(_pbpd.RemainingTime); })
|
||||
.AddTo(this);
|
||||
_btnClose.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.GiftPiggyBankPopupPanel));
|
||||
_btnInfo.onClick.AddListener(
|
||||
async () => await UIManager.Instance.ShowUI(UITypes.GiftPiggyBankInfoPopupPanel));
|
||||
_btnBuy.onClick.AddListener(async () => { await OnClickBuy(); });
|
||||
_btnBuyGray.onClick.AddListener(() =>
|
||||
{ ToastPanel.Show(LocalizationMgr.GetFormatTextValue("UI_ToastPanel_72", _pbpd.CanBuyCount)); });
|
||||
_textBubbleNormal.text = _pbpd.Progress.ToString();
|
||||
_textBubbleFull.text = _pbpd.Progress.ToString();
|
||||
bool isCanBuy = _pbpd.Progress >= _pbpd.CanBuyCount;
|
||||
_bubbleNormal.SetActive(!isCanBuy);
|
||||
_bubbleFull.SetActive(isCanBuy);
|
||||
_tagFull.SetActive(_pbpd.IsFull);
|
||||
_textContentNormal.SetActive(!_pbpd.IsFull);
|
||||
_textContentFull.SetActive(_pbpd.IsFull);
|
||||
text_info.SetActive(isCanBuy);
|
||||
_btnBuy.gameObject.SetActive(isCanBuy);
|
||||
_btnBuyGray.gameObject.SetActive(!isCanBuy);
|
||||
int IAPID = _tables.TbSpecialPack[_tables.TbEventPackManager[_pbpd.RedirectID].VIPPackList[_pbpd.VIPLvlWhenEventActivated][0]].IAPID[0];
|
||||
_iap = _tables.TbIAPItemList.GetOrDefault(IAPID);
|
||||
//Debug.Log($"iap: {_iap}");
|
||||
SKUDetailDataEvent sdde = new SKUDetailDataEvent(_iap);
|
||||
GContext.Publish(sdde);
|
||||
_textPrice.text = sdde.price;
|
||||
_textPriceGray.text = sdde.price;
|
||||
_textBarMid.text = _pbpd.CanBuyCount.ToString();
|
||||
_textBarEnd.text = _pbpd.Target.ToString();
|
||||
_progressBar.fillAmount = (float)_pbpd.Progress / (float)_pbpd.Target;
|
||||
oldPanelName = panelName;
|
||||
base.Start();
|
||||
}
|
||||
private async System.Threading.Tasks.Task OnClickBuy()
|
||||
{
|
||||
List<ItemData> itemDatas = GContext.container.Resolve<PlayerItemData>()
|
||||
.GetItemDataByDropId(_pbpd.RewardDropID);
|
||||
itemDatas[0].count = _pbpd.Progress;
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.EventPack;
|
||||
shopBuyTypeData.ID = _pbpd.CurrentEventID;
|
||||
|
||||
bool res = await GContext.container.Resolve<PlayerShopData>()
|
||||
.OnBuy(_pbpd.RewardDropID,shopBuyTypeData, _iap, itemDatas);
|
||||
if (res)
|
||||
{
|
||||
//_pbpd.AddPurchase();
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPiggyBankPopupPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPiggyBankPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPiggyBankPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7304a222d4e2def4d86ba14c800b0912
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
144
Assets/Scripts/UI/Shop/GiftPopupItem.cs
Normal file
144
Assets/Scripts/UI/Shop/GiftPopupItem.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftPopupItem : MonoBehaviour
|
||||
{
|
||||
Tables _tables;
|
||||
Transform rewardRoot;
|
||||
List<RewardItemNew> items = new List<RewardItemNew>();
|
||||
public List<ItemData> itemData;
|
||||
public Pack pack;
|
||||
public IAPItemList iAPItemList;
|
||||
public int dataIndex;
|
||||
Button btn_buy;
|
||||
TMP_Text text_buy;
|
||||
GameObject done;
|
||||
GameObject arrow;
|
||||
Action OnBuySuccess;
|
||||
GameObject lockGo;
|
||||
RectTransform rectTransform;
|
||||
int isDone;
|
||||
GameObject bg1;
|
||||
GameObject bg2;
|
||||
GameObject light1;
|
||||
GameObject light2;
|
||||
private void Awake()
|
||||
{
|
||||
rewardRoot = transform.Find("reward");
|
||||
int count = rewardRoot.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
items.Add(rewardRoot.GetChild(i).GetComponent<RewardItemNew>());
|
||||
}
|
||||
btn_buy = transform.Find("btn_buy/btn_green").GetComponent<Button>();
|
||||
text_buy = transform.Find("btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
done = transform.Find("done").gameObject;
|
||||
arrow = transform.Find("arrow").gameObject;
|
||||
lockGo = transform.Find("btn_buy/btn_green/lock").gameObject;
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
bg1 = transform.Find("bg1").gameObject;
|
||||
bg2 = transform.Find("bg2").gameObject;
|
||||
light1 = transform.Find("light1").gameObject;
|
||||
light2 = transform.Find("light2").gameObject;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_buy.onClick.AddListener(OnBuy);
|
||||
}
|
||||
public void SetData(Action action, int packId, int isDone, int dataIndex, int index)
|
||||
{
|
||||
this.dataIndex = dataIndex;
|
||||
arrow.SetActive(index > 0);
|
||||
done.SetActive(isDone == 0);
|
||||
btn_buy.gameObject.SetActive(isDone != 0);
|
||||
this.isDone = isDone;
|
||||
lockGo.SetActive(isDone == 2);
|
||||
pack = _tables.TbPack.GetOrDefault(packId);
|
||||
iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID);
|
||||
itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(pack.DropID);
|
||||
|
||||
int itemCount = itemData.Count;
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
items[i].gameObject.SetActive(i < itemCount);
|
||||
if (i < itemCount)
|
||||
{
|
||||
items[i].SetData(itemData[i]);
|
||||
items[i].SetReceived(isDone == 0);
|
||||
}
|
||||
}
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
text_buy.text = sKUDetailDataEvent.price;
|
||||
this.OnBuySuccess = action;
|
||||
bool isOne = dataIndex % 2 == 0;
|
||||
bg1.SetActive(isOne && isDone != 1);
|
||||
bg2.SetActive(!isOne && isDone != 1);
|
||||
light1.SetActive(isOne && isDone == 1);
|
||||
light2.SetActive(!isOne && isDone == 1);
|
||||
}
|
||||
public void SetReceived()
|
||||
{
|
||||
int itemCount = itemData.Count;
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
items[i].SetReceived(true);
|
||||
}
|
||||
}
|
||||
public void PlayMove(int index)
|
||||
{
|
||||
rectTransform.DOKill();
|
||||
rectTransform.anchoredPosition = Vector3.down * rectTransform.rect.height;
|
||||
rectTransform.DOAnchorPosY(0, 0.5f).SetEase(Ease.Linear);
|
||||
//await Awaiters.Seconds(0.5f);
|
||||
//if (index == 0)
|
||||
//{
|
||||
// arrow.SetActive(false);
|
||||
//}
|
||||
}
|
||||
async void OnBuy()
|
||||
{
|
||||
if (isDone == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (isDone == 2)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_30"));
|
||||
}
|
||||
if (GContext.container.Resolve<PlayerShopData>().ChainPackData.index == dataIndex)
|
||||
{
|
||||
btn_buy.onClick.RemoveAllListeners();
|
||||
if (iAPItemList == null)
|
||||
{
|
||||
GContext.Publish(new ShowData(itemData, RewardType.Normal));
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemData);
|
||||
GContext.Publish(new ShowData());
|
||||
GContext.container.Resolve<PlayerShopData>().AddOpenChainGifIndex();
|
||||
OnBuySuccess?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.EventPack;
|
||||
shopBuyTypeData.ID = GContext.container.Resolve<PlayerShopData>().ChainPackData.ID;
|
||||
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(pack.DropID, shopBuyTypeData, iAPItemList, itemData, RewardType.Normal);
|
||||
if (Result)
|
||||
{
|
||||
OnBuySuccess?.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
btn_buy.onClick.AddListener(OnBuy);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupItem.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f3143a46a553b5498c706d3e0e36e1c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
107
Assets/Scripts/UI/Shop/GiftPopupPanel.cs
Normal file
107
Assets/Scripts/UI/Shop/GiftPopupPanel.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftPopupPanel : MonoBehaviour
|
||||
{
|
||||
protected GiftRewardAttached giftRewardAttached3;
|
||||
protected GiftRewardAttached giftRewardAttached4;
|
||||
protected Tables _tables;
|
||||
//Button btn_mask;
|
||||
protected Button btn_close;
|
||||
protected Button btn_buy;
|
||||
protected TMP_Text text_buy;
|
||||
|
||||
protected TMP_Text text_time;
|
||||
protected GameObject tag_more;
|
||||
protected TMP_Text text_best;
|
||||
protected TMP_Text Remaining;
|
||||
|
||||
protected Pack pack;
|
||||
protected IAPItemList iAPItemList;
|
||||
protected List<ItemData> itemDatas = new List<ItemData>();
|
||||
|
||||
protected int curRedirectID;
|
||||
private void Reset()
|
||||
{
|
||||
Awake();
|
||||
}
|
||||
protected virtual void Awake()
|
||||
{
|
||||
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
btn_buy = transform.Find("root/btn_buy/btn_green").GetComponent<Button>();
|
||||
text_buy = transform.Find("root/btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
text_time = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
||||
giftRewardAttached3 = transform.Find("root/reward_3").GetComponent<GiftRewardAttached>();
|
||||
giftRewardAttached4 = transform.Find("root/reward_4").GetComponent<GiftRewardAttached>();
|
||||
tag_more = transform.Find("root/tag_more").gameObject;
|
||||
text_best = transform.Find("root/tag_more/text_best").GetComponent<TMP_Text>();
|
||||
Remaining = transform.Find("root/text_remaining").GetComponent<TMP_Text>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
curRedirectID = GContext.container.Resolve<IFaceUIService>().curRedirectID;
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
btn_buy.onClick.AddListener(OnBuy);
|
||||
}
|
||||
|
||||
async void OnBuy()
|
||||
{
|
||||
btn_buy.enabled = false;
|
||||
if (iAPItemList == null)
|
||||
{
|
||||
GContext.Publish(new ShowData(itemDatas));
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemDatas);
|
||||
GContext.Publish(new ShowData());
|
||||
OnSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = GetShopBuyTypeData();
|
||||
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(pack.DropID, shopBuyTypeData, iAPItemList, itemDatas);
|
||||
if (Result)
|
||||
{
|
||||
OnBuySuccess();
|
||||
}
|
||||
}
|
||||
btn_buy.enabled = true;
|
||||
}
|
||||
protected virtual ShopBuyTypeData GetShopBuyTypeData()
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.ShopPackDailyBuy;
|
||||
return shopBuyTypeData;
|
||||
}
|
||||
protected virtual void OnSuccess()
|
||||
{
|
||||
|
||||
}
|
||||
protected virtual void OnBuySuccess()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void SetShowData()
|
||||
{
|
||||
if (itemDatas != null && itemDatas.Count > 0)
|
||||
{
|
||||
giftRewardAttached3.gameObject.SetActive(itemDatas.Count <= 3);
|
||||
giftRewardAttached4.gameObject.SetActive(itemDatas.Count > 3);
|
||||
if (itemDatas.Count <= 3)
|
||||
{
|
||||
giftRewardAttached3.SetData(itemDatas);
|
||||
}
|
||||
else
|
||||
{
|
||||
giftRewardAttached4.SetData(itemDatas);
|
||||
}
|
||||
}
|
||||
Remaining.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1", 1, 1);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75553f47323f2dd47b210d84ad4c8a12
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/Scripts/UI/Shop/GiftPopupPanel_10.cs
Normal file
36
Assets/Scripts/UI/Shop/GiftPopupPanel_10.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GiftPopupPanel_10 : MonoBehaviour
|
||||
{
|
||||
GiftPopupPanel_10_sub root_3rewards;
|
||||
GiftPopupPanel_10_sub root_4rewards;
|
||||
private void Awake()
|
||||
{
|
||||
root_3rewards = transform.Find("root/root_3rewards").GetComponent<GiftPopupPanel_10_sub>();
|
||||
root_4rewards = transform.Find("root/root_4rewards").GetComponent<GiftPopupPanel_10_sub>();
|
||||
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
int index = fishingEventData.GetPack1A1Index();
|
||||
if (index >= 2)
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_10);
|
||||
return;
|
||||
}
|
||||
EventPackManager eventPackDataRead = fishingEventData.Get1A1EventPackManager();
|
||||
if (eventPackDataRead == null)
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_10);
|
||||
return;
|
||||
}
|
||||
List<int> vipPackIds = eventPackDataRead.VIPPackList[fishingEventData.Pack1A1Data.vipLevel];
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
var pack1 = _tables.TbPack.GetOrDefault(vipPackIds[0]);
|
||||
var itemData1 = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(pack1.DropID);
|
||||
root_3rewards.gameObject.SetActive(itemData1.Count <= 3);
|
||||
root_4rewards.gameObject.SetActive(itemData1.Count > 3);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_10.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_10.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab7d6f15d470fdd4cbad72825e1b4b31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
167
Assets/Scripts/UI/Shop/GiftPopupPanel_10_sub.cs
Normal file
167
Assets/Scripts/UI/Shop/GiftPopupPanel_10_sub.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftPopupPanel_10_sub : MonoBehaviour
|
||||
{
|
||||
Button btn_close;
|
||||
TMP_Text text_time;
|
||||
Tables _tables;
|
||||
Transform rewardRoot1;
|
||||
List<RewardItemNew> items1 = new List<RewardItemNew>();
|
||||
List<ItemData> itemData1;
|
||||
Pack pack1;
|
||||
IAPItemList iAPItemList1;
|
||||
Button btn_buy1;
|
||||
TMP_Text text_buy1;
|
||||
GameObject done1;
|
||||
GameObject lockGo2;
|
||||
|
||||
Transform rewardRoot2;
|
||||
List<RewardItemNew> items2 = new List<RewardItemNew>();
|
||||
List<ItemData> itemData2;
|
||||
Pack pack2;
|
||||
//IAPItemList iAPItemList2;
|
||||
Button btn_buy2;
|
||||
//TMP_Text text_buy2;
|
||||
|
||||
FishingEventData fishingEventData;
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
text_time = transform.Find("text_time").GetComponent<TMP_Text>();
|
||||
|
||||
rewardRoot1 = transform.Find("gift1/Item/reward");
|
||||
int count = rewardRoot1.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
items1.Add(rewardRoot1.GetChild(i).GetComponent<RewardItemNew>());
|
||||
}
|
||||
btn_buy1 = transform.Find("gift1/Item/btn_buy/btn_green").GetComponent<Button>();
|
||||
text_buy1 = transform.Find("gift1/Item/btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
|
||||
rewardRoot2 = transform.Find("gift2/Item/reward");
|
||||
count = rewardRoot2.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
items2.Add(rewardRoot2.GetChild(i).GetComponent<RewardItemNew>());
|
||||
}
|
||||
btn_buy2 = transform.Find("gift2/Item/btn_buy/btn_green").GetComponent<Button>();
|
||||
//text_buy2 = transform.Find("gift2/Item/btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
|
||||
|
||||
done1 = transform.Find("gift1/Item/done").gameObject;
|
||||
lockGo2 = transform.Find("gift2/Item/btn_buy/btn_green/Ani_Container/p_text/lock").gameObject;
|
||||
|
||||
}
|
||||
protected void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
SetEndTime();
|
||||
SetData();
|
||||
btn_buy1.onClick.AddListener(OnBuy1);
|
||||
btn_buy2.onClick.AddListener(OnBuy2);
|
||||
}
|
||||
|
||||
void SetData()
|
||||
{
|
||||
int index = fishingEventData.GetPack1A1Index();
|
||||
if (index >= 2)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
EventPackManager eventPackDataRead = fishingEventData.Get1A1EventPackManager();
|
||||
if (eventPackDataRead == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<int> vipPackIds = eventPackDataRead.VIPPackList[fishingEventData.Pack1A1Data.vipLevel];
|
||||
done1.SetActive(index != 0);
|
||||
btn_buy1.gameObject.SetActive(index == 0);
|
||||
lockGo2.SetActive(index == 0);
|
||||
|
||||
pack1 = _tables.TbPack.GetOrDefault(vipPackIds[0]);
|
||||
iAPItemList1 = _tables.TbIAPItemList.GetOrDefault(pack1.IAPID);
|
||||
itemData1 = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(pack1.DropID);
|
||||
int itemCount = itemData1.Count;
|
||||
for (int i = 0; i < items1.Count; i++)
|
||||
{
|
||||
items1[i].gameObject.SetActive(i < itemCount);
|
||||
if (i < itemCount)
|
||||
{
|
||||
items1[i].SetData(itemData1[i]);
|
||||
items1[i].SetReceived(index != 0);
|
||||
}
|
||||
}
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList1);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
text_buy1.text = sKUDetailDataEvent.price;
|
||||
|
||||
pack2 = _tables.TbPack.GetOrDefault(vipPackIds[1]);
|
||||
//iAPItemList2 = _tables.TbIAPItemList.GetOrDefault(pack2.IAPID);
|
||||
itemData2 = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(pack2.DropID);
|
||||
itemCount = itemData2.Count;
|
||||
for (int i = 0; i < items2.Count; i++)
|
||||
{
|
||||
items2[i].gameObject.SetActive(i < itemCount);
|
||||
if (i < itemCount)
|
||||
{
|
||||
items2[i].SetData(itemData2[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
async void OnBuy1()
|
||||
{
|
||||
btn_buy1.enabled = false;
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.EventPack;
|
||||
shopBuyTypeData.ID = fishingEventData.Pack1A1Data.lastID;
|
||||
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(pack1.DropID, shopBuyTypeData, iAPItemList1, itemData1);
|
||||
if (Result)
|
||||
{
|
||||
//GContext.container.Resolve<FishingEventData>().SetPack1A1Index(1);
|
||||
SetData();
|
||||
}
|
||||
btn_buy1.enabled = true;
|
||||
}
|
||||
void OnBuy2()
|
||||
{
|
||||
if (fishingEventData.GetPack1A1Index() == 0)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_30"));
|
||||
return;
|
||||
}
|
||||
GContext.Publish(new ShowData(itemData2));
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemData2);
|
||||
GContext.Publish(new ShowData());
|
||||
GContext.container.Resolve<FishingEventData>().SetPack1A1Index(2);
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_10);
|
||||
}
|
||||
void SetEndTime()
|
||||
{
|
||||
DateTime endTime = fishingEventData.GetEvent1A1EndTime();
|
||||
TimeSpan all = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
double seconds = all.TotalSeconds;
|
||||
this.AttachTimer((float)seconds,
|
||||
() => { OnClickClose(); },
|
||||
(elapsed) =>
|
||||
{
|
||||
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
}, useRealTime: true);
|
||||
}
|
||||
void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_10);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_10_sub.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_10_sub.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdf7d4c06a628ad429934c371a35fe36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Scripts/UI/Shop/GiftPopupPanel_11.cs
Normal file
31
Assets/Scripts/UI/Shop/GiftPopupPanel_11.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GiftPopupPanel_11 : MonoBehaviour
|
||||
{
|
||||
GameObject root_3rewards;
|
||||
GameObject root_4rewards;
|
||||
private void Awake()
|
||||
{
|
||||
root_3rewards = transform.Find("root/root_3rewards").gameObject;
|
||||
root_4rewards = transform.Find("root/root_4rewards").gameObject;
|
||||
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
|
||||
EventPackManager eventPackDataRead = fishingEventData.Get1A2EventPackManager();
|
||||
if (eventPackDataRead == null)
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_11);
|
||||
return;
|
||||
}
|
||||
List<int> vipPackIds = eventPackDataRead.VIPPackList[fishingEventData.Pack1A2Data.vipLevel];
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
var pack1 = _tables.TbPack.GetOrDefault(vipPackIds[0]);
|
||||
var itemData1 = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(pack1.DropID);
|
||||
root_3rewards.gameObject.SetActive(itemData1.Count <= 3);
|
||||
root_4rewards.gameObject.SetActive(itemData1.Count > 3);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_11.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_11.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb1c228b9ee356c4cb27c04dea0fa3bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
138
Assets/Scripts/UI/Shop/GiftPopupPanel_11_sub.cs
Normal file
138
Assets/Scripts/UI/Shop/GiftPopupPanel_11_sub.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using System.Collections;
|
||||
|
||||
public class GiftPopupPanel_11_sub : MonoBehaviour
|
||||
{
|
||||
Button btn_close;
|
||||
TMP_Text text_time;
|
||||
List<GiftOneAddTwoItem> giftPopupItems = new List<GiftOneAddTwoItem>();
|
||||
GiftOneAddTwoItem giftOneAddTwoItem4;
|
||||
GiftOneAddTwoItem curItem;
|
||||
FishingEventData fishingEventData;
|
||||
IDisposable disposable;
|
||||
Animation ani;
|
||||
CanvasGroup canvasGroup;
|
||||
private void Awake()
|
||||
{
|
||||
fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
text_time = transform.Find("text_time").GetComponent<TMP_Text>();
|
||||
ani = GetComponent<Animation>();
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
giftPopupItems.Capacity = 3;
|
||||
for (int i = 2; i < 5; i++)
|
||||
{
|
||||
giftPopupItems.Add(transform.Find($"gift{i}/Item").GetComponent<GiftOneAddTwoItem>());
|
||||
}
|
||||
giftOneAddTwoItem4 = transform.Find("gift1/Item").GetComponent<GiftOneAddTwoItem>();
|
||||
disposable = GContext.OnEvent<RewardPanelClose>().Subscribe(OnRewardPanelClose);
|
||||
}
|
||||
protected void Start()
|
||||
{
|
||||
//btn_mask.onClick.AddListener(OnClickClose);
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
SetEndTime();
|
||||
SetData(false);
|
||||
}
|
||||
void OnBuySuccess()
|
||||
{
|
||||
//fishingEventData.SetPack1A2Index();
|
||||
curItem.SetReceived();
|
||||
}
|
||||
void OnRewardPanelClose(RewardPanelClose e)
|
||||
{
|
||||
SetData(true);
|
||||
}
|
||||
private void SetData(bool isPlay)
|
||||
{
|
||||
Tables tables = GContext.container.Resolve<Tables>();
|
||||
List<int> items = new List<int>();
|
||||
int curIndex = fishingEventData.GetPack1A2Index();
|
||||
EventPackManager eventPackManager = fishingEventData.Get1A2EventPackManager();
|
||||
List<int> packIDs = eventPackManager.VIPPackList[fishingEventData.Pack1A2Data.vipLevel];
|
||||
int startIndex = curIndex;
|
||||
Pack pack;
|
||||
if (curIndex > packIDs.Count - 3 && packIDs.Count >= 3)
|
||||
{
|
||||
startIndex = packIDs.Count - 3;
|
||||
}
|
||||
else if (isPlay)
|
||||
{
|
||||
pack = tables.TbPack.GetOrDefault(packIDs[startIndex - 1]);
|
||||
List<ItemData> itemDatas = fishingEventData.Get1A2ItemDatasBuyPack(pack.DropID);
|
||||
giftOneAddTwoItem4.SetData(OnBuySuccess, pack.DropID, pack.IAPID, 0, startIndex - 1, itemDatas);
|
||||
|
||||
//for (int i = 0; i < 3; i++)
|
||||
//{
|
||||
// giftPopupItems[i].PlayMove();
|
||||
//}
|
||||
//移动后重新设置数据
|
||||
StartCoroutine(PlayAni());
|
||||
}
|
||||
int isDone = 1;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (startIndex + i == curIndex)
|
||||
{
|
||||
isDone = 1;
|
||||
curItem = giftPopupItems[i];
|
||||
}
|
||||
else if (startIndex + i < curIndex)
|
||||
{
|
||||
isDone = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
isDone = 2;
|
||||
}
|
||||
if (startIndex + i >= packIDs.Count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pack = tables.TbPack.GetOrDefault(packIDs[startIndex + i]);
|
||||
List<ItemData> itemDatas = fishingEventData.Get1A2ItemDatasBuyPack(pack.DropID);
|
||||
giftPopupItems[i].SetData(OnBuySuccess, pack.DropID, pack.IAPID, isDone, startIndex + i, itemDatas);
|
||||
}
|
||||
}
|
||||
IEnumerator PlayAni()
|
||||
{
|
||||
ani.Play("4reward_change");
|
||||
canvasGroup.blocksRaycasts = false;
|
||||
yield return new WaitForSeconds(1f);
|
||||
canvasGroup.blocksRaycasts = true;
|
||||
yield return new WaitForSeconds(1.6f);
|
||||
ani.Play("4reward_loop");
|
||||
}
|
||||
void SetEndTime()
|
||||
{
|
||||
DateTime endTime = fishingEventData.GetEvent1A2EndTime();
|
||||
TimeSpan all = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
double seconds = all.TotalSeconds;
|
||||
this.AttachTimer((float)seconds,
|
||||
() => { OnClickClose(); },
|
||||
(elapsed) =>
|
||||
{
|
||||
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
}, useRealTime: true);
|
||||
}
|
||||
void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_11);
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_11_sub.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_11_sub.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6f2c6032430571408098605c0b36b43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
105
Assets/Scripts/UI/Shop/GiftPopupPanel_2.cs
Normal file
105
Assets/Scripts/UI/Shop/GiftPopupPanel_2.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftPopupPanel_2 : MonoBehaviour
|
||||
{
|
||||
//public Button btn_mask;
|
||||
public Button btn_close;
|
||||
public TMP_Text text_time;
|
||||
List<GiftPopupItem> giftPopupItems = new List<GiftPopupItem>();
|
||||
GiftPopupItem curData;
|
||||
private void Awake()
|
||||
{
|
||||
//btn_mask = transform.Find("mask").GetComponent<Button>();
|
||||
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
text_time = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
||||
giftPopupItems.Capacity = 3;
|
||||
for (int i = 1; i < 4; i++)
|
||||
{
|
||||
giftPopupItems.Add(transform.Find($"root/Content/gift{i}/Item").GetComponent<GiftPopupItem>());
|
||||
}
|
||||
|
||||
}
|
||||
protected void Start()
|
||||
{
|
||||
//btn_mask.onClick.AddListener(OnClickClose);
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
SetEndTime();
|
||||
SetData();
|
||||
}
|
||||
async void OnBuySuccess()
|
||||
{
|
||||
//GContext.container.Resolve<PlayerShopData>().AddOpenChainGifIndex();
|
||||
curData.SetReceived();
|
||||
await Awaiters.Seconds(0.5f);
|
||||
SetData();
|
||||
}
|
||||
private void SetData()
|
||||
{
|
||||
List<int> items = new List<int>();
|
||||
PlayerShopData playerShopData = GContext.container.Resolve<PlayerShopData>();
|
||||
int curIndex = playerShopData.ChainPackData.index;
|
||||
int vipLevel = playerShopData.ChainPackData.lastID;
|
||||
EventPackManager chainGiftPack = playerShopData.chainPackM;
|
||||
if (chainGiftPack == null)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
List<int> packIDs = chainGiftPack.VIPPackList[vipLevel];
|
||||
int startIndex = curIndex;
|
||||
if (curIndex > packIDs.Count - 3)
|
||||
{
|
||||
startIndex = packIDs.Count - 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
giftPopupItems[i].PlayMove(i);
|
||||
}
|
||||
}
|
||||
int isDone = 1;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (startIndex + i == curIndex)
|
||||
{
|
||||
isDone = 1;
|
||||
curData = giftPopupItems[i];
|
||||
}
|
||||
else if (startIndex + i < curIndex)
|
||||
{
|
||||
isDone = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
isDone = 2;
|
||||
}
|
||||
giftPopupItems[i].SetData(OnBuySuccess, packIDs[startIndex + i], isDone, startIndex + i, i);
|
||||
}
|
||||
}
|
||||
void SetEndTime()
|
||||
{
|
||||
DateTime endTime = GContext.container.Resolve<PlayerShopData>().GetChainEndTime();
|
||||
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
double seconds = now.TotalSeconds;
|
||||
this.AttachTimer((float)seconds,
|
||||
() => { OnClickClose(); },
|
||||
(elapsed) =>
|
||||
{
|
||||
now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
}, useRealTime: true);
|
||||
}
|
||||
void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(gameObject.name);
|
||||
//GContext.container.Resolve<IFaceUIService>().ShowFaceUI();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_2.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_2.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f99bcf9e3a14634f90d87d83f08e956
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
147
Assets/Scripts/UI/Shop/GiftPopupPanel_3.cs
Normal file
147
Assets/Scripts/UI/Shop/GiftPopupPanel_3.cs
Normal file
@@ -0,0 +1,147 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftPopupPanel_3 : GiftPopupPanel
|
||||
{
|
||||
string Type = "WheelPack";
|
||||
GameObject Advert;
|
||||
Button btn_advert;
|
||||
GameObject soldout;
|
||||
|
||||
WheelPack wheelPack;
|
||||
FishingEventData _fishingEventData;
|
||||
IDisposable ads;
|
||||
|
||||
private AdvertPopupType _curOpenAdType = AdvertPopupType.None;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
soldout = transform.Find("root/soldout").gameObject;
|
||||
Advert = transform.Find("root/advert").gameObject;
|
||||
btn_advert = transform.Find("root/advert/btn_advert").GetComponent<Button>();
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
wheelPack = _tables.TbWheelPack[1];
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
SetAdvertState();
|
||||
btn_advert.onClick.AddListener(OnWatchClick);
|
||||
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
SetData();
|
||||
}
|
||||
|
||||
public void SetData()
|
||||
{
|
||||
int vipLevel = GContext.container.Resolve<TriggerPackData>().GetVIPLevel(Type);
|
||||
int buyCount = GContext.container.Resolve<PlayerShopData>().GetShopPackBuyCount(Type);
|
||||
var PackList = wheelPack.PackList[vipLevel];
|
||||
if (buyCount >= PackList.Count)
|
||||
{
|
||||
buyCount = PackList.Count - 1;
|
||||
}
|
||||
pack = _tables.TbPack.GetOrDefault(wheelPack.PackList[vipLevel][buyCount]);
|
||||
iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID);
|
||||
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(pack.DropID);
|
||||
SetShowData();
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
text_buy.text = sKUDetailDataEvent.price;
|
||||
tag_more.SetActive(pack.Rebate > 0.0001);
|
||||
text_best.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", pack.Rebate * 100);
|
||||
SetState();
|
||||
}
|
||||
|
||||
protected override ShopBuyTypeData GetShopBuyTypeData()
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.ShopPackDailyBuy;
|
||||
shopBuyTypeData.key = Type;
|
||||
shopBuyTypeData.endDay = ZZTimeHelper.UtcNow().UtcNowOffset().Day;
|
||||
return shopBuyTypeData;
|
||||
}
|
||||
protected override void OnSuccess()
|
||||
{
|
||||
GContext.container.Resolve<PlayerShopData>().AddShopPackDailyBuyCount(Type);
|
||||
//GContext.container.Resolve<PlayerShopData>().AddShopPackDailyBuyCount(pack.ID, 1);
|
||||
GContext.container.Resolve<TriggerPackData>().SetVIPLevel(Type, wheelPack.VIPBonusForNextType);
|
||||
//SetState();
|
||||
OnClickClose();
|
||||
}
|
||||
protected override void OnBuySuccess()
|
||||
{
|
||||
//GContext.container.Resolve<PlayerShopData>().AddShopPackDailyBuyCount(Type);
|
||||
//GContext.container.Resolve<PlayerShopData>().AddShopPackDailyBuyCount(pack.ID, 1);
|
||||
GContext.container.Resolve<TriggerPackData>().SetVIPLevel(Type, wheelPack.VIPBonusForNextType);
|
||||
//SetState();
|
||||
OnClickClose();
|
||||
}
|
||||
void SetState()
|
||||
{
|
||||
int remainder = wheelPack.MaxPurchaseCount - GContext.container.Resolve<PlayerShopData>().GetShopPackBuyCount(Type);
|
||||
if (remainder <= 0)
|
||||
{
|
||||
remainder = 0;
|
||||
}
|
||||
Remaining.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1", remainder, wheelPack.MaxPurchaseCount);
|
||||
soldout.SetActive(remainder <= 0);
|
||||
btn_buy.gameObject.SetActive(remainder > 0);
|
||||
}
|
||||
protected void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_3);
|
||||
}
|
||||
|
||||
private void OnWatchClick()
|
||||
{
|
||||
btn_advert.enabled = false;
|
||||
AdsDispose();
|
||||
ads = GContext.OnEvent<AdsResult>().Subscribe(SetResult);
|
||||
_curOpenAdType = AdvertPopupType.Turntable;
|
||||
GContext.container.Resolve<IAdsService>().ShowRewarded(AdvertPopupType.Turntable);
|
||||
}
|
||||
void SetResult(AdsResult adsResult)
|
||||
{
|
||||
if (adsResult.Result == 0 && adsResult.Type == _curOpenAdType)
|
||||
{
|
||||
OnSucceed();
|
||||
}
|
||||
AdsDispose();
|
||||
btn_advert.enabled = true;
|
||||
}
|
||||
void AdsDispose()
|
||||
{
|
||||
if (ads != null)
|
||||
{
|
||||
_curOpenAdType = AdvertPopupType.None;
|
||||
ads.Dispose();
|
||||
ads = null;
|
||||
}
|
||||
}
|
||||
|
||||
void OnSucceed()
|
||||
{
|
||||
GContext.container.Resolve<PlayerShopData>().AddAdvertCount(_fishingEventData.wheelInit.ID);
|
||||
GContext.container.Resolve<PlayerItemData>().AddItemByDrop(1000001);
|
||||
GContext.Publish(new ShowData());
|
||||
SetAdvertState();
|
||||
}
|
||||
void SetAdvertState()
|
||||
{
|
||||
int count = GContext.container.Resolve<PlayerShopData>().GetAdvertCount(_fishingEventData.wheelInit.ID);
|
||||
int WheelIAADailyCount = _tables.TbGlobalConfig.WheelIAADailyCount;
|
||||
Advert.SetActive(count < WheelIAADailyCount);
|
||||
}
|
||||
protected void OnDestroy()
|
||||
{
|
||||
AdsDispose();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_3.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_3.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ad48c9db2542eb45a044c1937462bd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
79
Assets/Scripts/UI/Shop/GiftPopupPanel_5.cs
Normal file
79
Assets/Scripts/UI/Shop/GiftPopupPanel_5.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftPopupPanel_5 : GiftPopupPanel_Base
|
||||
{
|
||||
protected override int Type => 53;
|
||||
protected GiftRewardAttached giftRewardAttached3;
|
||||
protected GiftRewardAttached giftRewardAttached4;
|
||||
|
||||
Image bgImage1;
|
||||
|
||||
BgDownload bgDownload;
|
||||
protected override void InitPanel()
|
||||
{
|
||||
giftRewardAttached3 = transform.Find("root/reward_3").GetComponent<GiftRewardAttached>();
|
||||
giftRewardAttached4 = transform.Find("root/reward_4").GetComponent<GiftRewardAttached>();
|
||||
bgDownload = transform.Find("root/download").GetComponent<BgDownload>();
|
||||
|
||||
bgImage1 = transform.Find("root/mask_bg2/bg").GetComponent<Image>();
|
||||
imageData = new ShowImageData(bgImage1);
|
||||
}
|
||||
protected override void SetShowData()
|
||||
{
|
||||
var Param = packManager.Param;
|
||||
if (Param.Count > 1)
|
||||
{
|
||||
LoadBg();
|
||||
}
|
||||
if (itemDatas != null && itemDatas.Count > 0)
|
||||
{
|
||||
giftRewardAttached3.gameObject.SetActive(itemDatas.Count <= 3);
|
||||
giftRewardAttached4.gameObject.SetActive(itemDatas.Count > 3);
|
||||
if (itemDatas.Count <= 3)
|
||||
{
|
||||
giftRewardAttached3.SetData(itemDatas);
|
||||
}
|
||||
else
|
||||
{
|
||||
giftRewardAttached4.SetData(itemDatas);
|
||||
}
|
||||
}
|
||||
Remaining.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1", 1, 1);
|
||||
}
|
||||
|
||||
bool isLoading = false;
|
||||
ShowImageData imageData;
|
||||
async void LoadBg()
|
||||
{
|
||||
isLoading = true;
|
||||
ShowLoad();
|
||||
imageData.SetName(packManager.Param[1]);
|
||||
await GContext.container.Resolve<IUIService>().SetImageSprite(imageData);
|
||||
if (bgImage1 != null && packManager != null)
|
||||
{
|
||||
if (isLoading && imageData.image.sprite != null && imageData.image.sprite.name == packManager.Param[1])
|
||||
{
|
||||
isLoading = false;
|
||||
bgDownload.OnLoadSucceed();
|
||||
}
|
||||
}
|
||||
}
|
||||
async void ShowLoad()
|
||||
{
|
||||
bgDownload.gameObject.SetActive(false);
|
||||
await Awaiters.Seconds(1);
|
||||
if (isLoading)
|
||||
{
|
||||
bgDownload.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.MapPackPanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_5.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_5.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d87d1d22d3d348240b4fcec12de3cb8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Assets/Scripts/UI/Shop/GiftPopupPanel_6.cs
Normal file
49
Assets/Scripts/UI/Shop/GiftPopupPanel_6.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
public class GiftPopupPanelEnergyEvent
|
||||
{
|
||||
public bool isClose;
|
||||
}
|
||||
public class GiftPopupPanel_6 : GiftPopupPanel_Energy
|
||||
{
|
||||
protected override int Type => 1;
|
||||
|
||||
protected override void OnClickClose()
|
||||
{
|
||||
base.OnClickClose();
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_6);
|
||||
}
|
||||
|
||||
protected override void SetPack()
|
||||
{
|
||||
int vipLevel = curTriggerPackState.vipLevel;
|
||||
int buyCount = GContext.container.Resolve<PlayerShopData>().GetShopPackBuyCount(curTriggerPackState.lastID);
|
||||
List<int> VIPPackList = packManager.VIPPackList[vipLevel];
|
||||
if (buyCount > VIPPackList.Count)
|
||||
{
|
||||
buyCount = VIPPackList.Count;
|
||||
}
|
||||
else if (buyCount <= 0)
|
||||
{
|
||||
buyCount = 1;
|
||||
}
|
||||
int id = VIPPackList[buyCount - 1];
|
||||
|
||||
MMTService mMTService = GContext.container.Resolve<MMTService>();
|
||||
|
||||
|
||||
if (mMTService.mmt && id == 4000002)
|
||||
{
|
||||
id = 4000003;
|
||||
}
|
||||
Debug.Log($"[MMBeginnerPack] packID == {id}");
|
||||
pack = _tables.TbPack.GetOrDefault(id);
|
||||
if (pack == null)
|
||||
{
|
||||
Debug.LogError($"[MMBeginnerPack] pack is null, id == {id}");
|
||||
pack = _tables.TbPack.GetOrDefault(4000002);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_6.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_6.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4f1cec6aeacdcb4da768efc3c936d6f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
111
Assets/Scripts/UI/Shop/GiftPopupPanel_7.cs
Normal file
111
Assets/Scripts/UI/Shop/GiftPopupPanel_7.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class GiftPopupPanel_7 : GiftPopupPanel
|
||||
{
|
||||
protected string Type = "CollectingTarget";
|
||||
FishingEventData _fishingEventData;
|
||||
List<List<int>> VIPPackList;
|
||||
int allCount = 0;
|
||||
int buyCount = 0;
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
VIPPackList = _fishingEventData.VIPPackList;
|
||||
base.Start();
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
Init();
|
||||
SetTriggerPackTimer();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
SetData();
|
||||
}
|
||||
|
||||
public void SetData()
|
||||
{
|
||||
int vipLevel = GContext.container.Resolve<TriggerPackData>().GetVIPLevel(Type);
|
||||
if (VIPPackList != null && VIPPackList.Count > vipLevel)
|
||||
{
|
||||
allCount = VIPPackList[vipLevel].Count;
|
||||
buyCount = GContext.container.Resolve<FishingEventData>().GetCollectingTargetCount();
|
||||
if (buyCount >= allCount)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
pack = _tables.TbPack.GetOrDefault(VIPPackList[vipLevel][buyCount]);
|
||||
|
||||
iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID);
|
||||
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(pack.DropID);
|
||||
SetShowData();
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
text_buy.text = sKUDetailDataEvent.price;
|
||||
tag_more.SetActive(pack.Rebate > 0.0001);
|
||||
text_best.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", pack.Rebate * 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnClickClose();
|
||||
}
|
||||
}
|
||||
protected override ShopBuyTypeData GetShopBuyTypeData()
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.EventPack;
|
||||
shopBuyTypeData.ID = _fishingEventData.GetEtDropAfterDropDic(0);
|
||||
return shopBuyTypeData;
|
||||
}
|
||||
protected override async void OnSuccess()
|
||||
{
|
||||
GContext.container.Resolve<FishingEventData>().AddCollectingTargetCount();
|
||||
OnClickClose();
|
||||
await System.Threading.Tasks.Task.Delay(1000);
|
||||
GContext.container.Resolve<FishingEventData>().ShowCTGift();
|
||||
}
|
||||
protected override async void OnBuySuccess()
|
||||
{
|
||||
OnClickClose();
|
||||
await System.Threading.Tasks.Task.Delay(1000);
|
||||
GContext.container.Resolve<FishingEventData>().ShowCTGift();
|
||||
}
|
||||
|
||||
public async void SetTriggerPackTimer()
|
||||
{
|
||||
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
DateTime dateTime1 = dateTime.AddDays(1);
|
||||
DateTime endTime = _fishingEventData.GetCollectingTargetEndTime();
|
||||
while (this != null && dateTime.Ticks < dateTime1.Ticks)
|
||||
{
|
||||
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
OnClickClose();
|
||||
}
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
await System.Threading.Tasks.Task.Delay(1000);
|
||||
dateTime.AddSeconds(1);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetShowData()
|
||||
{
|
||||
base.SetShowData();
|
||||
Remaining.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1", allCount - buyCount, allCount);
|
||||
}
|
||||
|
||||
|
||||
protected void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_7);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_7.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_7.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d78af28ee5a863649a10a1eb60fbfba9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Scripts/UI/Shop/GiftPopupPanel_8.cs
Normal file
29
Assets/Scripts/UI/Shop/GiftPopupPanel_8.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
|
||||
public class GiftPopupPanel_8 : GiftPopupPanel_Energy
|
||||
{
|
||||
protected override int Type => 4;
|
||||
protected override void SetPack()
|
||||
{
|
||||
int vipLevel = GContext.container.Resolve<TriggerPackData>().GetVIPLevel(Type);
|
||||
int packIDA = packManager.VIPPackList[vipLevel][0];
|
||||
EnergyDef energyDef = _tables.TbEnergyDef.DataList[GContext.container.Resolve<PlayerData>().magnification];
|
||||
int packIDB = energyDef.PackID;
|
||||
if (packIDA > packIDB + 2)
|
||||
{
|
||||
packIDA = packIDB + 2;
|
||||
}
|
||||
else if (packIDA < packIDB)
|
||||
{
|
||||
packIDA = packIDB;
|
||||
}
|
||||
pack = _tables.TbPack.GetOrDefault(packIDA);
|
||||
}
|
||||
protected override void OnClickClose()
|
||||
{
|
||||
base.OnClickClose();
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_8);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_8.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_8.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9c3182355cd29241914ed48cf0187ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
101
Assets/Scripts/UI/Shop/GiftPopupPanel_9.cs
Normal file
101
Assets/Scripts/UI/Shop/GiftPopupPanel_9.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class GiftPopupPanel_9 : MonoBehaviour
|
||||
{
|
||||
private List<int> _VIPList;//correct vip list of the current pack
|
||||
private EventPackData _epd;
|
||||
private FishingEvent _currentEvent;
|
||||
private Tables _tables;
|
||||
private Button closeBtn;
|
||||
private Button[] buyBtns;
|
||||
private TMPro.TMP_Text[] buyTexts;
|
||||
private List<List<RewardItemNew>> rewardItems = new List<List<RewardItemNew>>();
|
||||
private PlayerItemData _playerItemData;
|
||||
private IAPItemList[] iaps;
|
||||
private Pack[] packs;
|
||||
private List<List<ItemData>> itemDataLists;
|
||||
protected void Start()
|
||||
{
|
||||
_epd = GContext.container.Resolve<EventPackData>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
_currentEvent = _tables.TbFishingEvent.DataMap[_epd.CurrentEventID];
|
||||
closeBtn = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
buyBtns = new Button[3];
|
||||
iaps = new IAPItemList[3];
|
||||
packs = new Pack[3];
|
||||
itemDataLists = new List<List<ItemData>>();
|
||||
if (closeBtn == null)
|
||||
Debug.LogWarning($"Not close button found in {gameObject}.");
|
||||
else
|
||||
closeBtn.onClick.AddListener(OnClickClose);
|
||||
if (!_epd.IsActive)
|
||||
OnClickClose();
|
||||
List<int> VIPDrops = _tables.TbEventPackManager.DataMap[_currentEvent.RedirectID]
|
||||
.VIPPackList[_epd.VIPLvlWhenEventActivated];
|
||||
buyBtns[0] = transform.Find("root/gift1/Item/btn_buy/btn_green").GetComponent<Button>();
|
||||
buyBtns[1] = transform.Find("root/gift2/Item/btn_buy/btn_green").GetComponent<Button>();
|
||||
buyBtns[2] = transform.Find("root/gift3/Item/btn_buy/btn_green").GetComponent<Button>();
|
||||
buyBtns[0].onClick.AddListener(async () => await OnClickBuy(0));
|
||||
buyBtns[1].onClick.AddListener(async () => await OnClickBuy(1));
|
||||
buyBtns[2].onClick.AddListener(async () => await OnClickBuy(2));
|
||||
for (int i = 0; i < VIPDrops.Count; i++)
|
||||
{
|
||||
int packIAP = _tables.TbPack.DataMap[VIPDrops[i]].IAPID;
|
||||
packs[i] = _tables.TbPack.DataMap[VIPDrops[i]];
|
||||
iaps[i] = _tables.TbIAPItemList.GetOrDefault(packIAP);
|
||||
SKUDetailDataEvent sdde = new SKUDetailDataEvent(iaps[i]);
|
||||
GContext.Publish(sdde);
|
||||
buyBtns[i].gameObject.transform.Find("Ani_Container/p_text")
|
||||
.GetComponent<TMPro.TMP_Text>().text = sdde.price;
|
||||
}
|
||||
//Show reward item Icons and quantities
|
||||
Transform[] rewards = new Transform[3];
|
||||
rewards[0] = transform.Find("root/gift1/Item/reward/");
|
||||
rewards[1] = transform.Find("root/gift2/Item/reward/");
|
||||
rewards[2] = transform.Find("root/gift3/Item/reward/");
|
||||
rewardItems = new List<List<RewardItemNew>>();
|
||||
for (int i = 0; i < rewards.Length; i++)
|
||||
{
|
||||
rewardItems.Add(rewards[i].GetComponentsInChildren<RewardItemNew>().ToList());
|
||||
itemDataLists.Add(_playerItemData.GetItemDataByDropId(VIPDrops[i]));
|
||||
for (int j = 0; j < rewardItems[i].Count; j++)
|
||||
rewardItems[i][j].SetData(itemDataLists[i][j], abbr: true);
|
||||
}
|
||||
|
||||
//Update time
|
||||
transform.Find("root/text_time").GetComponent<TMPro.TMP_Text>().text = GetRemainingTime();
|
||||
}
|
||||
private async System.Threading.Tasks.Task OnClickBuy(int idx)
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.EventPack;
|
||||
shopBuyTypeData.ID = _epd.CurrentEventID;
|
||||
bool res = await GContext.container.Resolve<PlayerShopData>()
|
||||
.OnBuy(packs[idx].DropID, shopBuyTypeData, iaps[idx], itemDataLists[idx]);
|
||||
if (res)
|
||||
{
|
||||
foreach (Button b in buyBtns)
|
||||
{
|
||||
b.onClick.RemoveAllListeners();
|
||||
}
|
||||
//_epd.AddPurchaceCount();
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_9);
|
||||
}
|
||||
}
|
||||
private string GetRemainingTime()
|
||||
{
|
||||
TimeSpan ts = DateTime.Parse((_currentEvent.TimeDefinition as LimitedTime).EndTime) - ZZTimeHelper.UtcNow();
|
||||
return ConvertTools.ConvertTime2(ts);
|
||||
}
|
||||
private void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftPopupPanel_9);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_9.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_9.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca74ba06af838b844893bc6ab3242552
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
297
Assets/Scripts/UI/Shop/GiftPopupPanel_Base.cs
Normal file
297
Assets/Scripts/UI/Shop/GiftPopupPanel_Base.cs
Normal file
@@ -0,0 +1,297 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftPopupPanel_Base : MonoBehaviour
|
||||
{
|
||||
Tables _tables;
|
||||
//Button btn_mask;
|
||||
Button btn_close;
|
||||
Button btn_buy;
|
||||
TMP_Text text_buy;
|
||||
|
||||
TMP_Text text_time;
|
||||
GameObject tag_more;
|
||||
TMP_Text text_best;
|
||||
protected TMP_Text Remaining;
|
||||
|
||||
GameObject ImageItem;
|
||||
List<GameObject> ImageItemList = new List<GameObject>();
|
||||
List<GameObject> selectGos = new List<GameObject>();
|
||||
GameObject SlidingRoot;
|
||||
Button btn_left;
|
||||
Button btn_right;
|
||||
GameObject btn_left_icon;
|
||||
GameObject btn_left_icon_gray;
|
||||
GameObject btn_right_icon;
|
||||
GameObject btn_right_icon_gray;
|
||||
|
||||
protected TriggerPackManager packManager;
|
||||
Pack pack;
|
||||
IAPItemList iAPItemList;
|
||||
protected List<ItemData> itemDatas = new List<ItemData>();
|
||||
protected TriggerPackBuyData curTriggerPackState;
|
||||
|
||||
List<TriggerPackBuyData> triggerPackDic;
|
||||
int index = 0;
|
||||
int allCount = 0;
|
||||
int curRedirectID;
|
||||
protected virtual int Type { get; }
|
||||
private void Awake()
|
||||
{
|
||||
curRedirectID = GContext.container.Resolve<IFaceUIService>().curRedirectID;
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
//btn_mask = transform.Find("mask").GetComponent<Button>();
|
||||
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
btn_buy = transform.Find("root/btn_buy/btn_green").GetComponent<Button>();
|
||||
text_buy = transform.Find("root/btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
text_time = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
||||
|
||||
tag_more = transform.Find("root/tag_more").gameObject;
|
||||
text_best = transform.Find("root/tag_more/text_best").GetComponent<TMP_Text>();
|
||||
Remaining = transform.Find("root/text_remaining").GetComponent<TMP_Text>();
|
||||
|
||||
ImageItem = transform.Find("root/SlidingRoot/Sliding/ImageItem").gameObject;
|
||||
ImageItem.SetActive(false);
|
||||
|
||||
SlidingRoot = transform.Find("root/SlidingRoot").gameObject;
|
||||
btn_left = transform.Find("root/SlidingRoot/btn_arrow_left").GetComponent<Button>();
|
||||
btn_right = transform.Find("root/SlidingRoot/btn_arrow_right").GetComponent<Button>();
|
||||
btn_left_icon = transform.Find("root/SlidingRoot/btn_arrow_left/icon").gameObject;
|
||||
btn_left_icon_gray = transform.Find("root/SlidingRoot/btn_arrow_left/icon_gray").gameObject;
|
||||
btn_right_icon = transform.Find("root/SlidingRoot/btn_arrow_right/icon").gameObject;
|
||||
btn_right_icon_gray = transform.Find("root/SlidingRoot/btn_arrow_right/icon_gray").gameObject;
|
||||
InitPanel();
|
||||
}
|
||||
protected virtual void InitPanel()
|
||||
{
|
||||
}
|
||||
protected void Start()
|
||||
{
|
||||
triggerPackDic = GContext.container.Resolve<TriggerPackData>().GetTriggerPackList(Type);
|
||||
if (triggerPackDic.Count <= 0)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
triggerPackDic.Sort((a, b) => a.time.CompareTo(b.time));
|
||||
index = triggerPackDic.Count - 1;
|
||||
if (curRedirectID > 0)
|
||||
{
|
||||
for (int i = 0; i < triggerPackDic.Count; i++)
|
||||
{
|
||||
if (triggerPackDic[i].ID == curRedirectID)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
btn_left.onClick.AddListener(OnLeftClick);
|
||||
btn_right.onClick.AddListener(OnRightClick);
|
||||
//btn_mask.onClick.AddListener(OnClickClose);
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
btn_buy.onClick.AddListener(OnBuy);
|
||||
SetTriggerPackTimer();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
allCount = triggerPackDic.Count;
|
||||
if (allCount <= 0)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
if (index >= allCount)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
SlidingRoot.SetActive(allCount > 1);
|
||||
int curCount = ImageItemList.Count;
|
||||
if (curCount < allCount)
|
||||
{
|
||||
for (int i = curCount; i < allCount; i++)
|
||||
{
|
||||
GameObject go = Instantiate(ImageItem, ImageItem.transform.parent);
|
||||
go.SetActive(true);
|
||||
selectGos.Add(go.transform.Find("Select").gameObject);
|
||||
ImageItemList.Add(go);
|
||||
}
|
||||
}
|
||||
else if (curCount > allCount)
|
||||
{
|
||||
for (int i = allCount; i < curCount; i++)
|
||||
{
|
||||
ImageItemList[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
SetData();
|
||||
}
|
||||
void SetSelect()
|
||||
{
|
||||
for (int i = 0; i < selectGos.Count; i++)
|
||||
{
|
||||
selectGos[i].SetActive(i == index);
|
||||
}
|
||||
btn_left_icon.SetActive(index > 0);
|
||||
btn_left_icon_gray.SetActive(index <= 0);
|
||||
btn_right_icon.SetActive(index < allCount - 1);
|
||||
btn_right_icon_gray.SetActive(index >= allCount - 1);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (allCount > 1)
|
||||
{
|
||||
//左右滑动屏幕一半距离触发OnLeftClick或OnRightClick
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
OnBeginDrag();
|
||||
}
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
OnEndDrag();
|
||||
}
|
||||
}
|
||||
}
|
||||
float beginDragPosX = 0;
|
||||
void OnBeginDrag()
|
||||
{
|
||||
beginDragPosX = Input.mousePosition.x;
|
||||
}
|
||||
void OnEndDrag()
|
||||
{
|
||||
//滑动屏幕一半距离触发OnLeftClick或OnRightClick
|
||||
if (Mathf.Abs(Input.mousePosition.x - beginDragPosX) > Screen.width / 4)
|
||||
{
|
||||
if (Input.mousePosition.x > beginDragPosX)
|
||||
{
|
||||
OnLeftClick();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnRightClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnLeftClick()
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
index--;
|
||||
SetData();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnRightClick()
|
||||
{
|
||||
if (index < allCount - 1)
|
||||
{
|
||||
index++;
|
||||
SetData();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData()
|
||||
{
|
||||
if (allCount > 1)
|
||||
{
|
||||
SetSelect();
|
||||
}
|
||||
curTriggerPackState = triggerPackDic[index];
|
||||
int id = curTriggerPackState.ID;
|
||||
packManager = _tables.TbTriggerPackManager.GetOrDefault(id);
|
||||
int vipLevel = curTriggerPackState.vipLevel;
|
||||
int count = packManager.VIPPackList[vipLevel].Count;
|
||||
int buyCount = curTriggerPackState.index;
|
||||
if (buyCount >= count)
|
||||
{
|
||||
buyCount = count - 1;
|
||||
}
|
||||
pack = _tables.TbPack.GetOrDefault(packManager.VIPPackList[vipLevel][buyCount]);
|
||||
iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID);
|
||||
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(pack.DropID, curTriggerPackState.mapID);
|
||||
SetShowData();
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
text_buy.text = sKUDetailDataEvent.price;
|
||||
tag_more.SetActive(pack.Rebate > 0.0001);
|
||||
text_best.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", pack.Rebate * 100);
|
||||
//Remaining.gameObject.SetActive(false);
|
||||
TimeSpan now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(curTriggerPackState);
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
triggerPackDic.Remove(curTriggerPackState);
|
||||
Init();
|
||||
}
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
}
|
||||
protected virtual void SetShowData()
|
||||
{
|
||||
}
|
||||
|
||||
async void OnBuy()
|
||||
{
|
||||
btn_buy.enabled = false;
|
||||
if (iAPItemList == null)
|
||||
{
|
||||
GContext.Publish(new ShowData(itemDatas, RewardType.Normal));
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemDatas);
|
||||
GContext.Publish(new ShowData());
|
||||
GContext.container.Resolve<TriggerPackData>().AddTriggerPackCount(packManager.ID);
|
||||
OnBuySuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.TriggerPack;
|
||||
shopBuyTypeData.ID = packManager.ID;
|
||||
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(pack.DropID, shopBuyTypeData, iAPItemList, itemDatas);
|
||||
if (Result)
|
||||
{
|
||||
OnBuySuccess();
|
||||
}
|
||||
}
|
||||
btn_buy.enabled = true;
|
||||
}
|
||||
void OnBuySuccess()
|
||||
{
|
||||
//GContext.container.Resolve<TriggerPackData>().AddTriggerPackCount(packManager.ID);
|
||||
triggerPackDic.Remove(curTriggerPackState);
|
||||
Init();
|
||||
}
|
||||
protected virtual void OnClickClose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async void SetTriggerPackTimer()
|
||||
{
|
||||
Init();
|
||||
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
DateTime dateTime1 = dateTime.AddDays(1).Date;
|
||||
while (this != null && dateTime.Ticks < dateTime1.Ticks)
|
||||
{
|
||||
TimeSpan now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(curTriggerPackState);
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
triggerPackDic.Remove(curTriggerPackState);
|
||||
Init();
|
||||
}
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
await System.Threading.Tasks.Task.Delay(1000);
|
||||
dateTime.AddSeconds(1);
|
||||
}
|
||||
if (this != null && dateTime.Ticks >= dateTime1.Ticks)
|
||||
{
|
||||
SetTriggerPackTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_Base.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_Base.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4b9199764f2c494db60876327d2d74a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
157
Assets/Scripts/UI/Shop/GiftPopupPanel_Energy.cs
Normal file
157
Assets/Scripts/UI/Shop/GiftPopupPanel_Energy.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class GiftPopupPanel_Energy : GiftPopupPanel
|
||||
{
|
||||
protected virtual int Type => 1;
|
||||
protected TriggerPackManager packManager;
|
||||
protected TriggerPackBuyData curTriggerPackState;
|
||||
|
||||
List<TriggerPackBuyData> triggerPackDic;
|
||||
int index = 0;
|
||||
int allCount = 0;
|
||||
|
||||
TMP_Text txt_packName;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
Transform text_title = transform.Find("root/text_title");
|
||||
txt_packName = text_title?.GetComponent<TMP_Text>();
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
triggerPackDic = GContext.container.Resolve<TriggerPackData>().GetTriggerPackList(Type);
|
||||
if (triggerPackDic.Count <= 0)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
triggerPackDic.Sort((a, b) => b.time.CompareTo(a.time));
|
||||
index = 0;
|
||||
if (curRedirectID > 0)
|
||||
{
|
||||
for (int i = 0; i < triggerPackDic.Count; i++)
|
||||
{
|
||||
if (triggerPackDic[i].ID == curRedirectID)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
base.Start();
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
SetTriggerPackTimer();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
allCount = triggerPackDic.Count;
|
||||
if (allCount <= 0)
|
||||
{
|
||||
OnClickClose();
|
||||
return;
|
||||
}
|
||||
if (index >= allCount)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
SetData();
|
||||
}
|
||||
protected virtual void SetPack()
|
||||
{
|
||||
int vipLevel = curTriggerPackState.vipLevel;
|
||||
int buyCount = GContext.container.Resolve<PlayerShopData>().GetShopPackBuyCount(curTriggerPackState.lastID);
|
||||
List<int> VIPPackList = packManager.VIPPackList[vipLevel];
|
||||
if (buyCount > VIPPackList.Count)
|
||||
{
|
||||
buyCount = VIPPackList.Count;
|
||||
}
|
||||
else if (buyCount <= 0)
|
||||
{
|
||||
buyCount = 1;
|
||||
}
|
||||
pack = _tables.TbPack.GetOrDefault(VIPPackList[buyCount - 1]);
|
||||
}
|
||||
public void SetData()
|
||||
{
|
||||
curTriggerPackState = triggerPackDic[index];
|
||||
int id = curTriggerPackState.ID;
|
||||
packManager = _tables.TbTriggerPackManager.GetOrDefault(id);
|
||||
SetPack();
|
||||
iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID);
|
||||
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(pack.DropID);
|
||||
SetShowData();
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
text_buy.text = sKUDetailDataEvent.price;
|
||||
tag_more.SetActive(pack.Rebate > 0.01);
|
||||
text_best.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", (pack.Rebate * 100).ToString("F0"));
|
||||
//Remaining.gameObject.SetActive(false);
|
||||
TimeSpan now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(curTriggerPackState);
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
triggerPackDic.Remove(curTriggerPackState);
|
||||
Init();
|
||||
}
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
if (txt_packName != null)
|
||||
{
|
||||
txt_packName.text = LocalizationMgr.GetText(pack.Title_l10n_key);
|
||||
}
|
||||
}
|
||||
protected override ShopBuyTypeData GetShopBuyTypeData()
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.TriggerPack;
|
||||
shopBuyTypeData.ID = packManager.ID;
|
||||
return shopBuyTypeData;
|
||||
}
|
||||
protected override void OnSuccess()
|
||||
{
|
||||
GContext.container.Resolve<TriggerPackData>().AddTriggerPackCount(packManager.ID);
|
||||
triggerPackDic.Remove(curTriggerPackState);
|
||||
Init();
|
||||
}
|
||||
protected override void OnBuySuccess()
|
||||
{
|
||||
//GContext.container.Resolve<TriggerPackData>().AddTriggerPackCount(packManager.ID);
|
||||
triggerPackDic.Remove(curTriggerPackState);
|
||||
Init();
|
||||
}
|
||||
|
||||
public async void SetTriggerPackTimer()
|
||||
{
|
||||
Init();
|
||||
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
DateTime dateTime1 = dateTime.AddDays(1).Date;
|
||||
while (this != null && dateTime.Ticks < dateTime1.Ticks)
|
||||
{
|
||||
TimeSpan now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(curTriggerPackState);
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
triggerPackDic.Remove(curTriggerPackState);
|
||||
Init();
|
||||
}
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
await System.Threading.Tasks.Task.Delay(1000);
|
||||
dateTime.AddSeconds(1);
|
||||
}
|
||||
if (this != null && dateTime.Ticks >= dateTime1.Ticks)
|
||||
{
|
||||
SetTriggerPackTimer();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnClickClose()
|
||||
{
|
||||
GContext.Publish(new GiftPopupPanelEnergyEvent { isClose = true });
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftPopupPanel_Energy.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftPopupPanel_Energy.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b4aed520e168704697da6e3af9264fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Assets/Scripts/UI/Shop/GiftRewardAttached.cs
Normal file
28
Assets/Scripts/UI/Shop/GiftRewardAttached.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GiftRewardAttached : MonoBehaviour
|
||||
{
|
||||
public GameObject[] gift;
|
||||
private void Reset()
|
||||
{
|
||||
int count = transform.childCount - 1;
|
||||
gift = new GameObject[count];
|
||||
for (int i = 0; i < gift.Length; i++)
|
||||
{
|
||||
gift[i] = transform.Find("gift" + (i + 1)).gameObject;
|
||||
}
|
||||
}
|
||||
public void SetData(List<ItemData> itemDatas)
|
||||
{
|
||||
for (int i = 0; i < gift.Length; i++)
|
||||
{
|
||||
gift[i].SetActive(i < itemDatas.Count);
|
||||
if (i < itemDatas.Count)
|
||||
{
|
||||
gift[i].GetComponentInChildren<RewardItemNew>().SetData(itemDatas[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftRewardAttached.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftRewardAttached.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2cbb25de07d3c144af470ff8ba9218b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
59
Assets/Scripts/UI/Shop/GiftRodSelectePopupPanel.cs
Normal file
59
Assets/Scripts/UI/Shop/GiftRodSelectePopupPanel.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftRodSelectePopupPanel : BasePanel
|
||||
{
|
||||
private Button _btnClose, _btnConfirm;
|
||||
private List<GiftRodSelectionSlot> _rods;
|
||||
private RodSelectionPackData _rspd;
|
||||
//public Action OnGameObjectDestroy;
|
||||
//private int _chosenRodID;
|
||||
private void Awake()
|
||||
{
|
||||
_rspd = GContext.container.Resolve<RodSelectionPackData>();
|
||||
_btnClose = transform.Find("btn_close").GetComponent<Button>();
|
||||
_btnConfirm = transform.Find("root/btn_confrim/btn_green").GetComponent<Button>();
|
||||
_rods = new List<GiftRodSelectionSlot>();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
_rods.Add(transform.Find($"root/Content/Item{i + 1}").GetComponent<GiftRodSelectionSlot>());
|
||||
}
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
_btnClose.onClick.AddListener(ClosePanel);
|
||||
_btnConfirm.onClick.AddListener(OnClickConfirm);
|
||||
//_chosenRodID = _rspd.RodID;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
_rods[i].InitializeSlot(_rspd.PackRodList[i], _rspd);
|
||||
_rods[i].Toggle.isOn = _rspd.PackRodList[i] == _rspd.RodID;
|
||||
}
|
||||
base.Start();
|
||||
}
|
||||
private void ClosePanel()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftRodSelectePopupPanel);
|
||||
}
|
||||
private void OnClickConfirm()
|
||||
{
|
||||
//_rspd.RodID = _chosenRodID;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (!_rods[i].Toggle.isOn)
|
||||
continue;
|
||||
_rspd.RodID = _rspd.PackRodList[i];
|
||||
break;
|
||||
}
|
||||
GContext.Publish<GiftRodSelectEvent>(new GiftRodSelectEvent(_rspd.RodID));
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftRodSelectePopupPanel);
|
||||
}
|
||||
//protected override void OnDestroy()
|
||||
//{
|
||||
// OnGameObjectDestroy?.Invoke();
|
||||
// OnGameObjectDestroy = null;
|
||||
//}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftRodSelectePopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftRodSelectePopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: baccb1739996dad419790dd867067832
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
88
Assets/Scripts/UI/Shop/GiftRodSelectionPopupPanel.cs
Normal file
88
Assets/Scripts/UI/Shop/GiftRodSelectionPopupPanel.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using System;
|
||||
using game;
|
||||
|
||||
public class GiftRodSelectionPopupPanel : BasePanel
|
||||
{
|
||||
#region UI
|
||||
private Button _btnBuy, _btnClose, _btnSelect;
|
||||
private TMP_Text _textTimer, _textPrice, _textRemain;
|
||||
private GiftRewardAttached _rewards;
|
||||
#endregion
|
||||
#region config
|
||||
private Tables _tables;
|
||||
private RodSelectionPackData _rspd;
|
||||
#endregion
|
||||
private IAPItemList _iap;
|
||||
private void Awake()
|
||||
{
|
||||
#region UI
|
||||
_btnBuy = transform.Find("root/btn_buy/btn_green").GetComponent<Button>();
|
||||
_btnClose = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
_btnSelect = transform.Find("root/reward_4/gift1/btn_selection").GetComponent<Button>();
|
||||
_textTimer = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
||||
_textPrice = transform.Find("root/btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
_rewards = transform.Find("root/reward_4").GetComponent<GiftRewardAttached>();
|
||||
_textRemain = transform.Find("root/text_remaining").GetComponent<TMP_Text>();
|
||||
#endregion
|
||||
#region config
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_rspd = GContext.container.Resolve<RodSelectionPackData>();
|
||||
#endregion
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
_btnClose.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.GiftRodSelectionPopupPanel));
|
||||
_textTimer.text = ConvertTools.ConvertTime2(_rspd.RemainingTime);
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe(_ => { _textTimer.text = ConvertTools.ConvertTime2(_rspd.RemainingTime); })
|
||||
.AddTo(this);
|
||||
GContext.OnEvent<GiftRodSelectEvent>()
|
||||
.Subscribe(e => { _rewards.SetData(_rspd.RewardList); })
|
||||
.AddTo(this);
|
||||
GContext.Publish(new GiftRodSelectEvent(_rspd.RodID));
|
||||
//_rewards.SetData(_rspd.RewardList);
|
||||
_textRemain.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1",
|
||||
_rspd.MaxPurchaseCount - _rspd.PurchaseCount, _rspd.MaxPurchaseCount);
|
||||
//_textRemain.text = $"Remaining: {_rspd.MaxPurchaseCount - _rspd.PurchaseCount}/{_rspd.MaxPurchaseCount}";
|
||||
_iap = _tables.TbIAPItemList.GetOrDefault(_rspd.IAPID);
|
||||
//Debug.Log($"_iap: {_iap}");
|
||||
SKUDetailDataEvent sdde = new SKUDetailDataEvent(_iap);
|
||||
GContext.Publish(sdde);
|
||||
_textPrice.text = sdde.price;
|
||||
_btnBuy.onClick.AddListener(async () => await OnClickBuy());
|
||||
_btnSelect.onClick.AddListener(async () => await OpenSelectPanel());
|
||||
}
|
||||
private async System.Threading.Tasks.Task OnClickBuy()
|
||||
{
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.EventPack;
|
||||
shopBuyTypeData.ID = _rspd.CurrentEventID;
|
||||
bool res = await GContext.container.Resolve<PlayerShopData>().OnBuy(_rspd.DropID, shopBuyTypeData, _iap, _rspd.RewardList);
|
||||
if (res)
|
||||
{
|
||||
//_rspd.AddPurchase();
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftRodSelectionPopupPanel);
|
||||
}
|
||||
}
|
||||
private async System.Threading.Tasks.Task OpenSelectPanel()
|
||||
{
|
||||
GameObject selectPanel = await UIManager.Instance.ShowUI(UITypes.GiftRodSelectePopupPanel);
|
||||
//selectPanel.GetComponent<GiftRodSelectePopupPanel>()
|
||||
// .OnGameObjectDestroy += () => _rewards.SetData(_rspd.RewardList);
|
||||
}
|
||||
}
|
||||
public struct GiftRodSelectEvent
|
||||
{
|
||||
public int RodID;
|
||||
public GiftRodSelectEvent(int id)
|
||||
{
|
||||
RodID = id;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftRodSelectionPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftRodSelectionPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abad196566aa89a45b0592f82b5ea701
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
126
Assets/Scripts/UI/Shop/GiftRodSelectionSlot.cs
Normal file
126
Assets/Scripts/UI/Shop/GiftRodSelectionSlot.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftRodSelectionSlot : MonoBehaviour
|
||||
{
|
||||
private Button _btnInfo, _btnSelect;
|
||||
private TMP_Text _textLvl, _textRodName, _textRodNameSelected;
|
||||
private List<GameObject> _emptyStars = new List<GameObject>();
|
||||
private List<StarItem> _solidStars = new List<StarItem>();
|
||||
private GameObject _selectedMask, _emptyMask, _stars;
|
||||
private Image _rodIcon, _rodBg;
|
||||
private int _rodID;
|
||||
private RodSelectionPackData _rspd;
|
||||
private TbItem _item;
|
||||
private PlayerFishData _pfd;
|
||||
private TbRodAscend _rodAscend;
|
||||
private Toggle _tgl;
|
||||
private Tables _tables;
|
||||
|
||||
public Toggle Toggle { get => _tgl; }
|
||||
//public Button BtnSelect { get => _btnSelect; }
|
||||
//private RodSelectionPackData _rspd = GContext.container.Resolve<RodSelectionPackData>();
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_item = GContext.container.Resolve<Tables>().TbItem;
|
||||
_pfd = GContext.container.Resolve<PlayerFishData>();
|
||||
_rodAscend = GContext.container.Resolve<Tables>().TbRodAscend;
|
||||
_btnInfo = transform.Find("btn_green/rod/btn_questionmark").GetComponent<Button>();
|
||||
//_btnSelect = transform.Find("btn_green").GetComponent<Button>();
|
||||
_textLvl = transform.Find("btn_green/rod/text_level").GetComponent<TMP_Text>();
|
||||
_textRodName = transform.Find("btn_green/bg/text_map").GetComponent<TMP_Text>();
|
||||
_textRodNameSelected = transform.Find("btn_green/selected/text_map").GetComponent<TMP_Text>();
|
||||
int i = 1;
|
||||
_stars = transform.Find("btn_green/rod/star").gameObject;
|
||||
Transform emptyStar, star;
|
||||
while (true)
|
||||
{
|
||||
emptyStar = transform.Find($"btn_green/rod/star/star_empty/star{i}");
|
||||
star = transform.Find($"btn_green/rod/star/star/star{i}");
|
||||
if (emptyStar == null || star == null)
|
||||
break;
|
||||
_emptyStars.Add(emptyStar.gameObject);
|
||||
_solidStars.Add(star.GetComponent<StarItem>());
|
||||
i++;
|
||||
}
|
||||
_selectedMask = transform.Find("btn_green/selected").gameObject;
|
||||
_emptyMask = transform.Find("btn_green/rod/mask_empty").gameObject;
|
||||
_rodIcon = transform.Find("btn_green/rod/img_map").GetComponent<Image>();
|
||||
_rodBg = transform.Find("btn_green/rod/bg").GetComponent<Image>();
|
||||
_tgl = GetComponent<Toggle>();
|
||||
_tgl.onValueChanged.AddListener((isOn) =>
|
||||
{
|
||||
_selectedMask.SetActive(isOn);
|
||||
});
|
||||
}
|
||||
public void InitializeSlot(int rodID, RodSelectionPackData rspd)
|
||||
{
|
||||
_rodID = rodID;
|
||||
_rspd = rspd;
|
||||
int rodRid = _item[_rodID].RedirectID;
|
||||
int MaxAscent = _rodAscend[rodRid].MaxAscent;
|
||||
int fragID = _rodAscend[rodRid].FragmentID;
|
||||
string rodName = LocalizationMgr.GetText(_tables.TbRodSkinData[_item[_rodID].RedirectID].Name_l10n_key);
|
||||
_textRodName.text = rodName;
|
||||
_textRodNameSelected.text = rodName;
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(_rodIcon, _item[_rodID].Icon, BasePanel.PanelName);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(_rodBg, Define.sp_rod_card[_tables.TbRodData[rodRid].Quality - 1], BasePanel.PanelName);
|
||||
//UIManager.Instance.SetImageSprite(_rodIcon, _item[_rodID].Icon);
|
||||
if (_pfd.NotRod(rodRid))
|
||||
{
|
||||
_emptyMask.SetActive(true);
|
||||
_textLvl.gameObject.SetActive(false);
|
||||
_stars.SetActive(false);
|
||||
return;
|
||||
}
|
||||
//_btnInfo
|
||||
//_btnSelect.onClick.RemoveAllListeners();
|
||||
//_btnSelect.onClick.AddListener(OnSlotSelected);
|
||||
int star = _pfd.GetRodPiece(rodRid);
|
||||
|
||||
int ShowCount = PlayerFishData.SetRodStar(star, MaxAscent,
|
||||
_emptyStars,
|
||||
null,
|
||||
_solidStars);
|
||||
|
||||
for (int i = 0; i < ShowCount; i++)
|
||||
{
|
||||
_solidStars[i].PlayShow();
|
||||
}
|
||||
//if (star <= MaxAscent / 2)
|
||||
//{
|
||||
// for (int i = 1; i <= star; i++)
|
||||
// {
|
||||
// _solidStars[i - 1].SetStar(1);
|
||||
// _solidStars[i - 1].PlayShow();
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// for (int i = 1; i <= MaxAscent / 2; i++)
|
||||
// {
|
||||
// _solidStars[i - 1].SetStar(i <= star - MaxAscent / 2 ? 2 : 1);
|
||||
// _solidStars[i - 1].PlayShow();
|
||||
// }
|
||||
//}
|
||||
_textLvl.text = (_pfd.GetRodLevel(rodRid) + 1).ToString();
|
||||
_btnInfo.onClick.AddListener(async () => { await OpenFishingRodPanel(); });
|
||||
}
|
||||
private async System.Threading.Tasks.Task OpenFishingRodPanel()
|
||||
{
|
||||
_pfd.RodSelectedInPack = _item[_rodID].RedirectID;
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingRodBagPanel);
|
||||
_pfd.RodSelectedInPack = 0;
|
||||
}
|
||||
//public void ToggleSlotSelected(bool isSelected)
|
||||
//{
|
||||
// _selectedMask.SetActive(isSelected);
|
||||
//}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftRodSelectionSlot.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftRodSelectionSlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b685ec3790ed60c48a48d694040a95e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
75
Assets/Scripts/UI/Shop/GiftSelectionPackCustomizePanel.cs
Normal file
75
Assets/Scripts/UI/Shop/GiftSelectionPackCustomizePanel.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftSelectionPackCustomizePanel : MonoBehaviour
|
||||
{
|
||||
private GameObject[] _items;
|
||||
private Button _btnClose, _btnConfirm, _btnConfirmGray;
|
||||
private Animator _aniConfirm;
|
||||
private ToggleGroup _tglItem;
|
||||
private IEventAggregator _eventAggregator;
|
||||
private int _rewardSelectIdx = -1;
|
||||
public void Init(ItemData[] items, int selected, IEventAggregator ea)
|
||||
{
|
||||
_items = new GameObject[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
_items[i] = transform.Find($"root/Content_item/Item{i + 1}").gameObject;
|
||||
_btnClose = transform.Find("btn_close").GetComponent<Button>();
|
||||
_btnConfirm = transform.Find("root/btn_confrim/btn_green").GetComponent<Button>();
|
||||
_aniConfirm = transform.Find("root/btn_confrim/btn_green").GetComponent<Animator>();
|
||||
_btnConfirmGray = transform.Find("root/btn_confrim_gray/btn_green").GetComponent<Button>();
|
||||
_tglItem = transform.Find("root/Content_item").GetComponent<ToggleGroup>();
|
||||
|
||||
_btnClose.onClick.AddListener(() => {
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftSelectPackCustomizePanel);
|
||||
});
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int index = i;
|
||||
_items[i] = transform.Find($"root/Content_item/Item{i + 1}").gameObject;
|
||||
_items[i].transform.Find("btn_cherk/Ani_Container/Checkmark").gameObject.SetActive(false);
|
||||
_items[i].GetComponent<Toggle>().onValueChanged.AddListener((bool isOn) =>
|
||||
{
|
||||
_rewardSelectIdx = index;
|
||||
_items[index].transform.Find("btn_cherk/Ani_Container/Checkmark").gameObject.SetActive(isOn);
|
||||
_btnConfirm.gameObject.SetActive(true);
|
||||
_btnConfirmGray.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
_tglItem.allowSwitchOff = true;
|
||||
|
||||
_eventAggregator = ea;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (i >= items.Length)
|
||||
{
|
||||
_items[i].SetActive(false);
|
||||
continue;
|
||||
}
|
||||
_items[i].transform.Find("btn_green/reward_1").gameObject.GetComponent<RewardItemNew>()
|
||||
.SetData(items[i]);
|
||||
_items[i].GetComponent<Toggle>().isOn = (i == selected);
|
||||
_items[i].transform.Find("btn_cherk/Ani_Container/Checkmark").gameObject.SetActive(i == selected);
|
||||
}
|
||||
_btnConfirm.onClick.AddListener(OnClickConfirm);
|
||||
_btnConfirmGray.onClick.AddListener(() => ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_79")));
|
||||
if (selected != -1)
|
||||
{
|
||||
_rewardSelectIdx = selected;
|
||||
_btnConfirm.gameObject.SetActive(true);
|
||||
_btnConfirmGray.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_btnConfirm.gameObject.SetActive(false);
|
||||
_btnConfirmGray.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
private void OnClickConfirm()
|
||||
{
|
||||
_eventAggregator.Publish(new EventSelectionPackItemConfirm(_rewardSelectIdx));
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftSelectPackCustomizePanel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5067d51f4575b2c4e9496734ca57ea68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
167
Assets/Scripts/UI/Shop/GiftSelectionPackPanel.cs
Normal file
167
Assets/Scripts/UI/Shop/GiftSelectionPackPanel.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using System;
|
||||
using game;
|
||||
public class GiftSelectionPackPanel : BasePanel
|
||||
{
|
||||
#region UI
|
||||
private Button _btnBuy, _btnClose;
|
||||
private TMP_Text _textTimer, _textPrice, _textRemain;
|
||||
private GameObject _reward3, _reward4, _rewards;
|
||||
#endregion
|
||||
#region config
|
||||
private Tables _tables;
|
||||
private SelectionPackData _data;
|
||||
private TbSpecialPack _spp;
|
||||
private PlayerItemData _playerItemData;
|
||||
#endregion
|
||||
private IAPItemList _iap;
|
||||
private EventAggregator _eventAggregator = new EventAggregator();
|
||||
private int _rewardSlotsCount;
|
||||
private void Awake()
|
||||
{
|
||||
#region UI
|
||||
_btnClose = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
_btnBuy = transform.Find("root/btn_buy/btn_green").GetComponent<Button>();
|
||||
_reward4 = transform.Find("root/reward_4").gameObject;
|
||||
_reward3 = transform.Find("root/reward_3").gameObject;
|
||||
_textTimer = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
||||
_textPrice = transform.Find("root/btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
_textRemain = transform.Find("root/text_remaining").GetComponent<TMP_Text>();
|
||||
#endregion
|
||||
#region config
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_data = GContext.container.Resolve<SelectionPackData>();
|
||||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
_spp = GContext.container.Resolve<Tables>().TbSpecialPack;
|
||||
#endregion
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
_btnClose.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.GiftSelectionPanel));
|
||||
_textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe(_ => { _textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime); })
|
||||
.AddTo(this);
|
||||
_eventAggregator.GetEvent<EventSelectionPackItemConfirm>().Subscribe(HandleItemConfirm).AddTo(this);
|
||||
_rewardSlotsCount = _data.DropIDList.Count;
|
||||
_reward4.SetActive(_rewardSlotsCount == 4);
|
||||
_reward3.SetActive(_rewardSlotsCount == 3);
|
||||
_rewards = _rewardSlotsCount == 4 ? _reward4 : _reward3;
|
||||
for (int i = 0; i < _rewardSlotsCount; i++)
|
||||
{
|
||||
GiftSelectionPackSlot slot = _rewards.transform.Find($"gift{i + 1}")
|
||||
.GetComponent<GiftSelectionPackSlot>();
|
||||
if (_data.Selections[i] == -1)
|
||||
{
|
||||
slot.SetState();
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.SetState(GetItemData(i, _data.Selections[i]));
|
||||
}
|
||||
int index = i;
|
||||
_rewards.transform.Find($"gift{i + 1}/empty").GetComponent<Button>().onClick
|
||||
.AddListener(async () => await OnClickSlot(index));
|
||||
_rewards.transform.Find($"gift{i + 1}/reward_1/btn_selection").GetComponent<Button>().onClick
|
||||
.AddListener(async () => await OnClickSlot(index));
|
||||
}
|
||||
_textRemain.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1",
|
||||
_data.MaxPurchaseCount - _data.PurchaseCount, _data.MaxPurchaseCount);
|
||||
//_textRemain.text = $"Remaining: {_data.MaxPurchaseCount - _data.PurchaseCount}/{_data.MaxPurchaseCount}";
|
||||
_iap = _tables.TbIAPItemList.GetOrDefault(_data.IAPID);
|
||||
//Debug.Log($"_iap: {_iap}");
|
||||
SKUDetailDataEvent sdde = new SKUDetailDataEvent(_iap);
|
||||
GContext.Publish(sdde);
|
||||
_textPrice.text = sdde.price;
|
||||
_btnBuy.onClick.AddListener(async () => await OnClickBuy());
|
||||
oldPanelName = panelName;
|
||||
base.Start();
|
||||
}
|
||||
private int _currentSlotSelected = -1;
|
||||
private async System.Threading.Tasks.Task OnClickSlot(int idx)
|
||||
{
|
||||
GiftSelectionPackCustomizePanel customPanel = (await UIManager.Instance
|
||||
.ShowUI(UITypes.GiftSelectPackCustomizePanel)).GetComponent<GiftSelectionPackCustomizePanel>();
|
||||
DropPackageList d = _tables.TbDrop[_data.DropIDList[idx]].DropList;
|
||||
int count = d.DropIDList.Count;
|
||||
if (count != 3 && count != 4)
|
||||
Debug.LogWarning($"Item count {count} on slot {idx} is probably not an expected number.");
|
||||
ItemData[] items = new ItemData[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (d.DropIDList[i] == 1002)
|
||||
items[i] = new ItemData(d.DropIDList[i], _playerItemData.GetExtraCoinMag(d.DropCountList[i]));
|
||||
else
|
||||
items[i] = new ItemData(d.DropIDList[i], d.DropCountList[i]);
|
||||
}
|
||||
customPanel.Init(items, _data.Selections[idx], _eventAggregator);
|
||||
_currentSlotSelected = idx;
|
||||
}
|
||||
private async System.Threading.Tasks.Task OnClickBuy()
|
||||
{
|
||||
if (!_data.IsFullySelected)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetFormatTextValue("UI_ToastPanel_79"));
|
||||
return;
|
||||
}
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.EventPack;
|
||||
shopBuyTypeData.ID = _data.CurrentEventID;
|
||||
int dropID = 0;
|
||||
|
||||
bool res = await GContext.container.Resolve<PlayerShopData>().OnBuy(dropID, shopBuyTypeData, _iap, _data.RewardSelected);
|
||||
if (res)
|
||||
{
|
||||
//Debug.Log($"<color=red>{}</color>")
|
||||
//GContext.Publish(new EventHomeBuffPanelRefresh());
|
||||
//_data.AddPurchase();
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftSelectionPanel);
|
||||
}
|
||||
}
|
||||
private void HandleItemConfirm(EventSelectionPackItemConfirm e)
|
||||
{
|
||||
if (_currentSlotSelected == -1)
|
||||
{
|
||||
Debug.LogWarning("ConfirmButton pressed when no slot is selected.");
|
||||
return;
|
||||
}
|
||||
_rewards.transform.Find($"gift{_currentSlotSelected + 1}").GetComponent<GiftSelectionPackSlot>()
|
||||
.SetState(GetItemData(_currentSlotSelected, e.SelectedRewardIdx));
|
||||
_data.UpdateSelection(_currentSlotSelected, e.SelectedRewardIdx);
|
||||
_currentSlotSelected = -1;
|
||||
}
|
||||
private ItemData GetItemData(int slotIdx, int rewardIdx)
|
||||
{
|
||||
if (slotIdx < 0 || slotIdx >= _spp[_data.PackID].DropID.Count)
|
||||
{
|
||||
Debug.LogError($"SlotIndex {slotIdx} is out of expected range" +
|
||||
$"(0, {_spp[_data.PackID].DropID.Count}).");
|
||||
return null;
|
||||
}
|
||||
DropPackageList d = _tables.TbDrop[_spp[_data.PackID].DropID[slotIdx]].DropList;
|
||||
if (rewardIdx < 0 || rewardIdx >= d.DropIDList.Count)
|
||||
{
|
||||
Debug.LogError($"PickIndex {rewardIdx} is out of expected range (0, {d.DropIDList.Count}).");
|
||||
return null;
|
||||
}
|
||||
int itemID = d.DropIDList[rewardIdx];
|
||||
int itemCount = d.DropCountList[rewardIdx];
|
||||
if (itemID == 1002)
|
||||
itemCount = _playerItemData.GetExtraCoinMag(itemCount);
|
||||
return new ItemData(itemID, itemCount);
|
||||
}
|
||||
}
|
||||
public class EventSelectionPackItemConfirm
|
||||
{
|
||||
public int SelectedRewardIdx;
|
||||
public EventSelectionPackItemConfirm(int selectedRewardIdx)
|
||||
{
|
||||
SelectedRewardIdx = selectedRewardIdx;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftSelectionPackPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftSelectionPackPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d24b3ec5289ab542a014139c5cf2e58
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Assets/Scripts/UI/Shop/GiftSelectionPackSlot.cs
Normal file
27
Assets/Scripts/UI/Shop/GiftSelectionPackSlot.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftSelectionPackSlot : MonoBehaviour
|
||||
{
|
||||
private Button _btnEmpty, _btnReward, _btnSelect;
|
||||
private RewardItemNew _reward;
|
||||
private void Awake()
|
||||
{
|
||||
_btnEmpty = transform.Find("empty").GetComponent<Button>();
|
||||
_btnReward = transform.Find("reward_1").GetComponent<Button>();
|
||||
_btnSelect = transform.Find("reward_1/btn_selection").GetComponent<Button>();
|
||||
_reward = transform.Find("reward_1").GetComponent<RewardItemNew>();
|
||||
}
|
||||
public void SetState(ItemData item)
|
||||
{
|
||||
_btnEmpty.gameObject.SetActive(false);
|
||||
_btnReward.gameObject.SetActive(true);
|
||||
_reward.SetData(item, isCanClick: true);
|
||||
}
|
||||
public void SetState()
|
||||
{
|
||||
_btnEmpty.gameObject.SetActive(true);
|
||||
_btnReward.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/GiftSelectionPackSlot.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/GiftSelectionPackSlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: addd235272239de4688ab95453ec3277
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
176
Assets/Scripts/UI/Shop/ItemShopSlot.cs
Normal file
176
Assets/Scripts/UI/Shop/ItemShopSlot.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using tysdk;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ItemShopSlot : MonoBehaviour
|
||||
{
|
||||
#region Field&&Property
|
||||
[SerializeField]
|
||||
private Button btn_buy;
|
||||
|
||||
[SerializeField]
|
||||
private RewardItemNew rewardItem;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject
|
||||
go_soldOut;
|
||||
|
||||
[SerializeField]
|
||||
private Transform
|
||||
tran_tag;
|
||||
|
||||
[SerializeField]
|
||||
TMP_Text
|
||||
txt_itemName;
|
||||
|
||||
private PlayerShopData.ItemShopData _data;
|
||||
#endregion
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
#region Function
|
||||
public void SetData(PlayerShopData.ItemShopData data)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
_data = data;
|
||||
if (_data.Record.ItemID == 1002)
|
||||
{
|
||||
_data.Count = (int)GContext.container.Resolve<PlayerItemData>().GetExtraCoinMag(_data.Count);
|
||||
}
|
||||
RefreshView();
|
||||
}
|
||||
|
||||
public void RefreshView()
|
||||
{
|
||||
rewardItem.SetData(new ItemData
|
||||
{
|
||||
id = _data.Record.ItemID,
|
||||
count = _data.Count,
|
||||
});
|
||||
rewardItem.transform.Find("text_num").GetComponent<TMP_Text>().text = "x" + ConvertTools.GetNumberString(_data.Count);
|
||||
txt_itemName.text = LocalizationMgr.GetText(GContext.container.Resolve<Tables>().TbItem.DataMap[_data.Record.ItemID].Name_l10n_key);
|
||||
|
||||
for (int i = 0; i < tran_tag.childCount; i++)
|
||||
{
|
||||
tran_tag.GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
// go_redPoint.SetActive(false);
|
||||
btn_buy.transform.Find("Ani_Container/p_text").gameObject.SetActive(false);
|
||||
if (_data.Record.hasBought == 0)
|
||||
{
|
||||
// GContext.container.Resolve<IUIService>().SetImageSprite(img_light, ( $"bg_shop_resource_item_{quality + 1}" ));
|
||||
|
||||
//Not Boudght
|
||||
go_soldOut.SetActive(false);
|
||||
btn_buy.transform.parent.gameObject.SetActive(true);
|
||||
btn_buy.onClick.AddListener(OnBuy);
|
||||
|
||||
//Cost
|
||||
var cost = _data.GetDiscountDiamondCost();
|
||||
//Not Free
|
||||
btn_buy.transform.Find("Ani_Container/p_text").gameObject.SetActive(true);
|
||||
btn_buy.transform.Find("Ani_Container/p_text").GetComponent<TMP_Text>().text = ConvertTools.GetNumberString(cost);
|
||||
|
||||
|
||||
//Discount
|
||||
var discount = _data.Record.Discount;
|
||||
var tagJudgeList = GContext.container.Resolve<Tables>().TbStoreConfig.Get(1).PriceTag;
|
||||
if (!Mathf.Approximately(discount, 1f))
|
||||
{
|
||||
var lastDiscount = 0f;
|
||||
var index = 0;
|
||||
foreach (var tagjudge in tagJudgeList)
|
||||
{
|
||||
if (discount * 10f > lastDiscount && discount * 10f <= tagjudge)
|
||||
{
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
lastDiscount = tagjudge;
|
||||
}
|
||||
if (tran_tag.childCount <= index)
|
||||
Debug.LogError($"[ItemShopSlot::RefreshView] tagJudge {index} exceeds tagsCount {tran_tag.childCount}");
|
||||
|
||||
var tag = tran_tag.GetChild(index);
|
||||
tag.gameObject.SetActive(true);
|
||||
tag.GetChild(0).GetComponent<TMP_Text>().text = ConvertTools.GetNumberString3(discount);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Has Bought
|
||||
// img_light.enabled = false;
|
||||
go_soldOut.SetActive(true);
|
||||
btn_buy.transform.parent.gameObject.SetActive(false);
|
||||
btn_buy.onClick.RemoveAllListeners();
|
||||
|
||||
// cg_rewardItem.alpha = 0.6f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnBuy()
|
||||
{
|
||||
if (_data.Record.hasBought == 0)
|
||||
{
|
||||
var cost = _data.GetDiscountDiamondCost();
|
||||
if (cost == 0)
|
||||
{
|
||||
//Free
|
||||
var itemData = new ItemData { id = _data.Record.ItemID, count = _data.Count };
|
||||
itemData.curCount = (ulong)GContext.container.Resolve<PlayerItemData>().GetItemCount(_data.Record.ItemID);
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemData);
|
||||
GContext.container.Resolve<PlayerShopData>().SetItemShopSlotBought(_data.ItemShopID);
|
||||
GContext.Publish(new ShowData(new List<ItemData> { itemData }, RewardType.NormalOne));
|
||||
GContext.Publish(new ShowData());
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
var curDiamond = GContext.container.Resolve<PlayerData>().diamond;
|
||||
//Not Free
|
||||
if (curDiamond >= cost)
|
||||
{
|
||||
var itemData = new ItemData { id = _data.Record.ItemID, count = _data.Count };
|
||||
itemData.curCount = (ulong)GContext.container.Resolve<PlayerItemData>().GetItemCount(_data.Record.ItemID);
|
||||
GContext.container.Resolve<PlayerData>().AddDiamond(-cost);
|
||||
GContext.container.Resolve<PlayerShopData>().SetItemShopSlotBought(_data.ItemShopID);
|
||||
GContext.Publish(new ShowData(new List<ItemData> { itemData }, RewardType.NormalOne));
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemData);
|
||||
GContext.Publish(new ShowData());
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("resource_shop"))
|
||||
{
|
||||
e.AddContent("cost_diamond_count", cost)
|
||||
.AddContent("change_type", 2)
|
||||
.AddContent("change_num", _data.Count)
|
||||
.AddContent("item_id", _data.Record.ItemID);
|
||||
}
|
||||
#endif
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_59"));
|
||||
_ = UIManager.Instance.ShowUI(UITypes.LackOfResourceConfirmPopupPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/ItemShopSlot.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/ItemShopSlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bdf061ff87c3ff4a86a956a715fc04c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
253
Assets/Scripts/UI/Shop/ItemsShopPanel.cs
Normal file
253
Assets/Scripts/UI/Shop/ItemsShopPanel.cs
Normal file
@@ -0,0 +1,253 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using tysdk;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
/// <summary>
|
||||
/// hasBought: 0 未购买 1 已购买
|
||||
/// </summary>
|
||||
public class ItemShopRecord
|
||||
{
|
||||
public int ItemID;
|
||||
public float Discount;
|
||||
public int hasBought;
|
||||
public ItemShopRecord(int itemID, float discount, int hasBought)
|
||||
{
|
||||
ItemID = itemID;
|
||||
this.Discount = discount;
|
||||
this.hasBought = hasBought;
|
||||
}
|
||||
}
|
||||
public class ItemsShopPanel : MonoBehaviour
|
||||
{
|
||||
|
||||
#region Field&&Property
|
||||
[SerializeField]
|
||||
private GameObject
|
||||
go_refreshFree,
|
||||
go_refreshDiamonIcon,
|
||||
go_fishCardSlot,
|
||||
go_itemSlot;
|
||||
[SerializeField]
|
||||
private Transform
|
||||
tran_fishCardParent,
|
||||
tran_itemSlotParent;
|
||||
[SerializeField]
|
||||
private List<EnergyShopSlot> _energyShopSlots = new List<EnergyShopSlot>();
|
||||
private List<ItemShopSlot> _itemShopSlots = new List<ItemShopSlot>();
|
||||
|
||||
[SerializeField]
|
||||
private TMP_Text
|
||||
txt_curMap,
|
||||
txt_itemShopTimer,
|
||||
txt_refreshCost;
|
||||
|
||||
[SerializeField]
|
||||
private Button
|
||||
btn_chagneMap,
|
||||
btn_refreshGray,
|
||||
btn_refresh;
|
||||
|
||||
private List<ItemStore> _itemStores;
|
||||
private List<ResourceStore> _energySlotDatas;
|
||||
private List<ResourceStore> _fishCardSlotDatas;
|
||||
|
||||
private PlayerShopData _shopData;
|
||||
private int curSlelectingMapID;
|
||||
|
||||
private TimeSpan _autoRefreshTimer;
|
||||
#endregion
|
||||
|
||||
IDisposable disposable;
|
||||
#region Function
|
||||
private void Awake()
|
||||
{
|
||||
go_itemSlot.SetActive(false);
|
||||
go_fishCardSlot.SetActive(false);
|
||||
var tables = GContext.container.Resolve<Tables>();
|
||||
_itemStores = tables.TbItemStore.DataList;
|
||||
_shopData = GContext.container.Resolve<PlayerShopData>();
|
||||
_energySlotDatas = tables.TbResourceStore.DataList.Where(x => x.Type == 1 && x.IsShow == 1).ToList();
|
||||
_fishCardSlotDatas = tables.TbResourceStore.DataList.Where(x => x.Type == 2).ToList();
|
||||
disposable = GContext.OnEvent<FishCardShopSlot.SChangeFishCardMapEvent>().Where(x => x.IsConfirm).Subscribe(x => OnChangeMapID(x));
|
||||
}
|
||||
protected void Start()
|
||||
{
|
||||
btn_refresh.onClick.AddListener(OnRefresh);
|
||||
btn_refreshGray.onClick.AddListener(OnCannotRefersh);
|
||||
btn_chagneMap.onClick.AddListener(OnChagneFishCardMap);
|
||||
|
||||
RefreshView();
|
||||
}
|
||||
protected void OnDestroy()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
btn_refresh.onClick.RemoveAllListeners();
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(IE_SetTimer());
|
||||
}
|
||||
|
||||
private void RefreshView()
|
||||
{
|
||||
RefreshEnergySlots();
|
||||
RefreshItemSlots();
|
||||
RefreshRefreshInfo();
|
||||
RefreshFishCardSlots();
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(IE_SetTimer());
|
||||
}
|
||||
private void RefreshItemBars()
|
||||
{
|
||||
RefreshItemSlots();
|
||||
RefreshRefreshInfo();
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(IE_SetTimer());
|
||||
}
|
||||
|
||||
private void RefreshFishCardSlots()
|
||||
{
|
||||
var curMapID = GContext.container.Resolve<PlayerData>().currentMapId;
|
||||
var mapData = GContext.container.Resolve<Tables>().GetMapData(curMapID);
|
||||
OnChangeMapID(new FishCardShopSlot.SChangeFishCardMapEvent { MapData = mapData });
|
||||
for (int i = 0; i < _fishCardSlotDatas.Count; i++)
|
||||
{
|
||||
var fishCardSlot = Instantiate(go_fishCardSlot, tran_fishCardParent).GetComponent<FishCardShopSlot>();
|
||||
fishCardSlot.SetData(_fishCardSlotDatas[i], curMapID);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnChangeMapID(FishCardShopSlot.SChangeFishCardMapEvent data)
|
||||
{
|
||||
curSlelectingMapID = data.MapData.ID;
|
||||
txt_curMap.text = LocalizationMgr.GetText(data.MapData.Name_l10n_key);
|
||||
}
|
||||
private void RefreshEnergySlots()
|
||||
{
|
||||
for (int i = 0; i < _energySlotDatas.Count; i++)
|
||||
{
|
||||
if (i >= _energyShopSlots.Count)
|
||||
{
|
||||
Debug.LogError("EnergySLot Not Enough!");
|
||||
return;
|
||||
}
|
||||
_energyShopSlots[i].SetData(_energySlotDatas[i]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshItemSlots()
|
||||
{
|
||||
foreach (var slot in _itemShopSlots)
|
||||
{
|
||||
Destroy(slot.gameObject);
|
||||
}
|
||||
_itemShopSlots.Clear();
|
||||
var shopDatas = _shopData.GetItemShopData();
|
||||
foreach (var data in shopDatas)
|
||||
{
|
||||
var slot = Instantiate(go_itemSlot, tran_itemSlotParent).GetComponent<ItemShopSlot>();
|
||||
slot.SetData(data);
|
||||
_itemShopSlots.Add(slot);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshRefreshInfo()
|
||||
{
|
||||
var cost = _shopData.GetDiamondShopRefreshCost();
|
||||
if (cost == 0)
|
||||
{
|
||||
go_refreshFree.SetActive(true);
|
||||
go_refreshDiamonIcon.SetActive(false);
|
||||
txt_refreshCost.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
go_refreshFree.SetActive(false);
|
||||
go_refreshDiamonIcon.SetActive(true);
|
||||
txt_refreshCost.gameObject.SetActive(true);
|
||||
txt_refreshCost.text = cost.ToString();
|
||||
}
|
||||
var refreshInfo = _shopData.GetDiamondShopRefreshInfo();
|
||||
if (refreshInfo.refresh <= 0)
|
||||
{
|
||||
btn_refreshGray.transform.parent.gameObject.SetActive(true);
|
||||
btn_refresh.transform.parent.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_refreshGray.transform.parent.gameObject.SetActive(false);
|
||||
btn_refresh.transform.parent.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnRefresh()
|
||||
{
|
||||
var diamondCount = GContext.container.Resolve<PlayerData>().diamond;
|
||||
var cost = _shopData.GetDiamondShopRefreshCost();
|
||||
if (diamondCount >= cost)
|
||||
{
|
||||
GContext.container.Resolve<PlayerData>().AddDiamond(-cost);
|
||||
_shopData.RefreshDiamondShop();
|
||||
RefreshItemBars();
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("click_free_button"))
|
||||
{
|
||||
var refreshInfo = _shopData.GetDiamondShopRefreshInfo();
|
||||
e.AddContent("cost_diamond_count", cost)
|
||||
.AddContent("click_free_count", refreshInfo.refresh);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_59"));
|
||||
}
|
||||
private void OnCannotRefersh()
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_64"));
|
||||
|
||||
}
|
||||
private async void OnChagneFishCardMap()
|
||||
{
|
||||
var selectPanel = await UIManager.Instance.ShowUI(UITypes.FishingShopSelectMapPopupPanel);
|
||||
selectPanel.GetComponent<FishingShopSelectMapPopupPanel>().Init(curSlelectingMapID);
|
||||
}
|
||||
private void OnTimerEnd()
|
||||
{
|
||||
GContext.container.Resolve<PlayerShopData>().AutoRefreshDiamonShop();
|
||||
RefreshItemBars();
|
||||
}
|
||||
|
||||
private IEnumerator IE_SetTimer()
|
||||
{
|
||||
_autoRefreshTimer = _shopData.GetDiamondShopRefreshTime();
|
||||
var miliSeconds = _autoRefreshTimer.Milliseconds;
|
||||
txt_itemShopTimer.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_refresh", ConvertTools.ConvertTime2(_autoRefreshTimer));
|
||||
yield return new WaitForSeconds(miliSeconds / 1000);
|
||||
_autoRefreshTimer.Subtract(TimeSpan.FromMilliseconds(miliSeconds));
|
||||
txt_itemShopTimer.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_refresh", ConvertTools.ConvertTime2(_autoRefreshTimer));
|
||||
|
||||
while (_autoRefreshTimer.TotalSeconds > 0)
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
_autoRefreshTimer = _autoRefreshTimer.Subtract(TimeSpan.FromSeconds(1));
|
||||
txt_itemShopTimer.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_refresh", ConvertTools.ConvertTime2(_autoRefreshTimer));
|
||||
}
|
||||
OnTimerEnd();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/ItemsShopPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/ItemsShopPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d741c5a952b0524bafff9428180d5fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/Scripts/UI/Shop/LackOfLuresConfirmPopupPanel.cs
Normal file
44
Assets/Scripts/UI/Shop/LackOfLuresConfirmPopupPanel.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LackOfLuresConfirmPopupPanel : MonoBehaviour
|
||||
{
|
||||
Button confirmButton;
|
||||
Button cancelButton;
|
||||
private void Awake()
|
||||
{
|
||||
confirmButton = transform.Find("root/btn_confrim/btn_green").GetComponent<Button>();
|
||||
cancelButton = transform.Find("btn_close").GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
confirmButton.onClick.AddListener(OnConfirmButtonClick);
|
||||
cancelButton.onClick.AddListener(OnCancelButtonClick);
|
||||
}
|
||||
private async void OnConfirmButtonClick()
|
||||
{
|
||||
var campData = GContext.container.Resolve<CampDataMM>();
|
||||
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
||||
bool isCanEnter = await loadResourceService.Loads(campData.AllPrefabs);
|
||||
if (isCanEnter)
|
||||
{
|
||||
GContext.Publish(new UnloadActToNextAct("BuildAct"));
|
||||
}
|
||||
else
|
||||
{
|
||||
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||||
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, () => GContext.Publish(new UnloadActToNextAct("BuildAct")));
|
||||
//var panel = await UIManager.Instance.ShowUI(UITypes.FishingDownLoadPopupPanel);
|
||||
//panel.GetComponent<FishingDownLoadPopupPanel>().SetBtn(null, () => GContext.Publish(new UnloadActToNextAct("BuildAct")));
|
||||
}
|
||||
UIManager.Instance.DestroyUI(UITypes.LackOfLuresConfirmPopupPanel);
|
||||
}
|
||||
private void OnCancelButtonClick()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.LackOfLuresConfirmPopupPanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/LackOfLuresConfirmPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/LackOfLuresConfirmPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fac7e984d0ab2b941ba23479db724743
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Scripts/UI/Shop/LackOfResourceConfirmPopupPanel.cs
Normal file
38
Assets/Scripts/UI/Shop/LackOfResourceConfirmPopupPanel.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class LackOfResourceConfirmEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 0.资源商店 1.钻石商店
|
||||
/// </summary>
|
||||
public int state;
|
||||
}
|
||||
|
||||
public class LackOfResourceConfirmPopupPanel : MonoBehaviour
|
||||
{
|
||||
Button confirmButton;
|
||||
Button cancelButton;
|
||||
private void Awake()
|
||||
{
|
||||
confirmButton = transform.Find("root/btn_confrim/btn_green").GetComponent<Button>();
|
||||
cancelButton = transform.Find("btn_close").GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
confirmButton.onClick.AddListener(OnConfirmButtonClick);
|
||||
cancelButton.onClick.AddListener(OnCancelButtonClick);
|
||||
}
|
||||
private async void OnConfirmButtonClick()
|
||||
{
|
||||
await UIManager.Instance.GetUIAsync(UITypes.FishingShopPanel);
|
||||
GContext.Publish(new LackOfResourceConfirmEvent() { state = 1 });
|
||||
UIManager.Instance.DestroyUI(UITypes.LackOfResourceConfirmPopupPanel);
|
||||
GContext.Publish(new HideHomePanelEvent());
|
||||
}
|
||||
private void OnCancelButtonClick()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.LackOfResourceConfirmPopupPanel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f8e0cded7fef1145b987adec66b63cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
106
Assets/Scripts/UI/Shop/LackOfResourcePopupPanel.cs
Normal file
106
Assets/Scripts/UI/Shop/LackOfResourcePopupPanel.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LackOfResourceCloseEvent
|
||||
{
|
||||
public bool resultToShop;
|
||||
}
|
||||
public class LackOfResourcePopupPanel : MonoBehaviour
|
||||
{
|
||||
Button btn_mask;
|
||||
Button btn_diamond;
|
||||
TMP_Text text_info;
|
||||
GameObject info;
|
||||
PlayerData _playerData;
|
||||
Tables _tables;
|
||||
Timer packTimer;
|
||||
#region Field&&Property
|
||||
[SerializeField]
|
||||
private EnergyShopSlot[] _diamondShopSlots;
|
||||
#endregion
|
||||
protected CompositeDisposable disposables = new CompositeDisposable();
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_playerData = GContext.container.Resolve<PlayerData>();
|
||||
btn_mask = transform.Find("mask").GetComponent<Button>();
|
||||
text_info = transform.Find("root/bg_info/text_info").GetComponent<TMP_Text>();
|
||||
info = transform.Find("root/bg_info").gameObject;
|
||||
btn_diamond = transform.Find("top_area/resource/icon_diamond").GetComponent<Button>();
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
btn_mask.onClick.AddListener(OnClose);
|
||||
btn_diamond.onClick.AddListener(async () =>
|
||||
{
|
||||
btn_diamond.enabled = false;
|
||||
LackOfResourceCloseEvent lackOfResourceCloseEvent = new LackOfResourceCloseEvent();
|
||||
lackOfResourceCloseEvent.resultToShop = true;
|
||||
GContext.Publish(lackOfResourceCloseEvent);
|
||||
await UIManager.Instance.GetUIAsync(UITypes.FishingShopPanel);
|
||||
UIManager.Instance.DestroyUI(UITypes.LackOfResourcePopupPanel);
|
||||
GContext.Publish(new HideHomePanelEvent());
|
||||
});
|
||||
GContext.OnEvent<LackOfResourceConfirmEvent>().Subscribe(x =>
|
||||
{
|
||||
LackOfResourceCloseEvent lackOfResourceCloseEvent = new LackOfResourceCloseEvent();
|
||||
lackOfResourceCloseEvent.resultToShop = true;
|
||||
GContext.Publish(lackOfResourceCloseEvent);
|
||||
UIManager.Instance.DestroyUI(UITypes.LackOfResourcePopupPanel);
|
||||
}).AddTo(disposables);
|
||||
|
||||
var shopTokens = GContext.container.Resolve<Tables>().TbResourceStore.DataList;
|
||||
EnergyDef energyDef = _tables.TbEnergyDef.DataList[GContext.container.Resolve<PlayerData>().magnification];
|
||||
_diamondShopSlots[0].SetData(shopTokens[0]);
|
||||
for (int i = 1; i < _diamondShopSlots.Length; i++)
|
||||
{
|
||||
_diamondShopSlots[i].gameObject.SetActive(false);
|
||||
}
|
||||
if (_diamondShopSlots.Length >= energyDef.ShopID)
|
||||
{
|
||||
_diamondShopSlots[energyDef.ShopID - 1].gameObject.SetActive(true);
|
||||
_diamondShopSlots[energyDef.ShopID - 1].SetData(GContext.container.Resolve<Tables>().TbResourceStore.GetOrDefault(energyDef.ShopID));
|
||||
}
|
||||
info.SetActive(false);
|
||||
//if (LackOfResourceEvent.type == 4)
|
||||
//{
|
||||
info.SetActive(true);
|
||||
TimeSpan now = _playerData.GetEnergyRecoveryTimeMAndS();
|
||||
packTimer = this.AttachTimer((float)now.TotalSeconds, null,
|
||||
(elapsed) =>
|
||||
{
|
||||
now = _playerData.GetEnergyRecoveryTimeMAndS();
|
||||
int EnergyRecover = _playerData.EnergyRecover;
|
||||
string Time2 = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
text_info.text = LocalizationMgr.GetFormatTextValue("UI_LackOfResourcePopupPanel_3", EnergyRecover, Time2);
|
||||
if (now.TotalMilliseconds <= 0 || _playerData.Energy >= _playerData.MaxEnergy)
|
||||
{
|
||||
packTimer?.Cancel();
|
||||
packTimer = null;
|
||||
info.SetActive(false);
|
||||
}
|
||||
}, useRealTime: true);
|
||||
//}
|
||||
|
||||
}
|
||||
void OnClose()
|
||||
{
|
||||
LackOfResourceCloseEvent lackOfResourceCloseEvent = new LackOfResourceCloseEvent();
|
||||
GContext.Publish(lackOfResourceCloseEvent);
|
||||
UIManager.Instance.DestroyUI(UITypes.LackOfResourcePopupPanel);
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
packTimer?.Cancel();
|
||||
packTimer = null;
|
||||
disposables?.Dispose();
|
||||
disposables = null;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/LackOfResourcePopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/LackOfResourcePopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b368e4b3b9a3c74ead9b728223befc7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
106
Assets/Scripts/UI/Shop/LackOfTicketPopupPanel.cs
Normal file
106
Assets/Scripts/UI/Shop/LackOfTicketPopupPanel.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LackOfTicketPopupPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private RewardItemNew _rewardShown;
|
||||
[SerializeField] private Button btnBuy, btnMask, btnDiscount;
|
||||
[SerializeField] private TMP_Text textPrice, textPriceOrigin, textPriceDiscount, textDiscount;
|
||||
[SerializeField] private GameObject discountTag;
|
||||
private Tables _tables;
|
||||
private TbWheelLevel _tableWheelLevel;
|
||||
private FishingEventData _fishingEventData;
|
||||
private PlayerItemData _playerItemData;
|
||||
private int _wheelLvl, _diamondCost;
|
||||
private ItemData _reward;
|
||||
private const int LackOfTicketPurchaseCount = -2;
|
||||
private TbWheelInit _tableWheelInit;
|
||||
private int PurchaseCount
|
||||
{
|
||||
get => _fishingEventData.WheelLevelCount[LackOfTicketPurchaseCount];
|
||||
set => _fishingEventData.WheelLevelCount[LackOfTicketPurchaseCount] = value;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
btnMask.onClick.AddListener(OnClickContinue);
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_tableWheelLevel = _tables.TbWheelLevel;
|
||||
_tableWheelInit = _tables.TbWheelInit;
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
_wheelLvl = _fishingEventData.wheelLevel.Level;
|
||||
_reward = new ItemData(1004, _tableWheelLevel[_wheelLvl].BuyCount);
|
||||
SetupPurchaseConfig();
|
||||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
_rewardShown.SetData(_reward);
|
||||
btnBuy.onClick.AddListener(OnClickBuy);
|
||||
btnDiscount.onClick.AddListener(OnClickBuy);
|
||||
}
|
||||
|
||||
private void SetupPurchaseConfig()
|
||||
{
|
||||
_diamondCost = _tableWheelLevel[_wheelLvl].Price;
|
||||
var discountList = _tableWheelInit.DataList[0].Discount;
|
||||
if (PurchaseCount >= discountList.Count)
|
||||
{
|
||||
btnBuy.gameObject.SetActive(true);
|
||||
btnDiscount.gameObject.SetActive(false);
|
||||
discountTag.SetActive(false);
|
||||
textPrice.text = ConvertTools.GetNumberString(_diamondCost);
|
||||
}
|
||||
else
|
||||
{
|
||||
btnBuy.gameObject.SetActive(false);
|
||||
btnDiscount.gameObject.SetActive(true);
|
||||
discountTag.SetActive(true);
|
||||
textDiscount.text = ConvertTools.GetNumberString3(discountList[PurchaseCount]);
|
||||
textPriceOrigin.text = ConvertTools.GetNumberString(_diamondCost);
|
||||
_diamondCost = (int) (_diamondCost * discountList[PurchaseCount]);
|
||||
int r = _diamondCost % 5;
|
||||
_diamondCost -= r;
|
||||
if (r >= 3)
|
||||
_diamondCost += 5;
|
||||
textPriceDiscount.text = ConvertTools.GetNumberString(_diamondCost);
|
||||
}
|
||||
}
|
||||
private void OnClickBuy()
|
||||
{
|
||||
int diamondCount = (int)_playerItemData.GetItemCount(1005);
|
||||
if (diamondCount < _diamondCost)
|
||||
{
|
||||
UIManager.Instance.ShowUI(UITypes.LackOfResourceConfirmPopupPanel);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerItemData.AddItem(_reward);
|
||||
_playerItemData.AddItemCount(1005, -_diamondCost);
|
||||
GContext.Publish(new ShowData(_reward));
|
||||
GContext.Publish(new ShowData());
|
||||
PurchaseCount++;
|
||||
_fishingEventData.UpdateTurnTableData();
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("resource_shop"))
|
||||
{
|
||||
e.AddContent("cost_diamond_count", _diamondCost)
|
||||
.AddContent("change_type", 5)
|
||||
.AddContent("change_num", _reward.count)
|
||||
.AddContent("item_id", "1004")
|
||||
.AddContent("change_count", 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
GContext.Publish(new ResAddEvent(1004));
|
||||
UIManager.Instance.DestroyUI(UITypes.LackOfTicketPopupPanel);
|
||||
}
|
||||
}
|
||||
private void OnClickContinue()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.LackOfTicketPopupPanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Shop/LackOfTicketPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Shop/LackOfTicketPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81178acb711291c48a2d5b703f6a1b14
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user