瀏覽代碼

抽卡特效

zhaoyang 3 年之前
父節點
當前提交
3bdd0a922a

+ 42 - 11
GameClient/Assets/Game/HotUpdate/Utils/DateUtils.cs

@@ -22,35 +22,66 @@ namespace GFGGame
 
             return (int)timeSpan.TotalSeconds;
         }
-        public string getFormatBySecond(int second, int type = 1, int showLength = 2)
+        //direction排版方向:0横向,1纵向
+        public string getFormatBySecond(int second, int type = 1, int direction = 0)
         {
-            string str  = "";
+            string str = "";
             int ms = second * 1000;
             switch (type)
             {
                 case DateUtils.TIME_FORMAT_1:
-                    str = this.format_1(second);
+                    str = this.format_1(second, direction);
                     break;
             }
             return str;
         }
         //剩余时间大于1天返回天数,小于一天返回小时数,小于一小时返回分钟数,小于1分钟返回秒数
-        public string format_1(int second)
+        public string format_1(int second, int direction = 0)
         {
             if (second / this.SECOND_PER_DAY >= 1)
             {
-                return string.Format ("剩余{0}天", Mathf.Floor(second / this.SECOND_PER_DAY));
+                if (direction == 0)
+                {
+                    return string.Format("剩余{0}天", Mathf.Floor(second / this.SECOND_PER_DAY));
+                }
+                else
+                {
+                    return string.Format("剩\n余\n{0}\n天", Mathf.Floor(second / this.SECOND_PER_DAY));
+                }
             }
-            else if(second / this.SECOND_PER_DAY<1&& second/(this.MUNITE_PER_HOUR*this.SECOND_PER_MUNITE) >= 1)
+            else if (second / this.SECOND_PER_DAY < 1 && second / (this.MUNITE_PER_HOUR * this.SECOND_PER_MUNITE) >= 1)
             {
-                return string.Format("剩余{0}小时", Mathf.Floor(second /( this.MUNITE_PER_HOUR * this.SECOND_PER_MUNITE)));
+                if (direction == 0)
+                {
+                    return string.Format("剩余{0}小时", Mathf.Floor(second / (this.MUNITE_PER_HOUR * this.SECOND_PER_MUNITE)));
+
+                }
+                else
+                {
+                    return string.Format("剩\n余\n{0}\n小\n时", Mathf.Floor(second / (this.MUNITE_PER_HOUR * this.SECOND_PER_MUNITE)));
+                }
             }
-            else if (second / this.SECOND_PER_DAY < 1 && second / (this.MUNITE_PER_HOUR * this.SECOND_PER_MUNITE) < 1&& second/this. SECOND_PER_MUNITE>=1)
+            else if (second / this.SECOND_PER_DAY < 1 && second / (this.MUNITE_PER_HOUR * this.SECOND_PER_MUNITE) < 1 && second / this.SECOND_PER_MUNITE >= 1)
             {
-                return string.Format("剩余{0}分钟", Mathf.Floor(second / this.SECOND_PER_MUNITE));
-            }else if (second< this.SECOND_PER_MUNITE)
+                if (direction == 0)
+                {
+                    return string.Format("剩余{0}分钟", Mathf.Floor(second / this.SECOND_PER_MUNITE));
+                }
+                else
+                {
+                    return string.Format("剩\n余\n{0}\n分\n钟", Mathf.Floor(second / this.SECOND_PER_MUNITE));
+                }
+            }
+            else if (second < this.SECOND_PER_MUNITE)
             {
-                return string.Format("剩余{0}秒", second);
+                if (direction == 0)
+                {
+                    return string.Format("剩余{0}秒", second);
+                }
+                else
+                {
+                    return string.Format("剩\n余\n{0}\n秒", second);
+                }
             }
             return "";
         }

+ 27 - 10
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxStarView.cs

@@ -18,6 +18,11 @@ namespace GFGGame
         private List<GoWrapper> _wrappers = new List<GoWrapper>();
         private List<GameObject> _gameObjects1 = new List<GameObject>();
         private List<GoWrapper> _wrappers1 = new List<GoWrapper>();
+        private Dictionary<int, List<GameObject>> dicGameobj = new Dictionary<int, List<GameObject>>();
+        private Dictionary<int, List<GoWrapper>> dicWrappers = new Dictionary<int, List<GoWrapper>>();
+        private Dictionary<int, List<GameObject>> dicGameobj1 = new Dictionary<int, List<GameObject>>();
+        private Dictionary<int, List<GoWrapper>> dicWrappers1 = new Dictionary<int, List<GoWrapper>>();
+
 
         private GObject curComStar;//当前选中的星星
         private Vector2 lastPos;//鼠标的上一个位置,每颗星星初始时默认为Vector2.right;
