From 65171bcb4e556e5ff19d3ae3349ea1159126d3ca Mon Sep 17 00:00:00 2001
From: Client_PangDeRong <593317293@qq.com>
Date: 星期三, 24 十月 2018 11:26:06 +0800
Subject: [PATCH] 4232 许愿池功能开发

---
 System/OpenServerActivity/WishingPoolModel.cs |   67 +++++++++++++++++++++++++++------
 1 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/System/OpenServerActivity/WishingPoolModel.cs b/System/OpenServerActivity/WishingPoolModel.cs
index 4726406..491ad19 100644
--- a/System/OpenServerActivity/WishingPoolModel.cs
+++ b/System/OpenServerActivity/WishingPoolModel.cs
@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
+using TableConfig;
 
 namespace Snxxz.UI
 {
@@ -9,6 +10,7 @@
     {
         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()
@@ -16,7 +18,7 @@
             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()
@@ -108,11 +110,9 @@
         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;
@@ -130,28 +130,37 @@
             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);
             }
 
@@ -159,8 +168,38 @@
             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();
         }
@@ -211,7 +250,7 @@
             }
         }
 
-        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))
@@ -322,7 +361,7 @@
 
         public void ResetPoolData()
         {
-            freeStartTime = 25;
+            freeStartTime = 0;
             poolDataDict.Clear();
             wishingDataDict.Clear();
             wishingAwardDict.Clear();
@@ -333,11 +372,13 @@
             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;
             }
         }
     }

--
Gitblit v1.8.0