| | |
| | | using System.Collections.Generic;
|
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | | using TableConfig;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | |
| | | {
|
| | | public event Action<int> UpdateWishingDataEvent;
|
| | | public event Action<int> UpdatePoolDataEvent;
|
| | | public event Action UpdateWishAwardEvent;
|
| | | public event Action<int> onStateUpate;
|
| | | public const int WishRedKey = 20915;
|
| | | public override void Init()
|
| | |
| | | OperationTimeHepler.Instance.operationStartEvent += OperationStartEvent;
|
| | | OperationTimeHepler.Instance.operationEndEvent += OperationEndEvent;
|
| | | OperationTimeHepler.Instance.operationAdvanceEvent += OperationAdvanceEvent;
|
| | | OpenServerActivityCenter.Instance.Register((int)OpenServerActivityCenter.OSActivityType.FlashRushToBuy, this);
|
| | | OpenServerActivityCenter.Instance.Register((int)OpenServerActivityCenter.OSActivityType.WishingPool, this);
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | |
| | | public bool TryGetFreeWishCoolTime(out int second)
|
| | | {
|
| | | second = 0;
|
| | | if (freeStartTime == 25) return false;
|
| | |
|
| | | int endhour = freeStartTime + 2;
|
| | | int nowHour = TimeUtility.ServerNow.Hour;
|
| | | second = (endhour - nowHour) * 3600;
|
| | | int endSeconds = freeStartTime + freeRefreshCoolTime;
|
| | | DateTime endTime = TimeUtility.GetTime((uint)endSeconds);
|
| | | second = Mathf.CeilToInt((float)(endTime - TimeUtility.ServerNow).TotalSeconds);
|
| | | if(second > 0)
|
| | | {
|
| | | return true;
|
| | |
| | | isDraging = false;
|
| | | dragIndex = -1;
|
| | | }
|
| | | public int freeRefreshCoolTime { get; private set;}
|
| | | public string wishingPriceFormula { get; private set;}
|
| | | public void ParseConfig()
|
| | | {
|
| | | FuncConfigConfig funcConfig = Config.Instance.Get<FuncConfigConfig>("WishingWellCfg");
|
| | | freeRefreshCoolTime = int.Parse(funcConfig.Numerical1);
|
| | | wishingPriceFormula = funcConfig.Numerical2;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region 协议
|
| | | Dictionary<int, WishingWellItem> poolDataDict = new Dictionary<int, WishingWellItem>();
|
| | | public int freeStartTime { get; private set; }// 免费开始倒计时时间
|
| | | public int alreadyWishNum { get; private set; } // 许愿付费刷新次数
|
| | |
|
| | | public int wishingPrice { get; private set;}
|
| | | public void SetWishingWellPlayerInfo(HAA1A_tagMCActWishingWellPlayerInfo wishInfo)
|
| | | {
|
| | | freeStartTime = (int)wishInfo.FreeStartTime;
|
| | | alreadyWishNum = (int)wishInfo.WishCnt;
|
| | | wishingPrice = GetWishingPrice((int)wishInfo.WishCnt);
|
| | | for(int i = 0; i < wishInfo.WellItemCnt; i++)
|
| | | {
|
| | | var itemInfo = wishInfo.WellItemInfo[i];
|
| | | WishingWellItem wellItem = new WishingWellItem((int)itemInfo.ItemID,itemInfo.ItemCnt,itemInfo.IsBind);
|
| | | WishingWellItem wellItem = new WishingWellItem((int)itemInfo.ItemID,itemInfo.ItemCnt,itemInfo.IsBind,itemInfo.IsSpecial);
|
| | | SetWishingPoolData(i,wellItem);
|
| | | }
|
| | |
|
| | | for(int i = 0; i < wishInfo.CurAwardCnt; i++)
|
| | | {
|
| | | var itemInfo = wishInfo.CurAwardItemInfo[i];
|
| | | WishingWellItem wellItem = new WishingWellItem((int)itemInfo.ItemID, itemInfo.ItemCnt, itemInfo.IsBind);
|
| | | WishingWellItem wellItem = new WishingWellItem((int)itemInfo.ItemID, itemInfo.ItemCnt, itemInfo.IsBind, itemInfo.IsSpecial);
|
| | | SetWishingData(i, wellItem);
|
| | | }
|
| | |
|
| | |
| | | for (int i = 0; i < wishInfo.LastAwardCnt; i++)
|
| | | {
|
| | | var itemInfo = wishInfo.LastAwardItemInfo[i];
|
| | | WishingWellItem wellItem = new WishingWellItem((int)itemInfo.ItemID, itemInfo.ItemCnt, itemInfo.IsBind);
|
| | | WishingWellItem wellItem = new WishingWellItem((int)itemInfo.ItemID, itemInfo.ItemCnt, itemInfo.IsBind, itemInfo.IsSpecial);
|
| | | SetWishingAwardData(i, wellItem);
|
| | | }
|
| | | UpdateRedpoint();
|
| | | if(UpdateWishAwardEvent != null)
|
| | | {
|
| | | UpdateWishAwardEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | public int GetWishingPrice(int wishNum)
|
| | | {
|
| | | Equation.Instance.Clear();
|
| | | Equation.Instance.AddKeyValue("refreshCnt",wishNum);
|
| | | return Equation.Instance.Eval<int>(wishingPriceFormula);
|
| | | }
|
| | |
|
| | | public void SetWishingResultInfo(HAA1B_tagMCActWishingDragResult result)
|
| | | {
|
| | | for(int i = 0; i < result.Cnt;i++)
|
| | | {
|
| | | var resultInfo = result.InfoList[i];
|
| | | WishingWellItem wellItem = new WishingWellItem((int)resultInfo.ItemID, resultInfo.ItemCnt, resultInfo.IsBind, resultInfo.IsSpecial);
|
| | | switch (resultInfo.WellType)
|
| | | {
|
| | | case 0:
|
| | | SetWishingPoolData(resultInfo.Index, wellItem);
|
| | | break;
|
| | | case 1:
|
| | | SetWishingData(resultInfo.Index, wellItem);
|
| | | break;
|
| | | }
|
| | | }
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | Dictionary<int, WishingWellItem> wishingAwardDict = new Dictionary<int, WishingWellItem>();
|
| | | public Dictionary<int, WishingWellItem> wishingAwardDict = new Dictionary<int, WishingWellItem>();
|
| | | public void SetWishingAwardData(int index, WishingWellItem wellItem)
|
| | | {
|
| | | if (!wishingAwardDict.ContainsKey(index))
|
| | |
| | |
|
| | | public void ResetPoolData()
|
| | | {
|
| | | freeStartTime = 25;
|
| | | freeStartTime = 0;
|
| | | poolDataDict.Clear();
|
| | | wishingDataDict.Clear();
|
| | | wishingAwardDict.Clear();
|
| | |
| | | public int itemId;
|
| | | public int itemCount;
|
| | | public int isBind;
|
| | | public WishingWellItem(int id,int count,int isBind)
|
| | | public int isBest;
|
| | | public WishingWellItem(int id,int count,int isBind,int isBest)
|
| | | {
|
| | | this.itemId = id;
|
| | | this.itemCount = count;
|
| | | this.isBind = isBind;
|
| | | this.isBest = isBest;
|
| | | }
|
| | | }
|
| | | }
|