@@ -28,6 +33,7 @@ namespace GFGGame
         private const int imgLineWidth = 10;//线的原始长度
 
         private bool isGuide = false;
+        private bool isFirst = true;
         public override void Dispose()
         {
             for (int i = 0; i < _gameObjects.Count; i++)
@@ -35,6 +41,7 @@ namespace GFGGame
                 SceneController.DestroyObjectFromView(_gameObjects[i]);
                 SceneController.DestroyObjectFromView(_gameObjects1[i]);
             }
+
             base.Dispose();
         }
 
@@ -59,7 +66,7 @@ namespace GFGGame
             _ui.m_ctrlBuyType.selectedIndex = _rewardList != null && _rewardList.Count > 1 ? 1 : 0;
 
             _ui.m_ctrlRewardsType.selectedIndex = Array.IndexOf(LuckyBoxCfgArray.Instance.dataArray, LuckyBoxCfgArray.Instance.GetCfg((int)viewData)); ;
-
+            isFirst = true;
             ResetStartView();
 
         }
@@ -80,21 +87,25 @@ namespace GFGGame
                 comStar.m_imgLine.width = imgLineWidth;
                 comStar.m_imgLine.rotation = 0;
 
-                if (_gameObjects.Count <= index)
+                if (isFirst && (!dicGameobj.ContainsKey(_ui.m_ctrlRewardsType.selectedIndex) || dicGameobj1[_ui.m_ctrlRewardsType.selectedIndex].Count <= index))
                 {
                     GameObject gameObject = _gameObjects.Count > index ? _gameObjects[index] : null;
                     GoWrapper wrapper = _wrappers.Count > index ? _wrappers[index] : null;
                     string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck");
                     SceneController.AddObjectToView(gameObject, wrapper, comStar.m_holder, resPath, out gameObject, out wrapper);
-                    _gameObjects.Add(gameObject);
-                    _wrappers.Add(wrapper);
+                    if (!dicGameobj.ContainsKey(_ui.m_ctrlRewardsType.selectedIndex)) dicGameobj.Add(_ui.m_ctrlRewardsType.selectedIndex, new List<GameObject>());
+                    if (!dicWrappers.ContainsKey(_ui.m_ctrlRewardsType.selectedIndex)) dicWrappers.Add(_ui.m_ctrlRewardsType.selectedIndex, new List<GoWrapper>());
+                    dicGameobj[_ui.m_ctrlRewardsType.selectedIndex].Add(gameObject);
+                    dicWrappers[_ui.m_ctrlRewardsType.selectedIndex].Add(wrapper);
 
                     GameObject gameObject1 = _gameObjects1.Count > index ? _gameObjects1[index] : null;
                     GoWrapper wrapper1 = _wrappers1.Count > index ? _wrappers1[index] : null;
                     string resPath1 = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_dj");
                     SceneController.AddObjectToView(gameObject1, wrapper1, comStar.m_holder1, resPath1, out gameObject1, out wrapper1);
-                    _gameObjects1.Add(gameObject);
-                    _wrappers1.Add(wrapper);
+                    if (!dicGameobj1.ContainsKey(_ui.m_ctrlRewardsType.selectedIndex)) dicGameobj1.Add(_ui.m_ctrlRewardsType.selectedIndex, new List<GameObject>());
+                    if (!dicWrappers1.ContainsKey(_ui.m_ctrlRewardsType.selectedIndex)) dicWrappers1.Add(_ui.m_ctrlRewardsType.selectedIndex, new List<GoWrapper>());
+                    dicGameobj1[_ui.m_ctrlRewardsType.selectedIndex].Add(gameObject1);
+                    dicWrappers1[_ui.m_ctrlRewardsType.selectedIndex].Add(wrapper1);
                 }
                 star.data = new Vector2(comStar.target.x, comStar.target.y);
                 comStars.Add(star);
@@ -176,6 +187,7 @@ namespace GFGGame
         {
             if (isGuide && comStars.Count > 0)
             {
+                isFirst = false;
                 ResetStartView();
             }
             else
@@ -219,10 +231,15 @@ namespace GFGGame
         protected override void OnHide()
         {
             base.OnHide();
-            _gameObjects.Clear();
-            _wrappers.Clear();
-            _gameObjects1.Clear();
-            _wrappers1.Clear();
+            // _gameObjects.Clear();
+            // _wrappers.Clear();
+            // _gameObjects1.Clear();
+            // _wrappers1.Clear();
+            // for (int i = 0; i < _gameObjects.Count; i++)
+            // {
+            //     SceneController.DestroyObjectFromView(_gameObjects[i]);
+            //     SceneController.DestroyObjectFromView(_gameObjects1[i]);
+            // }
         }
     }
 }