From 6268b07e7672f15e6a590bde5e3032e86252747a Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期六, 13 四月 2019 15:35:41 +0800
Subject: [PATCH] 3335 整理代码
---
System/MainInterfacePanel/BuffInfoWin.cs | 442 +++++++++++++++++++++++++++---------------------------
1 files changed, 221 insertions(+), 221 deletions(-)
diff --git a/System/MainInterfacePanel/BuffListWin.cs b/System/MainInterfacePanel/BuffInfoWin.cs
similarity index 99%
rename from System/MainInterfacePanel/BuffListWin.cs
rename to System/MainInterfacePanel/BuffInfoWin.cs
index 9f714a9..81b225c 100644
--- a/System/MainInterfacePanel/BuffListWin.cs
+++ b/System/MainInterfacePanel/BuffInfoWin.cs
@@ -1,221 +1,221 @@
-锘�//--------------------------------------------------------
-// [Author]: 绗簩涓栫晫
-// [ Date ]: Thursday, October 26, 2017
-//--------------------------------------------------------
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.UI;
-//鍏充簬Buff闈㈡澘鐨勮缃�
-namespace Snxxz.UI
-{
-
- public class BuffListWin : Window
- {
- public float UpperAndLower = 50f;
- public float ItemHeight = 50f;
- public float MaxHeight = 300f;
- [SerializeField] Transform Viewport;
- [SerializeField] ScrollerController m_ScrollerController;
- private ScrollRect _ScrollRect;
- private Dictionary<int, ObjBuff> objBuffic;
- private List<int> _SortList = new List<int>();//鎺掑簭鍒楄〃
-
- BuffModel Buffmodel { get { return ModelCenter.Instance.GetModel<BuffModel>(); } }
-
- #region Built-in
- protected override void BindController()
- {
- _ScrollRect = Viewport.GetComponent<ScrollRect>();
- }
-
- protected override void AddListeners()
- {
- }
-
- protected override void OnPreOpen()
- {
- objBuffic = Buffmodel._BuffDic;
- m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
- BuffModel.Even_ObjAddBuf += AddBuff;
- BuffModel.Even_ObjDelBuff += DelBuff;
- BuffScheduling();
- UpdateControllerPosition();
- OnCreateGridLineCell(m_ScrollerController);
- }
-
- protected override void OnAfterOpen()
- {
- }
-
- protected override void OnPreClose()
- {
- }
-
- protected override void OnAfterClose()
- {
- m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
- BuffModel.Even_ObjAddBuf -= AddBuff;
- BuffModel.Even_ObjDelBuff -= DelBuff;
- }
- #endregion
-
-
- void UpdateControllerPosition()
- {
-
- if (_SortList.Count == 0)
- {
- Close();
- return;
-
- }
- if (_SortList.Count * ItemHeight >= MaxHeight)
- {
- _ScrollRect.vertical = true;
- (Viewport as RectTransform).sizeDelta = (Viewport as RectTransform).sizeDelta.SetY(MaxHeight + UpperAndLower);
- }
- else
- {
- _ScrollRect.vertical = false;
- (Viewport as RectTransform).sizeDelta = (Viewport as RectTransform).sizeDelta.SetY(_SortList.Count * ItemHeight + UpperAndLower);
- }
- }
-
- void OnCreateGridLineCell(ScrollerController gridCtrl)//棰勫埗浣撳垱寤�
- {
- gridCtrl.Refresh();
-
- for (int i = 0; i < _SortList.Count; i++)
- {
- gridCtrl.AddCell(ScrollerDataType.Header, i);
- }
- gridCtrl.Restart();
- }
- void OnRefreshGridCell(ScrollerDataType type, CellView cell)
- {
- int _index = cell.index;
- BuffBGMScripts _buffBGM = cell.GetComponent<BuffBGMScripts>();
-
- int _INList = _SortList[_index];
- _buffBGM.b_BuffIcon.SetSprite(objBuffic[_INList].ImagKey);
- _buffBGM.b_BuffName.text = objBuffic[_INList].BuffName;
- _buffBGM.b_BuffContent.text = objBuffic[_INList].BuffConent;
- int _UseTheSecond = Mathf.FloorToInt((float)(DateTime.Now - objBuffic[_INList]._dattTime).TotalSeconds);
- if (objBuffic[_INList].LastTime - _UseTheSecond > 0)
- {
- _buffBGM.b_BuffTime.gameObject.SetActive(true);
- _buffBGM._currentime = 0;
- _buffBGM._time = objBuffic[_INList].LastTime - _UseTheSecond;
- _buffBGM._OnOff = true;
-
- }
- else
- {
- _buffBGM.b_BuffTime.gameObject.SetActive(false);
- _buffBGM.b_BuffTime.text = "";
- }
- if (objBuffic[_INList].Layer > 0)
- {
- _buffBGM.BiBuffText.gameObject.SetActive(true);
- _buffBGM.BiBuffText.text = objBuffic[_INList].Layer.ToString();
- }
- else
- {
- _buffBGM.BiBuffText.gameObject.SetActive(false);
- }
-
- }
-
-
-
- void BuffScheduling()//buff鎺掑簭
- {
- _SortList.Clear();
- foreach (int key in objBuffic.Keys)
- {
- _SortList.Add(key);
- }
- _SortList.Sort(Compare);
-
- }
-
- int Compare(int x, int y)
- {
- bool havex = IsExperience(x);
- bool havey = IsExperience(y);
- if (havex.CompareTo(havey) != 0)
- {
- return -havex.CompareTo(havey);
- }
- int havex1 = TimeClassification(x);
- int havey1 = TimeClassification(y);
- if (havex1.CompareTo(havey1) != 0)
- {
- return havex1.CompareTo(havey1);
- }
- ObjBuff xPack = objBuffic[x];
- ObjBuff yPack = objBuffic[y];
- if (xPack._dattTime.CompareTo(yPack._dattTime) != 0)
- {
- return -xPack._dattTime.CompareTo(yPack._dattTime);
- }
- return 1;
- }
-
- private bool IsExperience(int BuffID)//鍒ゆ柇鏄惁鏄粡楠岀被鍨婤uff
- {
- bool IsBool = false;
- if (objBuffic.ContainsKey(BuffID))
- {
- if (objBuffic[BuffID].BuffType == 9)
- {
- IsBool = true;
- }
- }
- return IsBool;
- }
-
- private int TimeClassification(int BuffID)//鏃堕棿鍒嗙被
- {
- int Type = 0;
- return Type;
- }
-
- List<int> Priority()
- {
- List<int> _List = new List<int>();
- string[] _strList = FuncConfigConfig.Get("BuffType").Numerical2.Split('|');
- for (int i = 0; i < _strList.Length; i++)
- {
- _List.Add(int.Parse(_strList[i]));
-
- }
- return _List;
- }
-
- void AddBuff()
- {
- objBuffic = Buffmodel._BuffDic;
- BuffScheduling();
- UpdateControllerPosition();
- OnCreateGridLineCell(m_ScrollerController);
- }
-
- void DelBuff()
- {
- objBuffic = Buffmodel._BuffDic;
- BuffScheduling();
- UpdateControllerPosition();
- OnCreateGridLineCell(m_ScrollerController);
- }
-
- }
-
-}
-
-
-
-
+锘�//--------------------------------------------------------
+// [Author]: 绗簩涓栫晫
+// [ Date ]: Thursday, October 26, 2017
+//--------------------------------------------------------
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+//鍏充簬Buff闈㈡澘鐨勮缃�
+namespace Snxxz.UI
+{
+
+ public class BuffInfoWin : Window
+ {
+ public float UpperAndLower = 50f;
+ public float ItemHeight = 50f;
+ public float MaxHeight = 300f;
+ [SerializeField] Transform Viewport;
+ [SerializeField] ScrollerController m_ScrollerController;
+ private ScrollRect _ScrollRect;
+ private Dictionary<int, ObjBuff> objBuffic;
+ private List<int> _SortList = new List<int>();//鎺掑簭鍒楄〃
+
+ BuffModel Buffmodel { get { return ModelCenter.Instance.GetModel<BuffModel>(); } }
+
+ #region Built-in
+ protected override void BindController()
+ {
+ _ScrollRect = Viewport.GetComponent<ScrollRect>();
+ }
+
+ protected override void AddListeners()
+ {
+ }
+
+ protected override void OnPreOpen()
+ {
+ objBuffic = Buffmodel._BuffDic;
+ m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
+ BuffModel.Even_ObjAddBuf += AddBuff;
+ BuffModel.Even_ObjDelBuff += DelBuff;
+ BuffScheduling();
+ UpdateControllerPosition();
+ OnCreateGridLineCell(m_ScrollerController);
+ }
+
+ protected override void OnAfterOpen()
+ {
+ }
+
+ protected override void OnPreClose()
+ {
+ }
+
+ protected override void OnAfterClose()
+ {
+ m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
+ BuffModel.Even_ObjAddBuf -= AddBuff;
+ BuffModel.Even_ObjDelBuff -= DelBuff;
+ }
+ #endregion
+
+
+ void UpdateControllerPosition()
+ {
+
+ if (_SortList.Count == 0)
+ {
+ Close();
+ return;
+
+ }
+ if (_SortList.Count * ItemHeight >= MaxHeight)
+ {
+ _ScrollRect.vertical = true;
+ (Viewport as RectTransform).sizeDelta = (Viewport as RectTransform).sizeDelta.SetY(MaxHeight + UpperAndLower);
+ }
+ else
+ {
+ _ScrollRect.vertical = false;
+ (Viewport as RectTransform).sizeDelta = (Viewport as RectTransform).sizeDelta.SetY(_SortList.Count * ItemHeight + UpperAndLower);
+ }
+ }
+
+ void OnCreateGridLineCell(ScrollerController gridCtrl)//棰勫埗浣撳垱寤�
+ {
+ gridCtrl.Refresh();
+
+ for (int i = 0; i < _SortList.Count; i++)
+ {
+ gridCtrl.AddCell(ScrollerDataType.Header, i);
+ }
+ gridCtrl.Restart();
+ }
+ void OnRefreshGridCell(ScrollerDataType type, CellView cell)
+ {
+ int _index = cell.index;
+ BuffBGMScripts _buffBGM = cell.GetComponent<BuffBGMScripts>();
+
+ int _INList = _SortList[_index];
+ _buffBGM.b_BuffIcon.SetSprite(objBuffic[_INList].ImagKey);
+ _buffBGM.b_BuffName.text = objBuffic[_INList].BuffName;
+ _buffBGM.b_BuffContent.text = objBuffic[_INList].BuffConent;
+ int _UseTheSecond = Mathf.FloorToInt((float)(DateTime.Now - objBuffic[_INList]._dattTime).TotalSeconds);
+ if (objBuffic[_INList].LastTime - _UseTheSecond > 0)
+ {
+ _buffBGM.b_BuffTime.gameObject.SetActive(true);
+ _buffBGM._currentime = 0;
+ _buffBGM._time = objBuffic[_INList].LastTime - _UseTheSecond;
+ _buffBGM._OnOff = true;
+
+ }
+ else
+ {
+ _buffBGM.b_BuffTime.gameObject.SetActive(false);
+ _buffBGM.b_BuffTime.text = "";
+ }
+ if (objBuffic[_INList].Layer > 0)
+ {
+ _buffBGM.BiBuffText.gameObject.SetActive(true);
+ _buffBGM.BiBuffText.text = objBuffic[_INList].Layer.ToString();
+ }
+ else
+ {
+ _buffBGM.BiBuffText.gameObject.SetActive(false);
+ }
+
+ }
+
+
+
+ void BuffScheduling()//buff鎺掑簭
+ {
+ _SortList.Clear();
+ foreach (int key in objBuffic.Keys)
+ {
+ _SortList.Add(key);
+ }
+ _SortList.Sort(Compare);
+
+ }
+
+ int Compare(int x, int y)
+ {
+ bool havex = IsExperience(x);
+ bool havey = IsExperience(y);
+ if (havex.CompareTo(havey) != 0)
+ {
+ return -havex.CompareTo(havey);
+ }
+ int havex1 = TimeClassification(x);
+ int havey1 = TimeClassification(y);
+ if (havex1.CompareTo(havey1) != 0)
+ {
+ return havex1.CompareTo(havey1);
+ }
+ ObjBuff xPack = objBuffic[x];
+ ObjBuff yPack = objBuffic[y];
+ if (xPack._dattTime.CompareTo(yPack._dattTime) != 0)
+ {
+ return -xPack._dattTime.CompareTo(yPack._dattTime);
+ }
+ return 1;
+ }
+
+ private bool IsExperience(int BuffID)//鍒ゆ柇鏄惁鏄粡楠岀被鍨婤uff
+ {
+ bool IsBool = false;
+ if (objBuffic.ContainsKey(BuffID))
+ {
+ if (objBuffic[BuffID].BuffType == 9)
+ {
+ IsBool = true;
+ }
+ }
+ return IsBool;
+ }
+
+ private int TimeClassification(int BuffID)//鏃堕棿鍒嗙被
+ {
+ int Type = 0;
+ return Type;
+ }
+
+ List<int> Priority()
+ {
+ List<int> _List = new List<int>();
+ string[] _strList = FuncConfigConfig.Get("BuffType").Numerical2.Split('|');
+ for (int i = 0; i < _strList.Length; i++)
+ {
+ _List.Add(int.Parse(_strList[i]));
+
+ }
+ return _List;
+ }
+
+ void AddBuff()
+ {
+ objBuffic = Buffmodel._BuffDic;
+ BuffScheduling();
+ UpdateControllerPosition();
+ OnCreateGridLineCell(m_ScrollerController);
+ }
+
+ void DelBuff()
+ {
+ objBuffic = Buffmodel._BuffDic;
+ BuffScheduling();
+ UpdateControllerPosition();
+ OnCreateGridLineCell(m_ScrollerController);
+ }
+
+ }
+
+}
+
+
+
+
--
Gitblit v1.8.0