| | |
| | | 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()
|
| | | {
|
| | | ParseConfig();
|
| | | 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);
|
| | | SetWishRedpoint();
|
| | | }
|
| | |
|
| | | 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;
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | public bool IsBestItem()
|
| | | {
|
| | | foreach(var key in poolDataDict.Keys)
|
| | | {
|
| | | if(poolDataDict[key].isBest == 1)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public int handStartIndex { get; private set; }
|
| | | public int handEndIndex { get; private set;}
|
| | | public event Action UpdateHandMoveEvent;
|
| | | public void SetHandMovePos(int wishIndex)
|
| | | {
|
| | | foreach(var key in poolDataDict.Keys)
|
| | | {
|
| | | if(poolDataDict[key].itemId != 0)
|
| | | {
|
| | | handStartIndex = key;
|
| | | break;
|
| | | }
|
| | | }
|
| | | handEndIndex = wishIndex;
|
| | | if(UpdateHandMoveEvent != null)
|
| | | {
|
| | | UpdateHandMoveEvent();
|
| | | }
|
| | | }
|
| | |
|
| | | #region 本地数据
|
| | | public bool isDraging { get; set; }
|
| | |
| | | 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);
|
| | | if(itemInfo.ItemID != 0)
|
| | | {
|
| | | 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))
|
| | |
| | | GameNetSystem.Instance.SendInfo(wishingRefresh);
|
| | | }
|
| | |
|
| | | public void SendGetAwardQuest()
|
| | | {
|
| | | CA504_tagCMPlayerGetReward getReward = new CA504_tagCMPlayerGetReward();
|
| | | getReward.RewardType = (byte)GotServerRewardType.Def_RewardType_WishingWell;
|
| | | getReward.DataEx = 0;
|
| | | getReward.DataExStrLen = 0;
|
| | | getReward.DataExStr = string.Empty;
|
| | | GameNetSystem.Instance.SendInfo(getReward);
|
| | | }
|
| | |
|
| | | public void SendRefreshWishInfo(int poolIndex,int wishIndex)
|
| | | {
|
| | | CAA06_tagCMActWishing actWishing = new CAA06_tagCMActWishing();
|
| | |
| | | }
|
| | | private void UpdateRedpoint()
|
| | | {
|
| | | int second = 0;
|
| | | bool isCool = TryGetFreeWishCoolTime(out second);
|
| | | if(IsOpen && !isCool)
|
| | | {
|
| | | freeWishRedpoint.state = RedPointState.Simple;
|
| | | }
|
| | | else
|
| | | {
|
| | | freeWishRedpoint.state = RedPointState.None;
|
| | | }
|
| | |
|
| | | for (int i = 0; i < wishPointlist.Count; i++)
|
| | | {
|
| | | var wishPoint = wishPointlist[i];
|
| | | wishPoint.state = RedPointState.None;
|
| | | }
|
| | |
|
| | | if (!IsOpen) return;
|
| | |
|
| | | int second = 0;
|
| | | bool isCool = TryGetFreeWishCoolTime(out second);
|
| | | if(!isCool)
|
| | | {
|
| | | freeWishRedpoint.state = RedPointState.Simple;
|
| | | }
|
| | |
|
| | | for (int i = 0; i < wishPointlist.Count; i++)
|
| | |
| | |
|
| | | 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;
|
| | | }
|
| | | }
|
| | | }
|