0015 卡牌服务端搭建 - 去掉旧命名空间vnxbqy.UI,调整目录如ui里是界面 旧项目是 ui/window 等
| | |
| | | |
| | | public void OnDrag(PointerEventData eventData) |
| | | { |
| | | // if (vnxbqy.UI.NewBieCenter.Instance.inGuiding) |
| | | // if (NewBieCenter.Instance.inGuiding) |
| | | // { |
| | | // return; |
| | | // } |
| | |
| | | // //-------------------------------------------------------- |
| | | // // [Author]: 第二世界 |
| | | // // [ Date ]: Monday, July 31, 2017 |
| | | // //-------------------------------------------------------- |
| | | // using UnityEngine; |
| | | // using System.Collections; |
| | | // using UnityEngine.UI; |
| | | // using System; |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Monday, July 31, 2017
|
| | | //--------------------------------------------------------
|
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using UnityEngine.UI;
|
| | | using System;
|
| | |
|
| | |
|
| | | public class ItemBehaviour : MonoBehaviour
|
| | | {
|
| | |
|
| | |
|
| | | [SerializeField] ImageEx m_Icon;
|
| | | public ImageEx icon { get { return m_Icon; } }
|
| | |
|
| | | [SerializeField] ImageEx m_BackGround;
|
| | | public ImageEx backGround { get { return m_BackGround; } }
|
| | |
|
| | | [SerializeField] Transform m_CountContainer;
|
| | | public Transform countContainer { get { return m_CountContainer; } }
|
| | |
|
| | | [SerializeField] Text m_Count;
|
| | | public Text count { get { return m_Count; } }
|
| | |
|
| | | [SerializeField] Button m_ViewDetails;
|
| | |
|
| | | [SerializeField] ItemType m_ItemType = ItemType.Rewards;
|
| | |
|
| | | EquipSuitEffect m_EquipSuitEffect;
|
| | | EquipSuitEffect equipSuitEffect
|
| | | {
|
| | | get
|
| | | {
|
| | | if (m_EquipSuitEffect == null)
|
| | | {
|
| | | m_EquipSuitEffect = EquipSuitEffect.Create(transform as RectTransform);
|
| | | }
|
| | | return m_EquipSuitEffect;
|
| | | }
|
| | | }
|
| | |
|
| | | //物品基础特效(物品表)
|
| | | ItemBaseEffect m_ItemBaseEffect;
|
| | | ItemBaseEffect itemBaseEffect
|
| | | {
|
| | | get
|
| | | {
|
| | | if (m_ItemBaseEffect == null)
|
| | | {
|
| | | m_ItemBaseEffect = ItemBaseEffect.Create(transform as RectTransform);
|
| | | }
|
| | | return m_ItemBaseEffect;
|
| | | }
|
| | | }
|
| | |
|
| | | bool m_ShowCount = true;
|
| | | public bool showCount
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_ShowCount;
|
| | | }
|
| | | set
|
| | | {
|
| | | if (m_ShowCount != value)
|
| | | {
|
| | | m_ShowCount = value;
|
| | | DisplayCount();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public int itemId
|
| | | {
|
| | | get; private set;
|
| | | }
|
| | |
|
| | | public int itemCount
|
| | | {
|
| | | get; private set;
|
| | | }
|
| | |
|
| | | public int itemQuality { get; private set; }
|
| | |
|
| | | private void Awake()
|
| | | {
|
| | | if (m_ViewDetails != null)
|
| | | {
|
| | | m_ViewDetails.SetListener(ViewDetails);
|
| | | }
|
| | | }
|
| | |
|
| | | public void SetItem(Item _item)
|
| | | {
|
| | | SetItem(_item.id, _item.count, _item.quality);
|
| | | }
|
| | |
|
| | | public void SetItem(int _id, int _count, int _quality = 0)
|
| | | {
|
| | | itemId = _id;
|
| | | itemCount = _count;
|
| | | itemQuality = _quality;
|
| | | DisplayBaseInfo();
|
| | | DisplayCount();
|
| | | }
|
| | |
|
| | | public void SetCount(int _count)
|
| | | {
|
| | | itemCount = _count;
|
| | | DisplayCount();
|
| | | }
|
| | |
|
| | | public void DisplayEmpty()
|
| | | {
|
| | | try
|
| | | {
|
| | | icon.SetActive(false);
|
| | | backGround.SetActive(false);
|
| | | if (countContainer != null)
|
| | | {
|
| | | countContainer.SetActive(false);
|
| | | }
|
| | | }
|
| | | catch (System.Exception ex)
|
| | | {
|
| | | Debug.Log(ex);
|
| | | }
|
| | | }
|
| | |
|
| | | private void DisplayBaseInfo()
|
| | | {
|
| | | try
|
| | | {
|
| | | var itemInfo = ItemConfig.Get(itemId);
|
| | | if (icon != null)
|
| | | {
|
| | | icon.SetActive(true);
|
| | | icon.SetSprite(itemInfo.IconKey);
|
| | | }
|
| | |
|
| | | if (backGround != null)
|
| | | {
|
| | | backGround.SetActive(true);
|
| | | backGround.SetItemBackGround(itemQuality != 0 ? itemQuality : itemInfo.ItemColor, itemInfo.QualityEchoType);
|
| | | }
|
| | |
|
| | | equipSuitEffect.Display(itemId);
|
| | | itemBaseEffect.Display(itemId);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Debug.Log(e);
|
| | | }
|
| | | }
|
| | |
|
| | | private void DisplayCount()
|
| | | {
|
| | | if (countContainer == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | switch (m_ItemType)
|
| | | {
|
| | | case ItemType.Rewards:
|
| | | if (showCount && itemCount > 1)
|
| | | {
|
| | | countContainer.SetActive(true);
|
| | | count.text = UIHelper.ReplaceLargeNum((ulong)itemCount);
|
| | | }
|
| | | else
|
| | | {
|
| | | countContainer.SetActive(false);
|
| | | }
|
| | | break;
|
| | | case ItemType.Use:
|
| | | var _itemCnt = PackManager.Instance.GetItemCountByID(PackType.Item, itemId);
|
| | | count.text = StringUtility.Contact(_itemCnt >= itemCount ? "<color=#35e112>" : "<color=#ff0303>", _itemCnt,
|
| | | "</color><color=#f7f7f7>/", itemCount, "</color>");
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | private void ViewDetails()
|
| | | {
|
| | | ItemTipUtility.Show(itemId);
|
| | | }
|
| | |
|
| | | public enum ItemType
|
| | | {
|
| | | Rewards,
|
| | | Use,
|
| | | }
|
| | | } |
| | | |
| | | // using vnxbqy.UI; |
| | | |
| | | // namespace vnxbqy.UI |
| | | // { |
| | | |
| | | // public class ItemBehaviour : MonoBehaviour |
| | | // { |
| | | |
| | | |
| | | // [SerializeField] ImageEx m_Icon; |
| | | // public ImageEx icon { get { return m_Icon; } } |
| | | |
| | | // [SerializeField] ImageEx m_BackGround; |
| | | // public ImageEx backGround { get { return m_BackGround; } } |
| | | |
| | | // [SerializeField] Transform m_CountContainer; |
| | | // public Transform countContainer { get { return m_CountContainer; } } |
| | | |
| | | // [SerializeField] Text m_Count; |
| | | // public Text count { get { return m_Count; } } |
| | | |
| | | // [SerializeField] Button m_ViewDetails; |
| | | |
| | | // [SerializeField] ItemType m_ItemType = ItemType.Rewards; |
| | | |
| | | // EquipSuitEffect m_EquipSuitEffect; |
| | | // EquipSuitEffect equipSuitEffect |
| | | // { |
| | | // get |
| | | // { |
| | | // if (m_EquipSuitEffect == null) |
| | | // { |
| | | // m_EquipSuitEffect = EquipSuitEffect.Create(transform as RectTransform); |
| | | // } |
| | | // return m_EquipSuitEffect; |
| | | // } |
| | | // } |
| | | |
| | | // //物品基础特效(物品表) |
| | | // ItemBaseEffect m_ItemBaseEffect; |
| | | // ItemBaseEffect itemBaseEffect |
| | | // { |
| | | // get |
| | | // { |
| | | // if (m_ItemBaseEffect == null) |
| | | // { |
| | | // m_ItemBaseEffect = ItemBaseEffect.Create(transform as RectTransform); |
| | | // } |
| | | // return m_ItemBaseEffect; |
| | | // } |
| | | // } |
| | | |
| | | // bool m_ShowCount = true; |
| | | // public bool showCount { |
| | | // get { |
| | | // return m_ShowCount; |
| | | // } |
| | | // set { |
| | | // if (m_ShowCount != value) |
| | | // { |
| | | // m_ShowCount = value; |
| | | // DisplayCount(); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // public int itemId { |
| | | // get; private set; |
| | | // } |
| | | |
| | | // public int itemCount { |
| | | // get; private set; |
| | | // } |
| | | |
| | | // public int itemQuality { get; private set; } |
| | | |
| | | // private void Awake() |
| | | // { |
| | | // if (m_ViewDetails != null) |
| | | // { |
| | | // m_ViewDetails.SetListener(ViewDetails); |
| | | // } |
| | | // } |
| | | |
| | | // public void SetItem(Item _item) |
| | | // { |
| | | // SetItem(_item.id, _item.count, _item.quality); |
| | | // } |
| | | |
| | | // public void SetItem(int _id, int _count, int _quality = 0) |
| | | // { |
| | | // itemId = _id; |
| | | // itemCount = _count; |
| | | // itemQuality = _quality; |
| | | // DisplayBaseInfo(); |
| | | // DisplayCount(); |
| | | // } |
| | | |
| | | // public void SetCount(int _count) |
| | | // { |
| | | // itemCount = _count; |
| | | // DisplayCount(); |
| | | // } |
| | | |
| | | // public void DisplayEmpty() |
| | | // { |
| | | // try |
| | | // { |
| | | // icon.SetActive(false); |
| | | // backGround.SetActive(false); |
| | | // if (countContainer != null) |
| | | // { |
| | | // countContainer.SetActive(false); |
| | | // } |
| | | // } |
| | | // catch (System.Exception ex) |
| | | // { |
| | | // Debug.Log(ex); |
| | | // } |
| | | // } |
| | | |
| | | // private void DisplayBaseInfo() |
| | | // { |
| | | // try |
| | | // { |
| | | // var itemInfo = ItemConfig.Get(itemId); |
| | | // if (icon != null) |
| | | // { |
| | | // icon.SetActive(true); |
| | | // icon.SetSprite(itemInfo.IconKey); |
| | | // } |
| | | |
| | | // if (backGround != null) |
| | | // { |
| | | // backGround.SetActive(true); |
| | | // backGround.SetItemBackGround(itemQuality != 0 ? itemQuality : itemInfo.ItemColor, itemInfo.QualityEchoType); |
| | | // } |
| | | |
| | | // equipSuitEffect.Display(itemId); |
| | | // itemBaseEffect.Display(itemId); |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.Log(e); |
| | | // } |
| | | // } |
| | | |
| | | // private void DisplayCount() |
| | | // { |
| | | // if (countContainer == null) |
| | | // { |
| | | // return; |
| | | // } |
| | | // switch (m_ItemType) |
| | | // { |
| | | // case ItemType.Rewards: |
| | | // if (showCount && itemCount > 1) |
| | | // { |
| | | // countContainer.SetActive(true); |
| | | // count.text = UIHelper.ReplaceLargeNum((ulong)itemCount); |
| | | // } |
| | | // else |
| | | // { |
| | | // countContainer.SetActive(false); |
| | | // } |
| | | // break; |
| | | // case ItemType.Use: |
| | | // var _itemCnt = ModelCenter.Instance.GetModel<PackModel>().GetItemCountByID(PackType.Item, itemId); |
| | | // count.text = StringUtility.Contact(_itemCnt >= itemCount ? "<color=#35e112>" : "<color=#ff0303>", _itemCnt, |
| | | // "</color><color=#f7f7f7>/", itemCount, "</color>"); |
| | | // break; |
| | | // } |
| | | // } |
| | | |
| | | // private void ViewDetails() |
| | | // { |
| | | // ItemTipUtility.Show(itemId); |
| | | // } |
| | | |
| | | // public enum ItemType |
| | | // { |
| | | // Rewards, |
| | | // Use, |
| | | // } |
| | | // } |
| | | |
| | | // } |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine.EventSystems; |
| | | using System; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | public class PressTip : MonoBehaviour, IPointerDownHandler, IPointerUpHandler |
| | | { |
| | | [SerializeField] GameObject m_Container; |
| | | [SerializeField] float m_Delay = 0f; |
| | | |
| | | public class PressTip : MonoBehaviour, IPointerDownHandler, IPointerUpHandler |
| | | float timer = 0f; |
| | | PointerState pointerState = PointerState.Up; |
| | | bool triggered = false; |
| | | |
| | | private void OnEnable() |
| | | { |
| | | [SerializeField] GameObject m_Container; |
| | | [SerializeField] float m_Delay = 0f; |
| | | this.pointerState = PointerState.Up; |
| | | this.m_Container.SetActive(false); |
| | | } |
| | | |
| | | float timer = 0f; |
| | | PointerState pointerState = PointerState.Up; |
| | | bool triggered = false; |
| | | private void OnDisable() |
| | | { |
| | | this.pointerState = PointerState.Up; |
| | | this.m_Container.SetActive(false); |
| | | } |
| | | |
| | | private void OnEnable() |
| | | public virtual void OnPointerDown(PointerEventData eventData) |
| | | { |
| | | this.pointerState = PointerState.Down; |
| | | this.timer = 0f; |
| | | triggered = false; |
| | | } |
| | | |
| | | public virtual void OnPointerUp(PointerEventData eventData) |
| | | { |
| | | this.pointerState = PointerState.Up; |
| | | this.m_Container.SetActive(false); |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | if (this.pointerState != PointerState.Down) |
| | | { |
| | | this.pointerState = PointerState.Up; |
| | | this.m_Container.SetActive(false); |
| | | return; |
| | | } |
| | | |
| | | private void OnDisable() |
| | | this.timer += Time.deltaTime; |
| | | if (this.timer > this.m_Delay && !triggered) |
| | | { |
| | | this.pointerState = PointerState.Up; |
| | | this.m_Container.SetActive(false); |
| | | } |
| | | triggered = true; |
| | | |
| | | public virtual void OnPointerDown(PointerEventData eventData) |
| | | { |
| | | this.pointerState = PointerState.Down; |
| | | this.timer = 0f; |
| | | triggered = false; |
| | | } |
| | | |
| | | public virtual void OnPointerUp(PointerEventData eventData) |
| | | { |
| | | this.pointerState = PointerState.Up; |
| | | this.m_Container.SetActive(false); |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | if (this.pointerState != PointerState.Down) |
| | | if (this.m_Container != null) |
| | | { |
| | | return; |
| | | this.m_Container.SetActive(true); |
| | | AdjustmentContainerPosition(this.m_Container.transform as RectTransform); |
| | | } |
| | | |
| | | this.timer += Time.deltaTime; |
| | | if (this.timer > this.m_Delay && !triggered) |
| | | { |
| | | triggered = true; |
| | | |
| | | if (this.m_Container != null) |
| | | { |
| | | this.m_Container.SetActive(true); |
| | | AdjustmentContainerPosition(this.m_Container.transform as RectTransform); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | void AdjustmentContainerPosition(RectTransform _container) |
| | | { |
| | | if (_container == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var viewPortPoint = CameraManager.uiCamera.ScreenToViewportPoint(Input.mousePosition); |
| | | var normalizedOffset = CalculateNormalizedOffset(_container); |
| | | |
| | | var containerSize = new Vector2(_container.rect.width, _container.rect.height); |
| | | var xOffset = viewPortPoint.x < normalizedOffset.x ? 1 : viewPortPoint.x > (1 - normalizedOffset.x) ? -1 : 0; |
| | | var yOffset = viewPortPoint.y > (1 - normalizedOffset.y * 2) ? -1 : xOffset != 0 ? 0 : 1; |
| | | |
| | | var uiposition = CameraManager.uiCamera.ViewportToWorldPoint(viewPortPoint); |
| | | |
| | | _container.position = uiposition.SetZ(0); |
| | | _container.localPosition += new Vector3(xOffset * containerSize.x * 0.5f, yOffset * containerSize.y * 0.5f, -_container.localPosition.z); |
| | | } |
| | | |
| | | Vector2 CalculateNormalizedOffset(RectTransform _rectTransform) |
| | | { |
| | | var offsetX = _rectTransform.rect.width / Constants.DESIGN_RESOLUTION.x * 0.5f; |
| | | var offsetY = _rectTransform.rect.height / Constants.DESIGN_RESOLUTION.y * 0.5f; |
| | | |
| | | return new Vector2(offsetX, offsetY); |
| | | } |
| | | |
| | | enum PointerState |
| | | { |
| | | Down, |
| | | Up |
| | | } |
| | | |
| | | } |
| | | |
| | | void AdjustmentContainerPosition(RectTransform _container) |
| | | { |
| | | if (_container == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var viewPortPoint = CameraManager.uiCamera.ScreenToViewportPoint(Input.mousePosition); |
| | | var normalizedOffset = CalculateNormalizedOffset(_container); |
| | | |
| | | var containerSize = new Vector2(_container.rect.width, _container.rect.height); |
| | | var xOffset = viewPortPoint.x < normalizedOffset.x ? 1 : viewPortPoint.x > (1 - normalizedOffset.x) ? -1 : 0; |
| | | var yOffset = viewPortPoint.y > (1 - normalizedOffset.y * 2) ? -1 : xOffset != 0 ? 0 : 1; |
| | | |
| | | var uiposition = CameraManager.uiCamera.ViewportToWorldPoint(viewPortPoint); |
| | | |
| | | _container.position = uiposition.SetZ(0); |
| | | _container.localPosition += new Vector3(xOffset * containerSize.x * 0.5f, yOffset * containerSize.y * 0.5f, -_container.localPosition.z); |
| | | } |
| | | |
| | | Vector2 CalculateNormalizedOffset(RectTransform _rectTransform) |
| | | { |
| | | var offsetX = _rectTransform.rect.width / Constants.DESIGN_RESOLUTION.x * 0.5f; |
| | | var offsetY = _rectTransform.rect.height / Constants.DESIGN_RESOLUTION.y * 0.5f; |
| | | |
| | | return new Vector2(offsetX, offsetY); |
| | | } |
| | | |
| | | enum PointerState |
| | | { |
| | | Down, |
| | | Up |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | public class RandomTip : MonoBehaviour |
| | | { |
| | | int index = 0; |
| | | [SerializeField] UpdateType m_UpdateType; |
| | | [SerializeField] Text m_Content; |
| | | [SerializeField] float m_Interval = 2f; |
| | | [SerializeField] string[] m_LanguageKeys; |
| | | |
| | | public class RandomTip : MonoBehaviour |
| | | float timer = 0f; |
| | | private void OnEnable() |
| | | { |
| | | int index = 0; |
| | | [SerializeField] UpdateType m_UpdateType; |
| | | [SerializeField] Text m_Content; |
| | | [SerializeField] float m_Interval = 2f; |
| | | [SerializeField] string[] m_LanguageKeys; |
| | | timer = 0f; |
| | | UpdateTip(); |
| | | } |
| | | |
| | | float timer = 0f; |
| | | private void OnEnable() |
| | | private void OnDisable() |
| | | { |
| | | |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | timer += Time.deltaTime; |
| | | if (timer > m_Interval) |
| | | { |
| | | timer = 0f; |
| | | UpdateTip(); |
| | | } |
| | | } |
| | | |
| | | private void OnDisable() |
| | | private void UpdateTip() |
| | | { |
| | | if (m_LanguageKeys == null || m_LanguageKeys.Length == 0) |
| | | { |
| | | |
| | | return; |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | switch (m_UpdateType) |
| | | { |
| | | timer += Time.deltaTime; |
| | | if (timer > m_Interval) |
| | | { |
| | | timer = 0f; |
| | | UpdateTip(); |
| | | } |
| | | case UpdateType.Queue: |
| | | index = (++index) % m_LanguageKeys.Length; |
| | | m_Content.text = Language.Get(m_LanguageKeys[index]); |
| | | break; |
| | | case UpdateType.Random: |
| | | var randomIndex = index; |
| | | while (index == randomIndex) |
| | | { |
| | | randomIndex = Random.Range(0, m_LanguageKeys.Length); |
| | | } |
| | | index = randomIndex; |
| | | m_Content.text = Language.Get(m_LanguageKeys[index]); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void UpdateTip() |
| | | { |
| | | if (m_LanguageKeys == null || m_LanguageKeys.Length == 0) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | switch (m_UpdateType) |
| | | { |
| | | case UpdateType.Queue: |
| | | index = (++index) % m_LanguageKeys.Length; |
| | | m_Content.text = Language.Get(m_LanguageKeys[index]); |
| | | break; |
| | | case UpdateType.Random: |
| | | var randomIndex = index; |
| | | while (index == randomIndex) |
| | | { |
| | | randomIndex = Random.Range(0, m_LanguageKeys.Length); |
| | | } |
| | | index = randomIndex; |
| | | m_Content.text = Language.Get(m_LanguageKeys[index]); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | public enum UpdateType |
| | | { |
| | | Queue, |
| | | Random, |
| | | } |
| | | |
| | | public enum UpdateType |
| | | { |
| | | Queue, |
| | | Random, |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI { |
| | | |
| | | [RequireComponent(typeof(Text))] |
| | | public class RollNumber:MonoBehaviour { |
| | | [RequireComponent(typeof(Text))] |
| | | public class RollNumber:MonoBehaviour { |
| | | |
| | | [SerializeField] |
| | | Text m_Text; |
| | | public Text text { |
| | | get { |
| | | return m_Text; |
| | | } |
| | | [SerializeField] |
| | | Text m_Text; |
| | | public Text text { |
| | | get { |
| | | return m_Text; |
| | | } |
| | | } |
| | | |
| | | float to = 0; |
| | | float from = 0; |
| | | float now = 0; |
| | | float to = 0; |
| | | float from = 0; |
| | | float now = 0; |
| | | |
| | | float duration = 0f; |
| | | float timer = 0f; |
| | | Action endCallBack = null; |
| | | float duration = 0f; |
| | | float timer = 0f; |
| | | Action endCallBack = null; |
| | | |
| | | public void Perform(int _from,int _to,float _duration,Action _callBack) { |
| | | ResetTimer(); |
| | | duration = Mathf.Clamp(_duration,0f,float.MaxValue); |
| | | from = _from; |
| | | to = _to; |
| | | endCallBack = _callBack; |
| | | } |
| | | public void Perform(int _from,int _to,float _duration,Action _callBack) { |
| | | ResetTimer(); |
| | | duration = Mathf.Clamp(_duration,0f,float.MaxValue); |
| | | from = _from; |
| | | to = _to; |
| | | endCallBack = _callBack; |
| | | } |
| | | |
| | | private void LateUpdate() { |
| | | if(timer < duration) { |
| | | timer += Time.deltaTime; |
| | | now = Mathf.Lerp(from,to,Mathf.Clamp01(timer / duration)); |
| | | if(timer > duration) { |
| | | ResetTimer(); |
| | | now = to; |
| | | if(endCallBack != null) { |
| | | endCallBack(); |
| | | endCallBack = null; |
| | | } |
| | | } |
| | | |
| | | if(text != null) { |
| | | var nowInt = (int)now; |
| | | text.text = nowInt.ToString(); |
| | | private void LateUpdate() { |
| | | if(timer < duration) { |
| | | timer += Time.deltaTime; |
| | | now = Mathf.Lerp(from,to,Mathf.Clamp01(timer / duration)); |
| | | if(timer > duration) { |
| | | ResetTimer(); |
| | | now = to; |
| | | if(endCallBack != null) { |
| | | endCallBack(); |
| | | endCallBack = null; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void ResetTimer() { |
| | | timer = 0f; |
| | | duration = 0f; |
| | | if(text != null) { |
| | | var nowInt = (int)now; |
| | | text.text = nowInt.ToString(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void ResetTimer() { |
| | | timer = 0f; |
| | | duration = 0f; |
| | | } |
| | | } |
| | | |
| | |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | public class ScreenDiffuseMove : MonoBehaviour |
| | | { |
| | | |
| | | public class ScreenDiffuseMove : MonoBehaviour |
| | | [SerializeField] DiffuseType m_MoveType = DiffuseType.MoveUp; |
| | | public DiffuseType moveType { get { return m_MoveType; } } |
| | | |
| | | [SerializeField] float m_Speed = 10f; |
| | | public float speed { |
| | | get { return m_Speed; } |
| | | set { m_Speed = value; } |
| | | } |
| | | |
| | | [SerializeField] TweenCurve m_SpeedRatioCurve; |
| | | [SerializeField] float m_Duration = 1f; |
| | | public float duration { |
| | | get { return m_Duration; } |
| | | set { m_Duration = value; } |
| | | } |
| | | |
| | | [SerializeField] float m_Delay = 0f; |
| | | public float delay { |
| | | get { return m_Delay; } |
| | | set { m_Delay = value; } |
| | | } |
| | | |
| | | [SerializeField] bool m_IsLocal = true; |
| | | public bool isLocal { |
| | | get { return m_IsLocal; } |
| | | } |
| | | |
| | | float beginTime = 0f; |
| | | float endTime = 0f; |
| | | Vector2 direction = Vector2.up; |
| | | bool disableOnEnd = true; |
| | | |
| | | public void Begin(bool _disableOnEnd = true) |
| | | { |
| | | beginTime = Time.time + delay; |
| | | endTime = Time.time + delay + duration; |
| | | disableOnEnd = _disableOnEnd; |
| | | |
| | | [SerializeField] DiffuseType m_MoveType = DiffuseType.MoveUp; |
| | | public DiffuseType moveType { get { return m_MoveType; } } |
| | | |
| | | [SerializeField] float m_Speed = 10f; |
| | | public float speed { |
| | | get { return m_Speed; } |
| | | set { m_Speed = value; } |
| | | } |
| | | |
| | | [SerializeField] TweenCurve m_SpeedRatioCurve; |
| | | [SerializeField] float m_Duration = 1f; |
| | | public float duration { |
| | | get { return m_Duration; } |
| | | set { m_Duration = value; } |
| | | } |
| | | |
| | | [SerializeField] float m_Delay = 0f; |
| | | public float delay { |
| | | get { return m_Delay; } |
| | | set { m_Delay = value; } |
| | | } |
| | | |
| | | [SerializeField] bool m_IsLocal = true; |
| | | public bool isLocal { |
| | | get { return m_IsLocal; } |
| | | } |
| | | |
| | | float beginTime = 0f; |
| | | float endTime = 0f; |
| | | Vector2 direction = Vector2.up; |
| | | bool disableOnEnd = true; |
| | | |
| | | public void Begin(bool _disableOnEnd = true) |
| | | switch (m_MoveType) |
| | | { |
| | | beginTime = Time.time + delay; |
| | | endTime = Time.time + delay + duration; |
| | | disableOnEnd = _disableOnEnd; |
| | | |
| | | switch (m_MoveType) |
| | | { |
| | | case DiffuseType.MoveUp: |
| | | direction = Vector2.up * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveDown: |
| | | direction = Vector2.down * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveLeft: |
| | | direction = Vector2.left * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveRight: |
| | | direction = Vector2.right * m_Speed; |
| | | break; |
| | | case DiffuseType.RelativePosition: |
| | | direction = new Vector2(this.transform.position.x, this.transform.position.y).normalized * m_Speed; |
| | | break; |
| | | case DiffuseType.ReversalRelativePosition: |
| | | direction = new Vector2(-this.transform.position.x, this.transform.position.y).normalized * m_Speed; |
| | | break; |
| | | } |
| | | |
| | | this.enabled = true; |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | this.SetActive(true); |
| | | } |
| | | |
| | | case DiffuseType.MoveUp: |
| | | direction = Vector2.up * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveDown: |
| | | direction = Vector2.down * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveLeft: |
| | | direction = Vector2.left * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveRight: |
| | | direction = Vector2.right * m_Speed; |
| | | break; |
| | | case DiffuseType.RelativePosition: |
| | | direction = new Vector2(this.transform.position.x, this.transform.position.y).normalized * m_Speed; |
| | | break; |
| | | case DiffuseType.ReversalRelativePosition: |
| | | direction = new Vector2(-this.transform.position.x, this.transform.position.y).normalized * m_Speed; |
| | | break; |
| | | } |
| | | |
| | | public void Begin(Vector3 _direction, bool _disableOnEnd = true) |
| | | this.enabled = true; |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | beginTime = Time.time + delay; |
| | | endTime = Time.time + delay + duration; |
| | | disableOnEnd = _disableOnEnd; |
| | | |
| | | switch (m_MoveType) |
| | | { |
| | | case DiffuseType.MoveUp: |
| | | direction = Vector2.up * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveDown: |
| | | direction = Vector2.down * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveLeft: |
| | | direction = Vector2.left * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveRight: |
| | | direction = Vector2.right * m_Speed; |
| | | break; |
| | | case DiffuseType.RelativePosition: |
| | | direction = new Vector2(_direction.x, _direction.y).normalized * m_Speed; |
| | | break; |
| | | case DiffuseType.ReversalRelativePosition: |
| | | direction = new Vector2(_direction.x, -_direction.y).normalized * m_Speed; |
| | | break; |
| | | } |
| | | |
| | | this.enabled = true; |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | this.SetActive(true); |
| | | } |
| | | this.SetActive(true); |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | if (Time.time < beginTime) |
| | | { |
| | | return; |
| | | } |
| | | } |
| | | |
| | | if (Time.time < endTime) |
| | | { |
| | | var delta = direction * Time.deltaTime * m_SpeedRatioCurve.Evaluate((Time.time - beginTime) / duration); |
| | | if (isLocal) |
| | | { |
| | | this.transform.localPosition += new Vector3(delta.x, delta.y, 0); |
| | | } |
| | | else |
| | | { |
| | | this.transform.position += new Vector3(delta.x, delta.y, 0); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (disableOnEnd) |
| | | { |
| | | this.enabled = false; |
| | | } |
| | | } |
| | | public void Begin(Vector3 _direction, bool _disableOnEnd = true) |
| | | { |
| | | beginTime = Time.time + delay; |
| | | endTime = Time.time + delay + duration; |
| | | disableOnEnd = _disableOnEnd; |
| | | |
| | | switch (m_MoveType) |
| | | { |
| | | case DiffuseType.MoveUp: |
| | | direction = Vector2.up * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveDown: |
| | | direction = Vector2.down * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveLeft: |
| | | direction = Vector2.left * m_Speed; |
| | | break; |
| | | case DiffuseType.MoveRight: |
| | | direction = Vector2.right * m_Speed; |
| | | break; |
| | | case DiffuseType.RelativePosition: |
| | | direction = new Vector2(_direction.x, _direction.y).normalized * m_Speed; |
| | | break; |
| | | case DiffuseType.ReversalRelativePosition: |
| | | direction = new Vector2(_direction.x, -_direction.y).normalized * m_Speed; |
| | | break; |
| | | } |
| | | |
| | | |
| | | public enum DiffuseType |
| | | this.enabled = true; |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | MoveUp, |
| | | MoveDown, |
| | | MoveLeft, |
| | | MoveRight, |
| | | RelativePosition, |
| | | ReversalRelativePosition, |
| | | this.SetActive(true); |
| | | } |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | if (Time.time < beginTime) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (Time.time < endTime) |
| | | { |
| | | var delta = direction * Time.deltaTime * m_SpeedRatioCurve.Evaluate((Time.time - beginTime) / duration); |
| | | if (isLocal) |
| | | { |
| | | this.transform.localPosition += new Vector3(delta.x, delta.y, 0); |
| | | } |
| | | else |
| | | { |
| | | this.transform.position += new Vector3(delta.x, delta.y, 0); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (disableOnEnd) |
| | | { |
| | | this.enabled = false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public enum DiffuseType |
| | | { |
| | | MoveUp, |
| | | MoveDown, |
| | | MoveLeft, |
| | | MoveRight, |
| | | RelativePosition, |
| | | ReversalRelativePosition, |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | using UnityEngine.UI; |
| | | using System; |
| | | |
| | | namespace vnxbqy.UI |
| | | public class ScreenMoveTo : MonoBehaviour |
| | | { |
| | | |
| | | public class ScreenMoveTo : MonoBehaviour |
| | | [SerializeField] |
| | | LerpType m_LerpType = LerpType.Linear; |
| | | |
| | | [SerializeField] |
| | | Vector2 m_Destination; |
| | | public Vector2 destination { |
| | | get { return m_Destination; } |
| | | set { m_Destination = value; } |
| | | } |
| | | |
| | | [SerializeField] |
| | | float m_Duration = 0.5f; |
| | | public float duration { |
| | | get { return m_Duration; } |
| | | set { m_Duration = value; } |
| | | } |
| | | |
| | | [SerializeField] |
| | | bool m_IsLocal = true; |
| | | public bool isLocal { |
| | | get { return m_IsLocal; } |
| | | } |
| | | |
| | | bool disableOnEnd = true; |
| | | float endTime = 0f; |
| | | |
| | | Vector3 startPosition = Vector3.zero; |
| | | Vector3 startLocalPosition = Vector3.zero; |
| | | Vector3 refPosition = Vector3.zero; |
| | | |
| | | bool end = false; |
| | | Action endCallBack = null; |
| | | |
| | | public void Begin(bool _deActiveOnEnd = true) |
| | | { |
| | | endTime = Time.time + duration; |
| | | end = false; |
| | | disableOnEnd = _deActiveOnEnd; |
| | | startPosition = this.transform.position; |
| | | startLocalPosition = this.transform.localPosition; |
| | | refPosition = Vector3.zero; |
| | | endCallBack = null; |
| | | |
| | | [SerializeField] |
| | | LerpType m_LerpType = LerpType.Linear; |
| | | |
| | | [SerializeField] |
| | | Vector2 m_Destination; |
| | | public Vector2 destination { |
| | | get { return m_Destination; } |
| | | set { m_Destination = value; } |
| | | } |
| | | |
| | | [SerializeField] |
| | | float m_Duration = 0.5f; |
| | | public float duration { |
| | | get { return m_Duration; } |
| | | set { m_Duration = value; } |
| | | } |
| | | |
| | | [SerializeField] |
| | | bool m_IsLocal = true; |
| | | public bool isLocal { |
| | | get { return m_IsLocal; } |
| | | } |
| | | |
| | | bool disableOnEnd = true; |
| | | float endTime = 0f; |
| | | |
| | | Vector3 startPosition = Vector3.zero; |
| | | Vector3 startLocalPosition = Vector3.zero; |
| | | Vector3 refPosition = Vector3.zero; |
| | | |
| | | bool end = false; |
| | | Action endCallBack = null; |
| | | |
| | | public void Begin(bool _deActiveOnEnd = true) |
| | | this.enabled = true; |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | endTime = Time.time + duration; |
| | | end = false; |
| | | disableOnEnd = _deActiveOnEnd; |
| | | startPosition = this.transform.position; |
| | | startLocalPosition = this.transform.localPosition; |
| | | refPosition = Vector3.zero; |
| | | endCallBack = null; |
| | | |
| | | this.enabled = true; |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | this.SetActive(true); |
| | | } |
| | | this.SetActive(true); |
| | | } |
| | | } |
| | | |
| | | public void Begin(Action _callBack, bool _disableOnEnd = true) |
| | | public void Begin(Action _callBack, bool _disableOnEnd = true) |
| | | { |
| | | endTime = Time.time + duration; |
| | | end = false; |
| | | disableOnEnd = _disableOnEnd; |
| | | startPosition = this.transform.position; |
| | | startLocalPosition = this.transform.localPosition; |
| | | refPosition = Vector3.zero; |
| | | endCallBack = _callBack; |
| | | |
| | | this.enabled = true; |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | endTime = Time.time + duration; |
| | | end = false; |
| | | disableOnEnd = _disableOnEnd; |
| | | startPosition = this.transform.position; |
| | | startLocalPosition = this.transform.localPosition; |
| | | refPosition = Vector3.zero; |
| | | endCallBack = _callBack; |
| | | |
| | | this.enabled = true; |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | this.SetActive(true); |
| | | } |
| | | this.SetActive(true); |
| | | } |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | private void LateUpdate() |
| | | { |
| | | switch (m_LerpType) |
| | | { |
| | | switch (m_LerpType) |
| | | { |
| | | case LerpType.Linear: |
| | | if (Time.time < endTime) |
| | | { |
| | | var t = Mathf.Clamp01(1f - (endTime - Time.time) / m_Duration); |
| | | if (isLocal) |
| | | { |
| | | this.transform.localPosition = Vector3.Lerp(startLocalPosition, destination, t); |
| | | } |
| | | else |
| | | { |
| | | this.transform.position = Vector3.Lerp(startPosition, destination, t); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | end = true; |
| | | if (isLocal) |
| | | { |
| | | this.transform.localPosition = destination; |
| | | } |
| | | else |
| | | { |
| | | this.transform.position = destination; |
| | | } |
| | | } |
| | | break; |
| | | case LerpType.Smooth: |
| | | |
| | | case LerpType.Linear: |
| | | if (Time.time < endTime) |
| | | { |
| | | var t = Mathf.Clamp01(1f - (endTime - Time.time) / m_Duration); |
| | | if (isLocal) |
| | | { |
| | | if (Vector3.Distance(this.transform.localPosition, new Vector3(destination.x, destination.y)) > 1) |
| | | { |
| | | this.transform.localPosition = Vector3.SmoothDamp(this.transform.localPosition, destination, ref refPosition, duration); |
| | | } |
| | | else |
| | | { |
| | | this.transform.localPosition = destination; |
| | | end = true; |
| | | } |
| | | this.transform.localPosition = Vector3.Lerp(startLocalPosition, destination, t); |
| | | } |
| | | else |
| | | { |
| | | if (Vector3.Distance(this.transform.position, new Vector3(destination.x, destination.y)) > 1) |
| | | { |
| | | this.transform.position = Vector3.SmoothDamp(this.transform.position, destination, ref refPosition, duration); |
| | | } |
| | | else |
| | | { |
| | | this.transform.position = destination; |
| | | end = true; |
| | | } |
| | | this.transform.position = Vector3.Lerp(startPosition, destination, t); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | if (end) |
| | | { |
| | | if (endCallBack != null) |
| | | { |
| | | endCallBack(); |
| | | endCallBack = null; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | end = true; |
| | | if (isLocal) |
| | | { |
| | | this.transform.localPosition = destination; |
| | | } |
| | | else |
| | | { |
| | | this.transform.position = destination; |
| | | } |
| | | } |
| | | break; |
| | | case LerpType.Smooth: |
| | | |
| | | if (end && disableOnEnd) |
| | | { |
| | | this.enabled = false; |
| | | } |
| | | |
| | | if (isLocal) |
| | | { |
| | | if (Vector3.Distance(this.transform.localPosition, new Vector3(destination.x, destination.y)) > 1) |
| | | { |
| | | this.transform.localPosition = Vector3.SmoothDamp(this.transform.localPosition, destination, ref refPosition, duration); |
| | | } |
| | | else |
| | | { |
| | | this.transform.localPosition = destination; |
| | | end = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (Vector3.Distance(this.transform.position, new Vector3(destination.x, destination.y)) > 1) |
| | | { |
| | | this.transform.position = Vector3.SmoothDamp(this.transform.position, destination, ref refPosition, duration); |
| | | } |
| | | else |
| | | { |
| | | this.transform.position = destination; |
| | | end = true; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | |
| | | public enum LerpType |
| | | if (end) |
| | | { |
| | | Linear, |
| | | Smooth, |
| | | if (endCallBack != null) |
| | | { |
| | | endCallBack(); |
| | | endCallBack = null; |
| | | } |
| | | } |
| | | |
| | | if (end && disableOnEnd) |
| | | { |
| | | this.enabled = false; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public enum LerpType |
| | | { |
| | | Linear, |
| | | Smooth, |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | /** |
| | | 这是新的二级界面加载器 |
| | | */ |
| | | namespace vnxbqy.UI |
| | | { |
| | | |
| | | public enum FrameSize |
| | | public enum FrameSize |
| | | { |
| | | Free, |
| | | XLarge, |
| | | Large, |
| | | Medium, |
| | | Small, |
| | | } |
| | | |
| | | [ExecuteAlways] |
| | | public class SecondFrameLoader2 : UIPrefabLoader |
| | | { |
| | | [SerializeField] public FrameSize frameSize; |
| | | |
| | | [SerializeField] public Vector2 size; |
| | | |
| | | public string m_TitleKey; |
| | | |
| | | public override string prefabName { get { return "SecondFrame"; } } |
| | | |
| | | public override void Create() |
| | | { |
| | | Free, |
| | | XLarge, |
| | | Large, |
| | | Medium, |
| | | Small, |
| | | base.Create(); |
| | | UpdateSize(); |
| | | InitUI(); |
| | | } |
| | | |
| | | [ExecuteAlways] |
| | | public class SecondFrameLoader2 : UIPrefabLoader |
| | | private void Update() |
| | | { |
| | | [SerializeField] public FrameSize frameSize; |
| | | if (Application.isPlaying) |
| | | return; |
| | | UpdateSize(); |
| | | } |
| | | |
| | | [SerializeField] public Vector2 size; |
| | | |
| | | public string m_TitleKey; |
| | | |
| | | public override string prefabName { get { return "SecondFrame"; } } |
| | | |
| | | public override void Create() |
| | | public void InitUI() |
| | | { |
| | | var button = this.GetComponentInChildren<ButtonEx>(); |
| | | var window = this.GetComponentInParent<UIBase>(); |
| | | button.AddListener(() =>//关闭按钮 |
| | | { |
| | | base.Create(); |
| | | UpdateSize(); |
| | | InitUI(); |
| | | } |
| | | |
| | | private void Update() |
| | | Debug.Log("关闭窗口"); |
| | | window.CloseWindow(); |
| | | }); |
| | | var text = this.GetComponentInChildren<Text>(); |
| | | if (text != null) |
| | | { |
| | | if (Application.isPlaying) |
| | | return; |
| | | UpdateSize(); |
| | | } |
| | | |
| | | public void InitUI() |
| | | { |
| | | var button = this.GetComponentInChildren<ButtonEx>(); |
| | | var window = this.GetComponentInParent<UIBase>(); |
| | | button.AddListener(() =>//关闭按钮 |
| | | { |
| | | Debug.Log("关闭窗口"); |
| | | window.CloseWindow(); |
| | | }); |
| | | var text = this.GetComponentInChildren<Text>(); |
| | | if (text != null) |
| | | { |
| | | if (Application.isPlaying) |
| | | { |
| | | text.fontSize = 24; |
| | | text.resizeTextForBestFit = false; |
| | | text.rectTransform.sizeDelta = new Vector2(24, 141); |
| | | if (!string.IsNullOrEmpty(m_TitleKey)) |
| | | text.text = Language.Get(m_TitleKey); |
| | | } |
| | | else |
| | | text.text = "当前标题"; |
| | | text.fontSize = 24; |
| | | text.resizeTextForBestFit = false; |
| | | text.rectTransform.sizeDelta = new Vector2(24, 141); |
| | | if (!string.IsNullOrEmpty(m_TitleKey)) |
| | | text.text = Language.Get(m_TitleKey); |
| | | } |
| | | else |
| | | text.text = "当前标题"; |
| | | } |
| | | } |
| | | |
| | | public void UpdateSize() |
| | | { |
| | | if (instance == null) |
| | | return; |
| | | switch (frameSize) |
| | | { |
| | | case FrameSize.XLarge: |
| | | { |
| | | SetSize(1000, 650); |
| | | break; |
| | | } |
| | | case FrameSize.Large: |
| | | { |
| | | SetSize(800, 650); |
| | | break; |
| | | } |
| | | case FrameSize.Medium: |
| | | { |
| | | SetSize(650, 650); |
| | | break; |
| | | } |
| | | case FrameSize.Small: |
| | | { |
| | | SetSize(550, 650); |
| | | break; |
| | | } |
| | | case FrameSize.Free: |
| | | { |
| | | SetSize(size.x, size.y); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void UpdateSize() |
| | | { |
| | | if (instance == null) |
| | | return; |
| | | switch (frameSize) |
| | | { |
| | | case FrameSize.XLarge: |
| | | { |
| | | SetSize(1000, 650); |
| | | break; |
| | | } |
| | | case FrameSize.Large: |
| | | { |
| | | SetSize(800, 650); |
| | | break; |
| | | } |
| | | case FrameSize.Medium: |
| | | { |
| | | SetSize(650, 650); |
| | | break; |
| | | } |
| | | case FrameSize.Small: |
| | | { |
| | | SetSize(550, 650); |
| | | break; |
| | | } |
| | | case FrameSize.Free: |
| | | { |
| | | SetSize(size.x, size.y); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void SetSize(float width, float height) |
| | | { |
| | | if (instance == null) |
| | | return; |
| | | (instance.transform as RectTransform).sizeDelta = new Vector2(width, height); |
| | | } |
| | | |
| | | private void SetSize(float width, float height) |
| | | { |
| | | if (instance == null) |
| | | return; |
| | | (instance.transform as RectTransform).sizeDelta = new Vector2(width, height); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | using UnityEngine.UI; |
| | | using System; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | public class TimerBehaviour : MonoBehaviour |
| | | { |
| | | [SerializeField] protected Text m_TimeShow; |
| | | public Text timeShow { get { return m_TimeShow; } } |
| | | |
| | | public class TimerBehaviour : MonoBehaviour |
| | | [SerializeField] Pattern m_Pattern = Pattern.English; |
| | | |
| | | protected DateTime endTime; |
| | | Action onTime; |
| | | |
| | | float secondTimer = 0f; |
| | | |
| | | public void Begin(int seconds, Action _callBack = null) |
| | | { |
| | | [SerializeField] protected Text m_TimeShow; |
| | | public Text timeShow { get { return m_TimeShow; } } |
| | | |
| | | [SerializeField] Pattern m_Pattern = Pattern.English; |
| | | |
| | | protected DateTime endTime; |
| | | Action onTime; |
| | | |
| | | float secondTimer = 0f; |
| | | |
| | | public void Begin(int seconds, Action _callBack = null) |
| | | endTime = TimeUtility.ServerNow + new TimeSpan(seconds * TimeSpan.TicksPerSecond); |
| | | onTime = _callBack; |
| | | if (endTime > TimeUtility.ServerNow) |
| | | { |
| | | endTime = TimeUtility.ServerNow + new TimeSpan(seconds * TimeSpan.TicksPerSecond); |
| | | onTime = _callBack; |
| | | if (endTime > TimeUtility.ServerNow) |
| | | { |
| | | this.SetActive(true); |
| | | UpdateTimeShow(); |
| | | } |
| | | else |
| | | { |
| | | this.SetActive(false); |
| | | } |
| | | this.SetActive(true); |
| | | UpdateTimeShow(); |
| | | } |
| | | |
| | | public void Stop() |
| | | else |
| | | { |
| | | endTime = DateTime.MinValue; |
| | | onTime = null; |
| | | this.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | public void Stop() |
| | | { |
| | | endTime = DateTime.MinValue; |
| | | onTime = null; |
| | | this.SetActive(false); |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | if (TimeUtility.ServerNow > endTime) |
| | | { |
| | | if (TimeUtility.ServerNow > endTime) |
| | | if (onTime != null) |
| | | { |
| | | if (onTime != null) |
| | | { |
| | | onTime(); |
| | | onTime = null; |
| | | } |
| | | |
| | | this.SetActive(false); |
| | | onTime(); |
| | | onTime = null; |
| | | } |
| | | else |
| | | |
| | | this.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | secondTimer += Time.deltaTime; |
| | | if (secondTimer > 1f) |
| | | { |
| | | secondTimer += Time.deltaTime; |
| | | if (secondTimer > 1f) |
| | | { |
| | | secondTimer = 0f; |
| | | UpdateTimeShow(); |
| | | } |
| | | secondTimer = 0f; |
| | | UpdateTimeShow(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | protected virtual void UpdateTimeShow() |
| | | protected virtual void UpdateTimeShow() |
| | | { |
| | | var lastSecond = (float)(endTime - TimeUtility.ServerNow).TotalSeconds; |
| | | |
| | | switch (m_Pattern) |
| | | { |
| | | var lastSecond = (float)(endTime - TimeUtility.ServerNow).TotalSeconds; |
| | | |
| | | switch (m_Pattern) |
| | | { |
| | | case Pattern.English: |
| | | m_TimeShow.text = TimeUtility.SecondsToHMS(Mathf.RoundToInt(lastSecond)); |
| | | break; |
| | | case Pattern.Chinese: |
| | | m_TimeShow.text = TimeUtility.SecondsToDHMSCHS(Mathf.RoundToInt(lastSecond)); |
| | | break; |
| | | } |
| | | case Pattern.English: |
| | | m_TimeShow.text = TimeUtility.SecondsToHMS(Mathf.RoundToInt(lastSecond)); |
| | | break; |
| | | case Pattern.Chinese: |
| | | m_TimeShow.text = TimeUtility.SecondsToDHMSCHS(Mathf.RoundToInt(lastSecond)); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | public enum Pattern |
| | | { |
| | | English = 0, |
| | | Chinese = 1, |
| | | } |
| | | |
| | | public enum Pattern |
| | | { |
| | | English = 0, |
| | | Chinese = 1, |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | namespace vnxbqy.UI |
| | | { |
| | | public class TimerToChsBehaviour : TimerBehaviour |
| | | { |
| | | [HideInInspector] |
| | | public string addtionInfo = string.Empty; |
| | | |
| | | protected override void UpdateTimeShow() |
| | | { |
| | | var lastSecond = (endTime - TimeUtility.ServerNow).TotalSeconds; |
| | | m_TimeShow.text = StringUtility.Contact(TimeUtility.SecondsToDHMSCHS((int)lastSecond), addtionInfo); |
| | | } |
| | | public class TimerToChsBehaviour : TimerBehaviour |
| | | { |
| | | [HideInInspector] |
| | | public string addtionInfo = string.Empty; |
| | | |
| | | protected override void UpdateTimeShow() |
| | | { |
| | | var lastSecond = (endTime - TimeUtility.ServerNow).TotalSeconds; |
| | | m_TimeShow.text = StringUtility.Contact(TimeUtility.SecondsToDHMSCHS((int)lastSecond), addtionInfo); |
| | | } |
| | | } |
| | | |
| | |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | public class UIPlaySound : MonoBehaviour |
| | | { |
| | | [SerializeField] TriggerType m_TriggerType = TriggerType.Manual; |
| | | [SerializeField] int m_Audio = 1; |
| | | |
| | | public class UIPlaySound : MonoBehaviour |
| | | public void Play() |
| | | { |
| | | [SerializeField] TriggerType m_TriggerType = TriggerType.Manual; |
| | | [SerializeField] int m_Audio = 1; |
| | | SoundPlayer.Instance.PlayUIAudio(m_Audio); |
| | | } |
| | | |
| | | public void Play() |
| | | private void OnEnable() |
| | | { |
| | | if (m_TriggerType == TriggerType.OnEnable) |
| | | { |
| | | SoundPlayer.Instance.PlayUIAudio(m_Audio); |
| | | Play(); |
| | | } |
| | | } |
| | | |
| | | private void OnEnable() |
| | | private void Start() |
| | | { |
| | | if (m_TriggerType == TriggerType.OnStart) |
| | | { |
| | | if (m_TriggerType == TriggerType.OnEnable) |
| | | { |
| | | Play(); |
| | | } |
| | | Play(); |
| | | } |
| | | } |
| | | |
| | | private void Start() |
| | | { |
| | | if (m_TriggerType == TriggerType.OnStart) |
| | | { |
| | | Play(); |
| | | } |
| | | } |
| | | |
| | | public enum TriggerType |
| | | { |
| | | OnEnable, |
| | | OnStart, |
| | | Manual |
| | | } |
| | | |
| | | public enum TriggerType |
| | | { |
| | | OnEnable, |
| | | OnStart, |
| | | Manual |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using System; |
| | | namespace vnxbqy.UI |
| | | |
| | | |
| | | //只用于Text组件,补充设置文本,读取的是Y.语言表;游戏运行会设置文本内容 |
| | | public class UITextReplace : MonoBehaviour |
| | | { |
| | | //只用于Text组件,补充设置文本,读取的是Y.语言表;游戏运行会设置文本内容 |
| | | public class UITextReplace : MonoBehaviour |
| | | { |
| | | [SerializeField] string language; |
| | | [SerializeField] string language; |
| | | |
| | | private void Awake() |
| | | { |
| | | var textObj = this.transform.GetComponent<Text>(); |
| | | if (textObj == null) |
| | | return; |
| | | private void Awake() |
| | | { |
| | | var textObj = this.transform.GetComponent<Text>(); |
| | | if (textObj == null) |
| | | return; |
| | | |
| | | textObj.text = Language.Get(language); |
| | | } |
| | | |
| | | textObj.text = Language.Get(language); |
| | | } |
| | | |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using vnxbqy.UI; |
| | | |
| | | [DisallowMultipleComponent] |
| | | [RequireComponent(typeof(Canvas))] |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using vnxbqy.UI; |
| | | |
| | | [DisallowMultipleComponent] |
| | | [RequireComponent(typeof(Canvas))] |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | public class GrayGroup : MonoBehaviour |
| | | { |
| | | |
| | | public class GrayGroup : MonoBehaviour |
| | | { |
| | | Image[] m_Images; |
| | | Image[] images { |
| | | get { |
| | | if (m_Images == null) |
| | | { |
| | | m_Images = this.GetComponentsInChildren<Image>(); |
| | | } |
| | | return m_Images; |
| | | } |
| | | } |
| | | |
| | | Image[] m_Images; |
| | | Image[] images { |
| | | get { |
| | | if (m_Images == null) |
| | | bool m_Gray = false; |
| | | public bool gray { |
| | | get { return m_Gray; } |
| | | set { |
| | | m_Gray = value; |
| | | |
| | | for (int i = 0; i < images.Length; i++) |
| | | { |
| | | var image = images[i]; |
| | | if (this.m_Gray) |
| | | { |
| | | m_Images = this.GetComponentsInChildren<Image>(); |
| | | image.material = MaterialUtility.GetDefaultSpriteGrayMaterial(); |
| | | } |
| | | return m_Images; |
| | | else |
| | | { |
| | | image.material = MaterialUtility.GetUIDefaultGraphicMaterial(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | bool m_Gray = false; |
| | | public bool gray { |
| | | get { return m_Gray; } |
| | | set { |
| | | m_Gray = value; |
| | | |
| | | for (int i = 0; i < images.Length; i++) |
| | | { |
| | | var image = images[i]; |
| | | if (this.m_Gray) |
| | | { |
| | | image.material = MaterialUtility.GetDefaultSpriteGrayMaterial(); |
| | | } |
| | | else |
| | | { |
| | | image.material = MaterialUtility.GetUIDefaultGraphicMaterial(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI { |
| | | |
| | | [RequireComponent(typeof(Image))] |
| | | public class SpriteEffect:MonoBehaviour { |
| | | [RequireComponent(typeof(Image))] |
| | | public class SpriteEffect:MonoBehaviour { |
| | | |
| | | [SerializeField] |
| | | Effect m_Effect = Effect.None; |
| | | [SerializeField] |
| | | Effect m_Effect = Effect.None; |
| | | |
| | | CanvasAddition m_CanvasAddition; |
| | | public CanvasAddition canvasAddition { |
| | | get { |
| | | return this.m_CanvasAddition ?? (this.m_CanvasAddition = this.GetComponentInParent<CanvasAddition>()); |
| | | CanvasAddition m_CanvasAddition; |
| | | public CanvasAddition canvasAddition { |
| | | get { |
| | | return this.m_CanvasAddition ?? (this.m_CanvasAddition = this.GetComponentInParent<CanvasAddition>()); |
| | | } |
| | | } |
| | | |
| | | Image m_Image; |
| | | public Image image { |
| | | get { |
| | | return m_Image ?? (m_Image = this.AddMissingComponent<Image>()); |
| | | } |
| | | } |
| | | |
| | | Material m_TwinkleMaterial; |
| | | Material twinleMaterial { |
| | | get { |
| | | return m_TwinkleMaterial??(m_TwinkleMaterial=MaterialUtility.GetDefaultSpriteGrayMaterial()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private void OnEnable() { |
| | | if(this.image != null) { |
| | | switch(this.m_Effect) { |
| | | case Effect.Gray: |
| | | this.image.material = canvasAddition.spriteGrayMaterial; |
| | | break; |
| | | case Effect.Twinkle: |
| | | this.image.material = this.canvasAddition.spriteGrayMaterial; |
| | | break; |
| | | case Effect.None: |
| | | this.image.material = null; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Image m_Image; |
| | | public Image image { |
| | | get { |
| | | return m_Image ?? (m_Image = this.AddMissingComponent<Image>()); |
| | | } |
| | | } |
| | | |
| | | Material m_TwinkleMaterial; |
| | | Material twinleMaterial { |
| | | get { |
| | | return m_TwinkleMaterial??(m_TwinkleMaterial=MaterialUtility.GetDefaultSpriteGrayMaterial()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private void OnEnable() { |
| | | if(this.image != null) { |
| | | switch(this.m_Effect) { |
| | | case Effect.Gray: |
| | | this.image.material = canvasAddition.spriteGrayMaterial; |
| | | break; |
| | | case Effect.Twinkle: |
| | | this.image.material = this.canvasAddition.spriteGrayMaterial; |
| | | break; |
| | | case Effect.None: |
| | | this.image.material = null; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public enum Effect { |
| | | None, |
| | | Gray, |
| | | Twinkle, |
| | | } |
| | | |
| | | public enum Effect { |
| | | None, |
| | | Gray, |
| | | Twinkle, |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine.Sprites; |
| | | using System; |
| | | |
| | | namespace vnxbqy.UI { |
| | | |
| | | [DisallowMultipleComponent] |
| | | [RequireComponent(typeof(Image))] |
| | | public class CustomImage:BaseMeshEffect { |
| | | [DisallowMultipleComponent] |
| | | [RequireComponent(typeof(Image))] |
| | | public class CustomImage:BaseMeshEffect { |
| | | |
| | | [SerializeField] |
| | | Vector2[] m_Points; |
| | | public Vector2[] points { |
| | | get { |
| | | return this.m_Points; |
| | | } |
| | | set { |
| | | this.m_Points = value; |
| | | SetVerticesDirty(); |
| | | } |
| | | [SerializeField] |
| | | Vector2[] m_Points; |
| | | public Vector2[] points { |
| | | get { |
| | | return this.m_Points; |
| | | } |
| | | set { |
| | | this.m_Points = value; |
| | | SetVerticesDirty(); |
| | | } |
| | | } |
| | | |
| | | private Image m_Image; |
| | | public Image image { |
| | | get { |
| | | return this.m_Image ?? (this.m_Image = this.AddMissingComponent<Image>()); |
| | | } |
| | | } |
| | | |
| | | public void SetVerticesDirty() { |
| | | this.graphic.SetVerticesDirty(); |
| | | } |
| | | |
| | | public override void ModifyMesh(VertexHelper vh) { |
| | | vh.Clear(); |
| | | |
| | | if(this.image == null) { |
| | | throw new NullReferenceException(); |
| | | } |
| | | |
| | | private Image m_Image; |
| | | public Image image { |
| | | get { |
| | | return this.m_Image ?? (this.m_Image = this.AddMissingComponent<Image>()); |
| | | } |
| | | if(this.points == null || this.points.Length < 3) { |
| | | return; |
| | | } |
| | | |
| | | public void SetVerticesDirty() { |
| | | this.graphic.SetVerticesDirty(); |
| | | var width = this.image.rectTransform.rect.width; |
| | | var height = this.image.rectTransform.rect.height; |
| | | |
| | | var uv = this.image.overrideSprite != null ? DataUtility.GetOuterUV(this.image.overrideSprite) : Vector4.zero; |
| | | var uvcenterX = (uv.x + uv.z) * 0.5f; |
| | | var uvcenterY = (uv.y + uv.w) * 0.5f; |
| | | var uvscaleX = (uv.z - uv.x) / width; |
| | | var uvscaleY = (uv.w - uv.y) / height; |
| | | |
| | | for(var i = 0;i < this.points.Length;i++) { |
| | | var point = this.points[i]; |
| | | |
| | | var position = new Vector2(point.x,point.y); |
| | | var uv0 = new Vector2(position.x * uvscaleX + uvcenterX,position.y * uvscaleY + uvcenterY); |
| | | var vertex = UIUtility.PackageUIVertex(position,uv0,this.image.color); |
| | | vh.AddVert(vertex); |
| | | } |
| | | |
| | | public override void ModifyMesh(VertexHelper vh) { |
| | | vh.Clear(); |
| | | |
| | | if(this.image == null) { |
| | | throw new NullReferenceException(); |
| | | } |
| | | |
| | | if(this.points == null || this.points.Length < 3) { |
| | | return; |
| | | } |
| | | |
| | | var width = this.image.rectTransform.rect.width; |
| | | var height = this.image.rectTransform.rect.height; |
| | | |
| | | var uv = this.image.overrideSprite != null ? DataUtility.GetOuterUV(this.image.overrideSprite) : Vector4.zero; |
| | | var uvcenterX = (uv.x + uv.z) * 0.5f; |
| | | var uvcenterY = (uv.y + uv.w) * 0.5f; |
| | | var uvscaleX = (uv.z - uv.x) / width; |
| | | var uvscaleY = (uv.w - uv.y) / height; |
| | | |
| | | for(var i = 0;i < this.points.Length;i++) { |
| | | var point = this.points[i]; |
| | | |
| | | var position = new Vector2(point.x,point.y); |
| | | var uv0 = new Vector2(position.x * uvscaleX + uvcenterX,position.y * uvscaleY + uvcenterY); |
| | | var vertex = UIUtility.PackageUIVertex(position,uv0,this.image.color); |
| | | vh.AddVert(vertex); |
| | | } |
| | | |
| | | var vertexCount = this.points.Length; |
| | | var index = 0; |
| | | for(;index < vertexCount - 2;index++) { |
| | | vh.AddTriangle(index,index + 1,index + 2); |
| | | } |
| | | var vertexCount = this.points.Length; |
| | | var index = 0; |
| | | for(;index < vertexCount - 2;index++) { |
| | | vh.AddTriangle(index,index + 1,index + 2); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine.Sprites; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI { |
| | | |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class Hexagon:BaseMeshEffect { |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class Hexagon:BaseMeshEffect { |
| | | |
| | | const float SQUARE_ROOT_THREE = 1.732f; |
| | | Vector3[] positions = new Vector3[3]; |
| | | const float SQUARE_ROOT_THREE = 1.732f; |
| | | Vector3[] positions = new Vector3[3]; |
| | | |
| | | RectTransform m_RectTransform; |
| | | public RectTransform rectTransform { |
| | | get { |
| | | return m_RectTransform ?? (m_RectTransform = this.transform as RectTransform); |
| | | } |
| | | RectTransform m_RectTransform; |
| | | public RectTransform rectTransform { |
| | | get { |
| | | return m_RectTransform ?? (m_RectTransform = this.transform as RectTransform); |
| | | } |
| | | } |
| | | |
| | | Image m_Image; |
| | | public Image image { |
| | | get { |
| | | return m_Image ?? (m_Image = this.GetComponent<Image>()); |
| | | } |
| | | } |
| | | |
| | | public override void ModifyMesh(VertexHelper vh) { |
| | | vh.Clear(); |
| | | |
| | | var uv = this.image != null ? DataUtility.GetOuterUV(this.image.overrideSprite) : Vector4.zero; |
| | | |
| | | var uvCenterX = (uv.x + uv.z) * 0.5f; |
| | | var uvCenterY = (uv.y + uv.w) * 0.5f; |
| | | var uvScaleX = (uv.z - uv.x) / this.rectTransform.rect.width; |
| | | var uvScaleY = (uv.w - uv.y) / this.rectTransform.rect.height; |
| | | |
| | | var xoffset = this.rectTransform.rect.width * 0.5f; |
| | | var yoffset = this.rectTransform.rect.height * 0.5f; |
| | | |
| | | this.positions[0] = new Vector3(0,yoffset); |
| | | this.positions[1] = new Vector3(-xoffset,yoffset * (1f - SQUARE_ROOT_THREE)); |
| | | this.positions[2] = new Vector3(xoffset,yoffset * (1f - SQUARE_ROOT_THREE)); |
| | | |
| | | for(var i = 0;i < 3;i++) { |
| | | var position = this.positions[i]; |
| | | var uv0 = new Vector2(position.x * uvScaleX + uvCenterX,position.y * uvScaleY + uvCenterY); |
| | | var vertex = UIUtility.PackageUIVertex(position,uv0,this.image.color); |
| | | vh.AddVert(vertex); |
| | | |
| | | position = this.positions[i] * -1f; |
| | | uv0 = new Vector2(position.x * uvScaleX + uvCenterX,position.y * uvScaleY + uvCenterY); |
| | | vertex = UIUtility.PackageUIVertex(position,uv0,this.image.color); |
| | | vh.AddVert(vertex); |
| | | } |
| | | |
| | | Image m_Image; |
| | | public Image image { |
| | | get { |
| | | return m_Image ?? (m_Image = this.GetComponent<Image>()); |
| | | } |
| | | } |
| | | |
| | | public override void ModifyMesh(VertexHelper vh) { |
| | | vh.Clear(); |
| | | |
| | | var uv = this.image != null ? DataUtility.GetOuterUV(this.image.overrideSprite) : Vector4.zero; |
| | | |
| | | var uvCenterX = (uv.x + uv.z) * 0.5f; |
| | | var uvCenterY = (uv.y + uv.w) * 0.5f; |
| | | var uvScaleX = (uv.z - uv.x) / this.rectTransform.rect.width; |
| | | var uvScaleY = (uv.w - uv.y) / this.rectTransform.rect.height; |
| | | |
| | | var xoffset = this.rectTransform.rect.width * 0.5f; |
| | | var yoffset = this.rectTransform.rect.height * 0.5f; |
| | | |
| | | this.positions[0] = new Vector3(0,yoffset); |
| | | this.positions[1] = new Vector3(-xoffset,yoffset * (1f - SQUARE_ROOT_THREE)); |
| | | this.positions[2] = new Vector3(xoffset,yoffset * (1f - SQUARE_ROOT_THREE)); |
| | | |
| | | for(var i = 0;i < 3;i++) { |
| | | var position = this.positions[i]; |
| | | var uv0 = new Vector2(position.x * uvScaleX + uvCenterX,position.y * uvScaleY + uvCenterY); |
| | | var vertex = UIUtility.PackageUIVertex(position,uv0,this.image.color); |
| | | vh.AddVert(vertex); |
| | | |
| | | position = this.positions[i] * -1f; |
| | | uv0 = new Vector2(position.x * uvScaleX + uvCenterX,position.y * uvScaleY + uvCenterY); |
| | | vertex = UIUtility.PackageUIVertex(position,uv0,this.image.color); |
| | | vh.AddVert(vertex); |
| | | } |
| | | |
| | | vh.AddTriangle(0,2,4); |
| | | vh.AddTriangle(1,3,5); |
| | | } |
| | | |
| | | vh.AddTriangle(0,2,4); |
| | | vh.AddTriangle(1,3,5); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace vnxbqy.UI { |
| | | |
| | | public class OffsetImage:BaseMeshEffect { |
| | | public class OffsetImage:BaseMeshEffect { |
| | | |
| | | [SerializeField] |
| | | Vector2 m_Offset; |
| | | public Vector2 offset { |
| | | get { |
| | | return m_Offset; |
| | | } |
| | | set { |
| | | m_Offset = value; |
| | | [SerializeField] |
| | | Vector2 m_Offset; |
| | | public Vector2 offset { |
| | | get { |
| | | return m_Offset; |
| | | } |
| | | set { |
| | | m_Offset = value; |
| | | |
| | | } |
| | | } |
| | | |
| | | public override void ModifyMesh(VertexHelper vh) { |
| | | List<UIVertex> vertexs = new List<UIVertex>(); |
| | | vh.GetUIVertexStream(vertexs); |
| | | |
| | | if(vertexs == null || vertexs.Count == 0) { |
| | | return; |
| | | } |
| | | vh.Clear(); |
| | | |
| | | var positions = new Vector3[3]; |
| | | var uv0s = new Vector2[3]; |
| | | |
| | | var firstQuard = new UIVertex[6] { |
| | | vertexs[0], |
| | | vertexs[1], |
| | | vertexs[2], |
| | | vertexs[3], |
| | | vertexs[4], |
| | | vertexs[5] |
| | | }; |
| | | |
| | | for(var i = 0;i < firstQuard.Length;i++) { |
| | | var vertex = firstQuard[i]; |
| | | var position = vertex.position + new Vector3(offset.x,offset.y,0); |
| | | vertex.position = position; |
| | | firstQuard[i] = vertex; |
| | | |
| | | if((i % 3) == 2) { |
| | | positions[0] = firstQuard[i - 2].position; |
| | | uv0s[0] = firstQuard[i - 2].uv0; |
| | | positions[1] = firstQuard[i - 1].position; |
| | | uv0s[1] = firstQuard[i - 1].uv0; |
| | | positions[2] = firstQuard[i].position; |
| | | uv0s[2] = firstQuard[i].uv0; |
| | | |
| | | UIUtility.AddTriangle(vh,positions,Color.white,uv0s); |
| | | } |
| | | } |
| | | |
| | | public override void ModifyMesh(VertexHelper vh) { |
| | | List<UIVertex> vertexs = new List<UIVertex>(); |
| | | vh.GetUIVertexStream(vertexs); |
| | | |
| | | if(vertexs == null || vertexs.Count == 0) { |
| | | return; |
| | | } |
| | | vh.Clear(); |
| | | |
| | | var positions = new Vector3[3]; |
| | | var uv0s = new Vector2[3]; |
| | | var index = 5 * 6; |
| | | for(int i = 0;i < vertexs.Count;i++) { |
| | | |
| | | var firstQuard = new UIVertex[6] { |
| | | vertexs[0], |
| | | vertexs[1], |
| | | vertexs[2], |
| | | vertexs[3], |
| | | vertexs[4], |
| | | vertexs[5] |
| | | }; |
| | | if(i > index) { |
| | | |
| | | for(var i = 0;i < firstQuard.Length;i++) { |
| | | var vertex = firstQuard[i]; |
| | | var position = vertex.position + new Vector3(offset.x,offset.y,0); |
| | | vertex.position = position; |
| | | firstQuard[i] = vertex; |
| | | |
| | | if((i % 3) == 2) { |
| | | positions[0] = firstQuard[i - 2].position; |
| | | uv0s[0] = firstQuard[i - 2].uv0; |
| | | positions[1] = firstQuard[i - 1].position; |
| | | uv0s[1] = firstQuard[i - 1].uv0; |
| | | positions[2] = firstQuard[i].position; |
| | | uv0s[2] = firstQuard[i].uv0; |
| | | |
| | | UIUtility.AddTriangle(vh,positions,Color.white,uv0s); |
| | | } |
| | | } |
| | | |
| | | if((i % 3) == 2) { |
| | | positions[0] = vertexs[i - 2].position; |
| | | uv0s[0] = vertexs[i - 2].uv0; |
| | | positions[1] = vertexs[i - 1].position; |
| | | uv0s[1] = vertexs[i - 1].uv0; |
| | | positions[2] = vertexs[i].position; |
| | | uv0s[2] = vertexs[i].uv0; |
| | | |
| | | |
| | | var index = 5 * 6; |
| | | for(int i = 0;i < vertexs.Count;i++) { |
| | | |
| | | if(i > index) { |
| | | |
| | | } |
| | | |
| | | if((i % 3) == 2) { |
| | | positions[0] = vertexs[i - 2].position; |
| | | uv0s[0] = vertexs[i - 2].uv0; |
| | | positions[1] = vertexs[i - 1].position; |
| | | uv0s[1] = vertexs[i - 1].uv0; |
| | | positions[2] = vertexs[i].position; |
| | | uv0s[2] = vertexs[i].uv0; |
| | | |
| | | UIUtility.AddTriangle(vh,positions,Color.white,uv0s); |
| | | } |
| | | UIUtility.AddTriangle(vh,positions,Color.white,uv0s); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine.UI; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace vnxbqy.UI { |
| | | |
| | | public class OffsetImage2:Text { |
| | | public class OffsetImage2:Text { |
| | | |
| | | [SerializeField] |
| | | Vector2 m_Offset; |
| | | public Vector2 offset { |
| | | get { |
| | | return m_Offset; |
| | | } |
| | | set { |
| | | m_Offset = value; |
| | | |
| | | } |
| | | [SerializeField] |
| | | Vector2 m_Offset; |
| | | public Vector2 offset { |
| | | get { |
| | | return m_Offset; |
| | | } |
| | | |
| | | protected override void OnPopulateMesh(VertexHelper toFill) { |
| | | base.OnPopulateMesh(toFill); |
| | | List<UIVertex> vertexs = new List<UIVertex>(); |
| | | toFill.GetUIVertexStream(vertexs); |
| | | |
| | | if(vertexs == null || vertexs.Count == 0) { |
| | | return; |
| | | } |
| | | |
| | | toFill.Clear(); |
| | | var newVertexs = new List<UIVertex>(); |
| | | var index = 1 * 6 - 1; |
| | | for(int i = 0;i < vertexs.Count;i++) { |
| | | |
| | | var vertex = vertexs[i]; |
| | | if(i == index) { |
| | | newVertexs.AddRange(AddHexgon(vertexs[i - 5].position,new Vector2(offset.x,font.fontSize),Color.white)); |
| | | } |
| | | if(i > index) { |
| | | var position = vertex.position + new Vector3(offset.x,offset.y,0); |
| | | vertex.position = position; |
| | | } |
| | | newVertexs.Add(vertex); |
| | | } |
| | | |
| | | |
| | | var aaa= this.cachedTextGenerator.verts; |
| | | toFill.AddUIVertexTriangleStream(newVertexs); |
| | | LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform); |
| | | } |
| | | |
| | | private UIVertex[] AddHexgon(Vector3 _startPosition,Vector2 _offset,Color _color) { |
| | | |
| | | var hexgon = new UIVertex[4]; |
| | | var positions = new Vector3[4]; |
| | | positions[0] = _startPosition; |
| | | positions[1] = _startPosition + new Vector3(_offset.x,0,0); |
| | | positions[2] = _startPosition + new Vector3(_offset.x,-_offset.y,0); |
| | | positions[3] = _startPosition + new Vector3(0,-_offset.y,0); |
| | | |
| | | for(int i = 0;i < 4;i++) { |
| | | hexgon[i] = UIUtility.PackageUIVertexUV1(positions[i],Vector2.zero,_color); |
| | | } |
| | | |
| | | return hexgon; |
| | | set { |
| | | m_Offset = value; |
| | | |
| | | } |
| | | } |
| | | |
| | | protected override void OnPopulateMesh(VertexHelper toFill) { |
| | | base.OnPopulateMesh(toFill); |
| | | List<UIVertex> vertexs = new List<UIVertex>(); |
| | | toFill.GetUIVertexStream(vertexs); |
| | | |
| | | if(vertexs == null || vertexs.Count == 0) { |
| | | return; |
| | | } |
| | | |
| | | toFill.Clear(); |
| | | var newVertexs = new List<UIVertex>(); |
| | | var index = 1 * 6 - 1; |
| | | for(int i = 0;i < vertexs.Count;i++) { |
| | | |
| | | var vertex = vertexs[i]; |
| | | if(i == index) { |
| | | newVertexs.AddRange(AddHexgon(vertexs[i - 5].position,new Vector2(offset.x,font.fontSize),Color.white)); |
| | | } |
| | | if(i > index) { |
| | | var position = vertex.position + new Vector3(offset.x,offset.y,0); |
| | | vertex.position = position; |
| | | } |
| | | newVertexs.Add(vertex); |
| | | } |
| | | |
| | | |
| | | var aaa= this.cachedTextGenerator.verts; |
| | | toFill.AddUIVertexTriangleStream(newVertexs); |
| | | LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform); |
| | | } |
| | | |
| | | private UIVertex[] AddHexgon(Vector3 _startPosition,Vector2 _offset,Color _color) { |
| | | |
| | | var hexgon = new UIVertex[4]; |
| | | var positions = new Vector3[4]; |
| | | positions[0] = _startPosition; |
| | | positions[1] = _startPosition + new Vector3(_offset.x,0,0); |
| | | positions[2] = _startPosition + new Vector3(_offset.x,-_offset.y,0); |
| | | positions[3] = _startPosition + new Vector3(0,-_offset.y,0); |
| | | |
| | | for(int i = 0;i < 4;i++) { |
| | | hexgon[i] = UIUtility.PackageUIVertexUV1(positions[i],Vector2.zero,_color); |
| | | } |
| | | |
| | | return hexgon; |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI { |
| | | |
| | | /// <summary> |
| | | /// 这个组件接收一些顶点,绘制出水平和垂直的线。 |
| | | /// </summary> |
| | | public class PolylineImage:Graphic { |
| | | /// <summary> |
| | | /// 这个组件接收一些顶点,绘制出水平和垂直的线。 |
| | | /// </summary> |
| | | public class PolylineImage:Graphic { |
| | | |
| | | [SerializeField] |
| | | float m_Width; |
| | | public float width { |
| | | get { |
| | | return this.m_Width; |
| | | } |
| | | set { |
| | | this.m_Width = value; |
| | | base.SetVerticesDirty(); |
| | | } |
| | | [SerializeField] |
| | | float m_Width; |
| | | public float width { |
| | | get { |
| | | return this.m_Width; |
| | | } |
| | | set { |
| | | this.m_Width = value; |
| | | base.SetVerticesDirty(); |
| | | } |
| | | } |
| | | |
| | | [SerializeField] |
| | | Vector2[] m_Points; |
| | | public Vector2[] points { |
| | | get { |
| | | return this.m_Points; |
| | | } |
| | | set { |
| | | this.m_Points = value; |
| | | base.SetVerticesDirty(); |
| | | } |
| | | } |
| | | |
| | | protected override void OnPopulateMesh(VertexHelper vh) { |
| | | vh.Clear(); |
| | | if(this.points == null || this.points.Length < 2) { |
| | | return; |
| | | } |
| | | |
| | | [SerializeField] |
| | | Vector2[] m_Points; |
| | | public Vector2[] points { |
| | | get { |
| | | return this.m_Points; |
| | | } |
| | | set { |
| | | this.m_Points = value; |
| | | base.SetVerticesDirty(); |
| | | } |
| | | } |
| | | var hw = this.width * 0.5f; |
| | | |
| | | protected override void OnPopulateMesh(VertexHelper vh) { |
| | | vh.Clear(); |
| | | if(this.points == null || this.points.Length < 2) { |
| | | return; |
| | | } |
| | | for(var i = 0;i < this.points.Length - 1;i++) { |
| | | var point = this.points[i]; |
| | | var nextPoint = this.points[i + 1]; |
| | | |
| | | var hw = this.width * 0.5f; |
| | | var xReversal = point.x > nextPoint.x; |
| | | var yReversal = point.y > nextPoint.y; |
| | | |
| | | for(var i = 0;i < this.points.Length - 1;i++) { |
| | | var point = this.points[i]; |
| | | var nextPoint = this.points[i + 1]; |
| | | var positions = new Vector3[4]; |
| | | positions[0] = new Vector2(xReversal ? point.x + hw : point.x - hw,yReversal ? point.y + hw : point.y - hw); |
| | | positions[1] = new Vector2(xReversal ? nextPoint.x - hw : nextPoint.x + hw,yReversal ? point.y + hw : point.y - hw); |
| | | positions[2] = new Vector2(xReversal ? nextPoint.x - hw : nextPoint.x + hw,yReversal ? nextPoint.y - hw : nextPoint.y + hw); |
| | | positions[3] = new Vector2(xReversal ? point.x + hw : point.x - hw,yReversal ? nextPoint.y - hw : nextPoint.y + hw); |
| | | |
| | | var xReversal = point.x > nextPoint.x; |
| | | var yReversal = point.y > nextPoint.y; |
| | | |
| | | var positions = new Vector3[4]; |
| | | positions[0] = new Vector2(xReversal ? point.x + hw : point.x - hw,yReversal ? point.y + hw : point.y - hw); |
| | | positions[1] = new Vector2(xReversal ? nextPoint.x - hw : nextPoint.x + hw,yReversal ? point.y + hw : point.y - hw); |
| | | positions[2] = new Vector2(xReversal ? nextPoint.x - hw : nextPoint.x + hw,yReversal ? nextPoint.y - hw : nextPoint.y + hw); |
| | | positions[3] = new Vector2(xReversal ? point.x + hw : point.x - hw,yReversal ? nextPoint.y - hw : nextPoint.y + hw); |
| | | |
| | | UIUtility.AddQuad(vh,positions,color,new Vector2[4] { Vector2.one,Vector2.one,Vector2.one,Vector2.one }); |
| | | } |
| | | |
| | | UIUtility.AddQuad(vh,positions,color,new Vector2[4] { Vector2.one,Vector2.one,Vector2.one,Vector2.one }); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine.Sprites; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class Rhombus : BaseMeshEffect |
| | | { |
| | | const float SQUARE_ROOT_THREE = 1f; |
| | | Vector3[] positions = new Vector3[3]; |
| | | |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class Rhombus : BaseMeshEffect |
| | | RectTransform m_RectTransform; |
| | | public RectTransform rectTransform { |
| | | get { |
| | | return m_RectTransform ?? (m_RectTransform = this.transform as RectTransform); |
| | | } |
| | | } |
| | | |
| | | Image m_Image; |
| | | public Image image { |
| | | get { |
| | | return m_Image ?? (m_Image = this.GetComponent<Image>()); |
| | | } |
| | | } |
| | | |
| | | public override void ModifyMesh(VertexHelper vh) |
| | | { |
| | | const float SQUARE_ROOT_THREE = 1f; |
| | | Vector3[] positions = new Vector3[3]; |
| | | vh.Clear(); |
| | | |
| | | RectTransform m_RectTransform; |
| | | public RectTransform rectTransform { |
| | | get { |
| | | return m_RectTransform ?? (m_RectTransform = this.transform as RectTransform); |
| | | } |
| | | } |
| | | var uv = this.image != null ? DataUtility.GetOuterUV(this.image.overrideSprite) : Vector4.zero; |
| | | |
| | | Image m_Image; |
| | | public Image image { |
| | | get { |
| | | return m_Image ?? (m_Image = this.GetComponent<Image>()); |
| | | } |
| | | } |
| | | var uvCenterX = (uv.x + uv.z) * 0.5f; |
| | | var uvCenterY = (uv.y + uv.w) * 0.5f; |
| | | var uvScaleX = (uv.z - uv.x) / this.rectTransform.rect.width; |
| | | var uvScaleY = (uv.w - uv.y) / this.rectTransform.rect.height; |
| | | |
| | | public override void ModifyMesh(VertexHelper vh) |
| | | var xoffset = this.rectTransform.rect.width * 0.5f; |
| | | var yoffset = this.rectTransform.rect.height * 0.5f; |
| | | |
| | | this.positions[0] = new Vector3(0, yoffset); |
| | | this.positions[1] = new Vector3(-xoffset, yoffset * (1f - SQUARE_ROOT_THREE)); |
| | | this.positions[2] = new Vector3(xoffset, yoffset * (1f - SQUARE_ROOT_THREE)); |
| | | |
| | | for (var i = 0; i < 3; i++) |
| | | { |
| | | vh.Clear(); |
| | | var position = this.positions[i]; |
| | | var uv0 = new Vector2(position.x * uvScaleX + uvCenterX, position.y * uvScaleY + uvCenterY); |
| | | var vertex = UIUtility.PackageUIVertex(position, uv0, this.image.color); |
| | | vh.AddVert(vertex); |
| | | |
| | | var uv = this.image != null ? DataUtility.GetOuterUV(this.image.overrideSprite) : Vector4.zero; |
| | | |
| | | var uvCenterX = (uv.x + uv.z) * 0.5f; |
| | | var uvCenterY = (uv.y + uv.w) * 0.5f; |
| | | var uvScaleX = (uv.z - uv.x) / this.rectTransform.rect.width; |
| | | var uvScaleY = (uv.w - uv.y) / this.rectTransform.rect.height; |
| | | |
| | | var xoffset = this.rectTransform.rect.width * 0.5f; |
| | | var yoffset = this.rectTransform.rect.height * 0.5f; |
| | | |
| | | this.positions[0] = new Vector3(0, yoffset); |
| | | this.positions[1] = new Vector3(-xoffset, yoffset * (1f - SQUARE_ROOT_THREE)); |
| | | this.positions[2] = new Vector3(xoffset, yoffset * (1f - SQUARE_ROOT_THREE)); |
| | | |
| | | for (var i = 0; i < 3; i++) |
| | | { |
| | | var position = this.positions[i]; |
| | | var uv0 = new Vector2(position.x * uvScaleX + uvCenterX, position.y * uvScaleY + uvCenterY); |
| | | var vertex = UIUtility.PackageUIVertex(position, uv0, this.image.color); |
| | | vh.AddVert(vertex); |
| | | |
| | | position = this.positions[i] * -1f; |
| | | uv0 = new Vector2(position.x * uvScaleX + uvCenterX, position.y * uvScaleY + uvCenterY); |
| | | vertex = UIUtility.PackageUIVertex(position, uv0, this.image.color); |
| | | vh.AddVert(vertex); |
| | | } |
| | | |
| | | vh.AddTriangle(0, 2, 4); |
| | | vh.AddTriangle(1, 3, 5); |
| | | position = this.positions[i] * -1f; |
| | | uv0 = new Vector2(position.x * uvScaleX + uvCenterX, position.y * uvScaleY + uvCenterY); |
| | | vertex = UIUtility.PackageUIVertex(position, uv0, this.image.color); |
| | | vh.AddVert(vertex); |
| | | } |
| | | |
| | | vh.AddTriangle(0, 2, 4); |
| | | vh.AddTriangle(1, 3, 5); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class UILinerMove : MonoBehaviour |
| | | { |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class UILinerMove : MonoBehaviour |
| | | [SerializeField] float m_Duration; |
| | | public float duration { |
| | | get { return m_Duration; } |
| | | set { m_Duration = value; } |
| | | } |
| | | |
| | | [SerializeField] Vector2 m_From; |
| | | public Vector2 from { |
| | | get { return m_From; } |
| | | set { m_From = value; } |
| | | } |
| | | |
| | | [SerializeField] Vector2 m_To; |
| | | public Vector2 to { |
| | | get { return m_To; } |
| | | set { m_To = value; } |
| | | } |
| | | |
| | | float timer = float.MaxValue; |
| | | RectTransform rectTransform { get { return this.transform as RectTransform; } } |
| | | |
| | | public void Begin() |
| | | { |
| | | [SerializeField] float m_Duration; |
| | | public float duration { |
| | | get { return m_Duration; } |
| | | set { m_Duration = value; } |
| | | } |
| | | |
| | | [SerializeField] Vector2 m_From; |
| | | public Vector2 from { |
| | | get { return m_From; } |
| | | set { m_From = value; } |
| | | } |
| | | |
| | | [SerializeField] Vector2 m_To; |
| | | public Vector2 to { |
| | | get { return m_To; } |
| | | set { m_To = value; } |
| | | } |
| | | |
| | | float timer = float.MaxValue; |
| | | RectTransform rectTransform { get { return this.transform as RectTransform; } } |
| | | |
| | | public void Begin() |
| | | if (duration < 0f) |
| | | { |
| | | if (duration < 0f) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | Stop(); |
| | | } |
| | | else |
| | | { |
| | | timer = 0f; |
| | | rectTransform.anchoredPosition = from; |
| | | } |
| | | return; |
| | | } |
| | | |
| | | public void Stop() |
| | | if (!this.gameObject.activeInHierarchy) |
| | | { |
| | | timer = float.MaxValue; |
| | | rectTransform.anchoredPosition = to; |
| | | Stop(); |
| | | } |
| | | |
| | | private void OnDisable() |
| | | else |
| | | { |
| | | if (timer < duration) |
| | | { |
| | | Stop(); |
| | | } |
| | | timer = 0f; |
| | | rectTransform.anchoredPosition = from; |
| | | } |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | public void Stop() |
| | | { |
| | | timer = float.MaxValue; |
| | | rectTransform.anchoredPosition = to; |
| | | } |
| | | |
| | | private void OnDisable() |
| | | { |
| | | if (timer < duration) |
| | | { |
| | | if (timer < duration) |
| | | { |
| | | timer += Time.deltaTime; |
| | | var t = Mathf.Clamp01(timer / duration); |
| | | rectTransform.anchoredPosition = Vector2.Lerp(from, to, t); |
| | | } |
| | | Stop(); |
| | | } |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | if (timer < duration) |
| | | { |
| | | timer += Time.deltaTime; |
| | | var t = Mathf.Clamp01(timer / duration); |
| | | rectTransform.anchoredPosition = Vector2.Lerp(from, to, t); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | public class UISmoothMove : MonoBehaviour |
| | | { |
| | | [SerializeField] Vector2 m_To; |
| | | public Vector2 to { |
| | | get { return m_To; } |
| | | set { m_To = value; } |
| | | } |
| | | |
| | | public class UISmoothMove : MonoBehaviour |
| | | [SerializeField] float m_Smooth = 0.2f; |
| | | |
| | | Vector2 refPosition = Vector2.zero; |
| | | RectTransform rectTransform { get { return this.transform as RectTransform; } } |
| | | |
| | | bool show = false; |
| | | |
| | | public void Begin() |
| | | { |
| | | [SerializeField] Vector2 m_To; |
| | | public Vector2 to { |
| | | get { return m_To; } |
| | | set { m_To = value; } |
| | | } |
| | | refPosition = Vector2.zero; |
| | | show = true; |
| | | } |
| | | |
| | | [SerializeField] float m_Smooth = 0.2f; |
| | | public void Stop() |
| | | { |
| | | show = false; |
| | | } |
| | | |
| | | Vector2 refPosition = Vector2.zero; |
| | | RectTransform rectTransform { get { return this.transform as RectTransform; } } |
| | | |
| | | bool show = false; |
| | | |
| | | public void Begin() |
| | | private void LateUpdate() |
| | | { |
| | | if (Vector2.Distance(rectTransform.anchoredPosition, to) > 1f) |
| | | { |
| | | refPosition = Vector2.zero; |
| | | show = true; |
| | | if (show) |
| | | { |
| | | var newPosition = Vector2.SmoothDamp(rectTransform.anchoredPosition, to, ref refPosition, m_Smooth, 1000, Time.deltaTime); |
| | | rectTransform.anchoredPosition = newPosition; |
| | | } |
| | | } |
| | | |
| | | public void Stop() |
| | | else |
| | | { |
| | | show = false; |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | if (Vector2.Distance(rectTransform.anchoredPosition, to) > 1f) |
| | | { |
| | | if (show) |
| | | { |
| | | var newPosition = Vector2.SmoothDamp(rectTransform.anchoredPosition, to, ref refPosition, m_Smooth, 1000, Time.deltaTime); |
| | | rectTransform.anchoredPosition = newPosition; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | show = false; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | |
| | | namespace vnxbqy.UI { |
| | | public class PingPongMove:MonoBehaviour { |
| | | public class PingPongMove:MonoBehaviour { |
| | | |
| | | public Transform reference; |
| | | public Vector3 amplitue; |
| | | public float speed; |
| | | public Transform reference; |
| | | public Vector3 amplitue; |
| | | public float speed; |
| | | |
| | | Vector3 referencePos = Vector3.zero; |
| | | Vector3 referencePos = Vector3.zero; |
| | | |
| | | void OnEnable() { |
| | | referencePos = reference == null ? this.transform.localPosition : reference.localPosition; |
| | | } |
| | | |
| | | float x = 0f; |
| | | float y = 0f; |
| | | float z = 0f; |
| | | void LateUpdate() { |
| | | |
| | | if(Mathf.Abs(amplitue.x) > 0.001f) { |
| | | x = referencePos.x - amplitue.x * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.x); |
| | | } |
| | | else { |
| | | x = referencePos.x; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.y) > 0.001f) { |
| | | y = referencePos.y - amplitue.y * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.y); |
| | | } |
| | | else { |
| | | y = referencePos.y; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.z) > 0.001f) { |
| | | z = referencePos.z - amplitue.z * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.z); |
| | | } |
| | | else { |
| | | z = referencePos.z; |
| | | } |
| | | |
| | | this.transform.localPosition = new Vector3(x,y,z); |
| | | } |
| | | |
| | | void OnEnable() { |
| | | referencePos = reference == null ? this.transform.localPosition : reference.localPosition; |
| | | } |
| | | |
| | | float x = 0f; |
| | | float y = 0f; |
| | | float z = 0f; |
| | | void LateUpdate() { |
| | | |
| | | if(Mathf.Abs(amplitue.x) > 0.001f) { |
| | | x = referencePos.x - amplitue.x * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.x); |
| | | } |
| | | else { |
| | | x = referencePos.x; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.y) > 0.001f) { |
| | | y = referencePos.y - amplitue.y * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.y); |
| | | } |
| | | else { |
| | | y = referencePos.y; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.z) > 0.001f) { |
| | | z = referencePos.z - amplitue.z * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.z); |
| | | } |
| | | else { |
| | | z = referencePos.z; |
| | | } |
| | | |
| | | this.transform.localPosition = new Vector3(x,y,z); |
| | | } |
| | | |
| | | } |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | |
| | | namespace vnxbqy.UI { |
| | | public class PingPongRotation:MonoBehaviour { |
| | | |
| | | public Transform reference; |
| | | public Vector3 amplitue; |
| | | public float speed; |
| | | public class PingPongRotation:MonoBehaviour { |
| | | |
| | | Vector3 referenceEuler = Vector3.zero; |
| | | public Transform reference; |
| | | public Vector3 amplitue; |
| | | public float speed; |
| | | |
| | | void OnEnable() { |
| | | referenceEuler = reference == null ? this.transform.localEulerAngles : reference.localEulerAngles; |
| | | } |
| | | Vector3 referenceEuler = Vector3.zero; |
| | | |
| | | float x = 0f; |
| | | float y = 0f; |
| | | float z = 0f; |
| | | void LateUpdate() { |
| | | |
| | | if(Mathf.Abs(amplitue.x) > 0.001f) { |
| | | x = referenceEuler.x - amplitue.x * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.x); |
| | | } |
| | | else { |
| | | x = referenceEuler.x; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.y) > 0.001f) { |
| | | y = referenceEuler.y - amplitue.y * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.y); |
| | | } |
| | | else { |
| | | y = referenceEuler.y; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.z) > 0.001f) { |
| | | z = referenceEuler.z - amplitue.z * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.z); |
| | | } |
| | | else { |
| | | z = referenceEuler.z; |
| | | } |
| | | |
| | | this.transform.localEulerAngles = new Vector3(x,y,z); |
| | | } |
| | | |
| | | void OnEnable() { |
| | | referenceEuler = reference == null ? this.transform.localEulerAngles : reference.localEulerAngles; |
| | | } |
| | | |
| | | float x = 0f; |
| | | float y = 0f; |
| | | float z = 0f; |
| | | void LateUpdate() { |
| | | |
| | | if(Mathf.Abs(amplitue.x) > 0.001f) { |
| | | x = referenceEuler.x - amplitue.x * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.x); |
| | | } |
| | | else { |
| | | x = referenceEuler.x; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.y) > 0.001f) { |
| | | y = referenceEuler.y - amplitue.y * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.y); |
| | | } |
| | | else { |
| | | y = referenceEuler.y; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.z) > 0.001f) { |
| | | z = referenceEuler.z - amplitue.z * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.z); |
| | | } |
| | | else { |
| | | z = referenceEuler.z; |
| | | } |
| | | |
| | | this.transform.localEulerAngles = new Vector3(x,y,z); |
| | | } |
| | | |
| | | } |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | |
| | | namespace vnxbqy.UI { |
| | | public class PingPongScale:MonoBehaviour { |
| | | public class PingPongScale:MonoBehaviour { |
| | | |
| | | public Transform reference; |
| | | public Vector3 amplitue; |
| | | public float speed; |
| | | public Transform reference; |
| | | public Vector3 amplitue; |
| | | public float speed; |
| | | |
| | | Vector3 referenceScale = Vector3.zero; |
| | | Vector3 referenceScale = Vector3.zero; |
| | | |
| | | void OnEnable() { |
| | | referenceScale = reference == null ? this.transform.localScale : reference.localScale; |
| | | } |
| | | |
| | | float x = 0f; |
| | | float y = 0f; |
| | | float z = 0f; |
| | | void LateUpdate() { |
| | | |
| | | if(Mathf.Abs(amplitue.x) > 0.001f) { |
| | | x = referenceScale.x - amplitue.x * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.x); |
| | | } |
| | | else { |
| | | x = referenceScale.x; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.y) > 0.001f) { |
| | | y = referenceScale.y - amplitue.y * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.y); |
| | | } |
| | | else { |
| | | y = referenceScale.y; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.z) > 0.001f) { |
| | | z = referenceScale.z - amplitue.z * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.z); |
| | | } |
| | | else { |
| | | z = referenceScale.z; |
| | | } |
| | | |
| | | this.transform.localScale = new Vector3(x,y,z); |
| | | } |
| | | void OnEnable() { |
| | | referenceScale = reference == null ? this.transform.localScale : reference.localScale; |
| | | } |
| | | |
| | | float x = 0f; |
| | | float y = 0f; |
| | | float z = 0f; |
| | | void LateUpdate() { |
| | | |
| | | if(Mathf.Abs(amplitue.x) > 0.001f) { |
| | | x = referenceScale.x - amplitue.x * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.x); |
| | | } |
| | | else { |
| | | x = referenceScale.x; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.y) > 0.001f) { |
| | | y = referenceScale.y - amplitue.y * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.y); |
| | | } |
| | | else { |
| | | y = referenceScale.y; |
| | | } |
| | | |
| | | if(Mathf.Abs(amplitue.z) > 0.001f) { |
| | | z = referenceScale.z - amplitue.z * 0.5f + Mathf.PingPong(Time.time * speed,amplitue.z); |
| | | } |
| | | else { |
| | | z = referenceScale.z; |
| | | } |
| | | |
| | | this.transform.localScale = new Vector3(x,y,z); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | public class RotationTween : Tween |
| | | { |
| | | |
| | | public class RotationTween : Tween |
| | | public override void SetStartState() |
| | | { |
| | | base.SetStartState(); |
| | | this.transform.localEulerAngles = from; |
| | | } |
| | | |
| | | public override void SetEndState() |
| | | { |
| | | base.SetEndState(); |
| | | this.transform.localEulerAngles = to; |
| | | } |
| | | |
| | | protected override void OnPrepare() |
| | | { |
| | | base.OnPrepare(); |
| | | this.transform.localEulerAngles = reversal ? to : from; |
| | | } |
| | | |
| | | protected override void OnOnceEnd() |
| | | { |
| | | |
| | | public override void SetStartState() |
| | | { |
| | | base.SetStartState(); |
| | | this.transform.localEulerAngles = from; |
| | | } |
| | | this.transform.localEulerAngles = reversal ? from : to; |
| | | base.OnOnceEnd(); |
| | | } |
| | | |
| | | public override void SetEndState() |
| | | { |
| | | base.SetEndState(); |
| | | this.transform.localEulerAngles = to; |
| | | } |
| | | |
| | | protected override void OnPrepare() |
| | | { |
| | | base.OnPrepare(); |
| | | this.transform.localEulerAngles = reversal ? to : from; |
| | | } |
| | | |
| | | protected override void OnOnceEnd() |
| | | { |
| | | |
| | | this.transform.localEulerAngles = reversal ? from : to; |
| | | base.OnOnceEnd(); |
| | | } |
| | | |
| | | protected override void UpdateVector3() |
| | | { |
| | | base.UpdateVector3(); |
| | | this.transform.localEulerAngles = CalculateVector3(); |
| | | } |
| | | protected override void UpdateVector3() |
| | | { |
| | | base.UpdateVector3(); |
| | | this.transform.localEulerAngles = CalculateVector3(); |
| | | } |
| | | } |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | |
| | | public class ScaleTween : Tween |
| | | public class ScaleTween : Tween |
| | | { |
| | | public override void SetStartState() |
| | | { |
| | | public override void SetStartState() |
| | | { |
| | | base.SetStartState(); |
| | | this.transform.localScale = from; |
| | | } |
| | | base.SetStartState(); |
| | | this.transform.localScale = from; |
| | | } |
| | | |
| | | public override void SetEndState() |
| | | { |
| | | base.SetEndState(); |
| | | this.transform.localScale = to; |
| | | } |
| | | public override void SetEndState() |
| | | { |
| | | base.SetEndState(); |
| | | this.transform.localScale = to; |
| | | } |
| | | |
| | | protected override void OnPrepare() |
| | | { |
| | | base.OnPrepare(); |
| | | this.transform.localScale = reversal ? to : from; |
| | | } |
| | | protected override void OnPrepare() |
| | | { |
| | | base.OnPrepare(); |
| | | this.transform.localScale = reversal ? to : from; |
| | | } |
| | | |
| | | protected override void OnOnceEnd() |
| | | { |
| | | this.transform.localScale = reversal ? from : to; |
| | | base.OnOnceEnd(); |
| | | } |
| | | protected override void OnOnceEnd() |
| | | { |
| | | this.transform.localScale = reversal ? from : to; |
| | | base.OnOnceEnd(); |
| | | } |
| | | |
| | | protected override void UpdateVector3() |
| | | { |
| | | base.UpdateVector3(); |
| | | this.transform.localScale = CalculateVector3(); |
| | | } |
| | | protected override void UpdateVector3() |
| | | { |
| | | base.UpdateVector3(); |
| | | this.transform.localScale = CalculateVector3(); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | using System.Collections; |
| | | using System; |
| | | |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class Tween : MonoBehaviour |
| | | [RequireComponent(typeof(RectTransform))] |
| | | public class Tween : MonoBehaviour |
| | | { |
| | | public TweenCurve curve; |
| | | public Vector3 from; |
| | | public Vector3 to; |
| | | |
| | | public DelayMode delayMode = DelayMode.Time; |
| | | public float delay = 0f; |
| | | |
| | | public float duration = 1f; |
| | | public Trigger trigger = Trigger.Manual; |
| | | public WrapMode wrapMode; |
| | | public bool reversal; |
| | | |
| | | protected RectTransform rectTransform { get { return this.transform as RectTransform; } } |
| | | |
| | | protected float accumulatedTime; |
| | | protected float curveLength; |
| | | protected bool doTween = false; |
| | | |
| | | Action onPlayEndCallBack; |
| | | |
| | | public virtual void SetStartState() |
| | | { |
| | | public TweenCurve curve; |
| | | public Vector3 from; |
| | | public Vector3 to; |
| | | |
| | | public DelayMode delayMode = DelayMode.Time; |
| | | public float delay = 0f; |
| | | } |
| | | |
| | | public float duration = 1f; |
| | | public Trigger trigger = Trigger.Manual; |
| | | public WrapMode wrapMode; |
| | | public bool reversal; |
| | | public virtual void SetEndState() |
| | | { |
| | | |
| | | protected RectTransform rectTransform { get { return this.transform as RectTransform; } } |
| | | } |
| | | |
| | | protected float accumulatedTime; |
| | | protected float curveLength; |
| | | protected bool doTween = false; |
| | | public void Play() |
| | | { |
| | | onPlayEndCallBack = null; |
| | | reversal = false; |
| | | StopAllCoroutines(); |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | |
| | | Action onPlayEndCallBack; |
| | | public void Play(bool _reversal) |
| | | { |
| | | onPlayEndCallBack = null; |
| | | reversal = _reversal; |
| | | StopAllCoroutines(); |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | |
| | | public virtual void SetStartState() |
| | | public void Play(Action _callBack) |
| | | { |
| | | reversal = false; |
| | | onPlayEndCallBack = _callBack; |
| | | StopAllCoroutines(); |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | |
| | | public void Play(bool _reversal, Action _callBack) |
| | | { |
| | | reversal = _reversal; |
| | | onPlayEndCallBack = _callBack; |
| | | StopAllCoroutines(); |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | |
| | | void Start() |
| | | { |
| | | if (trigger == Trigger.Start) |
| | | { |
| | | |
| | | } |
| | | |
| | | public virtual void SetEndState() |
| | | { |
| | | |
| | | } |
| | | |
| | | public void Play() |
| | | { |
| | | onPlayEndCallBack = null; |
| | | reversal = false; |
| | | StopAllCoroutines(); |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | } |
| | | |
| | | public void Play(bool _reversal) |
| | | protected virtual void OnEnable() |
| | | { |
| | | if (trigger == Trigger.Enable) |
| | | { |
| | | onPlayEndCallBack = null; |
| | | reversal = _reversal; |
| | | StopAllCoroutines(); |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | } |
| | | |
| | | public void Play(Action _callBack) |
| | | protected virtual void OnDisable() |
| | | { |
| | | onPlayEndCallBack = null; |
| | | StopAllCoroutines(); |
| | | } |
| | | |
| | | void LateUpdate() |
| | | { |
| | | if (doTween && duration > 0.001f) |
| | | { |
| | | reversal = false; |
| | | onPlayEndCallBack = _callBack; |
| | | StopAllCoroutines(); |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | accumulatedTime += Time.deltaTime; |
| | | UpdateVector3(); |
| | | |
| | | public void Play(bool _reversal, Action _callBack) |
| | | { |
| | | reversal = _reversal; |
| | | onPlayEndCallBack = _callBack; |
| | | StopAllCoroutines(); |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | |
| | | void Start() |
| | | { |
| | | if (trigger == Trigger.Start) |
| | | { |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | } |
| | | |
| | | protected virtual void OnEnable() |
| | | { |
| | | if (trigger == Trigger.Enable) |
| | | { |
| | | StartCoroutine(Co_StartTween()); |
| | | } |
| | | } |
| | | |
| | | protected virtual void OnDisable() |
| | | { |
| | | onPlayEndCallBack = null; |
| | | StopAllCoroutines(); |
| | | } |
| | | |
| | | void LateUpdate() |
| | | { |
| | | if (doTween && duration > 0.001f) |
| | | { |
| | | accumulatedTime += Time.deltaTime; |
| | | UpdateVector3(); |
| | | |
| | | switch (wrapMode) |
| | | { |
| | | case WrapMode.Once: |
| | | if (accumulatedTime > duration) |
| | | { |
| | | OnOnceEnd(); |
| | | doTween = false; |
| | | } |
| | | break; |
| | | case WrapMode.PingPongOnce: |
| | | if (accumulatedTime > duration*2) |
| | | { |
| | | OnOnceEnd(); |
| | | doTween = false; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | IEnumerator Co_StartTween() |
| | | { |
| | | if (delay < 0f) |
| | | { |
| | | Debug.LogError("Delaytime should not be less than zero!"); |
| | | yield break; |
| | | } |
| | | if (duration < 0.001f) |
| | | { |
| | | Debug.LogError("Duration should not be less than zero!"); |
| | | yield break; |
| | | } |
| | | |
| | | if (curve.keys.Length < 2) |
| | | { |
| | | Debug.LogError("不正确的曲线!"); |
| | | yield break; |
| | | } |
| | | |
| | | accumulatedTime = 0f; |
| | | doTween = false; |
| | | OnPrepare(); |
| | | switch (delayMode) |
| | | { |
| | | case DelayMode.OneFrame: |
| | | yield return null; |
| | | break; |
| | | case DelayMode.TwiceFrame: |
| | | yield return null; |
| | | yield return null; |
| | | break; |
| | | case DelayMode.Time: |
| | | if (delay > 0.001f) |
| | | { |
| | | yield return new WaitForSeconds(delay); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | curveLength = curve.keys[curve.keys.Length - 1].time - curve.keys[0].time; |
| | | doTween = true; |
| | | |
| | | } |
| | | |
| | | protected Vector3 CalculateVector3() |
| | | { |
| | | Vector3 newVector3 = Vector3.zero; |
| | | float t = 0f; |
| | | switch (wrapMode) |
| | | { |
| | | case WrapMode.Once: |
| | | t = (accumulatedTime / duration) * curveLength; |
| | | if (accumulatedTime > duration) |
| | | { |
| | | OnOnceEnd(); |
| | | doTween = false; |
| | | } |
| | | break; |
| | | case WrapMode.Loop: |
| | | t = Mathf.Repeat((accumulatedTime / duration) * curveLength, 1); |
| | | break; |
| | | case WrapMode.PingPong: |
| | | case WrapMode.PingPongOnce: |
| | | t = Mathf.PingPong((accumulatedTime / duration) * curveLength, 1); |
| | | if (accumulatedTime > duration*2) |
| | | { |
| | | OnOnceEnd(); |
| | | doTween = false; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | var value = curve.Evaluate(reversal ? curveLength - t : t); |
| | | newVector3 = Vector3.LerpUnclamped(from, to, value); |
| | | |
| | | return newVector3; |
| | | } |
| | | |
| | | protected virtual void OnPrepare() |
| | | { |
| | | |
| | | } |
| | | |
| | | protected virtual void OnOnceEnd() |
| | | { |
| | | if (onPlayEndCallBack != null) |
| | | { |
| | | onPlayEndCallBack(); |
| | | onPlayEndCallBack = null; |
| | | } |
| | | } |
| | | |
| | | protected virtual void UpdateVector3() |
| | | { |
| | | |
| | | } |
| | | |
| | | public void Stop() |
| | | { |
| | | doTween = false; |
| | | } |
| | | |
| | | public enum DelayMode |
| | | { |
| | | OneFrame, |
| | | TwiceFrame, |
| | | Time, |
| | | } |
| | | |
| | | public enum Trigger |
| | | { |
| | | Manual, |
| | | Start, |
| | | Enable, |
| | | } |
| | | |
| | | public enum WrapMode |
| | | { |
| | | Once, |
| | | Loop, |
| | | PingPong, |
| | | PingPongOnce, |
| | | } |
| | | } |
| | | |
| | | IEnumerator Co_StartTween() |
| | | { |
| | | if (delay < 0f) |
| | | { |
| | | Debug.LogError("Delaytime should not be less than zero!"); |
| | | yield break; |
| | | } |
| | | if (duration < 0.001f) |
| | | { |
| | | Debug.LogError("Duration should not be less than zero!"); |
| | | yield break; |
| | | } |
| | | |
| | | if (curve.keys.Length < 2) |
| | | { |
| | | Debug.LogError("不正确的曲线!"); |
| | | yield break; |
| | | } |
| | | |
| | | accumulatedTime = 0f; |
| | | doTween = false; |
| | | OnPrepare(); |
| | | switch (delayMode) |
| | | { |
| | | case DelayMode.OneFrame: |
| | | yield return null; |
| | | break; |
| | | case DelayMode.TwiceFrame: |
| | | yield return null; |
| | | yield return null; |
| | | break; |
| | | case DelayMode.Time: |
| | | if (delay > 0.001f) |
| | | { |
| | | yield return new WaitForSeconds(delay); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | curveLength = curve.keys[curve.keys.Length - 1].time - curve.keys[0].time; |
| | | doTween = true; |
| | | |
| | | } |
| | | |
| | | protected Vector3 CalculateVector3() |
| | | { |
| | | Vector3 newVector3 = Vector3.zero; |
| | | float t = 0f; |
| | | switch (wrapMode) |
| | | { |
| | | case WrapMode.Once: |
| | | t = (accumulatedTime / duration) * curveLength; |
| | | break; |
| | | case WrapMode.Loop: |
| | | t = Mathf.Repeat((accumulatedTime / duration) * curveLength, 1); |
| | | break; |
| | | case WrapMode.PingPong: |
| | | case WrapMode.PingPongOnce: |
| | | t = Mathf.PingPong((accumulatedTime / duration) * curveLength, 1); |
| | | break; |
| | | } |
| | | |
| | | var value = curve.Evaluate(reversal ? curveLength - t : t); |
| | | newVector3 = Vector3.LerpUnclamped(from, to, value); |
| | | |
| | | return newVector3; |
| | | } |
| | | |
| | | protected virtual void OnPrepare() |
| | | { |
| | | |
| | | } |
| | | |
| | | protected virtual void OnOnceEnd() |
| | | { |
| | | if (onPlayEndCallBack != null) |
| | | { |
| | | onPlayEndCallBack(); |
| | | onPlayEndCallBack = null; |
| | | } |
| | | } |
| | | |
| | | protected virtual void UpdateVector3() |
| | | { |
| | | |
| | | } |
| | | |
| | | public void Stop() |
| | | { |
| | | doTween = false; |
| | | } |
| | | |
| | | public enum DelayMode |
| | | { |
| | | OneFrame, |
| | | TwiceFrame, |
| | | Time, |
| | | } |
| | | |
| | | public enum Trigger |
| | | { |
| | | Manual, |
| | | Start, |
| | | Enable, |
| | | } |
| | | |
| | | public enum WrapMode |
| | | { |
| | | Once, |
| | | Loop, |
| | | PingPong, |
| | | PingPongOnce, |
| | | } |
| | | } |
| | | |
| | |
| | | using vnxbqy.UI; |
| | | using UnityEngine; |
| | | using UnityEngine; |
| | | |
| | | public class EffectMgr : SingletonMonobehaviour<EffectMgr> |
| | | |
| | |
| | | using UnityEngine; |
| | | using System; |
| | | using UnityEngine.Rendering; |
| | | using vnxbqy.UI; |
| | | using UnityEngine.UI; |
| | | |
| | | #if UNITY_EDITOR |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | namespace vnxbqy.UI |
| | | public class UIEffectBehaviour : MonoBehaviour |
| | | { |
| | | public class UIEffectBehaviour : MonoBehaviour |
| | | private List<ParticleSystem> m_Particles = new List<ParticleSystem>(); |
| | | private List<Animator> m_Animators = new List<Animator>(); |
| | | private List<Renderer> m_Renderers = new List<Renderer>(); |
| | | |
| | | public float duration { get; private set; } |
| | | private Vector3 m_RectMaskPosition; |
| | | private bool m_RectMaskEnable; |
| | | private RectTransform m_RectMask; |
| | | |
| | | public bool IsAnimatorControl { get; private set; } |
| | | |
| | | private void Awake() |
| | | { |
| | | private List<ParticleSystem> m_Particles = new List<ParticleSystem>(); |
| | | private List<Animator> m_Animators = new List<Animator>(); |
| | | private List<Renderer> m_Renderers = new List<Renderer>(); |
| | | GetComponent(); |
| | | this.gameObject.SetLayer(LayerUtility.UIEffectLayer, true); |
| | | } |
| | | |
| | | public float duration { get; private set; } |
| | | private Vector3 m_RectMaskPosition; |
| | | private bool m_RectMaskEnable; |
| | | private RectTransform m_RectMask; |
| | | |
| | | public bool IsAnimatorControl { get; private set; } |
| | | |
| | | private void Awake() |
| | | public void SetParticlesScale(Vector3 _scale) |
| | | { |
| | | if (_scale != Vector3.one) |
| | | foreach (var par in m_Particles) |
| | | { |
| | | GetComponent(); |
| | | this.gameObject.SetLayer(LayerUtility.UIEffectLayer, true); |
| | | par.transform.localScale = _scale; |
| | | } |
| | | } |
| | | |
| | | public void SetParticlesScale(Vector3 _scale) |
| | | |
| | | public void SetOrder(int _order) |
| | | { |
| | | foreach (var _renderer in m_Renderers) |
| | | { |
| | | if (_scale != Vector3.one) |
| | | foreach (var par in m_Particles) |
| | | { |
| | | par.transform.localScale = _scale; |
| | | } |
| | | _renderer.sortingOrder = _order; |
| | | _renderer.sortingLayerName = "UI"; |
| | | } |
| | | } |
| | | |
| | | |
| | | public void SetOrder(int _order) |
| | | public void PerformMask(RectMask2D[] _masks) |
| | | { |
| | | RectTransform _rect = null; |
| | | var _mask = _masks == null || _masks.Length == 0 ? null : _masks[0]; |
| | | if (_mask == null) |
| | | { |
| | | foreach (var _renderer in m_Renderers) |
| | | { |
| | | _renderer.sortingOrder = _order; |
| | | _renderer.sortingLayerName = "UI"; |
| | | } |
| | | } |
| | | |
| | | public void PerformMask(RectMask2D[] _masks) |
| | | { |
| | | RectTransform _rect = null; |
| | | var _mask = _masks == null || _masks.Length == 0 ? null : _masks[0]; |
| | | if (_mask == null) |
| | | { |
| | | _rect = null; |
| | | } |
| | | else |
| | | { |
| | | _rect = _mask.rectTransform; |
| | | } |
| | | PerformMask(_rect); |
| | | } |
| | | |
| | | public void PerformMask(Mask[] _masks) |
| | | { |
| | | RectTransform _rect = null; |
| | | var _mask = _masks == null || _masks.Length == 0 ? null : _masks[0]; |
| | | if (_mask == null) |
| | | { |
| | | _rect = null; |
| | | } |
| | | else |
| | | { |
| | | _rect = _mask.rectTransform; |
| | | } |
| | | PerformMask(_rect); |
| | | } |
| | | |
| | | public void PerformMask(RectTransform _mask) |
| | | else |
| | | { |
| | | m_RectMask = _mask; |
| | | m_RectMaskEnable = _mask != null; |
| | | if (_mask != null) |
| | | { |
| | | m_RectMaskPosition = _mask.position; |
| | | _mask.GetWorldCorners(s_RectMask); |
| | | s_ClipRect.x = s_RectMask[0].x; s_ClipRect.y = s_RectMask[0].y; |
| | | s_ClipRect.z = s_RectMask[2].x; s_ClipRect.w = s_RectMask[2].y; |
| | | } |
| | | foreach (var _renderer in m_Renderers) |
| | | { |
| | | var _mat = _renderer.material; |
| | | SetClipRect(_mat, s_ClipRect, m_RectMaskEnable); |
| | | } |
| | | _rect = _mask.rectTransform; |
| | | } |
| | | PerformMask(_rect); |
| | | } |
| | | |
| | | private void GetComponent() |
| | | public void PerformMask(Mask[] _masks) |
| | | { |
| | | RectTransform _rect = null; |
| | | var _mask = _masks == null || _masks.Length == 0 ? null : _masks[0]; |
| | | if (_mask == null) |
| | | { |
| | | transform.GetComponentsInChildren(true, m_Renderers); |
| | | IsAnimatorControl = false; |
| | | TraverseChild(transform); |
| | | _rect = null; |
| | | } |
| | | |
| | | private void TraverseChild(Transform parent) |
| | | else |
| | | { |
| | | ParticleSystem particle = parent.GetComponent<ParticleSystem>(); |
| | | if (particle != null) |
| | | { |
| | | if (particle.main.duration > duration && !IsAnimatorControl) |
| | | { |
| | | duration = particle.main.duration; |
| | | } |
| | | m_Particles.Add(particle); |
| | | } |
| | | Animator animator = parent.GetComponent<Animator>(); |
| | | if (animator != null) |
| | | { |
| | | m_Animators.Add(animator); |
| | | AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo(0); |
| | | duration = state.length > duration ? state.length : duration; |
| | | IsAnimatorControl = true; |
| | | } |
| | | foreach (Transform child in parent) |
| | | { |
| | | TraverseChild(child); |
| | | } |
| | | _rect = _mask.rectTransform; |
| | | } |
| | | PerformMask(_rect); |
| | | } |
| | | |
| | | private Vector4 s_ClipRect = Vector4.zero; |
| | | private Vector3[] s_RectMask = new Vector3[4]; |
| | | |
| | | private void SetClipRect(Material _mat, Vector4 _clipRect, bool _mask) |
| | | public void PerformMask(RectTransform _mask) |
| | | { |
| | | m_RectMask = _mask; |
| | | m_RectMaskEnable = _mask != null; |
| | | if (_mask != null) |
| | | { |
| | | _mat.SetVector("_ClipRect", _clipRect); |
| | | _mat.SetFloat("_UseClipRect", _mask ? 1 : 0); |
| | | m_RectMaskPosition = _mask.position; |
| | | _mask.GetWorldCorners(s_RectMask); |
| | | s_ClipRect.x = s_RectMask[0].x; s_ClipRect.y = s_RectMask[0].y; |
| | | s_ClipRect.z = s_RectMask[2].x; s_ClipRect.w = s_RectMask[2].y; |
| | | } |
| | | |
| | | public Animator GetAnimator() |
| | | foreach (var _renderer in m_Renderers) |
| | | { |
| | | if (IsAnimatorControl && m_Animators.Count > 0) |
| | | var _mat = _renderer.material; |
| | | SetClipRect(_mat, s_ClipRect, m_RectMaskEnable); |
| | | } |
| | | } |
| | | |
| | | private void GetComponent() |
| | | { |
| | | transform.GetComponentsInChildren(true, m_Renderers); |
| | | IsAnimatorControl = false; |
| | | TraverseChild(transform); |
| | | } |
| | | |
| | | private void TraverseChild(Transform parent) |
| | | { |
| | | ParticleSystem particle = parent.GetComponent<ParticleSystem>(); |
| | | if (particle != null) |
| | | { |
| | | if (particle.main.duration > duration && !IsAnimatorControl) |
| | | { |
| | | return m_Animators[0]; |
| | | duration = particle.main.duration; |
| | | } |
| | | return null; |
| | | m_Particles.Add(particle); |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | Animator animator = parent.GetComponent<Animator>(); |
| | | if (animator != null) |
| | | { |
| | | if (m_RectMask != null && (m_RectMaskPosition != m_RectMask.position)) |
| | | { |
| | | m_RectMaskPosition = m_RectMask.position; |
| | | PerformMask(m_RectMask); |
| | | } |
| | | m_Animators.Add(animator); |
| | | AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo(0); |
| | | duration = state.length > duration ? state.length : duration; |
| | | IsAnimatorControl = true; |
| | | } |
| | | |
| | | private void OnDisable() |
| | | foreach (Transform child in parent) |
| | | { |
| | | m_RectMask = null; |
| | | TraverseChild(child); |
| | | } |
| | | } |
| | | |
| | | private Vector4 s_ClipRect = Vector4.zero; |
| | | private Vector3[] s_RectMask = new Vector3[4]; |
| | | |
| | | private void SetClipRect(Material _mat, Vector4 _clipRect, bool _mask) |
| | | { |
| | | _mat.SetVector("_ClipRect", _clipRect); |
| | | _mat.SetFloat("_UseClipRect", _mask ? 1 : 0); |
| | | } |
| | | |
| | | public Animator GetAnimator() |
| | | { |
| | | if (IsAnimatorControl && m_Animators.Count > 0) |
| | | { |
| | | return m_Animators[0]; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | if (m_RectMask != null && (m_RectMaskPosition != m_RectMask.position)) |
| | | { |
| | | m_RectMaskPosition = m_RectMask.position; |
| | | PerformMask(m_RectMask); |
| | | } |
| | | } |
| | | |
| | | private void OnDisable() |
| | | { |
| | | m_RectMask = null; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | |
| | | using UnityEngine;
|
| | | using vnxbqy.UI;
|
| | | using System;
|
| | | //01 02 玩家初始化#tagCDBPlayer
|
| | |
|
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | |
| | | //02 12 ������ʾ#tagNotifyCode |
| | | |
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using vnxbqy.UI;
|
| | | //03 16 ���������ɹ�#tagPackResetOK
|
| | |
|
| | |
|
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using System;
|
| | | using vnxbqy.UI;
|
| | |
|
| | | public class DTC0403_tagPlayerLoginLoadOK : DtcBasic
|
| | | {
|
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | |
| | | //07 04 ���DZ���ˢ��#tagRolePackRefresh |
| | | |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | |
| | | //07 06 ���ʹ����Ʒ�ɹ�#tagUseItemSuccess |
| | | public class DTC0706_tagUseItemSuccess : DtcBasic |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | |
| | | //07 07 ��Ʒ����ˢ��#tagItemCountRefresh |
| | | |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | |
| | | //07 09 �����Ʒ#tagClearItem |
| | | |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | //07 11 ��ձ���#tagClearItemPack |
| | | |
| | | |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | |
| | | //07 24 ���DZ����ѿ�������#tagRolePackCanUseCount |
| | | |
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using vnxbqy.UI; |
| | | |
| | | //07 25 ���DZ���ˢ�£�֪ͨ������Ʒ�� #tagRolePackRefreshEx |
| | | |
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using vnxbqy.UI;
|
| | |
|
| | | // A2 04 ���ⱳ����Ʒˢ�� #tagMCVPackRefresh
|
| | |
|
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using vnxbqy.UI;
|
| | |
|
| | | // A2 05 ���ⱳ����Ʒ��� #tagMCVPackClear
|
| | |
|
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using vnxbqy.UI;
|
| | |
|
| | | // A2 06 自动转化为对应物品ID个数刷新 #tagMCAutoItemCountRefresh
|
| | |
|
| | |
| | | // A3 62 邮件列表 #tagMCMailList
|
| | | using vnxbqy.UI;
|
| | |
|
| | | public class DTCA362_tagMCMailList : DtcBasic
|
| | | {
|
| | |
| | | // A3 63 邮件状态变更 #tagMCMailStateChange
|
| | | using vnxbqy.UI;
|
| | |
|
| | | public class DTCA363_tagMCMailStateChange : DtcBasic
|
| | | {
|
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using vnxbqy.UI;
|
| | | // A8 01 获得奖励信息 #tagMCGiveAwardInfo
|
| | |
|
| | | public class DTCA801_tagMCGiveAwardInfo : DtcBasic {
|
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using vnxbqy.UI;
|
| | | // A8 09 通知物品当日已使用次数 #tagMCItemDayUseCntInfo
|
| | |
|
| | | public class DTCA809_tagMCItemDayUseCntInfo : DtcBasic {
|
| | |
| | | // case CodeA2U.ExitGame: |
| | | // if (ChannelPlatform == E_ChannelPlatform.Free) |
| | | // { |
| | | // vnxbqy.UI.WindowCenter.Instance.Open<vnxbqy.UI.ExitGameWin>(); |
| | | // WindowCenter.Instance.Open<ExitGameWin>(); |
| | | // } |
| | | // else |
| | | // { |
| | |
| | | using vnxbqy.UI; |
| | | using System.Collections; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | |
| | | using vnxbqy.UI; |
| | | using System.Collections; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using EnhancedUI.EnhancedScroller; |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using vnxbqy.UI; |
| | | |
| | | namespace EnhancedUI.EnhancedScroller |
| | | { |
| | | // public class ChatFriendCell : ScrollerUI |
| | | // { |
| | | // [SerializeField] RichText m_ChatText; |
| | | // [SerializeField] Text m_VipText; |
| | | // [SerializeField] Text m_NameText; |
| | | // [SerializeField] AvatarCell m_ChatIcon; |
| | | // [SerializeField] ImageFitterText m_ImageFitter; |
| | | |
| | | // public override void Refresh(CellView cell) |
| | | // { |
| | | // var _index = cell.index; |
| | | // int _playerId = ChatCtrl.Inst.PteChatID; |
| | | // var _list = ChatCtrl.Inst.GetChatInfo(_playerId); |
| | | // if (_list != null && _index < _list.Count) |
| | | // { |
| | | // ChatFriendData chat = _list[_index]; |
| | | // m_ChatText.text = chat.content; |
| | | // if (type == ScrollerDataType.Header) |
| | | // { |
| | | // m_ChatText.AutoNewLine = false; |
| | | // if (m_ChatText.preferredWidth > m_ChatText.rectTransform.rect.width) |
| | | // { |
| | | // m_ChatText.alignment = TextAnchor.UpperLeft; |
| | | // } |
| | | // else |
| | | // { |
| | | // m_ChatText.alignment = TextAnchor.UpperRight; |
| | | // } |
| | | // m_ChatText.AutoNewLine = true; |
| | | // } |
| | | // m_ImageFitter.FiterRealTxtWidth = m_ChatText.alignment == TextAnchor.UpperRight; |
| | | // m_VipText.text = chat.vipLv > 0 ? StringUtility.Contact("V", chat.vipLv) : string.Empty; |
| | | // m_NameText.text = chat.name; |
| | | // m_ChatIcon.InitUI(AvatarHelper.GetAvatarModel(chat.player, chat.face, chat.facePic, chat.job)); |
| | | // m_ChatText.text = chat.content; |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | //public class ChatFriendCell : ScrollerUI
|
| | | //{
|
| | | // [SerializeField] RichText m_ChatText;
|
| | | // [SerializeField] Text m_VipText;
|
| | | // [SerializeField] Text m_NameText;
|
| | | // [SerializeField] AvatarCell m_ChatIcon;
|
| | | // [SerializeField] ImageFitterText m_ImageFitter;
|
| | |
|
| | | // public override void Refresh(CellView cell)
|
| | | // {
|
| | | // var _index = cell.index;
|
| | | // int _playerId = ChatCtrl.Inst.PteChatID;
|
| | | // var _list = ChatCtrl.Inst.GetChatInfo(_playerId);
|
| | | // if (_list != null && _index < _list.Count)
|
| | | // {
|
| | | // ChatFriendData chat = _list[_index];
|
| | | // m_ChatText.text = chat.content;
|
| | | // if (type == ScrollerDataType.Header)
|
| | | // {
|
| | | // m_ChatText.AutoNewLine = false;
|
| | | // if (m_ChatText.preferredWidth > m_ChatText.rectTransform.rect.width)
|
| | | // {
|
| | | // m_ChatText.alignment = TextAnchor.UpperLeft;
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // m_ChatText.alignment = TextAnchor.UpperRight;
|
| | | // }
|
| | | // m_ChatText.AutoNewLine = true;
|
| | | // }
|
| | | // m_ImageFitter.FiterRealTxtWidth = m_ChatText.alignment == TextAnchor.UpperRight;
|
| | | // m_VipText.text = chat.vipLv > 0 ? StringUtility.Contact("V", chat.vipLv) : string.Empty;
|
| | | // m_NameText.text = chat.name;
|
| | | // m_ChatIcon.InitUI(AvatarHelper.GetAvatarModel(chat.player, chat.face, chat.facePic, chat.job));
|
| | | // m_ChatText.text = chat.content;
|
| | | // }
|
| | | // }
|
| | | //} |
| | | |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI |
| | | public class ChatItemCell : CellView |
| | | { |
| | | public class ChatItemCell : CellView |
| | | { |
| | | [SerializeField] List<ItemCell> m_Items; |
| | | public List<ItemCell> items { get { return m_Items; } } |
| | | [SerializeField] List<Image> m_ItemEquips; |
| | | public List<Image> itemEquips { get { return m_ItemEquips; } } |
| | | } |
| | | [SerializeField] List<ItemCell> m_Items; |
| | | public List<ItemCell> items { get { return m_Items; } } |
| | | [SerializeField] List<Image> m_ItemEquips; |
| | | public List<Image> itemEquips { get { return m_ItemEquips; } } |
| | | } |
| | | |
| | |
| | | using System.Text; |
| | | using System; |
| | | using System.Text.RegularExpressions; |
| | | using vnxbqy.UI; |
| | | |
| | | using System.Linq; |
| | | |
| | |
| | | using vnxbqy.UI; |
| | | using System.Collections; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using EnhancedUI.EnhancedScroller; |
| | | |
| | | public class ChatRecentlyCell : ScrollerUI |
| | | |
| | | |
| | | public class ChatRecentlyCell : ScrollerUI |
| | | { |
| | | [SerializeField] Image m_PlayerBG; |
| | | [SerializeField] Image m_Select; |
| | | [SerializeField] Text m_PlayerName; |
| | | [SerializeField] Text m_Lv; |
| | | [SerializeField] Image m_LvSign; |
| | | [SerializeField] Text m_LvText; |
| | | [SerializeField] Button m_DetailBtn; |
| | | |
| | | public override void Refresh(CellView cell) |
| | | { |
| | | [SerializeField] Image m_PlayerBG; |
| | | [SerializeField] Image m_Select; |
| | | [SerializeField] Text m_PlayerName; |
| | | [SerializeField] Text m_Lv; |
| | | [SerializeField] Image m_LvSign; |
| | | [SerializeField] Text m_LvText; |
| | | [SerializeField] Button m_DetailBtn; |
| | | |
| | | public override void Refresh(CellView cell) |
| | | { |
| | | // TODO YYL |
| | | // var _playerId = cell.index; |
| | | // var _dict = friendModel.GetFriendInfoDict((byte)GroupType.RecentContact); |
| | | // FriendPlayer _friendPlayer = null; |
| | | // if (_dict != null && _dict.ContainsKey((uint)_playerId)) |
| | | // { |
| | | // _friendPlayer = _dict[(uint)_playerId]; |
| | | // } |
| | | // else if (friendModel.tempFriendData != null && friendModel.tempFriendData.PlayerID == _playerId) |
| | | // { |
| | | // _friendPlayer = friendModel.tempFriendData; |
| | | // } |
| | | // if (_friendPlayer == null) |
| | | // { |
| | | // return; |
| | | // } |
| | | // m_Select.SetActive(_playerId == ChatCtrl.Inst.PteChatID); |
| | | // m_PlayerName.text = _friendPlayer.PlayerName; |
| | | // m_LvSign.SetActive(false); |
| | | // var _lv = _friendPlayer.LV ; |
| | | // m_LvText.text = (_lv > 0 ? _lv : _friendPlayer.LV).ToString(); |
| | | // m_DetailBtn.onClick.RemoveAllListeners(); |
| | | // m_DetailBtn.onClick.AddListener(() => |
| | | // { |
| | | // PlayerDetails.ShowPlayerDetails(_playerId, null); |
| | | // }); |
| | | // SetOnline(_friendPlayer.OnlineType == 1); |
| | | } |
| | | |
| | | private void SetOnline(bool _online) |
| | | { |
| | | m_PlayerBG.material = _online ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetDefaultSpriteGrayMaterial(); |
| | | m_LvSign.material = _online ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetDefaultSpriteGrayMaterial(); |
| | | m_Lv.color = _online ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.White, true); |
| | | m_LvText.color = _online ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.White, true); |
| | | m_PlayerName.color = _online ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.White, true); |
| | | } |
| | | // TODO YYL |
| | | // var _playerId = cell.index; |
| | | // var _dict = friendModel.GetFriendInfoDict((byte)GroupType.RecentContact); |
| | | // FriendPlayer _friendPlayer = null; |
| | | // if (_dict != null && _dict.ContainsKey((uint)_playerId)) |
| | | // { |
| | | // _friendPlayer = _dict[(uint)_playerId]; |
| | | // } |
| | | // else if (friendModel.tempFriendData != null && friendModel.tempFriendData.PlayerID == _playerId) |
| | | // { |
| | | // _friendPlayer = friendModel.tempFriendData; |
| | | // } |
| | | // if (_friendPlayer == null) |
| | | // { |
| | | // return; |
| | | // } |
| | | // m_Select.SetActive(_playerId == ChatCtrl.Inst.PteChatID); |
| | | // m_PlayerName.text = _friendPlayer.PlayerName; |
| | | // m_LvSign.SetActive(false); |
| | | // var _lv = _friendPlayer.LV ; |
| | | // m_LvText.text = (_lv > 0 ? _lv : _friendPlayer.LV).ToString(); |
| | | // m_DetailBtn.onClick.RemoveAllListeners(); |
| | | // m_DetailBtn.onClick.AddListener(() => |
| | | // { |
| | | // PlayerDetails.ShowPlayerDetails(_playerId, null); |
| | | // }); |
| | | // SetOnline(_friendPlayer.OnlineType == 1); |
| | | } |
| | | |
| | | private void SetOnline(bool _online) |
| | | { |
| | | m_PlayerBG.material = _online ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetDefaultSpriteGrayMaterial(); |
| | | m_LvSign.material = _online ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetDefaultSpriteGrayMaterial(); |
| | | m_Lv.color = _online ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.White, true); |
| | | m_LvText.color = _online ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.White, true); |
| | | m_PlayerName.color = _online ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.White, true); |
| | | } |
| | | } |
| | | |
| | |
| | | using vnxbqy.UI; |
| | | using System.Collections; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using EnhancedUI.EnhancedScroller; |
| | | public class ChatTrailCell : ScrollerUI |
| | | { |
| | | [SerializeField] Image chatIcon; |
| | | [SerializeField] RichText chatText; |
| | | |
| | | public override void Refresh(CellView cell) |
| | | |
| | | public class ChatTrailCell : ScrollerUI |
| | | { |
| | | [SerializeField] Image chatIcon; |
| | | [SerializeField] RichText chatText; |
| | | |
| | | public override void Refresh(CellView cell) |
| | | { |
| | | ChatData _data = ChatCenter.Instance.GetChatData(ChatManager.Instance.presentChatType, cell.index); |
| | | if (_data == null) |
| | | { |
| | | ChatData _data = ChatCenter.Instance.GetChatData(ChatManager.Instance.presentChatType, cell.index); |
| | | if (_data == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_data.infoList != null) |
| | | { |
| | | chatText.SetExtenalData(_data.infoList); |
| | | } |
| | | chatIcon.SetActive(true); |
| | | if (_data.type == ChatInfoType.Invite) |
| | | { |
| | | chatIcon.SetSprite("ChatIcon_Invite"); |
| | | } |
| | | else if (_data.type == ChatInfoType.System) |
| | | { |
| | | chatIcon.SetSprite("ChatIcon_System"); |
| | | } |
| | | else if (_data.type == ChatInfoType.Friend) |
| | | { |
| | | chatIcon.SetSprite("ChatIcon_System"); |
| | | } |
| | | else |
| | | { |
| | | chatIcon.SetActive(false); |
| | | } |
| | | chatText.text = _data.type == ChatInfoType.Friend ? _data.content.Replace(ChatManager.KILL_IDENTIFY, string.Empty) : _data.content; |
| | | return; |
| | | } |
| | | if (_data.infoList != null) |
| | | { |
| | | chatText.SetExtenalData(_data.infoList); |
| | | } |
| | | chatIcon.SetActive(true); |
| | | if (_data.type == ChatInfoType.Invite) |
| | | { |
| | | chatIcon.SetSprite("ChatIcon_Invite"); |
| | | } |
| | | else if (_data.type == ChatInfoType.System) |
| | | { |
| | | chatIcon.SetSprite("ChatIcon_System"); |
| | | } |
| | | else if (_data.type == ChatInfoType.Friend) |
| | | { |
| | | chatIcon.SetSprite("ChatIcon_System"); |
| | | } |
| | | else |
| | | { |
| | | chatIcon.SetActive(false); |
| | | } |
| | | chatText.text = _data.type == ChatInfoType.Friend ? _data.content.Replace(ChatManager.KILL_IDENTIFY, string.Empty) : _data.content; |
| | | } |
| | | } |
| | | |
| | |
| | | using vnxbqy.UI; |
| | | using System.Collections.Generic; |
| | | using System.Collections.Generic; |
| | | |
| | | using System.Text; |
| | | using System; |
| | |
| | | |
| | | using UnityEngine.Events; |
| | | |
| | | namespace vnxbqy.UI |
| | | public class GMCmdPanel : UIBase |
| | | { |
| | | public class GMCmdPanel : UIBase |
| | | |
| | | [SerializeField] |
| | | private ScrollerController _cmdCtrl; |
| | | |
| | | [SerializeField] |
| | | private Button _closeBtn; |
| | | |
| | | GMCmdManager _cmdModel; |
| | | GMCmdManager cmdModel{ get { return GMCmdManager.Instance; } } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | base.OnPreOpen(); |
| | | _cmdCtrl.OnRefreshCell += RefreshCmdCell; |
| | | |
| | | _closeBtn.onClick.AddListener(OnClickCloseBtn); |
| | | |
| | | CreateCmdCell(); |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | | { |
| | | base.OnOpen(); |
| | | this.transform.SetAsLastSibling(); |
| | | } |
| | | |
| | | |
| | | private void CreateCmdCell() |
| | | { |
| | | _cmdCtrl.Refresh(); |
| | | var allKeys = GmCmdConfig.dic.Keys; |
| | | foreach (var key in allKeys) |
| | | { |
| | | _cmdCtrl.AddCell(ScrollerDataType.Header, key); |
| | | } |
| | | _cmdCtrl.Restart(); |
| | | } |
| | | |
| | | private void RefreshCmdCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | Button cellBtn = cell.GetComponent<Button>(); |
| | | Text cmdText = cell.transform.Find("Text").GetComponent<Text>(); |
| | | GmCmdConfig gmCmdModel = GmCmdConfig.Get(cell.index); |
| | | if (gmCmdModel == null) |
| | | return; |
| | | |
| | | cmdText.text = gmCmdModel.Cmd + "=" + gmCmdModel.ParamSet; |
| | | cellBtn.onClick.RemoveAllListeners(); |
| | | cellBtn.onClick.AddListener(() => { OnClickCmdCell(gmCmdModel.ParamSet); }); |
| | | } |
| | | |
| | | private void OnClickCmdCell(string paramSet) |
| | | { |
| | | SplitLongGMCmd(paramSet); |
| | | } |
| | | |
| | | public void SplitLongGMCmd(string value) |
| | | { |
| | | |
| | | [SerializeField] |
| | | private ScrollerController _cmdCtrl; |
| | | |
| | | [SerializeField] |
| | | private Button _closeBtn; |
| | | |
| | | GMCmdManager _cmdModel; |
| | | GMCmdManager cmdModel{ get { return GMCmdManager.Instance; } } |
| | | |
| | | protected override void OnPreOpen() |
| | | string[] longCmdArray = value.Split('|'); |
| | | for (int i = 0; i < longCmdArray.Length; i++) |
| | | { |
| | | base.OnPreOpen(); |
| | | _cmdCtrl.OnRefreshCell += RefreshCmdCell; |
| | | |
| | | _closeBtn.onClick.AddListener(OnClickCloseBtn); |
| | | |
| | | CreateCmdCell(); |
| | | cmdModel.OnSendGMQuest(longCmdArray[i].Trim()); |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | | { |
| | | base.OnOpen(); |
| | | this.transform.SetAsLastSibling(); |
| | | } |
| | | |
| | | |
| | | private void CreateCmdCell() |
| | | { |
| | | _cmdCtrl.Refresh(); |
| | | var allKeys = GmCmdConfig.dic.Keys; |
| | | foreach (var key in allKeys) |
| | | { |
| | | _cmdCtrl.AddCell(ScrollerDataType.Header, key); |
| | | } |
| | | _cmdCtrl.Restart(); |
| | | } |
| | | |
| | | private void RefreshCmdCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | Button cellBtn = cell.GetComponent<Button>(); |
| | | Text cmdText = cell.transform.Find("Text").GetComponent<Text>(); |
| | | GmCmdConfig gmCmdModel = GmCmdConfig.Get(cell.index); |
| | | if (gmCmdModel == null) |
| | | return; |
| | | |
| | | cmdText.text = gmCmdModel.Cmd + "=" + gmCmdModel.ParamSet; |
| | | cellBtn.onClick.RemoveAllListeners(); |
| | | cellBtn.onClick.AddListener(() => { OnClickCmdCell(gmCmdModel.ParamSet); }); |
| | | } |
| | | |
| | | private void OnClickCmdCell(string paramSet) |
| | | { |
| | | SplitLongGMCmd(paramSet); |
| | | } |
| | | |
| | | public void SplitLongGMCmd(string value) |
| | | { |
| | | |
| | | string[] longCmdArray = value.Split('|'); |
| | | for (int i = 0; i < longCmdArray.Length; i++) |
| | | { |
| | | cmdModel.OnSendGMQuest(longCmdArray[i].Trim()); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public void OnClickCloseBtn() |
| | | { |
| | | CloseWindow(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void OnClickCloseBtn() |
| | | { |
| | | CloseWindow(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | |
|
| | | namespace vnxbqy.UI
|
| | | public class GMInputWin : UIBase
|
| | | {
|
| | | public class GMInputWin : UIBase
|
| | | {
|
| | | [SerializeField]
|
| | | private ScrollerController _cmdCtrl;
|
| | | [SerializeField]
|
| | | private ScrollerController _cmdCtrl;
|
| | |
|
| | | [SerializeField]
|
| | | private InputField _inputCmd;
|
| | | [SerializeField]
|
| | | private InputField _inputCmd;
|
| | |
|
| | | [SerializeField]
|
| | | private Button _closeBtn;
|
| | | [SerializeField]
|
| | | private Button _closeBtn;
|
| | |
|
| | | [SerializeField]
|
| | | private Button _lookBtn;
|
| | | [SerializeField]
|
| | | private Button _lookBtn;
|
| | |
|
| | | [SerializeField]
|
| | | private Button _sendBtn;
|
| | | [SerializeField]
|
| | | private Button _sendBtn;
|
| | |
|
| | |
|
| | | [SerializeField]
|
| | | private Button _gmInfoBtn;
|
| | | [SerializeField]
|
| | | private Button _gmInfoBtn;
|
| | |
|
| | | [SerializeField]
|
| | | private Button _clearBtn;
|
| | | [SerializeField]
|
| | | private Button _clearBtn;
|
| | |
|
| | | [SerializeField]
|
| | | private Button achieveJumpTestBtn;
|
| | | [SerializeField]
|
| | | private Button achieveJumpTestBtn;
|
| | |
|
| | | [SerializeField]
|
| | | private GameObject _cmdContent;
|
| | | [SerializeField]
|
| | | private GameObject _cmdContent;
|
| | |
|
| | | private List<string> recordCmdlist;
|
| | | private List<string> recordCmdlist;
|
| | |
|
| | | GMCmdManager cmdModel { get { return GMCmdManager.Instance; } }
|
| | | GMCmdManager cmdModel { get { return GMCmdManager.Instance; } }
|
| | |
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | base.OnPreOpen();
|
| | | _cmdCtrl.OnRefreshCell += RefreshCmdCell;
|
| | | _closeBtn.onClick.AddListener(OnClickCloseBtn);
|
| | | _lookBtn.onClick.AddListener(OnClickLookBtn);
|
| | | _sendBtn.onClick.AddListener(() => { OnClickSendBtn(); });
|
| | | _gmInfoBtn.onClick.AddListener(OnClickGMInfoBtn);
|
| | | _clearBtn.onClick.AddListener(OnClickClearBtn);
|
| | | achieveJumpTestBtn.AddListener(ClickAchieveJumpBtn);
|
| | | _cmdContent.SetActive(false);
|
| | | }
|
| | |
|
| | | protected override void OnOpen()
|
| | | {
|
| | | base.HandleOpen();
|
| | | this.transform.SetAsLastSibling();
|
| | | }
|
| | | protected void LateUpdate()
|
| | | {
|
| | | if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
|
| | | {
|
| | | base.OnPreOpen();
|
| | | _cmdCtrl.OnRefreshCell += RefreshCmdCell;
|
| | | _closeBtn.onClick.AddListener(OnClickCloseBtn);
|
| | | _lookBtn.onClick.AddListener(OnClickLookBtn);
|
| | | _sendBtn.onClick.AddListener(() => { OnClickSendBtn(); });
|
| | | _gmInfoBtn.onClick.AddListener(OnClickGMInfoBtn);
|
| | | _clearBtn.onClick.AddListener(OnClickClearBtn);
|
| | | achieveJumpTestBtn.AddListener(ClickAchieveJumpBtn);
|
| | | OnClickSendBtn();
|
| | | }
|
| | | }
|
| | |
|
| | | private void CreateCmdCell()
|
| | | {
|
| | | _cmdCtrl.Refresh();
|
| | | int i = 0;
|
| | | for (i = recordCmdlist.Count - 1; i > -1; i--)
|
| | | {
|
| | | _cmdCtrl.AddCell(ScrollerDataType.Header, i);
|
| | | }
|
| | | _cmdCtrl.Restart();
|
| | | }
|
| | |
|
| | | private void RefreshCmdCell(ScrollerDataType type, CellView cell)
|
| | | {
|
| | | Button cellBtn = cell.GetComponent<Button>();
|
| | | Text cmdText = cell.transform.Find("Text").GetComponent<Text>();
|
| | | string cmdStr = recordCmdlist[cell.index];
|
| | | cmdText.text = cmdStr;
|
| | | cellBtn.onClick.RemoveAllListeners();
|
| | | cellBtn.onClick.AddListener(() =>
|
| | | {
|
| | | OnClickCmdCell(cmdStr);
|
| | | });
|
| | | }
|
| | |
|
| | | private void OnClickCmdCell(string paramSet)
|
| | | {
|
| | | _inputCmd.text = paramSet;
|
| | | }
|
| | |
|
| | | private void OnClickGMInfoBtn()
|
| | | {
|
| | | ServerTipDetails.OpenGMPanel();
|
| | | }
|
| | |
|
| | | private void OnClickLookBtn()
|
| | | {
|
| | | if (_cmdContent.gameObject.activeInHierarchy)
|
| | | {
|
| | | _cmdContent.SetActive(false);
|
| | | }
|
| | |
|
| | | protected override void OnOpen()
|
| | | else
|
| | | {
|
| | | base.HandleOpen();
|
| | | this.transform.SetAsLastSibling();
|
| | | _cmdContent.SetActive(true);
|
| | | recordCmdlist = cmdModel.GetRecordCmdlist();
|
| | | CreateCmdCell();
|
| | | }
|
| | | protected void LateUpdate()
|
| | | {
|
| | | if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
|
| | | {
|
| | | OnClickSendBtn();
|
| | | }
|
| | | }
|
| | |
|
| | | private void CreateCmdCell()
|
| | | {
|
| | | _cmdCtrl.Refresh();
|
| | | int i = 0;
|
| | | for (i = recordCmdlist.Count - 1; i > -1; i--)
|
| | | {
|
| | | _cmdCtrl.AddCell(ScrollerDataType.Header, i);
|
| | | }
|
| | | _cmdCtrl.Restart();
|
| | | }
|
| | |
|
| | | private void RefreshCmdCell(ScrollerDataType type, CellView cell)
|
| | | {
|
| | | Button cellBtn = cell.GetComponent<Button>();
|
| | | Text cmdText = cell.transform.Find("Text").GetComponent<Text>();
|
| | | string cmdStr = recordCmdlist[cell.index];
|
| | | cmdText.text = cmdStr;
|
| | | cellBtn.onClick.RemoveAllListeners();
|
| | | cellBtn.onClick.AddListener(() =>
|
| | | {
|
| | | OnClickCmdCell(cmdStr);
|
| | | });
|
| | | }
|
| | |
|
| | | private void OnClickCmdCell(string paramSet)
|
| | | {
|
| | | _inputCmd.text = paramSet;
|
| | | }
|
| | |
|
| | | private void OnClickGMInfoBtn()
|
| | | {
|
| | | ServerTipDetails.OpenGMPanel();
|
| | | }
|
| | |
|
| | | private void OnClickLookBtn()
|
| | | {
|
| | | if (_cmdContent.gameObject.activeInHierarchy)
|
| | | {
|
| | | _cmdContent.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | _cmdContent.SetActive(true);
|
| | | recordCmdlist = cmdModel.GetRecordCmdlist();
|
| | | CreateCmdCell();
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnClickSendBtn()
|
| | | {
|
| | | if (_inputCmd.text == null || _inputCmd.text == "" || _inputCmd.text == string.Empty)
|
| | | return;
|
| | |
|
| | | // if (_inputCmd.text == "HappyXB")
|
| | | // {
|
| | | // WindowCenter.Instance.Open<HappyXBWin>();
|
| | | // return;
|
| | | // }
|
| | | // else if (_inputCmd.text == "TreasureFindHost")
|
| | | // {
|
| | | // WindowCenter.Instance.Open<TreasureFindHostWin>();
|
| | | // return;
|
| | | // }
|
| | | // if (_inputCmd.text.Equals("EnterFB 31250"))
|
| | | // {
|
| | | // cmdModel.OnSendGMQuest("SetFBStar 31250");
|
| | | // ClientGuardDungeon.RequestEnter();
|
| | | // return;
|
| | | // }
|
| | |
|
| | | cmdModel.OnSendGMQuest(_inputCmd.text.Trim());
|
| | | cmdModel.SetRecordCmdlist(_inputCmd.text);
|
| | | }
|
| | |
|
| | |
|
| | | private void OnClickClearBtn()
|
| | | {
|
| | | cmdModel.ClearRecordCmdlist();
|
| | | OnClickLookBtn();
|
| | | }
|
| | |
|
| | | private void OnClickCloseBtn()
|
| | | {
|
| | | CloseWindow();
|
| | | }
|
| | |
|
| | | private void ClickAchieveJumpBtn()
|
| | | {
|
| | | // try
|
| | | // {
|
| | | // int achieveId = int.Parse(_inputCmd.text);
|
| | | // ModelCenter.Instance.GetModel<AchievementModel>().GotoCompleteAchievement(achieveId);
|
| | | // }
|
| | | // catch (Exception ex)
|
| | | // {
|
| | | // }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private void OnClickSendBtn()
|
| | | {
|
| | | if (_inputCmd.text == null || _inputCmd.text == "" || _inputCmd.text == string.Empty)
|
| | | return;
|
| | |
|
| | | // if (_inputCmd.text == "HappyXB")
|
| | | // {
|
| | | // WindowCenter.Instance.Open<HappyXBWin>();
|
| | | // return;
|
| | | // }
|
| | | // else if (_inputCmd.text == "TreasureFindHost")
|
| | | // {
|
| | | // WindowCenter.Instance.Open<TreasureFindHostWin>();
|
| | | // return;
|
| | | // }
|
| | | // if (_inputCmd.text.Equals("EnterFB 31250"))
|
| | | // {
|
| | | // cmdModel.OnSendGMQuest("SetFBStar 31250");
|
| | | // ClientGuardDungeon.RequestEnter();
|
| | | // return;
|
| | | // }
|
| | |
|
| | | cmdModel.OnSendGMQuest(_inputCmd.text.Trim());
|
| | | cmdModel.SetRecordCmdlist(_inputCmd.text);
|
| | | }
|
| | |
|
| | |
|
| | | private void OnClickClearBtn()
|
| | | {
|
| | | cmdModel.ClearRecordCmdlist();
|
| | | OnClickLookBtn();
|
| | | }
|
| | |
|
| | | private void OnClickCloseBtn()
|
| | | {
|
| | | CloseWindow();
|
| | | }
|
| | |
|
| | | private void ClickAchieveJumpBtn()
|
| | | {
|
| | | // try
|
| | | // {
|
| | | // int achieveId = int.Parse(_inputCmd.text);
|
| | | // ModelCenter.Instance.GetModel<AchievementModel>().GotoCompleteAchievement(achieveId);
|
| | | // }
|
| | | // catch (Exception ex)
|
| | | // {
|
| | | // }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace vnxbqy.UI |
| | | public class MoveObj : MonoBehaviour,IDragHandler,IBeginDragHandler,IEndDragHandler |
| | | { |
| | | public class MoveObj : MonoBehaviour,IDragHandler,IBeginDragHandler,IEndDragHandler |
| | | private Vector3 vec3; |
| | | private Vector3 pos; |
| | | public const string GMInputPos_Key = "GMInputPos"; |
| | | private float[] gmInputPos = new float[3]; |
| | | |
| | | |
| | | private void OnEnable() |
| | | { |
| | | private Vector3 vec3; |
| | | private Vector3 pos; |
| | | public const string GMInputPos_Key = "GMInputPos"; |
| | | private float[] gmInputPos = new float[3]; |
| | | |
| | | |
| | | private void OnEnable() |
| | | if (LocalSave.GetFloatArray(GMInputPos_Key) != null) |
| | | { |
| | | if (LocalSave.GetFloatArray(GMInputPos_Key) != null) |
| | | { |
| | | gmInputPos = LocalSave.GetFloatArray(GMInputPos_Key); |
| | | transform.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(gmInputPos[0], gmInputPos[1], gmInputPos[2]); |
| | | } |
| | | gmInputPos = LocalSave.GetFloatArray(GMInputPos_Key); |
| | | transform.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(gmInputPos[0], gmInputPos[1], gmInputPos[2]); |
| | | } |
| | | |
| | | |
| | | public void OnBeginDrag(PointerEventData eventData) |
| | | { |
| | | GameObject _moveObj = eventData.pointerDrag; |
| | | vec3 = Input.mousePosition; |
| | | pos = transform.GetComponent<RectTransform>().anchoredPosition3D; |
| | | } |
| | | |
| | | public void OnDrag(PointerEventData eventData) |
| | | { |
| | | Vector3 off = Input.mousePosition - vec3; |
| | | vec3 = Input.mousePosition; |
| | | pos = pos + off; |
| | | |
| | | if (pos.x > -506 && pos.y > -318 && pos.x < 515 && pos.y < 336) |
| | | { |
| | | transform.GetComponent<RectTransform>().anchoredPosition3D = pos; |
| | | gmInputPos[0] = pos.x; |
| | | gmInputPos[1] = pos.y; |
| | | gmInputPos[2] = pos.z; |
| | | LocalSave.SetFloatArray(GMInputPos_Key, gmInputPos); |
| | | } |
| | | } |
| | | |
| | | public void OnEndDrag(PointerEventData eventData) |
| | | { |
| | | Debug.Log(pos.x + "和" + pos.y); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public void OnBeginDrag(PointerEventData eventData) |
| | | { |
| | | GameObject _moveObj = eventData.pointerDrag; |
| | | vec3 = Input.mousePosition; |
| | | pos = transform.GetComponent<RectTransform>().anchoredPosition3D; |
| | | } |
| | | |
| | | public void OnDrag(PointerEventData eventData) |
| | | { |
| | | Vector3 off = Input.mousePosition - vec3; |
| | | vec3 = Input.mousePosition; |
| | | pos = pos + off; |
| | | |
| | | if (pos.x > -506 && pos.y > -318 && pos.x < 515 && pos.y < 336) |
| | | { |
| | | transform.GetComponent<RectTransform>().anchoredPosition3D = pos; |
| | | gmInputPos[0] = pos.x; |
| | | gmInputPos[1] = pos.y; |
| | | gmInputPos[2] = pos.z; |
| | | LocalSave.SetFloatArray(GMInputPos_Key, gmInputPos); |
| | | } |
| | | } |
| | | |
| | | public void OnEndDrag(PointerEventData eventData) |
| | | { |
| | | Debug.Log(pos.x + "和" + pos.y); |
| | | } |
| | | |
| | | } |
| | |
| | | using vnxbqy.UI;
|
| | | using System;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | |
|
| | |
|
| | | public class ItemModel
|
| | | {
|
| | | public readonly PackType packType;
|
| | | public class ItemModel
|
| | | {
|
| | | public readonly PackType packType;
|
| | |
|
| | | public ItemConfig config { get; private set; }
|
| | | public ItemInfo itemInfo { get; private set; }
|
| | | public int score { get; private set; }
|
| | | public Dictionary<int, List<int>> useDataDict { get; private set; }
|
| | | public ItemConfig config { get; private set; }
|
| | | public ItemInfo itemInfo { get; private set; }
|
| | | public int score { get; private set; }
|
| | | public Dictionary<int, List<int>> useDataDict { get; private set; }
|
| | |
|
| | | public string guid { get { return itemInfo == null ? string.Empty : itemInfo.guid; } }
|
| | | public int itemId { get { return itemInfo == null ? 0 : itemInfo.itemId; } }
|
| | | public int count { get { return itemInfo == null ? 0 : itemInfo.count; } }
|
| | | public int gridIndex { get { return itemInfo == null ? 0 : itemInfo.index; } }
|
| | | public bool isAuction { get { return itemInfo == null ? false : itemInfo.isAuction == 1; } }
|
| | | public int preItemCount { get; private set; }
|
| | | public string guid { get { return itemInfo == null ? string.Empty : itemInfo.guid; } }
|
| | | public int itemId { get { return itemInfo == null ? 0 : itemInfo.itemId; } }
|
| | | public int count { get { return itemInfo == null ? 0 : itemInfo.count; } }
|
| | | public int gridIndex { get { return itemInfo == null ? 0 : itemInfo.index; } }
|
| | | public bool isAuction { get { return itemInfo == null ? false : itemInfo.isAuction == 1; } }
|
| | | public int preItemCount { get; private set; }
|
| | |
|
| | | public int auctionSurplusTime {
|
| | | public int auctionSurplusTime {
|
| | |
|
| | | get {
|
| | | get {
|
| | | return 0;
|
| | | /*
|
| | | var createTime = GetUseDataFirstValue(50);
|
| | | if (createTime > 0)
|
| | | {
|
| | | var overdueTime = TimeUtility.GetTime((uint)createTime) + new TimeSpan(GeneralDefine.acutionItemHour * TimeSpan.TicksPerHour);
|
| | | return (int)(overdueTime).Subtract(TimeUtility.ServerNow).TotalSeconds;
|
| | | }
|
| | | else
|
| | | {
|
| | | return 0;
|
| | | /*
|
| | | var createTime = GetUseDataFirstValue(50);
|
| | | if (createTime > 0)
|
| | | {
|
| | | var overdueTime = TimeUtility.GetTime((uint)createTime) + new TimeSpan(GeneralDefine.acutionItemHour * TimeSpan.TicksPerHour);
|
| | | return (int)(overdueTime).Subtract(TimeUtility.ServerNow).TotalSeconds;
|
| | | }
|
| | | else
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | */
|
| | | }
|
| | | */
|
| | | }
|
| | | }
|
| | |
|
| | | public int overdueSurplusTime {
|
| | | get {
|
| | | var surplusTime = 0;
|
| | | if (config.ExpireTime > 0)
|
| | | {
|
| | | var createTime = GetUseDataFirstValue((int)ItemUseDataKey.createTime);
|
| | | if (createTime > 0)
|
| | | {
|
| | | var seconds = GetUseDataFirstValue(48);
|
| | | var overdueTime = DateTime.Now;
|
| | | if (seconds != 0)
|
| | | {
|
| | | overdueTime = TimeUtility.GetTime((uint)createTime).AddSeconds(seconds);
|
| | | }
|
| | | else
|
| | | {
|
| | | overdueTime = TimeUtility.GetTime((uint)createTime).AddSeconds(config.ExpireTime);
|
| | | }
|
| | |
|
| | | surplusTime = (int)(overdueTime).Subtract(TimeUtility.ServerNow).TotalSeconds;
|
| | | }
|
| | | }
|
| | |
|
| | | return surplusTime;
|
| | | }
|
| | | }
|
| | |
|
| | | public ItemModel(PackType type, ItemInfo info)
|
| | | {
|
| | | packType = type;
|
| | | SetItemInfo(info);
|
| | | }
|
| | |
|
| | | public void SetItemInfo(ItemInfo info)
|
| | | {
|
| | | if (itemInfo != null)
|
| | | {
|
| | | preItemCount = itemInfo.count;
|
| | | }
|
| | |
|
| | | itemInfo = info;
|
| | | config = ItemConfig.Get(info.itemId);
|
| | | useDataDict = ConfigParse.Analysis(info.userData);
|
| | |
|
| | | var customCount = GetUseDataFirstValue((int)ItemUseDataKey.itemCount);
|
| | | if (customCount > 0)
|
| | | {
|
| | | itemInfo.count = customCount;
|
| | | }
|
| | |
|
| | | public int overdueSurplusTime {
|
| | | get {
|
| | | var surplusTime = 0;
|
| | | if (config.ExpireTime > 0)
|
| | | {
|
| | | var createTime = GetUseDataFirstValue((int)ItemUseDataKey.createTime);
|
| | | if (createTime > 0)
|
| | | {
|
| | | var serverSurplusTime = GetUseDataFirstValue(48);
|
| | | //ItemLogicUtility.Instance.SetItemEffectCDTime(info.guid, info.itemId, createTime, serverSurplusTime);
|
| | | var seconds = GetUseDataFirstValue(48);
|
| | | var overdueTime = DateTime.Now;
|
| | | if (seconds != 0)
|
| | | {
|
| | | overdueTime = TimeUtility.GetTime((uint)createTime).AddSeconds(seconds);
|
| | | }
|
| | | else
|
| | | {
|
| | | overdueTime = TimeUtility.GetTime((uint)createTime).AddSeconds(config.ExpireTime);
|
| | | }
|
| | |
|
| | | surplusTime = (int)(overdueTime).Subtract(TimeUtility.ServerNow).TotalSeconds;
|
| | | }
|
| | | }
|
| | |
|
| | | this.score = info.gearScore;//ItemLogicUtility.Instance.GetEquipScore(itemId, useDataDict);
|
| | | return surplusTime;
|
| | | }
|
| | |
|
| | | public void RefreshCount(int count)
|
| | | {
|
| | | if (itemInfo != null)
|
| | | {
|
| | | preItemCount = itemInfo.count;
|
| | | }
|
| | |
|
| | | itemInfo.count = count;
|
| | | }
|
| | |
|
| | | public List<int> GetUseData(int key)
|
| | | {
|
| | | List<int> list = null;
|
| | | if (useDataDict != null)
|
| | | {
|
| | | useDataDict.TryGetValue(key, out list);
|
| | | }
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | public int GetUseDataFirstValue(int key)
|
| | | {
|
| | | if (useDataDict != null && useDataDict.ContainsKey(key) && useDataDict[key].Count > 0)
|
| | | {
|
| | | return useDataDict[key][0];
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public class ItemInfo
|
| | | public ItemModel(PackType type, ItemInfo info)
|
| | | {
|
| | | public int index; //位置索引
|
| | | packType = type;
|
| | | SetItemInfo(info);
|
| | | }
|
| | |
|
| | | public int itemId;
|
| | |
|
| | | public int count; //物品数量
|
| | |
|
| | | public int isAuction;//是否拍品
|
| | |
|
| | | public int remainHour; //剩余时间(小时)
|
| | |
|
| | | public string userData;//size = UserDataLen
|
| | |
|
| | | public string guid; //物品的实例ID
|
| | | public int gearScore; //评分
|
| | |
|
| | | public ItemInfo()
|
| | | public void SetItemInfo(ItemInfo info)
|
| | | {
|
| | | if (itemInfo != null)
|
| | | {
|
| | |
|
| | | preItemCount = itemInfo.count;
|
| | | }
|
| | |
|
| | | public ItemInfo(H0725_tagRolePackRefreshEx.tagRoleItemRefresh serverItem)
|
| | | itemInfo = info;
|
| | | config = ItemConfig.Get(info.itemId);
|
| | | useDataDict = ConfigParse.Analysis(info.userData);
|
| | |
|
| | | var customCount = GetUseDataFirstValue((int)ItemUseDataKey.itemCount);
|
| | | if (customCount > 0)
|
| | | {
|
| | | itemId = (int)serverItem.ItemID;
|
| | | index = serverItem.ItemPlace;
|
| | | count = serverItem.ItemCount;
|
| | | remainHour = (int)serverItem.RemainHour;
|
| | | userData = serverItem.UserData;
|
| | | guid = serverItem.ItemGUID;
|
| | | isAuction = serverItem.IsBind;
|
| | | gearScore = (int)serverItem.GearScore;
|
| | | itemInfo.count = customCount;
|
| | | }
|
| | |
|
| | | public ItemInfo(H0704_tagRolePackRefresh serverItem)
|
| | | if (config.ExpireTime > 0)
|
| | | {
|
| | | itemId = (int)serverItem.ItemID;
|
| | | index = serverItem.ItemPlace;
|
| | | count = serverItem.ItemCount;
|
| | | remainHour = (int)serverItem.RemainHour;
|
| | | userData = serverItem.UserData;
|
| | | guid = serverItem.ItemGUID;
|
| | | isAuction = serverItem.IsBind;
|
| | | gearScore = (int)serverItem.GearScore;
|
| | | var createTime = GetUseDataFirstValue((int)ItemUseDataKey.createTime);
|
| | | if (createTime > 0)
|
| | | {
|
| | | var serverSurplusTime = GetUseDataFirstValue(48);
|
| | | //ItemLogicUtility.Instance.SetItemEffectCDTime(info.guid, info.itemId, createTime, serverSurplusTime);
|
| | | }
|
| | | }
|
| | |
|
| | | this.score = info.gearScore;//ItemLogicUtility.Instance.GetEquipScore(itemId, useDataDict);
|
| | | }
|
| | |
|
| | | public void RefreshCount(int count)
|
| | | {
|
| | | if (itemInfo != null)
|
| | | {
|
| | | preItemCount = itemInfo.count;
|
| | | }
|
| | |
|
| | | itemInfo.count = count;
|
| | | }
|
| | |
|
| | | public List<int> GetUseData(int key)
|
| | | {
|
| | | List<int> list = null;
|
| | | if (useDataDict != null)
|
| | | {
|
| | | useDataDict.TryGetValue(key, out list);
|
| | | }
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | public int GetUseDataFirstValue(int key)
|
| | | {
|
| | | if (useDataDict != null && useDataDict.ContainsKey(key) && useDataDict[key].Count > 0)
|
| | | {
|
| | | return useDataDict[key][0];
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public class ItemInfo
|
| | | {
|
| | | public int index; //位置索引
|
| | |
|
| | | public int itemId;
|
| | |
|
| | | public int count; //物品数量
|
| | |
|
| | | public int isAuction;//是否拍品
|
| | |
|
| | | public int remainHour; //剩余时间(小时)
|
| | |
|
| | | public string userData;//size = UserDataLen
|
| | |
|
| | | public string guid; //物品的实例ID
|
| | | public int gearScore; //评分
|
| | |
|
| | | public ItemInfo()
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | public ItemInfo(H0725_tagRolePackRefreshEx.tagRoleItemRefresh serverItem)
|
| | | {
|
| | | itemId = (int)serverItem.ItemID;
|
| | | index = serverItem.ItemPlace;
|
| | | count = serverItem.ItemCount;
|
| | | remainHour = (int)serverItem.RemainHour;
|
| | | userData = serverItem.UserData;
|
| | | guid = serverItem.ItemGUID;
|
| | | isAuction = serverItem.IsBind;
|
| | | gearScore = (int)serverItem.GearScore;
|
| | | }
|
| | |
|
| | | public ItemInfo(H0704_tagRolePackRefresh serverItem)
|
| | | {
|
| | | itemId = (int)serverItem.ItemID;
|
| | | index = serverItem.ItemPlace;
|
| | | count = serverItem.ItemCount;
|
| | | remainHour = (int)serverItem.RemainHour;
|
| | | userData = serverItem.UserData;
|
| | | guid = serverItem.ItemGUID;
|
| | | isAuction = serverItem.IsBind;
|
| | | gearScore = (int)serverItem.GearScore;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using vnxbqy.UI; |
| | | |
| | | public class SinglePack |
| | | public class SinglePack |
| | | { |
| | | public readonly PackType type; |
| | | public int unlockedGridCount { get; private set; } |
| | | private Dictionary<int, ItemModel> items = new Dictionary<int, ItemModel>(); //key 物品位置索引 |
| | | private Dictionary<int, List<int>> itemIDs = new Dictionary<int, List<int>>(); //key 物品ID:物品位置索引 |
| | | public SinglePack(PackType type) |
| | | { |
| | | public readonly PackType type; |
| | | public int unlockedGridCount { get; private set; } |
| | | private Dictionary<int, ItemModel> items = new Dictionary<int, ItemModel>(); //key 物品位置索引 |
| | | private Dictionary<int, List<int>> itemIDs = new Dictionary<int, List<int>>(); //key 物品ID:物品位置索引 |
| | | public SinglePack(PackType type) |
| | | { |
| | | this.type = type; |
| | | } |
| | | this.type = type; |
| | | } |
| | | |
| | | public bool HasItem(int itemID) |
| | | { |
| | | return itemIDs.ContainsKey(itemID); |
| | | } |
| | | public bool HasItem(int itemID) |
| | | { |
| | | return itemIDs.ContainsKey(itemID); |
| | | } |
| | | |
| | | public ItemModel UpdateItem(ItemInfo itemInfo) |
| | | public ItemModel UpdateItem(ItemInfo itemInfo) |
| | | { |
| | | //字典索引为物品位置索引 |
| | | var index = itemInfo.index; |
| | | if (!items.ContainsKey(index)) |
| | | { |
| | | //字典索引为物品位置索引 |
| | | var index = itemInfo.index; |
| | | if (!items.ContainsKey(index)) |
| | | items.Add(index, new ItemModel(type, itemInfo)); |
| | | } |
| | | else |
| | | { |
| | | //位置上的物品变化,先移除原来的 |
| | | var itemID = items[index].itemId; |
| | | if (itemIDs.ContainsKey(itemID)) |
| | | { |
| | | items.Add(index, new ItemModel(type, itemInfo)); |
| | | } |
| | | else |
| | | { |
| | | //位置上的物品变化,先移除原来的 |
| | | var itemID = items[index].itemId; |
| | | if (itemIDs.ContainsKey(itemID)) |
| | | if (itemIDs[itemID].Contains(index)) |
| | | { |
| | | if (itemIDs[itemID].Contains(index)) |
| | | if (itemIDs[itemID].Count == 1) |
| | | { |
| | | if (itemIDs[itemID].Count == 1) |
| | | { |
| | | itemIDs.Remove(itemID); |
| | | } |
| | | else |
| | | { |
| | | itemIDs[itemID].Remove(index); |
| | | } |
| | | } |
| | | } |
| | | |
| | | items[index].SetItemInfo(itemInfo); |
| | | } |
| | | |
| | | //字典索引为物品ID |
| | | if (!itemIDs.ContainsKey(itemInfo.itemId)) |
| | | { |
| | | itemIDs.Add(itemInfo.itemId, new List<int>()); |
| | | } |
| | | |
| | | if (!itemIDs[itemInfo.itemId].Contains(itemInfo.index)) |
| | | { |
| | | itemIDs[itemInfo.itemId].Add(itemInfo.index); |
| | | } |
| | | |
| | | return items[index]; |
| | | } |
| | | |
| | | public void RemoveItem(int index) |
| | | { |
| | | if (items.ContainsKey(index)) |
| | | { |
| | | //字典索引为物品ID |
| | | var itemID = items[index].itemId; |
| | | if (itemIDs.ContainsKey(itemID)) |
| | | { |
| | | if (itemIDs[itemID].Contains(index)) |
| | | { |
| | | if (itemIDs[itemID].Count == 1) |
| | | { |
| | | itemIDs.Remove(itemID); |
| | | } |
| | | else |
| | | { |
| | | itemIDs[itemID].Remove(index); |
| | | } |
| | | } |
| | | } |
| | | |
| | | items.Remove(index); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void SetOpenGridCount(int count) |
| | | { |
| | | unlockedGridCount = count; |
| | | } |
| | | |
| | | public ItemModel GetItemByIndex(int index) |
| | | { |
| | | ItemModel item = null; |
| | | items.TryGetValue(index, out item); |
| | | return item; |
| | | } |
| | | |
| | | public Dictionary<int, ItemModel> GetAllItems() |
| | | { |
| | | return items; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取指定ID的一个物品 |
| | | /// </summary> |
| | | /// <param name="itemId"></param> |
| | | /// <param name="includeAuction"></param> |
| | | /// <returns></returns> |
| | | public ItemModel GetItemByID(int itemId, bool includeAuction = true) |
| | | { |
| | | //foreach (var item in items.Values) |
| | | //{ |
| | | // if (!includeAuction && item.isAuction) |
| | | // { |
| | | // continue; |
| | | // } |
| | | |
| | | // if (item.itemId == itemId) |
| | | // { |
| | | // return item; |
| | | // } |
| | | //} |
| | | |
| | | //return null; |
| | | |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | | foreach (var index in itemIDs[itemId]) |
| | | { |
| | | var item = items[index]; |
| | | if (!includeAuction && item.isAuction) |
| | | { |
| | | continue; |
| | | } |
| | | return item; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取包内的指定ID的所有物品 |
| | | /// </summary> |
| | | /// <param name="itemId"></param> |
| | | /// <param name="includeAuction"></param> |
| | | /// <returns></returns> |
| | | public List<ItemModel> GetItemsById(int itemId, bool includeAuction = true) |
| | | { |
| | | var list = new List<ItemModel>(); |
| | | //foreach (var item in items.Values) |
| | | //{ |
| | | // if (!includeAuction && item.isAuction) |
| | | // { |
| | | // continue; |
| | | // } |
| | | |
| | | // if (item.itemId == itemId) |
| | | // { |
| | | // list.Add(item); |
| | | // } |
| | | //} |
| | | |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | | foreach (var index in itemIDs[itemId]) |
| | | { |
| | | var item = items[index]; |
| | | if (!includeAuction && item.isAuction) |
| | | { |
| | | continue; |
| | | } |
| | | list.Add(item); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public int GetCountById(int itemId, bool includeAuction = true) |
| | | { |
| | | var count = 0; |
| | | //foreach (var item in items.Values) |
| | | //{ |
| | | // if (!includeAuction && item.isAuction) |
| | | // { |
| | | // continue; |
| | | // } |
| | | |
| | | // if (item.itemId == itemId) |
| | | // { |
| | | // count += item.count; |
| | | // } |
| | | //} |
| | | |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | | foreach (var index in itemIDs[itemId]) |
| | | { |
| | | var item = items[index]; |
| | | if (!includeAuction && item.isAuction) |
| | | { |
| | | continue; |
| | | } |
| | | count += item.count; |
| | | } |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | public List<ItemModel> GetItems(FilterParams filterParams) |
| | | { |
| | | var list = new List<ItemModel>(); |
| | | foreach (var item in items.Values) |
| | | { |
| | | var levelValid = filterParams.levels == null || filterParams.levels.Contains(item.config.LV); |
| | | if (!levelValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var qualityValid = filterParams.qualitys == null || filterParams.qualitys.Contains(item.config.ItemColor); |
| | | if (!qualityValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var typeValid = filterParams.itemTypes == null || filterParams.itemTypes.Contains(item.config.Type); |
| | | if (!typeValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var equipTypeValid = filterParams.equipTypes == null || filterParams.equipTypes.Contains(item.config.EquipPlace); |
| | | if (!equipTypeValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var jobValid = filterParams.jobs == null || filterParams.jobs.Contains(item.config.JobLimit); |
| | | if (!jobValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | //var auctionValid = filterParams.isAuction == item.isAuction; |
| | | //if (!auctionValid) |
| | | //{ |
| | | // continue; |
| | | //} |
| | | |
| | | var realmValid = filterParams.realmLimit == 0 || filterParams.realmLimit == item.config.RealmLimit; |
| | | if (!realmValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | list.Add(item); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | public int GetCountByType(int type) |
| | | { |
| | | var count = 0; |
| | | foreach (var item in items.Values) |
| | | { |
| | | if (item.config.Type == type) |
| | | { |
| | | count += item.count; |
| | | } |
| | | } |
| | | |
| | | return count; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 得到同一个id指定数量的物品格子序号 |
| | | /// </summary> |
| | | /// <param name="itemId"></param> |
| | | /// <param name="needCount"></param> |
| | | /// <param name="type"></param> |
| | | /// <returns></returns> |
| | | public List<int> GetItemIndexsAppointedCount(int itemId, int needCount, bool includeAuction = true) |
| | | { |
| | | //var goalItems = new List<ItemModel>(); |
| | | //foreach (var item in this.items.Values) |
| | | //{ |
| | | // if (!includeAuction && item.isAuction) |
| | | // { |
| | | // continue; |
| | | // } |
| | | |
| | | // if (item.itemId == itemId) |
| | | // { |
| | | // goalItems.Add(item); |
| | | // } |
| | | //} |
| | | |
| | | var itemIndexs = new List<int>(); |
| | | var count = 0; |
| | | //for (var i = 0; i < goalItems.Count; i++) |
| | | //{ |
| | | // if (count < needCount) |
| | | // { |
| | | // itemIndexs.Add(goalItems[i].gridIndex); |
| | | // count += goalItems[i].count; |
| | | // } |
| | | // else |
| | | // { |
| | | // break; |
| | | // } |
| | | |
| | | //} |
| | | |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | | foreach (var index in itemIDs[itemId]) |
| | | { |
| | | var item = items[index]; |
| | | if (!includeAuction && item.isAuction) |
| | | { |
| | | continue; |
| | | } |
| | | if (count < needCount) |
| | | { |
| | | itemIndexs.Add(index); |
| | | count += item.count; |
| | | itemIDs.Remove(itemID); |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | itemIDs[itemID].Remove(index); |
| | | } |
| | | } |
| | | } |
| | | return itemIndexs; |
| | | |
| | | items[index].SetItemInfo(itemInfo); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 得到第一个空格位置索引 |
| | | /// </summary> |
| | | /// <param name="type"></param> |
| | | /// <returns></returns> |
| | | public int GetFirstEmptyGridIndex() |
| | | //字典索引为物品ID |
| | | if (!itemIDs.ContainsKey(itemInfo.itemId)) |
| | | { |
| | | for (var index = 0; index < unlockedGridCount; index++) |
| | | itemIDs.Add(itemInfo.itemId, new List<int>()); |
| | | } |
| | | |
| | | if (!itemIDs[itemInfo.itemId].Contains(itemInfo.index)) |
| | | { |
| | | itemIDs[itemInfo.itemId].Add(itemInfo.index); |
| | | } |
| | | |
| | | return items[index]; |
| | | } |
| | | |
| | | public void RemoveItem(int index) |
| | | { |
| | | if (items.ContainsKey(index)) |
| | | { |
| | | //字典索引为物品ID |
| | | var itemID = items[index].itemId; |
| | | if (itemIDs.ContainsKey(itemID)) |
| | | { |
| | | if (!items.ContainsKey(index)) |
| | | if (itemIDs[itemID].Contains(index)) |
| | | { |
| | | return index; |
| | | if (itemIDs[itemID].Count == 1) |
| | | { |
| | | itemIDs.Remove(itemID); |
| | | } |
| | | else |
| | | { |
| | | itemIDs[itemID].Remove(index); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return -1; |
| | | items.Remove(index); |
| | | } |
| | | |
| | | public int GetEmptyGridCount() |
| | | } |
| | | |
| | | public void SetOpenGridCount(int count) |
| | | { |
| | | unlockedGridCount = count; |
| | | } |
| | | |
| | | public ItemModel GetItemByIndex(int index) |
| | | { |
| | | ItemModel item = null; |
| | | items.TryGetValue(index, out item); |
| | | return item; |
| | | } |
| | | |
| | | public Dictionary<int, ItemModel> GetAllItems() |
| | | { |
| | | return items; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取指定ID的一个物品 |
| | | /// </summary> |
| | | /// <param name="itemId"></param> |
| | | /// <param name="includeAuction"></param> |
| | | /// <returns></returns> |
| | | public ItemModel GetItemByID(int itemId, bool includeAuction = true) |
| | | { |
| | | //foreach (var item in items.Values) |
| | | //{ |
| | | // if (!includeAuction && item.isAuction) |
| | | // { |
| | | // continue; |
| | | // } |
| | | |
| | | // if (item.itemId == itemId) |
| | | // { |
| | | // return item; |
| | | // } |
| | | //} |
| | | |
| | | //return null; |
| | | |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | | return unlockedGridCount - items.Count; |
| | | foreach (var index in itemIDs[itemId]) |
| | | { |
| | | var item = items[index]; |
| | | if (!includeAuction && item.isAuction) |
| | | { |
| | | continue; |
| | | } |
| | | return item; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public void Clear() |
| | | /// <summary> |
| | | /// 获取包内的指定ID的所有物品 |
| | | /// </summary> |
| | | /// <param name="itemId"></param> |
| | | /// <param name="includeAuction"></param> |
| | | /// <returns></returns> |
| | | public List<ItemModel> GetItemsById(int itemId, bool includeAuction = true) |
| | | { |
| | | var list = new List<ItemModel>(); |
| | | //foreach (var item in items.Values) |
| | | //{ |
| | | // if (!includeAuction && item.isAuction) |
| | | // { |
| | | // continue; |
| | | // } |
| | | |
| | | // if (item.itemId == itemId) |
| | | // { |
| | | // list.Add(item); |
| | | // } |
| | | //} |
| | | |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | | items.Clear(); |
| | | itemIDs.Clear(); |
| | | foreach (var index in itemIDs[itemId]) |
| | | { |
| | | var item = items[index]; |
| | | if (!includeAuction && item.isAuction) |
| | | { |
| | | continue; |
| | | } |
| | | list.Add(item); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public struct FilterParams |
| | | public int GetCountById(int itemId, bool includeAuction = true) |
| | | { |
| | | var count = 0; |
| | | //foreach (var item in items.Values) |
| | | //{ |
| | | // if (!includeAuction && item.isAuction) |
| | | // { |
| | | // continue; |
| | | // } |
| | | |
| | | // if (item.itemId == itemId) |
| | | // { |
| | | // count += item.count; |
| | | // } |
| | | //} |
| | | |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | | public List<int> levels; |
| | | public List<int> qualitys; |
| | | public List<int> itemTypes; |
| | | public List<int> equipTypes; |
| | | public int realmLimit; |
| | | public bool isAuction; |
| | | public List<int> jobs; |
| | | foreach (var index in itemIDs[itemId]) |
| | | { |
| | | var item = items[index]; |
| | | if (!includeAuction && item.isAuction) |
| | | { |
| | | continue; |
| | | } |
| | | count += item.count; |
| | | } |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | public List<ItemModel> GetItems(FilterParams filterParams) |
| | | { |
| | | var list = new List<ItemModel>(); |
| | | foreach (var item in items.Values) |
| | | { |
| | | var levelValid = filterParams.levels == null || filterParams.levels.Contains(item.config.LV); |
| | | if (!levelValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var qualityValid = filterParams.qualitys == null || filterParams.qualitys.Contains(item.config.ItemColor); |
| | | if (!qualityValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var typeValid = filterParams.itemTypes == null || filterParams.itemTypes.Contains(item.config.Type); |
| | | if (!typeValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var equipTypeValid = filterParams.equipTypes == null || filterParams.equipTypes.Contains(item.config.EquipPlace); |
| | | if (!equipTypeValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var jobValid = filterParams.jobs == null || filterParams.jobs.Contains(item.config.JobLimit); |
| | | if (!jobValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | //var auctionValid = filterParams.isAuction == item.isAuction; |
| | | //if (!auctionValid) |
| | | //{ |
| | | // continue; |
| | | //} |
| | | |
| | | var realmValid = filterParams.realmLimit == 0 || filterParams.realmLimit == item.config.RealmLimit; |
| | | if (!realmValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | list.Add(item); |
| | | } |
| | | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public int GetCountByType(int type) |
| | | { |
| | | var count = 0; |
| | | foreach (var item in items.Values) |
| | | { |
| | | if (item.config.Type == type) |
| | | { |
| | | count += item.count; |
| | | } |
| | | } |
| | | |
| | | return count; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 得到同一个id指定数量的物品格子序号 |
| | | /// </summary> |
| | | /// <param name="itemId"></param> |
| | | /// <param name="needCount"></param> |
| | | /// <param name="type"></param> |
| | | /// <returns></returns> |
| | | public List<int> GetItemIndexsAppointedCount(int itemId, int needCount, bool includeAuction = true) |
| | | { |
| | | //var goalItems = new List<ItemModel>(); |
| | | //foreach (var item in this.items.Values) |
| | | //{ |
| | | // if (!includeAuction && item.isAuction) |
| | | // { |
| | | // continue; |
| | | // } |
| | | |
| | | // if (item.itemId == itemId) |
| | | // { |
| | | // goalItems.Add(item); |
| | | // } |
| | | //} |
| | | |
| | | var itemIndexs = new List<int>(); |
| | | var count = 0; |
| | | //for (var i = 0; i < goalItems.Count; i++) |
| | | //{ |
| | | // if (count < needCount) |
| | | // { |
| | | // itemIndexs.Add(goalItems[i].gridIndex); |
| | | // count += goalItems[i].count; |
| | | // } |
| | | // else |
| | | // { |
| | | // break; |
| | | // } |
| | | |
| | | //} |
| | | |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | | foreach (var index in itemIDs[itemId]) |
| | | { |
| | | var item = items[index]; |
| | | if (!includeAuction && item.isAuction) |
| | | { |
| | | continue; |
| | | } |
| | | if (count < needCount) |
| | | { |
| | | itemIndexs.Add(index); |
| | | count += item.count; |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return itemIndexs; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 得到第一个空格位置索引 |
| | | /// </summary> |
| | | /// <param name="type"></param> |
| | | /// <returns></returns> |
| | | public int GetFirstEmptyGridIndex() |
| | | { |
| | | for (var index = 0; index < unlockedGridCount; index++) |
| | | { |
| | | if (!items.ContainsKey(index)) |
| | | { |
| | | return index; |
| | | } |
| | | } |
| | | |
| | | return -1; |
| | | } |
| | | |
| | | public int GetEmptyGridCount() |
| | | { |
| | | return unlockedGridCount - items.Count; |
| | | } |
| | | |
| | | public void Clear() |
| | | { |
| | | items.Clear(); |
| | | itemIDs.Clear(); |
| | | } |
| | | |
| | | public struct FilterParams |
| | | { |
| | | public List<int> levels; |
| | | public List<int> qualitys; |
| | | public List<int> itemTypes; |
| | | public List<int> equipTypes; |
| | | public int realmLimit; |
| | | public bool isAuction; |
| | | public List<int> jobs; |
| | | } |
| | | |
| | | } |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using vnxbqy.UI; |
| | | using System.Collections.Generic; |
| | | using System; |
| | | |
| | | public class ItemCell : CommonItemBaisc |
| | | { |
| | | private Button m_Reducebtn; |
| | | public Button reducebtn { |
| | | get { |
| | | if (m_Reducebtn == null) |
| | | { |
| | | LoadPrefab(); |
| | | m_Reducebtn = this.transform.GetComponent<Button>("Container_ItemCell/Btn_Reduce"); |
| | | } |
| | | return m_Reducebtn; |
| | | } |
| | | } |
| | | |
| | | Image m_AuctionIcon; |
| | | public Image auctionIcon |
| | | { |
| | | get |
| | | public class ItemCell : CommonItemBaisc |
| | | { |
| | | private Button m_Reducebtn; |
| | | public Button reducebtn { |
| | | get { |
| | | if (m_Reducebtn == null) |
| | | { |
| | | if (m_AuctionIcon == null) |
| | | { |
| | | LoadPrefab(); |
| | | m_AuctionIcon = this.transform.GetComponent<Image>("Container_ItemCell/Img_Auction"); |
| | | } |
| | | return m_AuctionIcon; |
| | | LoadPrefab(); |
| | | m_Reducebtn = this.transform.GetComponent<Button>("Container_ItemCell/Btn_Reduce"); |
| | | } |
| | | } |
| | | |
| | | Image m_TimeMark; |
| | | public Image timeMark |
| | | { |
| | | get |
| | | { |
| | | if (m_TimeMark == null) |
| | | { |
| | | LoadPrefab(); |
| | | m_TimeMark = this.transform.GetComponent<Image>("Container_ItemCell/Img_Time"); |
| | | } |
| | | return m_TimeMark; |
| | | } |
| | | } |
| | | |
| | | public override void Init(ItemModel model, bool isCompare = false) |
| | | { |
| | | base.Init(model, isCompare); |
| | | reducebtn.SetActive(false); |
| | | auctionIcon.SetActive(false); |
| | | // auctionIcon.SetActive(model.isAuction); |
| | | // if (model.isAuction) |
| | | // { |
| | | // auctionIcon.SetSprite(ItemLogicUtility.Instance.IsOverdue(model.guid) ? "Item_Auction_3" : "Item_Auction_1"); |
| | | // } |
| | | |
| | | timeMark?.SetActive(model.config.Type == 145 && model.config.CDTime > 0); |
| | | } |
| | | |
| | | public override void Init(ItemCellModel model) |
| | | { |
| | | base.Init(model); |
| | | reducebtn.SetActive(false); |
| | | auctionIcon.SetActive(false); |
| | | |
| | | timeMark?.SetActive(model.itemConfig.Type == 145 && model.itemConfig.CDTime > 0); |
| | | return m_Reducebtn; |
| | | } |
| | | } |
| | | |
| | | Image m_AuctionIcon; |
| | | public Image auctionIcon |
| | | { |
| | | get |
| | | { |
| | | if (m_AuctionIcon == null) |
| | | { |
| | | LoadPrefab(); |
| | | m_AuctionIcon = this.transform.GetComponent<Image>("Container_ItemCell/Img_Auction"); |
| | | } |
| | | return m_AuctionIcon; |
| | | } |
| | | } |
| | | |
| | | Image m_TimeMark; |
| | | public Image timeMark |
| | | { |
| | | get |
| | | { |
| | | if (m_TimeMark == null) |
| | | { |
| | | LoadPrefab(); |
| | | m_TimeMark = this.transform.GetComponent<Image>("Container_ItemCell/Img_Time"); |
| | | } |
| | | return m_TimeMark; |
| | | } |
| | | } |
| | | |
| | | public override void Init(ItemModel model, bool isCompare = false) |
| | | { |
| | | base.Init(model, isCompare); |
| | | reducebtn.SetActive(false); |
| | | auctionIcon.SetActive(false); |
| | | // auctionIcon.SetActive(model.isAuction); |
| | | // if (model.isAuction) |
| | | // { |
| | | // auctionIcon.SetSprite(ItemLogicUtility.Instance.IsOverdue(model.guid) ? "Item_Auction_3" : "Item_Auction_1"); |
| | | // } |
| | | |
| | | timeMark?.SetActive(model.config.Type == 145 && model.config.CDTime > 0); |
| | | } |
| | | |
| | | public override void Init(ItemCellModel model) |
| | | { |
| | | base.Init(model); |
| | | reducebtn.SetActive(false); |
| | | auctionIcon.SetActive(false); |
| | | |
| | | timeMark?.SetActive(model.itemConfig.Type == 145 && model.itemConfig.CDTime > 0); |
| | | } |
| | | } |
| | | |
| | |
| | | using System.Text; |
| | | |
| | | using UnityEngine; |
| | | namespace vnxbqy.UI |
| | | |
| | | public class VirtualPackManager : GameSystemManager<VirtualPackManager> |
| | | { |
| | | Dictionary<PackType, List<VirtualPackItem>> virtualPackItems |
| | | = new Dictionary<PackType, List<VirtualPackItem>>(); |
| | | Dictionary<PackType, ObjectPool<VirtualPackItem>> m_VirtualItemPool |
| | | = new Dictionary<PackType, ObjectPool<VirtualPackItem>>(); |
| | | Dictionary<PackType, int> virtualPackCapacityDict = new Dictionary<PackType, int>(); |
| | | |
| | | public class VirtualPackManager : GameSystemManager<VirtualPackManager> |
| | | public event Action<PackType> virtualPackRefresh; |
| | | int getA206Count = 0; //收到了几次A206包 |
| | | bool isFrist = false; //是不是第一次获得聚魂碎片 |
| | | Dictionary<int, int> noPackItemCountDict = new Dictionary<int, int>(); //无需背包的物品数量刷新,自动转化为数值 |
| | | public event Action OnNoPackItemCountRefresh; |
| | | |
| | | public void OnBeforePlayerDataInitialize() |
| | | { |
| | | Dictionary<PackType, List<VirtualPackItem>> virtualPackItems |
| | | = new Dictionary<PackType, List<VirtualPackItem>>(); |
| | | Dictionary<PackType, ObjectPool<VirtualPackItem>> m_VirtualItemPool |
| | | = new Dictionary<PackType, ObjectPool<VirtualPackItem>>(); |
| | | Dictionary<PackType, int> virtualPackCapacityDict = new Dictionary<PackType, int>(); |
| | | |
| | | public event Action<PackType> virtualPackRefresh; |
| | | int getA206Count = 0; //收到了几次A206包 |
| | | bool isFrist = false; //是不是第一次获得聚魂碎片 |
| | | Dictionary<int, int> noPackItemCountDict = new Dictionary<int, int>(); //无需背包的物品数量刷新,自动转化为数值 |
| | | public event Action OnNoPackItemCountRefresh; |
| | | |
| | | public void OnBeforePlayerDataInitialize() |
| | | foreach (var packType in virtualPackItems.Keys) |
| | | { |
| | | foreach (var packType in virtualPackItems.Keys) |
| | | var pool = m_VirtualItemPool[packType]; |
| | | var items = virtualPackItems[packType]; |
| | | foreach (var item in items) |
| | | { |
| | | var pool = m_VirtualItemPool[packType]; |
| | | var items = virtualPackItems[packType]; |
| | | pool.Release(item); |
| | | } |
| | | } |
| | | virtualPackItems.Clear(); |
| | | noPackItemCountDict.Clear(); |
| | | getA206Count = 0; |
| | | isFrist = false; |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | | { |
| | | isFrist = noPackItemCountDict.Count == 0; |
| | | } |
| | | |
| | | public override void Init() |
| | | { |
| | | base.Init(); |
| | | ParseConfig(); |
| | | m_VirtualItemPool.Add(PackType.GatherSoul, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem)); |
| | | m_VirtualItemPool.Add(PackType.RunePack, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem)); |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | } |
| | | |
| | | public override void Release() |
| | | { |
| | | base.Release(); |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk; |
| | | } |
| | | |
| | | void ParseConfig() |
| | | { |
| | | var funcConfig = FuncConfigConfig.Get("RunePackageNum"); |
| | | virtualPackCapacityDict.Add(PackType.RunePack, int.Parse(funcConfig.Numerical1)); |
| | | } |
| | | |
| | | public bool IsVirtualPack(PackType packType) |
| | | { |
| | | switch (packType) |
| | | { |
| | | case PackType.GatherSoul: |
| | | case PackType.RunePack: |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public int GetPackCapacity(PackType packType) |
| | | { |
| | | if (virtualPackCapacityDict.ContainsKey(packType)) |
| | | { |
| | | return virtualPackCapacityDict[packType]; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public int GetPackRemainCount(PackType packType) |
| | | { |
| | | var capacity = GetPackCapacity(packType); |
| | | return capacity - GetPackItemCount(packType); |
| | | } |
| | | |
| | | public int GetPackItemCount(PackType packType) |
| | | { |
| | | if (virtualPackItems.ContainsKey(packType)) |
| | | { |
| | | return virtualPackItems[packType].Count; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public int GetItemCountById(PackType packType, int id) |
| | | { |
| | | var count = 0; |
| | | List<int> list; |
| | | if (TryGetItems(packType, out list)) |
| | | { |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | VirtualPackItem item; |
| | | if (TryGetItem(packType, list[i], out item) |
| | | && item.id == id) |
| | | { |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | public void GetItemIndexs(PackType packType, ref List<int> list) |
| | | { |
| | | list.Clear(); |
| | | List<VirtualPackItem> _list; |
| | | if (virtualPackItems.TryGetValue(packType, out _list)) |
| | | { |
| | | for (int i = 0; i < _list.Count; i++) |
| | | { |
| | | list.Add(_list[i].index); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public bool TryGetItems(PackType packType, out List<int> list) |
| | | { |
| | | list = new List<int>(); |
| | | List<VirtualPackItem> _list; |
| | | if (virtualPackItems.TryGetValue(packType, out _list)) |
| | | { |
| | | for (int i = 0; i < _list.Count; i++) |
| | | { |
| | | list.Add(_list[i].index); |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public bool TryGetItem<T>(PackType packType, int packIndex, out T item) where T : VirtualPackItem |
| | | { |
| | | item = default(T); |
| | | if (virtualPackItems.ContainsKey(packType)) |
| | | { |
| | | var _index = virtualPackItems[packType].FindIndex((x) => |
| | | { |
| | | return x.index == packIndex; |
| | | }); |
| | | if (_index != -1) |
| | | { |
| | | item = virtualPackItems[packType][_index] as T; |
| | | } |
| | | return _index != -1; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public void OnReceiveServerPack(HA204_tagMCVPackRefresh package) |
| | | { |
| | | var packType = (PackType)package.PackType; |
| | | if (!IsVirtualPack(packType)) |
| | | { |
| | | return; |
| | | } |
| | | List<VirtualPackItem> list; |
| | | if (!virtualPackItems.TryGetValue(packType, out list)) |
| | | { |
| | | list = new List<VirtualPackItem>(); |
| | | virtualPackItems.Add(packType, list); |
| | | } |
| | | SetVirtualItem(packType, ref list, package.VPacklItemList); |
| | | if (virtualPackRefresh != null) |
| | | { |
| | | virtualPackRefresh((PackType)package.PackType); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void OnReceiveServerPack(HA205_tagMCVPackClear package) |
| | | { |
| | | var packType = (PackType)package.PackType; |
| | | if (!IsVirtualPack(packType)) |
| | | { |
| | | return; |
| | | } |
| | | List<VirtualPackItem> list; |
| | | if (virtualPackItems.TryGetValue(packType, out list)) |
| | | { |
| | | var pool = m_VirtualItemPool[packType]; |
| | | for (int i = 0; i < package.Count; i++) |
| | | { |
| | | var index = package.ItemPlaceList[i]; |
| | | var items = list.FindAll((x) => |
| | | { |
| | | return x.index == index; |
| | | }); |
| | | foreach (var item in items) |
| | | { |
| | | list.Remove(item); |
| | | pool.Release(item); |
| | | } |
| | | } |
| | | virtualPackItems.Clear(); |
| | | noPackItemCountDict.Clear(); |
| | | getA206Count = 0; |
| | | isFrist = false; |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | | { |
| | | isFrist = noPackItemCountDict.Count == 0; |
| | | } |
| | | |
| | | public override void Init() |
| | | { |
| | | base.Init(); |
| | | ParseConfig(); |
| | | m_VirtualItemPool.Add(PackType.GatherSoul, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem)); |
| | | m_VirtualItemPool.Add(PackType.RunePack, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem)); |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | } |
| | | |
| | | public override void Release() |
| | | { |
| | | base.Release(); |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk; |
| | | } |
| | | |
| | | void ParseConfig() |
| | | { |
| | | var funcConfig = FuncConfigConfig.Get("RunePackageNum"); |
| | | virtualPackCapacityDict.Add(PackType.RunePack, int.Parse(funcConfig.Numerical1)); |
| | | } |
| | | |
| | | public bool IsVirtualPack(PackType packType) |
| | | { |
| | | switch (packType) |
| | | { |
| | | case PackType.GatherSoul: |
| | | case PackType.RunePack: |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public int GetPackCapacity(PackType packType) |
| | | { |
| | | if (virtualPackCapacityDict.ContainsKey(packType)) |
| | | { |
| | | return virtualPackCapacityDict[packType]; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public int GetPackRemainCount(PackType packType) |
| | | { |
| | | var capacity = GetPackCapacity(packType); |
| | | return capacity - GetPackItemCount(packType); |
| | | } |
| | | |
| | | public int GetPackItemCount(PackType packType) |
| | | { |
| | | if (virtualPackItems.ContainsKey(packType)) |
| | | { |
| | | return virtualPackItems[packType].Count; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public int GetItemCountById(PackType packType, int id) |
| | | { |
| | | var count = 0; |
| | | List<int> list; |
| | | if (TryGetItems(packType, out list)) |
| | | { |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | VirtualPackItem item; |
| | | if (TryGetItem(packType, list[i], out item) |
| | | && item.id == id) |
| | | { |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | public void GetItemIndexs(PackType packType, ref List<int> list) |
| | | { |
| | | list.Clear(); |
| | | List<VirtualPackItem> _list; |
| | | if (virtualPackItems.TryGetValue(packType, out _list)) |
| | | { |
| | | for (int i = 0; i < _list.Count; i++) |
| | | { |
| | | list.Add(_list[i].index); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public bool TryGetItems(PackType packType, out List<int> list) |
| | | { |
| | | list = new List<int>(); |
| | | List<VirtualPackItem> _list; |
| | | if (virtualPackItems.TryGetValue(packType, out _list)) |
| | | { |
| | | for (int i = 0; i < _list.Count; i++) |
| | | { |
| | | list.Add(_list[i].index); |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public bool TryGetItem<T>(PackType packType, int packIndex, out T item) where T : VirtualPackItem |
| | | { |
| | | item = default(T); |
| | | if (virtualPackItems.ContainsKey(packType)) |
| | | { |
| | | var _index = virtualPackItems[packType].FindIndex((x) => |
| | | { |
| | | return x.index == packIndex; |
| | | }); |
| | | if (_index != -1) |
| | | { |
| | | item = virtualPackItems[packType][_index] as T; |
| | | } |
| | | return _index != -1; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public void OnReceiveServerPack(HA204_tagMCVPackRefresh package) |
| | | { |
| | | var packType = (PackType)package.PackType; |
| | | if (!IsVirtualPack(packType)) |
| | | { |
| | | return; |
| | | } |
| | | List<VirtualPackItem> list; |
| | | if (!virtualPackItems.TryGetValue(packType, out list)) |
| | | { |
| | | list = new List<VirtualPackItem>(); |
| | | virtualPackItems.Add(packType, list); |
| | | } |
| | | SetVirtualItem(packType, ref list, package.VPacklItemList); |
| | | if (virtualPackRefresh != null) |
| | | { |
| | | virtualPackRefresh((PackType)package.PackType); |
| | | virtualPackRefresh(packType); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | public void OnReceiveServerPack(HA205_tagMCVPackClear package) |
| | | |
| | | public void UpdateAutoItemCountRefresh(HA206_tagMCAutoItemCountRefresh netPack) |
| | | { |
| | | |
| | | ShowRewardWin(netPack);//vNetData中ItemCount传的是碎片总数,需要在noPackItemCountDict写入数据之前计算差值 |
| | | for (int i = 0; i < netPack.Count; i++) |
| | | { |
| | | var packType = (PackType)package.PackType; |
| | | if (!IsVirtualPack(packType)) |
| | | { |
| | | noPackItemCountDict[(int)netPack.ItemCountList[i].ItemID] = (int)netPack.ItemCountList[i].ItemCount; |
| | | } |
| | | OnNoPackItemCountRefresh?.Invoke(); |
| | | } |
| | | |
| | | void ShowRewardWin(HA206_tagMCAutoItemCountRefresh vNetData) |
| | | { |
| | | getA206Count += 1; |
| | | if (ItemLogicUtility.Instance.hidePickItem) |
| | | return; |
| | | // if (ModelCenter.Instance.GetModel<GatheringSoulModel>().isOpenXBWin) |
| | | // return; |
| | | if (getA206Count <= 1 && !isFrist) |
| | | return; |
| | | |
| | | for (int i = 0; i < vNetData.ItemCountList.Length; i++) |
| | | { |
| | | int itemID = (int)vNetData.ItemCountList[i].ItemID; |
| | | int itemCount = (int)vNetData.ItemCountList[i].ItemCount; |
| | | if (noPackItemCountDict.ContainsKey(itemID) && noPackItemCountDict[itemID] > itemCount) |
| | | return; |
| | | } |
| | | List<VirtualPackItem> list; |
| | | if (virtualPackItems.TryGetValue(packType, out list)) |
| | | { |
| | | var pool = m_VirtualItemPool[packType]; |
| | | for (int i = 0; i < package.Count; i++) |
| | | { |
| | | var index = package.ItemPlaceList[i]; |
| | | var items = list.FindAll((x) => |
| | | { |
| | | return x.index == index; |
| | | }); |
| | | foreach (var item in items) |
| | | { |
| | | list.Remove(item); |
| | | pool.Release(item); |
| | | } |
| | | } |
| | | if (virtualPackRefresh != null) |
| | | { |
| | | virtualPackRefresh(packType); |
| | | } |
| | | } |
| | | ItemLogicUtility.Instance.RefreshPickItem(PackType.Item, itemID.ToString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void UpdateAutoItemCountRefresh(HA206_tagMCAutoItemCountRefresh netPack) |
| | | public int GetNoPackItemCount(int id) |
| | | { |
| | | if (noPackItemCountDict.ContainsKey(id)) |
| | | { |
| | | return noPackItemCountDict[id]; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | ShowRewardWin(netPack);//vNetData中ItemCount传的是碎片总数,需要在noPackItemCountDict写入数据之前计算差值 |
| | | for (int i = 0; i < netPack.Count; i++) |
| | | public Dictionary<int, int> GetAllNoPackItem() |
| | | { |
| | | return noPackItemCountDict; |
| | | } |
| | | |
| | | |
| | | |
| | | void SetVirtualItem(PackType packType, ref List<VirtualPackItem> list, HA204_tagMCVPackRefresh.tagMCVPackItem[] items) |
| | | { |
| | | var pool = m_VirtualItemPool[packType]; |
| | | for (int i = 0; i < items.Length; i++) |
| | | { |
| | | var item = list.Find((x) => |
| | | { |
| | | noPackItemCountDict[(int)netPack.ItemCountList[i].ItemID] = (int)netPack.ItemCountList[i].ItemCount; |
| | | return x.index == items[i].ItemPlace; |
| | | }); |
| | | if (item != null) |
| | | { |
| | | item.Release(); |
| | | } |
| | | OnNoPackItemCountRefresh?.Invoke(); |
| | | } |
| | | |
| | | void ShowRewardWin(HA206_tagMCAutoItemCountRefresh vNetData) |
| | | { |
| | | getA206Count += 1; |
| | | if (ItemLogicUtility.Instance.hidePickItem) |
| | | return; |
| | | // if (ModelCenter.Instance.GetModel<GatheringSoulModel>().isOpenXBWin) |
| | | // return; |
| | | if (getA206Count <= 1 && !isFrist) |
| | | return; |
| | | |
| | | for (int i = 0; i < vNetData.ItemCountList.Length; i++) |
| | | else |
| | | { |
| | | int itemID = (int)vNetData.ItemCountList[i].ItemID; |
| | | int itemCount = (int)vNetData.ItemCountList[i].ItemCount; |
| | | if (noPackItemCountDict.ContainsKey(itemID) && noPackItemCountDict[itemID] > itemCount) |
| | | return; |
| | | ItemLogicUtility.Instance.RefreshPickItem(PackType.Item, itemID.ToString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | public int GetNoPackItemCount(int id) |
| | | { |
| | | if (noPackItemCountDict.ContainsKey(id)) |
| | | { |
| | | return noPackItemCountDict[id]; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public Dictionary<int, int> GetAllNoPackItem() |
| | | { |
| | | return noPackItemCountDict; |
| | | } |
| | | |
| | | |
| | | |
| | | void SetVirtualItem(PackType packType, ref List<VirtualPackItem> list, HA204_tagMCVPackRefresh.tagMCVPackItem[] items) |
| | | { |
| | | var pool = m_VirtualItemPool[packType]; |
| | | for (int i = 0; i < items.Length; i++) |
| | | { |
| | | var item = list.Find((x) => |
| | | if (pool.inactivedCount > 0) |
| | | { |
| | | return x.index == items[i].ItemPlace; |
| | | }); |
| | | if (item != null) |
| | | { |
| | | item.Release(); |
| | | } |
| | | else |
| | | { |
| | | if (pool.inactivedCount > 0) |
| | | { |
| | | item = pool.Get(); |
| | | list.Add(item); |
| | | } |
| | | } |
| | | if (item == null) |
| | | { |
| | | item = VirtualPackItem.Get(packType); |
| | | item = pool.Get(); |
| | | list.Add(item); |
| | | } |
| | | item.ParsePackItem(items[i].ItemPlace, items[i].ItemData); |
| | | |
| | | ItemLogicUtility.Instance.RefreshPickItem(packType, item.id.ToString()); |
| | | } |
| | | } |
| | | if (item == null) |
| | | { |
| | | item = VirtualPackItem.Get(packType); |
| | | list.Add(item); |
| | | } |
| | | item.ParsePackItem(items[i].ItemPlace, items[i].ItemData); |
| | | |
| | | static void OnGetItem(VirtualPackItem item) |
| | | { |
| | | |
| | | } |
| | | |
| | | static void OnReleaseItem(VirtualPackItem item) |
| | | { |
| | | item.Release(); |
| | | ItemLogicUtility.Instance.RefreshPickItem(packType, item.id.ToString()); |
| | | } |
| | | } |
| | | |
| | | public abstract class VirtualPackItem |
| | | static void OnGetItem(VirtualPackItem item) |
| | | { |
| | | public int index { get; private set; } |
| | | |
| | | public int id { get; private set; } |
| | | |
| | | public int level { get; private set; } |
| | | |
| | | protected string dataString { get; set; } |
| | | |
| | | protected static StringBuilder sb = new StringBuilder(); |
| | | |
| | | public virtual void ParsePackItem(int index, uint data) |
| | | { |
| | | this.index = index; |
| | | |
| | | dataString = data.ToString(); |
| | | int delta = 10 - dataString.Length; |
| | | sb.Length = 0; |
| | | sb.Append('0', delta); |
| | | dataString = dataString.Insert(0, sb.ToString()); |
| | | |
| | | id = int.Parse(dataString.Substring(5, 5)); |
| | | level = int.Parse(dataString.Substring(2, 3)) + 1; |
| | | } |
| | | |
| | | public virtual void Release() |
| | | { |
| | | dataString = null; |
| | | } |
| | | |
| | | public static VirtualPackItem Get(PackType packType) |
| | | { |
| | | // switch (packType) |
| | | // { |
| | | // case PackType.RunePack: |
| | | // return new RuneItem(); |
| | | // } |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public struct VirtualItem |
| | | static void OnReleaseItem(VirtualPackItem item) |
| | | { |
| | | public PackType packType; |
| | | public int itemId; |
| | | public int index; |
| | | public int level; |
| | | item.Release(); |
| | | } |
| | | } |
| | | |
| | | public abstract class VirtualPackItem |
| | | { |
| | | public int index { get; private set; } |
| | | |
| | | public int id { get; private set; } |
| | | |
| | | public int level { get; private set; } |
| | | |
| | | protected string dataString { get; set; } |
| | | |
| | | protected static StringBuilder sb = new StringBuilder(); |
| | | |
| | | public virtual void ParsePackItem(int index, uint data) |
| | | { |
| | | this.index = index; |
| | | |
| | | dataString = data.ToString(); |
| | | int delta = 10 - dataString.Length; |
| | | sb.Length = 0; |
| | | sb.Append('0', delta); |
| | | dataString = dataString.Insert(0, sb.ToString()); |
| | | |
| | | id = int.Parse(dataString.Substring(5, 5)); |
| | | level = int.Parse(dataString.Substring(2, 3)) + 1; |
| | | } |
| | | |
| | | public virtual void Release() |
| | | { |
| | | dataString = null; |
| | | } |
| | | |
| | | public static VirtualPackItem Get(PackType packType) |
| | | { |
| | | // switch (packType) |
| | | // { |
| | | // case PackType.RunePack: |
| | | // return new RuneItem(); |
| | | // } |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public struct VirtualItem |
| | | { |
| | | public PackType packType; |
| | | public int itemId; |
| | | public int index; |
| | | public int level; |
| | | } |
| | | |
| | |
| | | using UnityEngine; |
| | | |
| | | namespace vnxbqy.UI |
| | | public class MailGlobalCell : CellView |
| | | { |
| | | public class MailGlobalCell : CellView |
| | | [SerializeField] ButtonEx btnMail; |
| | | [SerializeField] ImageEx imgState; |
| | | [SerializeField] ImageEx imgRed; |
| | | [SerializeField] TextEx txtTitle; |
| | | [SerializeField] TextEx txtDate; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | string uuid = string.Empty; |
| | | public void Display(int index, CellView cellView) |
| | | { |
| | | [SerializeField] ButtonEx btnMail; |
| | | [SerializeField] ImageEx imgState; |
| | | [SerializeField] ImageEx imgRed; |
| | | [SerializeField] TextEx txtTitle; |
| | | [SerializeField] TextEx txtDate; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | string uuid = string.Empty; |
| | | public void Display(int index, CellView cellView) |
| | | MailCategory mailCategory = (MailCategory)cellView.info.Value.infoInt1; |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | if (list == null || index < 0 || index >= list.Count) |
| | | return; |
| | | uuid = list[index]; |
| | | if (!model.TryGetMailData(uuid, out var mailData) || mailData == null) |
| | | return; |
| | | imgRed.SetActive(mailData.MailState == 1); |
| | | txtTitle.text = mailData.Title; |
| | | imgState.SetSprite(mailData.MailState == 2 || mailData.MailState == 3 ? "MailRead" : "MailNoRead"); |
| | | if (mailData.Items != null) |
| | | { |
| | | MailCategory mailCategory = (MailCategory)cellView.info.Value.infoInt1; |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | if (list == null || index < 0 || index >= list.Count) |
| | | return; |
| | | uuid = list[index]; |
| | | if (!model.TryGetMailData(uuid, out var mailData) || mailData == null) |
| | | return; |
| | | imgRed.SetActive(mailData.MailState == 1); |
| | | txtTitle.text = mailData.Title; |
| | | imgState.SetSprite(mailData.MailState == 2 || mailData.MailState == 3 ? "MailRead" : "MailNoRead"); |
| | | if (mailData.Items != null) |
| | | { |
| | | txtDate.text = model.FormatCreateMailTime(mailData.CreateDateTime); |
| | | } |
| | | else |
| | | { |
| | | int expiryDay = model.GetMailExpiryDays(mailData.CreateDateTime, mailData.LimitDays); |
| | | txtDate.text = expiryDay > 0 ? Language.Get("Mail07", expiryDay) : model.FormatCreateMailTime(mailData.CreateDateTime); |
| | | } |
| | | btnMail.SetListener(OnClickButtonMail); |
| | | txtDate.text = model.FormatCreateMailTime(mailData.CreateDateTime); |
| | | } |
| | | |
| | | private void OnClickButtonMail() |
| | | else |
| | | { |
| | | model.nowUuid = uuid; |
| | | if (!model.TryGetMailData(uuid, out var mailData) || mailData == null) |
| | | return; |
| | | if (mailData.MailState == 1) |
| | | { |
| | | model.ReadMail(uuid); |
| | | } |
| | | UIManager.Instance.OpenWindow<MailInfoWin>(); |
| | | int expiryDay = model.GetMailExpiryDays(mailData.CreateDateTime, mailData.LimitDays); |
| | | txtDate.text = expiryDay > 0 ? Language.Get("Mail07", expiryDay) : model.FormatCreateMailTime(mailData.CreateDateTime); |
| | | } |
| | | btnMail.SetListener(OnClickButtonMail); |
| | | } |
| | | } |
| | | |
| | | private void OnClickButtonMail() |
| | | { |
| | | model.nowUuid = uuid; |
| | | if (!model.TryGetMailData(uuid, out var mailData) || mailData == null) |
| | | return; |
| | | if (mailData.MailState == 1) |
| | | { |
| | | model.ReadMail(uuid); |
| | | } |
| | | UIManager.Instance.OpenWindow<MailInfoWin>(); |
| | | } |
| | | } |
| | |
| | | using UnityEngine; |
| | | |
| | | namespace vnxbqy.UI |
| | | public class MailInfoAwardItemCell : CellView |
| | | { |
| | | public class MailInfoAwardItemCell : CellView |
| | | [SerializeField] ItemCell itemCell; |
| | | [SerializeField] ImageEx imgHave; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | public void Display(int index, CellView cellView) |
| | | { |
| | | [SerializeField] ItemCell itemCell; |
| | | [SerializeField] ImageEx imgHave; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | public void Display(int index, CellView cellView) |
| | | { |
| | | int mailState = cellView.info.Value.infoInt1;//0-未知;1-未读;2-已读;3-已领; |
| | | if (!model.TryGetMailData(model.nowUuid, out MailData mailData) || mailData == null || mailData.Items == null) |
| | | return; |
| | | if (index < 0 || index >= mailData.Items.Count) |
| | | return; |
| | | MailItemData data = mailData.Items[index]; |
| | | itemCell.Init(new ItemCellModel((int)data.ItemID, true, (ulong)data.Count)); |
| | | itemCell.button.SetListener(() => ItemTipUtility.Show((int)data.ItemID)); |
| | | imgHave.SetActive(mailState == 3); |
| | | int mailState = cellView.info.Value.infoInt1;//0-未知;1-未读;2-已读;3-已领; |
| | | if (!model.TryGetMailData(model.nowUuid, out MailData mailData) || mailData == null || mailData.Items == null) |
| | | return; |
| | | if (index < 0 || index >= mailData.Items.Count) |
| | | return; |
| | | MailItemData data = mailData.Items[index]; |
| | | itemCell.Init(new ItemCellModel((int)data.ItemID, true, (ulong)data.Count)); |
| | | itemCell.button.SetListener(() => ItemTipUtility.Show((int)data.ItemID)); |
| | | imgHave.SetActive(mailState == 3); |
| | | |
| | | MailCategory mailCategory = (MailCategory)cellView.info.Value.infoInt1; |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | } |
| | | MailCategory mailCategory = (MailCategory)cellView.info.Value.infoInt1; |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | } |
| | | } |
| | | } |
| | |
| | | using UnityEngine; |
| | | namespace vnxbqy.UI |
| | | public class MailInfoWin : UIBase |
| | | { |
| | | public class MailInfoWin : UIBase |
| | | [SerializeField] TextEx txtDate; |
| | | [SerializeField] TextEx txtTitle; |
| | | [SerializeField] Transform transNoAward; |
| | | [SerializeField] RichText txtNoAwardInfo; |
| | | [SerializeField] Transform transAward; |
| | | [SerializeField] RichText txtAwardInfo; |
| | | [SerializeField] ScrollerController scrAwardItem; |
| | | [SerializeField] TextEx txtExpiryDate; |
| | | [SerializeField] ButtonEx btnHave; |
| | | [SerializeField] ButtonEx btnDelete; |
| | | MailData nowMailData; |
| | | bool isHasAward = false; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | [SerializeField] TextEx txtDate; |
| | | [SerializeField] TextEx txtTitle; |
| | | [SerializeField] Transform transNoAward; |
| | | [SerializeField] RichText txtNoAwardInfo; |
| | | [SerializeField] Transform transAward; |
| | | [SerializeField] RichText txtAwardInfo; |
| | | [SerializeField] ScrollerController scrAwardItem; |
| | | [SerializeField] TextEx txtExpiryDate; |
| | | [SerializeField] ButtonEx btnHave; |
| | | [SerializeField] ButtonEx btnDelete; |
| | | MailData nowMailData; |
| | | bool isHasAward = false; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | base.InitComponent(); |
| | | btnHave.SetListener(OnClickHaveButton); |
| | | btnDelete.SetListener(OnClickDeleteButton); |
| | | } |
| | | |
| | | protected override void InitComponent() |
| | | protected override void OnPreOpen() |
| | | { |
| | | scrAwardItem.OnRefreshCell += OnRefreshLowRewardCell; |
| | | model.OnUpdateMailListEvent += OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent += OnUpdateMailStateChangeEvent; |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | scrAwardItem.OnRefreshCell -= OnRefreshLowRewardCell; |
| | | model.OnUpdateMailListEvent -= OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent -= OnUpdateMailStateChangeEvent; |
| | | } |
| | | |
| | | private void OnClickHaveButton() |
| | | { |
| | | if (model.nowUuid == null || model.nowUuid == string.Empty) |
| | | { |
| | | base.InitComponent(); |
| | | btnHave.SetListener(OnClickHaveButton); |
| | | btnDelete.SetListener(OnClickDeleteButton); |
| | | Debug.Log("当前查看的邮件没有UUID"); |
| | | return; |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | model.ClaimMail(model.nowUuid); |
| | | } |
| | | private void OnClickDeleteButton() |
| | | { |
| | | if (model.nowUuid == null || model.nowUuid == string.Empty) |
| | | { |
| | | scrAwardItem.OnRefreshCell += OnRefreshLowRewardCell; |
| | | model.OnUpdateMailListEvent += OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent += OnUpdateMailStateChangeEvent; |
| | | Debug.Log("当前查看的邮件没有UUID"); |
| | | return; |
| | | } |
| | | model.DeleteMail(model.nowUuid); |
| | | UIManager.Instance.CloseWindow<MailInfoWin>(); |
| | | //邮件删除成功 |
| | | SysNotifyMgr.Instance.ShowTip("Mail01"); |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | private void OnUpdateMailStateChangeEvent() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | scrAwardItem.OnRefreshCell -= OnRefreshLowRewardCell; |
| | | model.OnUpdateMailListEvent -= OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent -= OnUpdateMailStateChangeEvent; |
| | | } |
| | | private void OnUpdateMailListEvent() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | private void OnClickHaveButton() |
| | | private void OnRefreshLowRewardCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell.GetComponent<MailInfoAwardItemCell>(); |
| | | _cell?.Display(cell.index, cell); |
| | | } |
| | | |
| | | private void CreateScrAward() |
| | | { |
| | | scrAwardItem.Refresh(); |
| | | if (isHasAward) |
| | | { |
| | | if (model.nowUuid == null || model.nowUuid == string.Empty) |
| | | for (int i = 0; i < nowMailData.Items.Count; i++) |
| | | { |
| | | Debug.Log("当前查看的邮件没有UUID"); |
| | | return; |
| | | CellInfo cellInfo = new CellInfo(); |
| | | cellInfo.infoInt1 = nowMailData.MailState; |
| | | scrAwardItem.AddCell(ScrollerDataType.Header, i); |
| | | } |
| | | model.ClaimMail(model.nowUuid); |
| | | } |
| | | private void OnClickDeleteButton() |
| | | { |
| | | if (model.nowUuid == null || model.nowUuid == string.Empty) |
| | | { |
| | | Debug.Log("当前查看的邮件没有UUID"); |
| | | return; |
| | | } |
| | | model.DeleteMail(model.nowUuid); |
| | | UIManager.Instance.CloseWindow<MailInfoWin>(); |
| | | //邮件删除成功 |
| | | SysNotifyMgr.Instance.ShowTip("Mail01"); |
| | | } |
| | | scrAwardItem.Restart(); |
| | | } |
| | | |
| | | private void OnUpdateMailStateChangeEvent() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | private void OnUpdateMailListEvent() |
| | | { |
| | | UpdateDataInfo(); |
| | | Display(); |
| | | CreateScrAward(); |
| | | } |
| | | |
| | | private void OnRefreshLowRewardCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell.GetComponent<MailInfoAwardItemCell>(); |
| | | _cell?.Display(cell.index, cell); |
| | | } |
| | | |
| | | private void CreateScrAward() |
| | | { |
| | | scrAwardItem.Refresh(); |
| | | if (isHasAward) |
| | | { |
| | | for (int i = 0; i < nowMailData.Items.Count; i++) |
| | | { |
| | | CellInfo cellInfo = new CellInfo(); |
| | | cellInfo.infoInt1 = nowMailData.MailState; |
| | | scrAwardItem.AddCell(ScrollerDataType.Header, i); |
| | | } |
| | | } |
| | | scrAwardItem.Restart(); |
| | | } |
| | | |
| | | private void Display() |
| | | { |
| | | if (nowMailData == null) |
| | | return; |
| | | transNoAward.SetActive(!isHasAward); |
| | | transAward.SetActive(isHasAward); |
| | | txtDate.text = model.FormatCreateMailTime(nowMailData.CreateDateTime); |
| | | private void Display() |
| | | { |
| | | if (nowMailData == null) |
| | | return; |
| | | transNoAward.SetActive(!isHasAward); |
| | | transAward.SetActive(isHasAward); |
| | | txtDate.text = model.FormatCreateMailTime(nowMailData.CreateDateTime); |
| | | |
| | | if (nowMailData.IsTemplateMail()) |
| | | if (nowMailData.IsTemplateMail()) |
| | | { |
| | | string key = nowMailData.GetTemplateKey(); |
| | | if (MailConfig.HasKey(key)) |
| | | { |
| | | string key = nowMailData.GetTemplateKey(); |
| | | if (MailConfig.HasKey(key)) |
| | | { |
| | | MailConfig config = MailConfig.Get(key); |
| | | var templateParams = nowMailData.GetTemplateParams(); |
| | | string content = string.Format(config.Content, templateParams.ToArray()); |
| | | txtTitle.text = config.Title; |
| | | txtNoAwardInfo.text = content; |
| | | txtAwardInfo.text = content; |
| | | } |
| | | else |
| | | { |
| | | txtTitle.text = nowMailData.Title; |
| | | txtNoAwardInfo.text = nowMailData.Text; |
| | | txtAwardInfo.text = nowMailData.Text; |
| | | } |
| | | MailConfig config = MailConfig.Get(key); |
| | | var templateParams = nowMailData.GetTemplateParams(); |
| | | string content = string.Format(config.Content, templateParams.ToArray()); |
| | | txtTitle.text = config.Title; |
| | | txtNoAwardInfo.text = content; |
| | | txtAwardInfo.text = content; |
| | | } |
| | | else |
| | | { |
| | |
| | | txtNoAwardInfo.text = nowMailData.Text; |
| | | txtAwardInfo.text = nowMailData.Text; |
| | | } |
| | | |
| | | int expiryDays = model.GetMailExpiryDays(nowMailData.CreateDateTime, nowMailData.LimitDays); |
| | | txtExpiryDate.text = expiryDays > 0 ? Language.Get("Mail07", expiryDays) : string.Empty; |
| | | |
| | | } |
| | | |
| | | private void UpdateDataInfo() |
| | | else |
| | | { |
| | | if (!model.TryGetMailData(model.nowUuid, out nowMailData)) |
| | | { |
| | | UIManager.Instance.CloseWindow<MailInfoWin>(); |
| | | } |
| | | isHasAward = nowMailData != null && nowMailData.Items != null; |
| | | txtTitle.text = nowMailData.Title; |
| | | txtNoAwardInfo.text = nowMailData.Text; |
| | | txtAwardInfo.text = nowMailData.Text; |
| | | } |
| | | |
| | | int expiryDays = model.GetMailExpiryDays(nowMailData.CreateDateTime, nowMailData.LimitDays); |
| | | txtExpiryDate.text = expiryDays > 0 ? Language.Get("Mail07", expiryDays) : string.Empty; |
| | | |
| | | } |
| | | |
| | | private void UpdateDataInfo() |
| | | { |
| | | if (!model.TryGetMailData(model.nowUuid, out nowMailData)) |
| | | { |
| | | UIManager.Instance.CloseWindow<MailInfoWin>(); |
| | | } |
| | | isHasAward = nowMailData != null && nowMailData.Items != null; |
| | | } |
| | | } |
| | | |
| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | |
| | | namespace vnxbqy.UI |
| | | public class MailManager : GameSystemManager<MailManager> |
| | | { |
| | | public class MailManager : GameSystemManager<MailManager> |
| | | /// <summary> |
| | | /// 邮件数据字典,存储所有邮件详情 |
| | | /// Key: 邮件GUID(唯一标识) |
| | | /// Value: 邮件详细数据(MailData结构体) |
| | | /// </summary> |
| | | Dictionary<string, MailData> mailDataDict = new Dictionary<string, MailData>(); |
| | | public MailCategory nowMailCategory = MailCategory.Personal; |
| | | public Redpoint parentRedpoint = new Redpoint(MainRedDot.MailRepoint); |
| | | public Redpoint tabRedpoint0; |
| | | public Redpoint tabRedpoint1; |
| | | public event Action OnUpdateMailListEvent;// 更新邮件列表数据 |
| | | public event Action OnUpdateMailStateChangeEvent;// 更新邮件状态变更 |
| | | public readonly string dateFormat = "yyyy-MM-dd"; |
| | | public string nowUuid = string.Empty; |
| | | public override void Init() |
| | | { |
| | | /// <summary> |
| | | /// 邮件数据字典,存储所有邮件详情 |
| | | /// Key: 邮件GUID(唯一标识) |
| | | /// Value: 邮件详细数据(MailData结构体) |
| | | /// </summary> |
| | | Dictionary<string, MailData> mailDataDict = new Dictionary<string, MailData>(); |
| | | public MailCategory nowMailCategory = MailCategory.Personal; |
| | | public Redpoint parentRedpoint = new Redpoint(MainRedDot.MailRepoint); |
| | | public Redpoint tabRedpoint0; |
| | | public Redpoint tabRedpoint1; |
| | | public event Action OnUpdateMailListEvent;// 更新邮件列表数据 |
| | | public event Action OnUpdateMailStateChangeEvent;// 更新邮件状态变更 |
| | | public readonly string dateFormat = "yyyy-MM-dd"; |
| | | public string nowUuid = string.Empty; |
| | | public override void Init() |
| | | { |
| | | tabRedpoint0 = new Redpoint(MainRedDot.MailRepoint, GetTabRedpointId(MailCategory.Personal)); |
| | | tabRedpoint1 = new Redpoint(MainRedDot.MailRepoint, GetTabRedpointId(MailCategory.Global)); |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitializeEvent; |
| | | } |
| | | tabRedpoint0 = new Redpoint(MainRedDot.MailRepoint, GetTabRedpointId(MailCategory.Personal)); |
| | | tabRedpoint1 = new Redpoint(MainRedDot.MailRepoint, GetTabRedpointId(MailCategory.Global)); |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitializeEvent; |
| | | } |
| | | |
| | | public override void Release() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitializeEvent; |
| | | } |
| | | public override void Release() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitializeEvent; |
| | | } |
| | | |
| | | public void OnBeforePlayerDataInitializeEvent() |
| | | { |
| | | mailDataDict.Clear(); |
| | | } |
| | | public void OnBeforePlayerDataInitializeEvent() |
| | | { |
| | | mailDataDict.Clear(); |
| | | } |
| | | |
| | | public bool HasNoReadMail(MailCategory category) |
| | | { |
| | | var list = GetMailList(category); |
| | | if (list.IsNullOrEmpty()) |
| | | return false; |
| | | |
| | | foreach (var guid in list) |
| | | { |
| | | if (mailDataDict.TryGetValue(guid, out var mailData) && mailData.MailState == 1) |
| | | return true; |
| | | } |
| | | public bool HasNoReadMail(MailCategory category) |
| | | { |
| | | var list = GetMailList(category); |
| | | if (list.IsNullOrEmpty()) |
| | | return false; |
| | | } |
| | | |
| | | public int GetTabRedpointId(MailCategory type) |
| | | foreach (var guid in list) |
| | | { |
| | | return MainRedDot.MailRepoint * 10 + (int)type; |
| | | if (mailDataDict.TryGetValue(guid, out var mailData) && mailData.MailState == 1) |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public void UpdatePersonalRedPoint() |
| | | public int GetTabRedpointId(MailCategory type) |
| | | { |
| | | return MainRedDot.MailRepoint * 10 + (int)type; |
| | | } |
| | | |
| | | public void UpdatePersonalRedPoint() |
| | | { |
| | | if (tabRedpoint0 == null) |
| | | return; |
| | | tabRedpoint0.state = RedPointState.None; |
| | | if (HasNoReadMail(MailCategory.Personal)) |
| | | { |
| | | if (tabRedpoint0 == null) |
| | | return; |
| | | tabRedpoint0.state = RedPointState.None; |
| | | if (HasNoReadMail(MailCategory.Personal)) |
| | | tabRedpoint0.state = RedPointState.Simple; |
| | | } |
| | | } |
| | | |
| | | public void UpdateGlobalRedPoint() |
| | | { |
| | | if (tabRedpoint1 == null) return; |
| | | tabRedpoint1.state = RedPointState.None; |
| | | if (HasNoReadMail(MailCategory.Global)) |
| | | { |
| | | tabRedpoint1.state = RedPointState.Simple; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新邮件红点提示状态 |
| | | /// </summary> |
| | | public void UpdateRedPoint() |
| | | { |
| | | UpdatePersonalRedPoint(); |
| | | UpdateGlobalRedPoint(); |
| | | } |
| | | |
| | | public bool TryGetMailData(string uuid, out MailData mailData) |
| | | { |
| | | return mailDataDict.TryGetValue(uuid, out mailData); |
| | | } |
| | | public string FormatCreateMailTime(DateTime createDateTime) |
| | | { |
| | | TimeSpan diff = TimeUtility.ServerNow - createDateTime; |
| | | if (diff.TotalHours <= 24) |
| | | { |
| | | int hours = (int)Math.Floor(diff.TotalHours); |
| | | return Language.Get("Mail05", hours); |
| | | } |
| | | else |
| | | { |
| | | return createDateTime.ToString(dateFormat); |
| | | } |
| | | } |
| | | |
| | | //返回有效期天数(正数=已过期天数,负数=剩余天数) |
| | | public int GetMailExpiryDays(DateTime createDateTime, int limitDays) |
| | | { |
| | | DateTime expiryDate = createDateTime.AddDays(limitDays); |
| | | return (int)(TimeUtility.ServerNow - expiryDate).TotalDays; |
| | | } |
| | | |
| | | |
| | | public List<string> GetMailList(MailCategory mailCategory) |
| | | { |
| | | var result = new List<string>(); |
| | | foreach (var kvp in mailDataDict) |
| | | { |
| | | if (kvp.Value.Category == mailCategory) |
| | | { |
| | | tabRedpoint0.state = RedPointState.Simple; |
| | | result.Add(kvp.Key); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public void UpdateGlobalRedPoint() |
| | | public List<string> GetSortMailScrList(MailCategory mailCategory) |
| | | { |
| | | List<string> resList = GetMailList(mailCategory); |
| | | return resList.OrderByDescending(guid => mailDataDict[guid].CreateDateTime).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新邮件列表数据 |
| | | /// </summary> |
| | | /// <param name="vNetData">从服务器接收的邮件列表数据包</param> |
| | | public void UpdateMailList(HA362_tagMCMailList vNetData) |
| | | { |
| | | if (vNetData == null) return; |
| | | |
| | | // 更新邮件数据字典 |
| | | foreach (var mail in vNetData.MailList) |
| | | { |
| | | if (tabRedpoint1 == null) return; |
| | | tabRedpoint1.state = RedPointState.None; |
| | | if (HasNoReadMail(MailCategory.Global)) |
| | | var category = vNetData.IsServerMail == 1 ? MailCategory.Global : MailCategory.Personal; |
| | | var mailData = new MailData(); |
| | | |
| | | mailData.Category = category; |
| | | mailData.GUID = mail.GUID; |
| | | mailData.Type = mail.Type; |
| | | mailData.CreateTime = mail.CreateTime; |
| | | mailData.CreateDateTime = Convert.ToDateTime(UIHelper.GetTime(mail.CreateTime)); |
| | | mailData.LimitDays = mail.LimitDays; |
| | | mailData.Title = mail.Title; |
| | | mailData.Text = mail.Text; |
| | | mailData.MailState = mail.MailState; |
| | | |
| | | mailData.Items = mail.Items?.Select(i => new MailItemData |
| | | { |
| | | tabRedpoint1.state = RedPointState.Simple; |
| | | } |
| | | ItemID = i.ItemID, |
| | | Count = i.Count, |
| | | IsBind = i.IsBind, |
| | | UserData = i.UserData |
| | | }).ToList(); |
| | | mailDataDict[mail.GUID] = mailData; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新邮件红点提示状态 |
| | | /// </summary> |
| | | public void UpdateRedPoint() |
| | | { |
| | | UpdatePersonalRedPoint(); |
| | | UpdateGlobalRedPoint(); |
| | | } |
| | | UpdateRedPoint(); |
| | | OnUpdateMailListEvent?.Invoke(); |
| | | } |
| | | |
| | | public bool TryGetMailData(string uuid, out MailData mailData) |
| | | /// <summary> |
| | | /// 更新邮件状态变更 |
| | | /// </summary> |
| | | /// <param name="vNetData">从服务器接收的邮件状态变更数据包</param> |
| | | public void UpdateMailStateChange(HA363_tagMCMailStateChange vNetData) |
| | | { |
| | | if (vNetData == null || vNetData.MailList == null) return; |
| | | |
| | | foreach (var stateChange in vNetData.MailList) |
| | | { |
| | | return mailDataDict.TryGetValue(uuid, out mailData); |
| | | } |
| | | public string FormatCreateMailTime(DateTime createDateTime) |
| | | { |
| | | TimeSpan diff = TimeUtility.ServerNow - createDateTime; |
| | | if (diff.TotalHours <= 24) |
| | | if (mailDataDict.TryGetValue(stateChange.GUID, out var mailData)) |
| | | { |
| | | int hours = (int)Math.Floor(diff.TotalHours); |
| | | return Language.Get("Mail05", hours); |
| | | } |
| | | else |
| | | { |
| | | return createDateTime.ToString(dateFormat); |
| | | } |
| | | } |
| | | |
| | | //返回有效期天数(正数=已过期天数,负数=剩余天数) |
| | | public int GetMailExpiryDays(DateTime createDateTime, int limitDays) |
| | | { |
| | | DateTime expiryDate = createDateTime.AddDays(limitDays); |
| | | return (int)(TimeUtility.ServerNow - expiryDate).TotalDays; |
| | | } |
| | | |
| | | |
| | | public List<string> GetMailList(MailCategory mailCategory) |
| | | { |
| | | var result = new List<string>(); |
| | | foreach (var kvp in mailDataDict) |
| | | { |
| | | if (kvp.Value.Category == mailCategory) |
| | | if (stateChange.MailState == 4) |
| | | { |
| | | result.Add(kvp.Key); |
| | | mailDataDict.Remove(stateChange.GUID); |
| | | continue; |
| | | } |
| | | mailData.MailState = stateChange.MailState; |
| | | mailDataDict[stateChange.GUID] = mailData; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public List<string> GetSortMailScrList(MailCategory mailCategory) |
| | | UpdateRedPoint(); |
| | | OnUpdateMailStateChangeEvent?.Invoke(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 阅读邮件 |
| | | /// </summary> |
| | | /// <param name="GUID">邮件GUID</param> |
| | | public void ReadMail(string GUID) |
| | | { |
| | | if (string.IsNullOrEmpty(GUID)) |
| | | { |
| | | List<string> resList = GetMailList(mailCategory); |
| | | return resList.OrderByDescending(guid => mailDataDict[guid].CreateDateTime).ToList(); |
| | | Debug.LogError("阅读邮件GUID不能为空"); |
| | | return; |
| | | } |
| | | SendRequestMail(GUID, 0); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新邮件列表数据 |
| | | /// </summary> |
| | | /// <param name="vNetData">从服务器接收的邮件列表数据包</param> |
| | | public void UpdateMailList(HA362_tagMCMailList vNetData) |
| | | { |
| | | if (vNetData == null) return; |
| | | /// <summary> |
| | | /// 领取邮件 |
| | | /// </summary> |
| | | /// <param name="GUID">邮件GUID,为空时批量领取所有邮件</param> |
| | | public void ClaimMail(string GUID = null) |
| | | { |
| | | SendRequestMail(GUID, 1); |
| | | } |
| | | |
| | | // 更新邮件数据字典 |
| | | foreach (var mail in vNetData.MailList) |
| | | { |
| | | var category = vNetData.IsServerMail == 1 ? MailCategory.Global : MailCategory.Personal; |
| | | var mailData = new MailData(); |
| | | /// <summary> |
| | | /// 删除邮件 |
| | | /// </summary> |
| | | /// <param name="GUID">邮件GUID,为空时批量删除已领取或无物品的已读邮件</param> |
| | | public void DeleteMail(string GUID = null) |
| | | { |
| | | SendRequestMail(GUID, 2); |
| | | } |
| | | |
| | | mailData.Category = category; |
| | | mailData.GUID = mail.GUID; |
| | | mailData.Type = mail.Type; |
| | | mailData.CreateTime = mail.CreateTime; |
| | | mailData.CreateDateTime = Convert.ToDateTime(UIHelper.GetTime(mail.CreateTime)); |
| | | mailData.LimitDays = mail.LimitDays; |
| | | mailData.Title = mail.Title; |
| | | mailData.Text = mail.Text; |
| | | mailData.MailState = mail.MailState; |
| | | |
| | | mailData.Items = mail.Items?.Select(i => new MailItemData |
| | | { |
| | | ItemID = i.ItemID, |
| | | Count = i.Count, |
| | | IsBind = i.IsBind, |
| | | UserData = i.UserData |
| | | }).ToList(); |
| | | mailDataDict[mail.GUID] = mailData; |
| | | } |
| | | |
| | | UpdateRedPoint(); |
| | | OnUpdateMailListEvent?.Invoke(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新邮件状态变更 |
| | | /// </summary> |
| | | /// <param name="vNetData">从服务器接收的邮件状态变更数据包</param> |
| | | public void UpdateMailStateChange(HA363_tagMCMailStateChange vNetData) |
| | | { |
| | | if (vNetData == null || vNetData.MailList == null) return; |
| | | |
| | | foreach (var stateChange in vNetData.MailList) |
| | | { |
| | | if (mailDataDict.TryGetValue(stateChange.GUID, out var mailData)) |
| | | { |
| | | if (stateChange.MailState == 4) |
| | | { |
| | | mailDataDict.Remove(stateChange.GUID); |
| | | continue; |
| | | } |
| | | mailData.MailState = stateChange.MailState; |
| | | mailDataDict[stateChange.GUID] = mailData; |
| | | } |
| | | } |
| | | |
| | | UpdateRedPoint(); |
| | | OnUpdateMailStateChangeEvent?.Invoke(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 阅读邮件 |
| | | /// </summary> |
| | | /// <param name="GUID">邮件GUID</param> |
| | | public void ReadMail(string GUID) |
| | | { |
| | | if (string.IsNullOrEmpty(GUID)) |
| | | { |
| | | Debug.LogError("阅读邮件GUID不能为空"); |
| | | return; |
| | | } |
| | | SendRequestMail(GUID, 0); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 领取邮件 |
| | | /// </summary> |
| | | /// <param name="GUID">邮件GUID,为空时批量领取所有邮件</param> |
| | | public void ClaimMail(string GUID = null) |
| | | { |
| | | SendRequestMail(GUID, 1); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除邮件 |
| | | /// </summary> |
| | | /// <param name="GUID">邮件GUID,为空时批量删除已领取或无物品的已读邮件</param> |
| | | public void DeleteMail(string GUID = null) |
| | | { |
| | | SendRequestMail(GUID, 2); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 发送邮件请求到服务器 |
| | | /// </summary> |
| | | /// <param name="GUID">邮件GUID</param> |
| | | /// <param name="ReqType">请求类型 0-设置已读,1-领取邮件,2-删除邮件</param> |
| | | public void SendRequestMail(string GUID, byte ReqType) |
| | | { |
| | | CA537_tagCMRequestMail pack = new CA537_tagCMRequestMail(); |
| | | pack.GUID = GUID; |
| | | pack.ReqType = ReqType; |
| | | GameNetSystem.Instance.SendInfo(pack); |
| | | } |
| | | /// <summary> |
| | | /// 发送邮件请求到服务器 |
| | | /// </summary> |
| | | /// <param name="GUID">邮件GUID</param> |
| | | /// <param name="ReqType">请求类型 0-设置已读,1-领取邮件,2-删除邮件</param> |
| | | public void SendRequestMail(string GUID, byte ReqType) |
| | | { |
| | | CA537_tagCMRequestMail pack = new CA537_tagCMRequestMail(); |
| | | pack.GUID = GUID; |
| | | pack.ReqType = ReqType; |
| | | GameNetSystem.Instance.SendInfo(pack); |
| | | } |
| | | |
| | | //没有一个可领取的个人邮件 |
| | | public bool IsCanHaveMail() |
| | | { |
| | | var personalMails = GetMailList(MailCategory.Personal); |
| | | return personalMails.Any(guid => |
| | | mailDataDict.TryGetValue(guid, out var mail) && |
| | | mail.MailState != 3 && |
| | | mail.Items != null && |
| | | mail.Items.Count > 0 |
| | | ); |
| | | } |
| | | } |
| | | |
| | | public enum MailCategory |
| | | //没有一个可领取的个人邮件 |
| | | public bool IsCanHaveMail() |
| | | { |
| | | Personal = 0, // 个人邮件 |
| | | Global = 1 // 全服邮件 |
| | | var personalMails = GetMailList(MailCategory.Personal); |
| | | return personalMails.Any(guid => |
| | | mailDataDict.TryGetValue(guid, out var mail) && |
| | | mail.MailState != 3 && |
| | | mail.Items != null && |
| | | mail.Items.Count > 0 |
| | | ); |
| | | } |
| | | } |
| | | |
| | | public class MailItemData |
| | | public enum MailCategory |
| | | { |
| | | Personal = 0, // 个人邮件 |
| | | Global = 1 // 全服邮件 |
| | | } |
| | | |
| | | public class MailItemData |
| | | { |
| | | public uint ItemID; //物品ID |
| | | public uint Count; //数量 |
| | | public byte IsBind; //是否绑定 |
| | | public string UserData; //自定义数据 |
| | | } |
| | | |
| | | public class MailData |
| | | { |
| | | public MailCategory Category; |
| | | public string GUID; //邮件GUID |
| | | public byte Type; //邮件类型,暂时默认0 |
| | | public string CreateTime; //创建时间 |
| | | public DateTime CreateDateTime; |
| | | public byte LimitDays; //有效天数 |
| | | public string Title; //标题 |
| | | public string Text; //内容 |
| | | public byte MailState; //邮件状态: 0-未知;1-未读;2-已读;3-已领; |
| | | public List<MailItemData> Items; //物品信息 |
| | | |
| | | /// <summary> |
| | | /// 判断是否为模板类型邮件 |
| | | /// </summary> |
| | | /// <returns>true-模板邮件, false-普通邮件</returns> |
| | | public bool IsTemplateMail() |
| | | { |
| | | public uint ItemID; //物品ID |
| | | public uint Count; //数量 |
| | | public byte IsBind; //是否绑定 |
| | | public string UserData; //自定义数据 |
| | | if (string.IsNullOrEmpty(Title)) |
| | | return false; |
| | | |
| | | return Title.StartsWith("<T>") && Title.EndsWith("</T>"); |
| | | } |
| | | |
| | | public class MailData |
| | | /// <summary> |
| | | /// 获取模板邮件的模板key |
| | | /// </summary> |
| | | /// <returns>模板key,如果不是模板邮件返回空字符串</returns> |
| | | public string GetTemplateKey() |
| | | { |
| | | public MailCategory Category; |
| | | public string GUID; //邮件GUID |
| | | public byte Type; //邮件类型,暂时默认0 |
| | | public string CreateTime; //创建时间 |
| | | public DateTime CreateDateTime; |
| | | public byte LimitDays; //有效天数 |
| | | public string Title; //标题 |
| | | public string Text; //内容 |
| | | public byte MailState; //邮件状态: 0-未知;1-未读;2-已读;3-已领; |
| | | public List<MailItemData> Items; //物品信息 |
| | | if (!IsTemplateMail()) |
| | | return string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 判断是否为模板类型邮件 |
| | | /// </summary> |
| | | /// <returns>true-模板邮件, false-普通邮件</returns> |
| | | public bool IsTemplateMail() |
| | | // 模板格式: <T>key</T> |
| | | // 跳过开头的"<T>" (3字符) |
| | | // 取中间部分,总长度减去"<T>"和"</T>"共7字符 |
| | | const int prefixLength = 3; // "<T>"长度 |
| | | const int suffixLength = 4; // "</T>"长度 |
| | | return Title.Substring(prefixLength, Title.Length - (prefixLength + suffixLength)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取模板邮件的参数列表 |
| | | /// </summary> |
| | | /// <returns>参数列表,如果不是模板邮件或参数为空则返回空列表</returns> |
| | | public List<string> GetTemplateParams() |
| | | { |
| | | if (!IsTemplateMail() || string.IsNullOrEmpty(Text)) |
| | | return new List<string>(); |
| | | |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(Title)) |
| | | return false; |
| | | |
| | | return Title.StartsWith("<T>") && Title.EndsWith("</T>"); |
| | | // 参数格式为JSON数组:[参数1, 参数2, ...] |
| | | return JsonUtility.FromJson<List<string>>(Text); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取模板邮件的模板key |
| | | /// </summary> |
| | | /// <returns>模板key,如果不是模板邮件返回空字符串</returns> |
| | | public string GetTemplateKey() |
| | | catch |
| | | { |
| | | if (!IsTemplateMail()) |
| | | return string.Empty; |
| | | |
| | | // 模板格式: <T>key</T> |
| | | // 跳过开头的"<T>" (3字符) |
| | | // 取中间部分,总长度减去"<T>"和"</T>"共7字符 |
| | | const int prefixLength = 3; // "<T>"长度 |
| | | const int suffixLength = 4; // "</T>"长度 |
| | | return Title.Substring(prefixLength, Title.Length - (prefixLength + suffixLength)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取模板邮件的参数列表 |
| | | /// </summary> |
| | | /// <returns>参数列表,如果不是模板邮件或参数为空则返回空列表</returns> |
| | | public List<string> GetTemplateParams() |
| | | { |
| | | if (!IsTemplateMail() || string.IsNullOrEmpty(Text)) |
| | | return new List<string>(); |
| | | |
| | | try |
| | | { |
| | | // 参数格式为JSON数组:[参数1, 参数2, ...] |
| | | return JsonUtility.FromJson<List<string>>(Text); |
| | | } |
| | | catch |
| | | { |
| | | return new List<string>(); |
| | | } |
| | | return new List<string>(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | using UnityEngine; |
| | | |
| | | namespace vnxbqy.UI |
| | | public class MailPersonalCell : CellView |
| | | { |
| | | public class MailPersonalCell : CellView |
| | | [SerializeField] ButtonEx btnMail; |
| | | [SerializeField] ImageEx imgState; |
| | | [SerializeField] ImageEx imgRed; |
| | | [SerializeField] TextEx txtTitle; |
| | | [SerializeField] TextEx txtDate; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | string uuid = string.Empty; |
| | | public void Display(int index, CellView cellView) |
| | | { |
| | | [SerializeField] ButtonEx btnMail; |
| | | [SerializeField] ImageEx imgState; |
| | | [SerializeField] ImageEx imgRed; |
| | | [SerializeField] TextEx txtTitle; |
| | | [SerializeField] TextEx txtDate; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | string uuid = string.Empty; |
| | | public void Display(int index, CellView cellView) |
| | | MailCategory mailCategory = (MailCategory)cellView.info.Value.infoInt1; |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | if (list == null || index < 0 || index >= list.Count) |
| | | return; |
| | | uuid = list[index]; |
| | | if (!model.TryGetMailData(uuid, out var mailData) || mailData == null) |
| | | return; |
| | | imgRed.SetActive(mailData.MailState == 1); |
| | | txtTitle.text = mailData.Title; |
| | | imgState.SetSprite(mailData.MailState == 2 || mailData.MailState == 3 ? "MailRead" : "MailNoRead"); |
| | | if (mailData.Items != null) |
| | | { |
| | | MailCategory mailCategory = (MailCategory)cellView.info.Value.infoInt1; |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | if (list == null || index < 0 || index >= list.Count) |
| | | return; |
| | | uuid = list[index]; |
| | | if (!model.TryGetMailData(uuid, out var mailData) || mailData == null) |
| | | return; |
| | | imgRed.SetActive(mailData.MailState == 1); |
| | | txtTitle.text = mailData.Title; |
| | | imgState.SetSprite(mailData.MailState == 2 || mailData.MailState == 3 ? "MailRead" : "MailNoRead"); |
| | | if (mailData.Items != null) |
| | | { |
| | | txtDate.text = model.FormatCreateMailTime(mailData.CreateDateTime); |
| | | } |
| | | else |
| | | { |
| | | int expiryDay = model.GetMailExpiryDays(mailData.CreateDateTime, mailData.LimitDays); |
| | | txtDate.text = expiryDay > 0 ? Language.Get("Mail07", expiryDay) : model.FormatCreateMailTime(mailData.CreateDateTime); |
| | | } |
| | | btnMail.SetListener(OnClickButtonMail); |
| | | txtDate.text = model.FormatCreateMailTime(mailData.CreateDateTime); |
| | | } |
| | | |
| | | private void OnClickButtonMail() |
| | | else |
| | | { |
| | | model.nowUuid = uuid; |
| | | if (!model.TryGetMailData(uuid, out var mailData) || mailData == null) |
| | | return; |
| | | if (mailData.MailState == 1) |
| | | { |
| | | model.ReadMail(uuid); |
| | | } |
| | | UIManager.Instance.OpenWindow<MailInfoWin>(); |
| | | int expiryDay = model.GetMailExpiryDays(mailData.CreateDateTime, mailData.LimitDays); |
| | | txtDate.text = expiryDay > 0 ? Language.Get("Mail07", expiryDay) : model.FormatCreateMailTime(mailData.CreateDateTime); |
| | | } |
| | | btnMail.SetListener(OnClickButtonMail); |
| | | } |
| | | } |
| | | |
| | | private void OnClickButtonMail() |
| | | { |
| | | model.nowUuid = uuid; |
| | | if (!model.TryGetMailData(uuid, out var mailData) || mailData == null) |
| | | return; |
| | | if (mailData.MailState == 1) |
| | | { |
| | | model.ReadMail(uuid); |
| | | } |
| | | UIManager.Instance.OpenWindow<MailInfoWin>(); |
| | | } |
| | | } |
| | |
| | | using System; |
| | | using UnityEngine; |
| | | namespace vnxbqy.UI |
| | | |
| | | |
| | | public class MailWin : UIBase |
| | | { |
| | | public class MailWin : UIBase |
| | | [SerializeField] Transform transPersonal; |
| | | [SerializeField] Transform transGlobal; |
| | | [SerializeField] ScrollerController scrPersonal; |
| | | [SerializeField] ScrollerController scrGlobal; |
| | | [SerializeField] ButtonEx btnDeleteRead; |
| | | [SerializeField] ButtonEx btnClaimAll; |
| | | [SerializeField] ToggleEx togTab0; |
| | | [SerializeField] RedpointBehaviour rpTab0; |
| | | [SerializeField] ToggleEx togTab1; |
| | | [SerializeField] RedpointBehaviour rpTab1; |
| | | [SerializeField] Transform transNoMail; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | protected override void InitComponent() |
| | | { |
| | | [SerializeField] Transform transPersonal; |
| | | [SerializeField] Transform transGlobal; |
| | | [SerializeField] ScrollerController scrPersonal; |
| | | [SerializeField] ScrollerController scrGlobal; |
| | | [SerializeField] ButtonEx btnDeleteRead; |
| | | [SerializeField] ButtonEx btnClaimAll; |
| | | [SerializeField] ToggleEx togTab0; |
| | | [SerializeField] RedpointBehaviour rpTab0; |
| | | [SerializeField] ToggleEx togTab1; |
| | | [SerializeField] RedpointBehaviour rpTab1; |
| | | [SerializeField] Transform transNoMail; |
| | | MailManager model { get { return MailManager.Instance; } } |
| | | protected override void InitComponent() |
| | | { |
| | | base.InitComponent(); |
| | | btnDeleteRead.SetListener(OnDeleteRead); |
| | | btnClaimAll.SetListener(OnClaimAll); |
| | | togTab0.SetListener(OnTab0); |
| | | togTab1.SetListener(OnTab1); |
| | | } |
| | | base.InitComponent(); |
| | | btnDeleteRead.SetListener(OnDeleteRead); |
| | | btnClaimAll.SetListener(OnClaimAll); |
| | | togTab0.SetListener(OnTab0); |
| | | togTab1.SetListener(OnTab1); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | model.OnUpdateMailListEvent += OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent += OnUpdateMailStateChangeEvent; |
| | | scrPersonal.OnRefreshCell += OnRefreshPersonalCell; |
| | | scrGlobal.OnRefreshCell += OnRefreshGlobalCell; |
| | | protected override void OnPreOpen() |
| | | { |
| | | model.OnUpdateMailListEvent += OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent += OnUpdateMailStateChangeEvent; |
| | | scrPersonal.OnRefreshCell += OnRefreshPersonalCell; |
| | | scrGlobal.OnRefreshCell += OnRefreshGlobalCell; |
| | | |
| | | rpTab0.redpointId = model.GetTabRedpointId(MailCategory.Personal); |
| | | rpTab1.redpointId = model.GetTabRedpointId(MailCategory.Global); |
| | | transNoMail.SetActive(false); |
| | | } |
| | | rpTab0.redpointId = model.GetTabRedpointId(MailCategory.Personal); |
| | | rpTab1.redpointId = model.GetTabRedpointId(MailCategory.Global); |
| | | transNoMail.SetActive(false); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | model.OnUpdateMailListEvent -= OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent -= OnUpdateMailStateChangeEvent; |
| | | scrPersonal.OnRefreshCell -= OnRefreshPersonalCell; |
| | | scrGlobal.OnRefreshCell -= OnRefreshGlobalCell; |
| | | } |
| | | protected override void OnPreClose() |
| | | { |
| | | model.OnUpdateMailListEvent -= OnUpdateMailListEvent; |
| | | model.OnUpdateMailStateChangeEvent -= OnUpdateMailStateChangeEvent; |
| | | scrPersonal.OnRefreshCell -= OnRefreshPersonalCell; |
| | | scrGlobal.OnRefreshCell -= OnRefreshGlobalCell; |
| | | } |
| | | |
| | | private void OnTab0(bool value) |
| | | private void OnTab0(bool value) |
| | | { |
| | | if (value) |
| | | { |
| | | if (value) |
| | | { |
| | | transPersonal.SetActive(true); |
| | | transGlobal.SetActive(false); |
| | | model.nowMailCategory = MailCategory.Personal; |
| | | CreatePersonalScr(model.nowMailCategory); |
| | | } |
| | | } |
| | | |
| | | private void OnTab1(bool value) |
| | | { |
| | | if (value) |
| | | { |
| | | transPersonal.SetActive(false); |
| | | transGlobal.SetActive(true); |
| | | model.nowMailCategory = MailCategory.Global; |
| | | CreateGlobalScr(model.nowMailCategory); |
| | | } |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | | { |
| | | togTab0.isOn = true; |
| | | togTab1.isOn = false; |
| | | transPersonal.SetActive(true); |
| | | transGlobal.SetActive(false); |
| | | model.nowMailCategory = MailCategory.Personal; |
| | | CreatePersonalScr(model.nowMailCategory); |
| | | } |
| | | } |
| | | |
| | | private void OnRefreshPersonalCell(ScrollerDataType type, CellView cell) |
| | | private void OnTab1(bool value) |
| | | { |
| | | if (value) |
| | | { |
| | | var _cell = cell.GetComponent<MailPersonalCell>(); |
| | | _cell?.Display(cell.index, cell); |
| | | transPersonal.SetActive(false); |
| | | transGlobal.SetActive(true); |
| | | model.nowMailCategory = MailCategory.Global; |
| | | CreateGlobalScr(model.nowMailCategory); |
| | | } |
| | | } |
| | | |
| | | private void OnRefreshGlobalCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell.GetComponent<MailGlobalCell>(); |
| | | _cell?.Display(cell.index, cell); |
| | | } |
| | | protected override void OnOpen() |
| | | { |
| | | togTab0.isOn = true; |
| | | togTab1.isOn = false; |
| | | model.nowMailCategory = MailCategory.Personal; |
| | | CreatePersonalScr(model.nowMailCategory); |
| | | } |
| | | |
| | | private void OnDeleteRead() |
| | | { |
| | | ConfirmCancel.ShowPopConfirm( |
| | | Language.Get("Mail101"), |
| | | Language.Get("Mail10"), |
| | | (bool isOk) => |
| | | { |
| | | if (isOk) |
| | | { |
| | | model.DeleteMail(); |
| | | //邮件删除成功 |
| | | SysNotifyMgr.Instance.ShowTip("Mail01"); |
| | | } |
| | | }); |
| | | } |
| | | private void OnRefreshPersonalCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell.GetComponent<MailPersonalCell>(); |
| | | _cell?.Display(cell.index, cell); |
| | | } |
| | | |
| | | private void OnClaimAll() |
| | | { |
| | | if (!model.IsCanHaveMail()) |
| | | private void OnRefreshGlobalCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell.GetComponent<MailGlobalCell>(); |
| | | _cell?.Display(cell.index, cell); |
| | | } |
| | | |
| | | private void OnDeleteRead() |
| | | { |
| | | ConfirmCancel.ShowPopConfirm( |
| | | Language.Get("Mail101"), |
| | | Language.Get("Mail10"), |
| | | (bool isOk) => |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("Mail02"); |
| | | return; |
| | | } |
| | | model.ClaimMail(); |
| | | } |
| | | |
| | | public void CreatePersonalScr(MailCategory mailCategory) |
| | | { |
| | | scrPersonal.Refresh(); |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | if (list != null) |
| | | { |
| | | for (int i = 0; i < list.Count; i++) |
| | | if (isOk) |
| | | { |
| | | CellInfo cellInfo = new CellInfo(); |
| | | cellInfo.infoInt1 = (int)mailCategory; |
| | | scrPersonal.AddCell(ScrollerDataType.Header, i, cellInfo); |
| | | model.DeleteMail(); |
| | | //邮件删除成功 |
| | | SysNotifyMgr.Instance.ShowTip("Mail01"); |
| | | } |
| | | } |
| | | scrPersonal.Restart(); |
| | | } |
| | | public void CreateGlobalScr(MailCategory mailCategory) |
| | | { |
| | | scrGlobal.Refresh(); |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | if (list != null) |
| | | { |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | CellInfo cellInfo = new CellInfo(); |
| | | cellInfo.infoInt1 = (int)mailCategory; |
| | | scrGlobal.AddCell(ScrollerDataType.Header, i, cellInfo); |
| | | } |
| | | } |
| | | scrGlobal.Restart(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void OnUpdateMailStateChangeEvent() |
| | | private void OnClaimAll() |
| | | { |
| | | if (!model.IsCanHaveMail()) |
| | | { |
| | | RefreshScr(); |
| | | SysNotifyMgr.Instance.ShowTip("Mail02"); |
| | | return; |
| | | } |
| | | model.ClaimMail(); |
| | | } |
| | | |
| | | private void OnUpdateMailListEvent() |
| | | public void CreatePersonalScr(MailCategory mailCategory) |
| | | { |
| | | scrPersonal.Refresh(); |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | if (list != null) |
| | | { |
| | | RefreshScr(); |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | CellInfo cellInfo = new CellInfo(); |
| | | cellInfo.infoInt1 = (int)mailCategory; |
| | | scrPersonal.AddCell(ScrollerDataType.Header, i, cellInfo); |
| | | } |
| | | } |
| | | scrPersonal.Restart(); |
| | | } |
| | | public void CreateGlobalScr(MailCategory mailCategory) |
| | | { |
| | | scrGlobal.Refresh(); |
| | | var list = model.GetSortMailScrList(mailCategory); |
| | | if (list != null) |
| | | { |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | CellInfo cellInfo = new CellInfo(); |
| | | cellInfo.infoInt1 = (int)mailCategory; |
| | | scrGlobal.AddCell(ScrollerDataType.Header, i, cellInfo); |
| | | } |
| | | } |
| | | scrGlobal.Restart(); |
| | | } |
| | | |
| | | private void RefreshScr() |
| | | { |
| | | var list = model.GetSortMailScrList(model.nowMailCategory); |
| | | if (list.IsNullOrEmpty()) |
| | | { |
| | | transNoMail.SetActive(true); |
| | | } |
| | | else |
| | | { |
| | | transNoMail.SetActive(false); |
| | | scrPersonal.m_Scorller.RefreshActiveCellViews(); |
| | | scrGlobal.m_Scorller.RefreshActiveCellViews(); |
| | | } |
| | | private void OnUpdateMailStateChangeEvent() |
| | | { |
| | | RefreshScr(); |
| | | } |
| | | |
| | | private void OnUpdateMailListEvent() |
| | | { |
| | | RefreshScr(); |
| | | } |
| | | |
| | | private void RefreshScr() |
| | | { |
| | | var list = model.GetSortMailScrList(model.nowMailCategory); |
| | | if (list.IsNullOrEmpty()) |
| | | { |
| | | transNoMail.SetActive(true); |
| | | } |
| | | else |
| | | { |
| | | transNoMail.SetActive(false); |
| | | scrPersonal.m_Scorller.RefreshActiveCellViews(); |
| | | scrGlobal.m_Scorller.RefreshActiveCellViews(); |
| | | } |
| | | } |
| | | } |
| | |
| | | using vnxbqy.UI; |
| | | using System; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | |
| | | using vnxbqy.UI; |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | |
| | | using vnxbqy.UI; |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | |
| | |
| | | using vnxbqy.UI; |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | |
| | | using UnityEngine; |
| | |
| | | // using System; |
| | | // using System.Collections; |
| | | // using System.Collections.Generic; |
| | | // using UnityEngine; |
| | | // namespace vnxbqy.UI |
| | | // { |
| | | // public static class RichViewItemUtility |
| | | // { |
| | | // static string s_CacheUserData = string.Empty; |
| | | |
| | | // static EquipGemModel equipGemModel { get { return ModelCenter.Instance.GetModel<EquipGemModel>(); } } |
| | | |
| | | // public static void DisplayItem(int itemId, ItemTipUtility.CustomItemPlus itemplus) |
| | | // { |
| | | // if (ItemLogicUtility.Instance.IsRealmEquip(itemId) && itemplus.Preview != 1) |
| | | // { |
| | | // var itemConfig = ItemConfig.Get(itemId); |
| | | // Dictionary<int, int> gems = new Dictionary<int, int>(); |
| | | // Dictionary<int, bool> gemHoleActiveStates = new Dictionary<int, bool>(); |
| | | // if (itemplus.Stone != null) |
| | | // { |
| | | // for (int i = 0; i < itemplus.Stone.Length; i++) |
| | | // { |
| | | // gems.Add(i, itemplus.Stone[i]); |
| | | // if (i == 3) |
| | | // { |
| | | // gemHoleActiveStates.Add(i, itemplus.Stone[i] != 0); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // for (int i = 0; i < EquipGemModel.EQUIPGEM_HOLE_COUNT; i++) |
| | | // { |
| | | // if (i < 3) |
| | | // { |
| | | // gemHoleActiveStates.Add(i, equipGemModel.IsGemHoleOpen(i, itemplus.Star)); |
| | | // } |
| | | // } |
| | | |
| | | // var legendProperties = new List<Int2>(); |
| | | // var equipSkillList = new List<int>(); |
| | | // Dictionary<int, List<int>> useDataDict = null; |
| | | // if (!string.IsNullOrEmpty(itemplus.UserData)) |
| | | // { |
| | | // useDataDict = ConfigParse.Analysis(itemplus.UserData); |
| | | // if (useDataDict != null) |
| | | // { |
| | | // if(useDataDict.ContainsKey((int)ItemUseDataKey.legendAttrID) && useDataDict.ContainsKey((int)ItemUseDataKey.legendAttrValue)) |
| | | // { |
| | | // var count = Mathf.Min(useDataDict[(int)ItemUseDataKey.legendAttrID].Count, useDataDict[(int)ItemUseDataKey.legendAttrValue].Count); |
| | | // for (int i = 0; i < count; i++) |
| | | // { |
| | | // legendProperties.Add(new Int2(useDataDict[(int)ItemUseDataKey.legendAttrID][i], useDataDict[(int)ItemUseDataKey.legendAttrValue][i])); |
| | | // } |
| | | // } |
| | | // if (useDataDict.ContainsKey((int)ItemUseDataKey.equipSkills)) |
| | | // { |
| | | // equipSkillList = useDataDict[(int)ItemUseDataKey.equipSkills]; |
| | | // } |
| | | |
| | | // } |
| | | // } |
| | | |
| | | // List<Int2> trainProperties = new List<Int2>(); |
| | | // if (!itemplus.Wash.Equals(default(ItemTipUtility.CustomEquipWash))) |
| | | // { |
| | | // var washType = EquipTrainModel.GetTrainType(itemConfig.EquipPlace); |
| | | // var trainConfig = EquipWashConfig.Get(washType, 1); |
| | | // for (int i = 0; i < itemplus.Wash.Value.Length; i++) |
| | | // { |
| | | // var propertyType = i == 0 ? trainConfig.config.attType1 : i == 1 ? |
| | | // trainConfig.config.attType2 : trainConfig.config.attType3; |
| | | // trainProperties.Add(new Int2(propertyType, itemplus.Wash.Value[i])); |
| | | // } |
| | | // } |
| | | |
| | | // Dictionary<EquipSuitType, int> suitLevels = new Dictionary<EquipSuitType, int>(); |
| | | // suitLevels.Add(EquipSuitType.TwoSuit, -1); |
| | | // suitLevels.Add(EquipSuitType.FiveSuit, -1); |
| | | // suitLevels.Add(EquipSuitType.EightSuit, -1); |
| | | |
| | | // List<int> suitplaces = new List<int>(); |
| | | |
| | | // Dictionary<int, int> placeStars = new Dictionary<int, int>(); |
| | | // for (int i = 1; i <= 8; i++) |
| | | // { |
| | | // placeStars.Add(i, -1); |
| | | // } |
| | | |
| | | // if (itemplus.placeStars != null) |
| | | // { |
| | | // for (int i = 0; i < itemplus.placeStars.Length; i++) |
| | | // { |
| | | // placeStars[i + 1] = itemplus.placeStars[i]; |
| | | // } |
| | | // } |
| | | |
| | | // if (itemplus.suitPlaces != null && itemplus.suitLevels != null) |
| | | // { |
| | | // suitplaces.AddRange(itemplus.suitPlaces); |
| | | // suitLevels[EquipSuitType.TwoSuit] = itemplus.suitLevels[0]; |
| | | // suitLevels[EquipSuitType.FiveSuit] = itemplus.suitLevels[1]; |
| | | // suitLevels[EquipSuitType.EightSuit] = itemplus.suitLevels[2]; |
| | | // } |
| | | // else if (itemplus.Equips != null) |
| | | // { |
| | | // var stars = new List<int>(); |
| | | // for (int i = 0; i < itemplus.Equips.Length; i++) |
| | | // { |
| | | // var array = itemplus.Equips[i]; |
| | | // var config = ItemConfig.Get(array[0]); |
| | | // if (config.EquipPlace > 8) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // stars.Add(array[1]); |
| | | |
| | | // placeStars[config.EquipPlace] = array[1]; |
| | | |
| | | // if (config.SuiteiD > 0) |
| | | // { |
| | | // suitplaces.Add(config.EquipPlace); |
| | | // } |
| | | // } |
| | | |
| | | // stars.Sort((int x, int y) => { return -x.CompareTo(y); }); |
| | | |
| | | // var twoSuitLevel = (suitplaces.Count > 1 && stars.Count > 1) ? stars[1] : -1; |
| | | // var fiveSuitLevel = (suitplaces.Count > 4 && stars.Count > 4) ? stars[4] : -1; |
| | | // var eightSuitLevel = (suitplaces.Count > 7 && stars.Count > 7) ? stars[7] : -1; |
| | | |
| | | // suitLevels[EquipSuitType.TwoSuit] = twoSuitLevel; |
| | | // suitLevels[EquipSuitType.FiveSuit] = fiveSuitLevel; |
| | | // suitLevels[EquipSuitType.EightSuit] = eightSuitLevel; |
| | | // } |
| | | |
| | | // ItemTipUtility.ShowCustomEquip(new ItemTipUtility.CustomEquipInfo() |
| | | // { |
| | | // itemId = itemId, |
| | | // job = itemConfig.JobLimit, |
| | | // strengthenLevel = itemplus.PlusLV, |
| | | // starLevel = itemplus.Star, |
| | | // gems = gems, |
| | | // legendProperties = legendProperties, |
| | | // score = ItemLogicUtility.Instance.GetEquipScore(itemId, useDataDict, true), |
| | | // gemHoleActiveStates = gemHoleActiveStates, |
| | | // suitLevels = suitLevels, |
| | | // suitPlaces = suitplaces, |
| | | // trainProperties = trainProperties, |
| | | // isEquiped = itemplus.Equipped == 1, |
| | | // placeStars = placeStars, |
| | | // equipSkillList = equipSkillList, |
| | | // }); |
| | | // } |
| | | // else |
| | | // { |
| | | // ItemTipUtility.Show(itemId); |
| | | // } |
| | | // } |
| | | |
| | | // public static void SendViewNotifyItem(string guid, string userdata) |
| | | // { |
| | | // s_CacheUserData = userdata; |
| | | // var pak = new CA905_tagCGQueryNotifyEquipDetailInfo(); |
| | | // pak.ItemGUID = guid; |
| | | // GameNetSystem.Instance.SendInfo(pak); |
| | | // } |
| | | |
| | | // public static void ReceivePackage(HA905_tagGCNotifyEquipDetailInfo package) |
| | | // { |
| | | // List<int[]> equips = null; |
| | | // if (package.ClassEquipCount > 0) |
| | | // { |
| | | // equips = new List<int[]>(); |
| | | // foreach (var equip in package.ClassEquipList) |
| | | // { |
| | | // equips.Add(new int[2] |
| | | // { |
| | | // (int)equip.ItemID, |
| | | // equip.Star, |
| | | // }); |
| | | // } |
| | | // } |
| | | |
| | | // ItemTipUtility.CustomItemPlus itemplus = new ItemTipUtility.CustomItemPlus() |
| | | // { |
| | | // ItemID = (int)package.ItemID, |
| | | // count = 1, |
| | | // Star = package.Star, |
| | | // PlusLV = package.PlusLV, |
| | | // EvolveLV = package.EvolveLV, |
| | | // Wash = new ItemTipUtility.CustomEquipWash() |
| | | // { |
| | | // LV = package.WashLV, |
| | | // Value = new int[3] |
| | | // { |
| | | // 0<package.WashValueList.Length?(int)package.WashValueList[0]:0, |
| | | // 1<package.WashValueList.Length?(int)package.WashValueList[1]:0, |
| | | // 2<package.WashValueList.Length?(int)package.WashValueList[2]:0, |
| | | // }, |
| | | // }, |
| | | // Equipped = 1, |
| | | // Stone = new int[4] |
| | | // { |
| | | // 0<package.StoneIDList.Length?(int)package.StoneIDList[0]:0, |
| | | // 1<package.StoneIDList.Length?(int)package.StoneIDList[1]:0, |
| | | // 2<package.StoneIDList.Length?(int)package.StoneIDList[2]:0, |
| | | // 3<package.StoneIDList.Length?(int)package.StoneIDList[3]:0, |
| | | // }, |
| | | // UserData = s_CacheUserData, |
| | | // Equips = equips == null ? null : equips.ToArray(), |
| | | // }; |
| | | |
| | | // DisplayItem((int)itemplus.ItemID, itemplus); |
| | | // } |
| | | // } |
| | | // } |
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using UnityEngine;
|
| | | //public static class RichViewItemUtility
|
| | | //{
|
| | | // static string s_CacheUserData = string.Empty;
|
| | |
|
| | | // static EquipGemModel equipGemModel { get { return ModelCenter.Instance.GetModel<EquipGemModel>(); } }
|
| | |
|
| | | // public static void DisplayItem(int itemId, ItemTipUtility.CustomItemPlus itemplus)
|
| | | // {
|
| | | // if (ItemLogicUtility.Instance.IsRealmEquip(itemId) && itemplus.Preview != 1)
|
| | | // {
|
| | | // var itemConfig = ItemConfig.Get(itemId);
|
| | | // Dictionary<int, int> gems = new Dictionary<int, int>();
|
| | | // Dictionary<int, bool> gemHoleActiveStates = new Dictionary<int, bool>();
|
| | | // if (itemplus.Stone != null)
|
| | | // {
|
| | | // for (int i = 0; i < itemplus.Stone.Length; i++)
|
| | | // {
|
| | | // gems.Add(i, itemplus.Stone[i]);
|
| | | // if (i == 3)
|
| | | // {
|
| | | // gemHoleActiveStates.Add(i, itemplus.Stone[i] != 0);
|
| | | // }
|
| | | // }
|
| | | // }
|
| | |
|
| | | // for (int i = 0; i < EquipGemModel.EQUIPGEM_HOLE_COUNT; i++)
|
| | | // {
|
| | | // if (i < 3)
|
| | | // {
|
| | | // gemHoleActiveStates.Add(i, equipGemModel.IsGemHoleOpen(i, itemplus.Star));
|
| | | // }
|
| | | // }
|
| | |
|
| | | // var legendProperties = new List<Int2>();
|
| | | // var equipSkillList = new List<int>();
|
| | | // Dictionary<int, List<int>> useDataDict = null;
|
| | | // if (!string.IsNullOrEmpty(itemplus.UserData))
|
| | | // {
|
| | | // useDataDict = ConfigParse.Analysis(itemplus.UserData);
|
| | | // if (useDataDict != null)
|
| | | // {
|
| | | // if (useDataDict.ContainsKey((int)ItemUseDataKey.legendAttrID) && useDataDict.ContainsKey((int)ItemUseDataKey.legendAttrValue))
|
| | | // {
|
| | | // var count = Mathf.Min(useDataDict[(int)ItemUseDataKey.legendAttrID].Count, useDataDict[(int)ItemUseDataKey.legendAttrValue].Count);
|
| | | // for (int i = 0; i < count; i++)
|
| | | // {
|
| | | // legendProperties.Add(new Int2(useDataDict[(int)ItemUseDataKey.legendAttrID][i], useDataDict[(int)ItemUseDataKey.legendAttrValue][i]));
|
| | | // }
|
| | | // }
|
| | | // if (useDataDict.ContainsKey((int)ItemUseDataKey.equipSkills))
|
| | | // {
|
| | | // equipSkillList = useDataDict[(int)ItemUseDataKey.equipSkills];
|
| | | // }
|
| | |
|
| | | // }
|
| | | // }
|
| | |
|
| | | // List<Int2> trainProperties = new List<Int2>();
|
| | | // if (!itemplus.Wash.Equals(default(ItemTipUtility.CustomEquipWash)))
|
| | | // {
|
| | | // var washType = EquipTrainModel.GetTrainType(itemConfig.EquipPlace);
|
| | | // var trainConfig = EquipWashConfig.Get(washType, 1);
|
| | | // for (int i = 0; i < itemplus.Wash.Value.Length; i++)
|
| | | // {
|
| | | // var propertyType = i == 0 ? trainConfig.config.attType1 : i == 1 ?
|
| | | // trainConfig.config.attType2 : trainConfig.config.attType3;
|
| | | // trainProperties.Add(new Int2(propertyType, itemplus.Wash.Value[i]));
|
| | | // }
|
| | | // }
|
| | |
|
| | | // Dictionary<EquipSuitType, int> suitLevels = new Dictionary<EquipSuitType, int>();
|
| | | // suitLevels.Add(EquipSuitType.TwoSuit, -1);
|
| | | // suitLevels.Add(EquipSuitType.FiveSuit, -1);
|
| | | // suitLevels.Add(EquipSuitType.EightSuit, -1);
|
| | |
|
| | | // List<int> suitplaces = new List<int>();
|
| | |
|
| | | // Dictionary<int, int> placeStars = new Dictionary<int, int>();
|
| | | // for (int i = 1; i <= 8; i++)
|
| | | // {
|
| | | // placeStars.Add(i, -1);
|
| | | // }
|
| | |
|
| | | // if (itemplus.placeStars != null)
|
| | | // {
|
| | | // for (int i = 0; i < itemplus.placeStars.Length; i++)
|
| | | // {
|
| | | // placeStars[i + 1] = itemplus.placeStars[i];
|
| | | // }
|
| | | // }
|
| | |
|
| | | // if (itemplus.suitPlaces != null && itemplus.suitLevels != null)
|
| | | // {
|
| | | // suitplaces.AddRange(itemplus.suitPlaces);
|
| | | // suitLevels[EquipSuitType.TwoSuit] = itemplus.suitLevels[0];
|
| | | // suitLevels[EquipSuitType.FiveSuit] = itemplus.suitLevels[1];
|
| | | // suitLevels[EquipSuitType.EightSuit] = itemplus.suitLevels[2];
|
| | | // }
|
| | | // else if (itemplus.Equips != null)
|
| | | // {
|
| | | // var stars = new List<int>();
|
| | | // for (int i = 0; i < itemplus.Equips.Length; i++)
|
| | | // {
|
| | | // var array = itemplus.Equips[i];
|
| | | // var config = ItemConfig.Get(array[0]);
|
| | | // if (config.EquipPlace > 8)
|
| | | // {
|
| | | // continue;
|
| | | // }
|
| | | // stars.Add(array[1]);
|
| | |
|
| | | // placeStars[config.EquipPlace] = array[1];
|
| | |
|
| | | // if (config.SuiteiD > 0)
|
| | | // {
|
| | | // suitplaces.Add(config.EquipPlace);
|
| | | // }
|
| | | // }
|
| | |
|
| | | // stars.Sort((int x, int y) => { return -x.CompareTo(y); });
|
| | |
|
| | | // var twoSuitLevel = (suitplaces.Count > 1 && stars.Count > 1) ? stars[1] : -1;
|
| | | // var fiveSuitLevel = (suitplaces.Count > 4 && stars.Count > 4) ? stars[4] : -1;
|
| | | // var eightSuitLevel = (suitplaces.Count > 7 && stars.Count > 7) ? stars[7] : -1;
|
| | |
|
| | | // suitLevels[EquipSuitType.TwoSuit] = twoSuitLevel;
|
| | | // suitLevels[EquipSuitType.FiveSuit] = fiveSuitLevel;
|
| | | // suitLevels[EquipSuitType.EightSuit] = eightSuitLevel;
|
| | | // }
|
| | |
|
| | | // ItemTipUtility.ShowCustomEquip(new ItemTipUtility.CustomEquipInfo()
|
| | | // {
|
| | | // itemId = itemId,
|
| | | // job = itemConfig.JobLimit,
|
| | | // strengthenLevel = itemplus.PlusLV,
|
| | | // starLevel = itemplus.Star,
|
| | | // gems = gems,
|
| | | // legendProperties = legendProperties,
|
| | | // score = ItemLogicUtility.Instance.GetEquipScore(itemId, useDataDict, true),
|
| | | // gemHoleActiveStates = gemHoleActiveStates,
|
| | | // suitLevels = suitLevels,
|
| | | // suitPlaces = suitplaces,
|
| | | // trainProperties = trainProperties,
|
| | | // isEquiped = itemplus.Equipped == 1,
|
| | | // placeStars = placeStars,
|
| | | // equipSkillList = equipSkillList,
|
| | | // });
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // ItemTipUtility.Show(itemId);
|
| | | // }
|
| | | // }
|
| | |
|
| | | // public static void SendViewNotifyItem(string guid, string userdata)
|
| | | // {
|
| | | // s_CacheUserData = userdata;
|
| | | // var pak = new CA905_tagCGQueryNotifyEquipDetailInfo();
|
| | | // pak.ItemGUID = guid;
|
| | | // GameNetSystem.Instance.SendInfo(pak);
|
| | | // }
|
| | |
|
| | | // public static void ReceivePackage(HA905_tagGCNotifyEquipDetailInfo package)
|
| | | // {
|
| | | // List<int[]> equips = null;
|
| | | // if (package.ClassEquipCount > 0)
|
| | | // {
|
| | | // equips = new List<int[]>();
|
| | | // foreach (var equip in package.ClassEquipList)
|
| | | // {
|
| | | // equips.Add(new int[2]
|
| | | // { |
| | | // (int)equip.ItemID, |
| | | // equip.Star,
|
| | | // });
|
| | | // }
|
| | | // }
|
| | |
|
| | | // ItemTipUtility.CustomItemPlus itemplus = new ItemTipUtility.CustomItemPlus()
|
| | | // {
|
| | | // ItemID = (int)package.ItemID,
|
| | | // count = 1,
|
| | | // Star = package.Star,
|
| | | // PlusLV = package.PlusLV,
|
| | | // EvolveLV = package.EvolveLV,
|
| | | // Wash = new ItemTipUtility.CustomEquipWash()
|
| | | // {
|
| | | // LV = package.WashLV,
|
| | | // Value = new int[3]
|
| | | // { |
| | | // 0<package.WashValueList.Length?(int)package.WashValueList[0]:0, |
| | | // 1<package.WashValueList.Length?(int)package.WashValueList[1]:0, |
| | | // 2<package.WashValueList.Length?(int)package.WashValueList[2]:0,
|
| | | // },
|
| | | // },
|
| | | // Equipped = 1,
|
| | | // Stone = new int[4]
|
| | | // { |
| | | // 0<package.StoneIDList.Length?(int)package.StoneIDList[0]:0, |
| | | // 1<package.StoneIDList.Length?(int)package.StoneIDList[1]:0, |
| | | // 2<package.StoneIDList.Length?(int)package.StoneIDList[2]:0, |
| | | // 3<package.StoneIDList.Length?(int)package.StoneIDList[3]:0,
|
| | | // },
|
| | | // UserData = s_CacheUserData,
|
| | | // Equips = equips == null ? null : equips.ToArray(),
|
| | | // };
|
| | |
|
| | | // DisplayItem((int)itemplus.ItemID, itemplus);
|
| | | // }
|
| | | //}
|
| | | |
| | |
| | | using vnxbqy.UI; |
| | | using System; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Text.RegularExpressions; |
| | |
| | | using vnxbqy.UI; |
| | | using System; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Text.RegularExpressions; |
| | |
| | | using UnityEngine.UI; |
| | | using UnityEngine.EventSystems; |
| | | using System; |
| | | namespace vnxbqy.UI |
| | | |
| | | public class FlipScroll : MaskableGraphic, IBeginDragHandler, IEndDragHandler, IDragHandler |
| | | { |
| | | public class FlipScroll : MaskableGraphic, IBeginDragHandler, IEndDragHandler, IDragHandler |
| | | public enum FlipDirEnum |
| | | { |
| | | public enum FlipDirEnum |
| | | { |
| | | Horizon, |
| | | Vertical, |
| | | Horizon, |
| | | Vertical, |
| | | } |
| | | private int page = 0; |
| | | /// <summary> |
| | | /// 当前页 |
| | | /// </summary> |
| | | public int Page { |
| | | get { return page; } |
| | | } |
| | | [SerializeField] |
| | | private FlipDirEnum flipType = FlipDirEnum.Horizon; |
| | | public FlipDirEnum FlipType { |
| | | get { |
| | | return flipType; |
| | | } |
| | | private int page = 0; |
| | | /// <summary> |
| | | /// 当前页 |
| | | /// </summary> |
| | | public int Page { |
| | | get { return page; } |
| | | set { |
| | | flipType = value; |
| | | } |
| | | [SerializeField] |
| | | private FlipDirEnum flipType = FlipDirEnum.Horizon; |
| | | public FlipDirEnum FlipType { |
| | | get { |
| | | return flipType; |
| | | } |
| | | [SerializeField] |
| | | private bool m_Loop = false; |
| | | public bool loop { |
| | | get { |
| | | return m_Loop; |
| | | } |
| | | set { |
| | | m_Loop = value; |
| | | } |
| | | } |
| | | |
| | | [SerializeField] |
| | | private TweenType _tweenType = TweenType.Linear; |
| | | public TweenType tweenType { |
| | | get { return _tweenType; } |
| | | set { _tweenType = value; } |
| | | } |
| | | [SerializeField] |
| | | private float sensitive = 5.0f; |
| | | |
| | | public float Sensitive { |
| | | get { return sensitive; } |
| | | set { sensitive = value; } |
| | | } |
| | | [SerializeField] |
| | | public bool resetOnEnable = true; |
| | | |
| | | private bool tweening = false; |
| | | public bool IsTweening { get { return tweening; } } |
| | | [SerializeField] |
| | | private float _tweenTime = 1.0f; |
| | | public float TweenTime { |
| | | get { return _tweenTime; } |
| | | set { _tweenTime = value; } |
| | | } |
| | | |
| | | public RectTransform presentRT; |
| | | public RectTransform lastRT; |
| | | |
| | | private RectTransform presentFlipRT; |
| | | private RectTransform lastFlipRT; |
| | | |
| | | public event Action<int, RectTransform> OnRefreshData; |
| | | public event Action OnTweenCompt; |
| | | |
| | | public int pageCnt = 0; |
| | | [HideInInspector] |
| | | public bool locked = false; |
| | | |
| | | protected override void Awake() |
| | | { |
| | | base.Awake(); |
| | | if (presentRT == null || lastRT == null) return; |
| | | presentRT.SetActive(false); |
| | | lastRT.SetActive(false); |
| | | presentFlipRT = presentRT; |
| | | lastFlipRT = lastRT; |
| | | } |
| | | |
| | | protected override void OnEnable() |
| | | { |
| | | base.OnEnable(); |
| | | if (presentRT == null || lastRT == null || pageCnt == 0) return; |
| | | presentRT.SetActive(true); |
| | | lastRT.SetActive(true); |
| | | presentRT.localPosition = Vector3.zero; |
| | | if (resetOnEnable) { |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: |
| | | lastRT.localPosition = rectTransform.localPosition.SetX(rectTransform.sizeDelta.x); |
| | | break; |
| | | case FlipDirEnum.Vertical: |
| | | lastRT.localPosition = rectTransform.localPosition.SetY(-rectTransform.sizeDelta.y); |
| | | break; |
| | | } |
| | | set { |
| | | flipType = value; |
| | | } |
| | | page = 0; |
| | | } |
| | | [SerializeField] |
| | | private bool m_Loop = false; |
| | | public bool loop { |
| | | get { |
| | | return m_Loop; |
| | | } |
| | | set { |
| | | m_Loop = value; |
| | | } |
| | | } |
| | | presentFlipRT = presentRT; |
| | | lastFlipRT = lastRT; |
| | | RefreshActive(); |
| | | } |
| | | |
| | | [SerializeField] |
| | | private TweenType _tweenType = TweenType.Linear; |
| | | public TweenType tweenType { |
| | | get { return _tweenType; } |
| | | set { _tweenType = value; } |
| | | } |
| | | [SerializeField] |
| | | private float sensitive = 5.0f; |
| | | private Vector2 lastPos = Vector2.zero; |
| | | public void OnBeginDrag(PointerEventData eventData) |
| | | { |
| | | lastPos = eventData.position; |
| | | } |
| | | |
| | | public float Sensitive { |
| | | get { return sensitive; } |
| | | set { sensitive = value; } |
| | | } |
| | | [SerializeField] |
| | | public bool resetOnEnable = true; |
| | | |
| | | private bool tweening = false; |
| | | public bool IsTweening { get { return tweening; } } |
| | | [SerializeField] |
| | | private float _tweenTime = 1.0f; |
| | | public float TweenTime { |
| | | get { return _tweenTime; } |
| | | set { _tweenTime = value; } |
| | | } |
| | | |
| | | public RectTransform presentRT; |
| | | public RectTransform lastRT; |
| | | |
| | | private RectTransform presentFlipRT; |
| | | private RectTransform lastFlipRT; |
| | | |
| | | public event Action<int, RectTransform> OnRefreshData; |
| | | public event Action OnTweenCompt; |
| | | |
| | | public int pageCnt = 0; |
| | | [HideInInspector] |
| | | public bool locked = false; |
| | | |
| | | protected override void Awake() |
| | | { |
| | | base.Awake(); |
| | | if (presentRT == null || lastRT == null) return; |
| | | presentRT.SetActive(false); |
| | | lastRT.SetActive(false); |
| | | presentFlipRT = presentRT; |
| | | lastFlipRT = lastRT; |
| | | } |
| | | |
| | | protected override void OnEnable() |
| | | { |
| | | base.OnEnable(); |
| | | if (presentRT == null || lastRT == null || pageCnt == 0) return; |
| | | presentRT.SetActive(true); |
| | | lastRT.SetActive(true); |
| | | presentRT.localPosition = Vector3.zero; |
| | | if (resetOnEnable) { |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: |
| | | lastRT.localPosition = rectTransform.localPosition.SetX(rectTransform.sizeDelta.x); |
| | | break; |
| | | case FlipDirEnum.Vertical: |
| | | lastRT.localPosition = rectTransform.localPosition.SetY(-rectTransform.sizeDelta.y); |
| | | break; |
| | | public void OnEndDrag(PointerEventData eventData) |
| | | { |
| | | if (IsTweening || locked) return; |
| | | Vector2 nPos = lastPos - eventData.position; |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: { |
| | | if (Math.Abs(nPos.x) < sensitive) return; |
| | | if (nPos.x > 0) { |
| | | FlipRight(); |
| | | } |
| | | else { |
| | | FlipLeft(); |
| | | } |
| | | } |
| | | break; |
| | | case FlipDirEnum.Vertical: { |
| | | if (Math.Abs(nPos.y) < sensitive) return; |
| | | Vector3 pos = Vector3.zero; |
| | | if (nPos.y < 0) { |
| | | FlipLeft(); |
| | | } |
| | | else { |
| | | FlipRight(); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | protected override void OnDisable() |
| | | { |
| | | tweening = false; |
| | | StopAllCoroutines(); |
| | | base.OnDisable(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | IEnumerator TweenPosition(Vector3 lPos, Vector3 nPos, Vector3 lastRtPos) |
| | | { |
| | | float time = 0; |
| | | Vector3 newPresentPos = Vector3.zero; |
| | | Vector3 newLastPos = Vector3.zero; |
| | | bool InView = false; |
| | | tweening = true; |
| | | while (time < _tweenTime) { |
| | | float per = 0; |
| | | switch (tweenType) { |
| | | case TweenType.Immediate: per = 1; break; |
| | | case TweenType.Linear: per = Linear(time / _tweenTime); break; |
| | | case TweenType.Smooth: per = Smooth(time / _tweenTime); break; |
| | | } |
| | | newPresentPos = Vector3.Lerp(lPos, nPos, per); |
| | | newLastPos = Vector3.Lerp(lastRtPos, Vector3.zero, per); |
| | | presentFlipRT.localPosition = newPresentPos; |
| | | lastFlipRT.localPosition = newLastPos; |
| | | time += Time.unscaledDeltaTime; |
| | | if (!InView) { |
| | | InView = InViewSide(); |
| | | } |
| | | if (tweenType == TweenType.Immediate) { |
| | | break; |
| | | } |
| | | yield return null; |
| | | } |
| | | tweening = false; |
| | | presentFlipRT.localPosition = nPos; |
| | | lastFlipRT.localPosition = Vector3.zero; |
| | | RectTransform temp = presentFlipRT; |
| | | presentFlipRT = lastFlipRT; |
| | | lastFlipRT = temp; |
| | | if (OnTweenCompt != null) OnTweenCompt(); |
| | | } |
| | | |
| | | public bool InViewSide() |
| | | { |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: { |
| | | if (Vector3.Distance(Vector3.zero, lastFlipRT.localPosition) < lastFlipRT.sizeDelta.x + rectTransform.sizeDelta.x) { |
| | | if (OnRefreshData != null) { |
| | | lastFlipRT.SetActive(true); |
| | | OnRefreshData(page, lastFlipRT); |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | break; |
| | | case FlipDirEnum.Vertical: { |
| | | if (Vector3.Distance(Vector3.zero, lastFlipRT.localPosition) < lastFlipRT.sizeDelta.y + rectTransform.sizeDelta.y) { |
| | | if (OnRefreshData != null) { |
| | | lastFlipRT.SetActive(true); |
| | | OnRefreshData(page, lastFlipRT); |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private float Linear(float val) |
| | | { |
| | | return Mathf.Lerp(0, 1, val); |
| | | } |
| | | |
| | | private float Smooth(float val) |
| | | { |
| | | float result = Mathf.SmoothStep(0, 1, val); |
| | | result = Mathf.Clamp(result, 0, 1); |
| | | return result; |
| | | } |
| | | |
| | | public void RefreshActive() |
| | | { |
| | | if (pageCnt == 0 || presentFlipRT == null) return; |
| | | if (OnRefreshData != null) { |
| | | presentFlipRT.SetActive(true); |
| | | OnRefreshData(page, presentFlipRT); |
| | | } |
| | | } |
| | | |
| | | public void FlipLeft() |
| | | { |
| | | if (IsTweening || pageCnt == 0) return; |
| | | Vector3 pos = Vector3.zero; |
| | | page--; |
| | | if (page < 0) { |
| | | if (loop) { |
| | | page = pageCnt - 1; |
| | | } |
| | | else { |
| | | page = 0; |
| | | return; |
| | | } |
| | | } |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: { |
| | | lastFlipRT.localPosition = rectTransform.localPosition.SetX(-rectTransform.sizeDelta.x); |
| | | pos = rectTransform.localPosition.SetX(rectTransform.sizeDelta.x); |
| | | } |
| | | break; |
| | | case FlipDirEnum.Vertical: { |
| | | lastFlipRT.localPosition = rectTransform.localPosition.SetY(rectTransform.sizeDelta.y); |
| | | pos = rectTransform.localPosition.SetY(-rectTransform.sizeDelta.y); |
| | | } |
| | | break; |
| | | } |
| | | StartCoroutine(TweenPosition(presentFlipRT.localPosition, pos, lastFlipRT.localPosition)); |
| | | } |
| | | |
| | | public void FlipRight() |
| | | { |
| | | if (IsTweening || pageCnt == 0) return; |
| | | Vector3 pos = Vector3.zero; |
| | | page++; |
| | | if (page >= pageCnt) { |
| | | if (loop) { |
| | | page = 0; |
| | | } |
| | | presentFlipRT = presentRT; |
| | | lastFlipRT = lastRT; |
| | | RefreshActive(); |
| | | } |
| | | |
| | | private Vector2 lastPos = Vector2.zero; |
| | | public void OnBeginDrag(PointerEventData eventData) |
| | | { |
| | | lastPos = eventData.position; |
| | | } |
| | | |
| | | public void OnEndDrag(PointerEventData eventData) |
| | | { |
| | | if (IsTweening || locked) return; |
| | | Vector2 nPos = lastPos - eventData.position; |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: { |
| | | if (Math.Abs(nPos.x) < sensitive) return; |
| | | if (nPos.x > 0) { |
| | | FlipRight(); |
| | | } |
| | | else { |
| | | FlipLeft(); |
| | | } |
| | | } |
| | | break; |
| | | case FlipDirEnum.Vertical: { |
| | | if (Math.Abs(nPos.y) < sensitive) return; |
| | | Vector3 pos = Vector3.zero; |
| | | if (nPos.y < 0) { |
| | | FlipLeft(); |
| | | } |
| | | else { |
| | | FlipRight(); |
| | | } |
| | | } |
| | | break; |
| | | else { |
| | | page = pageCnt - 1; |
| | | return; |
| | | } |
| | | } |
| | | |
| | | protected override void OnDisable() |
| | | { |
| | | tweening = false; |
| | | StopAllCoroutines(); |
| | | base.OnDisable(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | IEnumerator TweenPosition(Vector3 lPos, Vector3 nPos, Vector3 lastRtPos) |
| | | { |
| | | float time = 0; |
| | | Vector3 newPresentPos = Vector3.zero; |
| | | Vector3 newLastPos = Vector3.zero; |
| | | bool InView = false; |
| | | tweening = true; |
| | | while (time < _tweenTime) { |
| | | float per = 0; |
| | | switch (tweenType) { |
| | | case TweenType.Immediate: per = 1; break; |
| | | case TweenType.Linear: per = Linear(time / _tweenTime); break; |
| | | case TweenType.Smooth: per = Smooth(time / _tweenTime); break; |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: { |
| | | lastFlipRT.localPosition = rectTransform.localPosition.SetX(rectTransform.sizeDelta.x); |
| | | pos = rectTransform.localPosition.SetX(-rectTransform.sizeDelta.x); |
| | | } |
| | | newPresentPos = Vector3.Lerp(lPos, nPos, per); |
| | | newLastPos = Vector3.Lerp(lastRtPos, Vector3.zero, per); |
| | | presentFlipRT.localPosition = newPresentPos; |
| | | lastFlipRT.localPosition = newLastPos; |
| | | time += Time.unscaledDeltaTime; |
| | | if (!InView) { |
| | | InView = InViewSide(); |
| | | break; |
| | | case FlipDirEnum.Vertical: { |
| | | lastFlipRT.localPosition = rectTransform.localPosition.SetY(-rectTransform.sizeDelta.y); |
| | | pos = rectTransform.localPosition.SetY(rectTransform.sizeDelta.y); |
| | | } |
| | | if (tweenType == TweenType.Immediate) { |
| | | break; |
| | | } |
| | | yield return null; |
| | | } |
| | | tweening = false; |
| | | presentFlipRT.localPosition = nPos; |
| | | lastFlipRT.localPosition = Vector3.zero; |
| | | RectTransform temp = presentFlipRT; |
| | | presentFlipRT = lastFlipRT; |
| | | lastFlipRT = temp; |
| | | if (OnTweenCompt != null) OnTweenCompt(); |
| | | break; |
| | | } |
| | | StartCoroutine(TweenPosition(presentFlipRT.localPosition, pos, lastFlipRT.localPosition)); |
| | | } |
| | | |
| | | public bool InViewSide() |
| | | { |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: { |
| | | if (Vector3.Distance(Vector3.zero, lastFlipRT.localPosition) < lastFlipRT.sizeDelta.x + rectTransform.sizeDelta.x) { |
| | | if (OnRefreshData != null) { |
| | | lastFlipRT.SetActive(true); |
| | | OnRefreshData(page, lastFlipRT); |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | break; |
| | | case FlipDirEnum.Vertical: { |
| | | if (Vector3.Distance(Vector3.zero, lastFlipRT.localPosition) < lastFlipRT.sizeDelta.y + rectTransform.sizeDelta.y) { |
| | | if (OnRefreshData != null) { |
| | | lastFlipRT.SetActive(true); |
| | | OnRefreshData(page, lastFlipRT); |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | return false; |
| | | } |
| | | public void OnDrag(PointerEventData eventData) |
| | | { |
| | | |
| | | private float Linear(float val) |
| | | { |
| | | return Mathf.Lerp(0, 1, val); |
| | | } |
| | | } |
| | | |
| | | private float Smooth(float val) |
| | | { |
| | | float result = Mathf.SmoothStep(0, 1, val); |
| | | result = Mathf.Clamp(result, 0, 1); |
| | | return result; |
| | | } |
| | | |
| | | public void RefreshActive() |
| | | { |
| | | if (pageCnt == 0 || presentFlipRT == null) return; |
| | | if (OnRefreshData != null) { |
| | | presentFlipRT.SetActive(true); |
| | | OnRefreshData(page, presentFlipRT); |
| | | } |
| | | } |
| | | |
| | | public void FlipLeft() |
| | | { |
| | | if (IsTweening || pageCnt == 0) return; |
| | | Vector3 pos = Vector3.zero; |
| | | page--; |
| | | if (page < 0) { |
| | | if (loop) { |
| | | page = pageCnt - 1; |
| | | } |
| | | else { |
| | | page = 0; |
| | | return; |
| | | } |
| | | } |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: { |
| | | lastFlipRT.localPosition = rectTransform.localPosition.SetX(-rectTransform.sizeDelta.x); |
| | | pos = rectTransform.localPosition.SetX(rectTransform.sizeDelta.x); |
| | | } |
| | | break; |
| | | case FlipDirEnum.Vertical: { |
| | | lastFlipRT.localPosition = rectTransform.localPosition.SetY(rectTransform.sizeDelta.y); |
| | | pos = rectTransform.localPosition.SetY(-rectTransform.sizeDelta.y); |
| | | } |
| | | break; |
| | | } |
| | | StartCoroutine(TweenPosition(presentFlipRT.localPosition, pos, lastFlipRT.localPosition)); |
| | | } |
| | | |
| | | public void FlipRight() |
| | | { |
| | | if (IsTweening || pageCnt == 0) return; |
| | | Vector3 pos = Vector3.zero; |
| | | page++; |
| | | if (page >= pageCnt) { |
| | | if (loop) { |
| | | page = 0; |
| | | } |
| | | else { |
| | | page = pageCnt - 1; |
| | | return; |
| | | } |
| | | } |
| | | switch (FlipType) { |
| | | case FlipDirEnum.Horizon: { |
| | | lastFlipRT.localPosition = rectTransform.localPosition.SetX(rectTransform.sizeDelta.x); |
| | | pos = rectTransform.localPosition.SetX(-rectTransform.sizeDelta.x); |
| | | } |
| | | break; |
| | | case FlipDirEnum.Vertical: { |
| | | lastFlipRT.localPosition = rectTransform.localPosition.SetY(-rectTransform.sizeDelta.y); |
| | | pos = rectTransform.localPosition.SetY(rectTransform.sizeDelta.y); |
| | | } |
| | | break; |
| | | } |
| | | StartCoroutine(TweenPosition(presentFlipRT.localPosition, pos, lastFlipRT.localPosition)); |
| | | } |
| | | |
| | | public void OnDrag(PointerEventData eventData) |
| | | { |
| | | |
| | | } |
| | | |
| | | public enum TweenType |
| | | { |
| | | Immediate, |
| | | Linear, |
| | | Smooth, |
| | | } |
| | | public enum TweenType |
| | | { |
| | | Immediate, |
| | | Linear, |
| | | Smooth, |
| | | } |
| | | } |
| | | |
| | |
| | | using UnityEngine; |
| | | namespace EnhancedUI.EnhancedScroller |
| | | public abstract class ScrollerUI : MonoBehaviour |
| | | { |
| | | public abstract class ScrollerUI : MonoBehaviour |
| | | { |
| | | public ScrollerDataType type=ScrollerDataType.Header; |
| | | public ScrollerDataType type=ScrollerDataType.Header; |
| | | |
| | | public abstract void Refresh(CellView cell); |
| | | } |
| | | public abstract void Refresh(CellView cell); |
| | | } |
| | | |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | |
| | | using vnxbqy.UI; |
| | | using System; |
| | | |
| | | public class SoundPlayer : MonoBehaviour |
| | |
| | | |
| | | using System.Collections.Generic; |
| | | |
| | | namespace vnxbqy.UI |
| | | |
| | | public class SoundUtility |
| | | { |
| | | static DateTime lastHitAudioPlayTime = DateTime.Now; |
| | | static int hitAudioTimeInterval = 50;//毫秒 |
| | | |
| | | public class SoundUtility |
| | | static int hitAudioPoolMax = 2; |
| | | static int hitAudioCountPool = 2; |
| | | |
| | | static Dictionary<int, List<int>> jobHitAudio = new Dictionary<int, List<int>>() { |
| | | { 1,new List<int>(){101,102,103,104} }, |
| | | { 2,new List<int>(){146,147,148,149} }, |
| | | { 3,new List<int>(){101,102,103,104} }, |
| | | }; |
| | | |
| | | public static void PlayHitAudio(AudioSource _audioSource) |
| | | { |
| | | static DateTime lastHitAudioPlayTime = DateTime.Now; |
| | | static int hitAudioTimeInterval = 50;//毫秒 |
| | | if (_audioSource == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | static int hitAudioPoolMax = 2; |
| | | static int hitAudioCountPool = 2; |
| | | if (hitAudioCountPool < hitAudioPoolMax) |
| | | { |
| | | hitAudioCountPool = Mathf.Clamp(hitAudioCountPool + (int)((DateTime.Now - lastHitAudioPlayTime).TotalMilliseconds / hitAudioTimeInterval), 0, hitAudioPoolMax); |
| | | } |
| | | |
| | | static Dictionary<int, List<int>> jobHitAudio = new Dictionary<int, List<int>>() { |
| | | { 1,new List<int>(){101,102,103,104} }, |
| | | { 2,new List<int>(){146,147,148,149} }, |
| | | { 3,new List<int>(){101,102,103,104} }, |
| | | if (hitAudioCountPool > 0) |
| | | { |
| | | var job = PlayerDatas.Instance.baseData.Job; |
| | | if (jobHitAudio.ContainsKey(job)) |
| | | { |
| | | var audios = jobHitAudio[job]; |
| | | var index = UnityEngine.Random.Range(0, audios.Count); |
| | | SoundPlayer.Instance.PlayAudio(_audioSource, audios[index]); |
| | | lastHitAudioPlayTime = DateTime.Now; |
| | | hitAudioCountPool--; |
| | | } |
| | | } |
| | | } |
| | | |
| | | static Dictionary<int, int[]> fightRoars = new Dictionary<int, int[]>() { |
| | | { 1,new int[]{ 97,98,99 } }, |
| | | { 2,new int[]{ 142,143,144 } }, |
| | | }; |
| | | |
| | | public static void PlayHitAudio(AudioSource _audioSource) |
| | | public static void PlayFightRoar(AudioSource _audioSource, int _job) |
| | | { |
| | | var ableIndex = UnityEngine.Random.Range(0, 3); |
| | | if (ableIndex != 1) |
| | | { |
| | | if (_audioSource == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (hitAudioCountPool < hitAudioPoolMax) |
| | | { |
| | | hitAudioCountPool = Mathf.Clamp(hitAudioCountPool + (int)((DateTime.Now - lastHitAudioPlayTime).TotalMilliseconds / hitAudioTimeInterval), 0, hitAudioPoolMax); |
| | | } |
| | | |
| | | if (hitAudioCountPool > 0) |
| | | { |
| | | var job = PlayerDatas.Instance.baseData.Job; |
| | | if (jobHitAudio.ContainsKey(job)) |
| | | { |
| | | var audios = jobHitAudio[job]; |
| | | var index = UnityEngine.Random.Range(0, audios.Count); |
| | | SoundPlayer.Instance.PlayAudio(_audioSource, audios[index]); |
| | | lastHitAudioPlayTime = DateTime.Now; |
| | | hitAudioCountPool--; |
| | | } |
| | | } |
| | | return; |
| | | } |
| | | |
| | | static Dictionary<int, int[]> fightRoars = new Dictionary<int, int[]>() { |
| | | { 1,new int[]{ 97,98,99 } }, |
| | | { 2,new int[]{ 142,143,144 } }, |
| | | }; |
| | | |
| | | public static void PlayFightRoar(AudioSource _audioSource, int _job) |
| | | int[] audioList = null; |
| | | if (fightRoars.ContainsKey(_job)) |
| | | { |
| | | var ableIndex = UnityEngine.Random.Range(0, 3); |
| | | if (ableIndex != 1) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | int[] audioList = null; |
| | | if (fightRoars.ContainsKey(_job)) |
| | | { |
| | | audioList = fightRoars[_job]; |
| | | } |
| | | |
| | | if (audioList == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var randomIndex = UnityEngine.Random.Range(0, audioList.Length); |
| | | var audio = audioList[randomIndex]; |
| | | |
| | | SoundPlayer.Instance.PlayAudio(_audioSource, audio); |
| | | |
| | | audioList = fightRoars[_job]; |
| | | } |
| | | |
| | | static Dictionary<int, int> deadAudios = new Dictionary<int, int>() |
| | | if (audioList == null) |
| | | { |
| | | { 1,100}, |
| | | { 2,145}, |
| | | { 3,100}, |
| | | }; |
| | | |
| | | public static void PlayDeadAudio(AudioSource _audioSource, int _job) |
| | | { |
| | | SoundPlayer.Instance.PlayAudio(_audioSource, deadAudios[_job]); |
| | | return; |
| | | } |
| | | |
| | | static Dictionary<int, int[]> stateFootAudios = new Dictionary<int, int[]>() |
| | | { |
| | | { 1,new int[]{ 130, 131, 132,133} }, |
| | | { 2,new int[]{ 134, 135, 136, 137 } }, |
| | | { 3,new int[]{ 138, 139, 140, 141 } }, |
| | | }; |
| | | var randomIndex = UnityEngine.Random.Range(0, audioList.Length); |
| | | var audio = audioList[randomIndex]; |
| | | |
| | | static Dictionary<int, int[]> rideAudios = new Dictionary<int, int[]>(); |
| | | |
| | | static FootAudioType currentState = FootAudioType.Walk; |
| | | static int audioIndex = 0; |
| | | static Dictionary<int, DateTime> stateFootAudioLastPlayTimes = new Dictionary<int, DateTime>(); |
| | | |
| | | const float overTime = 2f; |
| | | |
| | | public static void PlayFootAudio(AudioSource _audioSource, FootAudioType _state, int _horseId = 0) |
| | | { |
| | | var stateInt = (int)_state; |
| | | if (!stateFootAudios.ContainsKey(stateInt)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (currentState != _state) |
| | | { |
| | | audioIndex = 0; |
| | | currentState = _state; |
| | | } |
| | | |
| | | if (stateFootAudioLastPlayTimes.ContainsKey(stateInt)) |
| | | { |
| | | var lastPlayTime = stateFootAudioLastPlayTimes[stateInt]; |
| | | if ((DateTime.Now - lastPlayTime).TotalSeconds > 2f) |
| | | { |
| | | audioIndex = 0; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | audioIndex = 0; |
| | | } |
| | | |
| | | int[] audios = null; |
| | | switch (stateInt) |
| | | { |
| | | case 1: |
| | | case 3: |
| | | audios = stateFootAudios[(int)_state]; |
| | | break; |
| | | // case 2: |
| | | // if (rideAudios.ContainsKey(_horseId)) |
| | | // { |
| | | // audios = rideAudios[_horseId]; |
| | | // } |
| | | // else |
| | | // { |
| | | // var config = HorseConfig.Get(_horseId); |
| | | // audios = new int[config.RideAudios.Length]; |
| | | // Array.Copy(config.RideAudios, audios, config.RideAudios.Length); |
| | | // rideAudios[_horseId] = audios; |
| | | // } |
| | | // break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | |
| | | if (audioIndex < audios.Length) |
| | | { |
| | | var audio = audios[audioIndex]; |
| | | SoundPlayer.Instance.PlayAudio(_audioSource, audio); |
| | | stateFootAudioLastPlayTimes[stateInt] = DateTime.Now; |
| | | audioIndex++; |
| | | } |
| | | |
| | | if (audioIndex >= audios.Length) |
| | | { |
| | | audioIndex = 0; |
| | | } |
| | | } |
| | | SoundPlayer.Instance.PlayAudio(_audioSource, audio); |
| | | |
| | | } |
| | | |
| | | static Dictionary<int, int> deadAudios = new Dictionary<int, int>() |
| | | { |
| | | { 1,100}, |
| | | { 2,145}, |
| | | { 3,100}, |
| | | }; |
| | | |
| | | public static void PlayDeadAudio(AudioSource _audioSource, int _job) |
| | | { |
| | | SoundPlayer.Instance.PlayAudio(_audioSource, deadAudios[_job]); |
| | | } |
| | | |
| | | static Dictionary<int, int[]> stateFootAudios = new Dictionary<int, int[]>() |
| | | { |
| | | { 1,new int[]{ 130, 131, 132,133} }, |
| | | { 2,new int[]{ 134, 135, 136, 137 } }, |
| | | { 3,new int[]{ 138, 139, 140, 141 } }, |
| | | }; |
| | | |
| | | static Dictionary<int, int[]> rideAudios = new Dictionary<int, int[]>(); |
| | | |
| | | static FootAudioType currentState = FootAudioType.Walk; |
| | | static int audioIndex = 0; |
| | | static Dictionary<int, DateTime> stateFootAudioLastPlayTimes = new Dictionary<int, DateTime>(); |
| | | |
| | | const float overTime = 2f; |
| | | |
| | | public static void PlayFootAudio(AudioSource _audioSource, FootAudioType _state, int _horseId = 0) |
| | | { |
| | | var stateInt = (int)_state; |
| | | if (!stateFootAudios.ContainsKey(stateInt)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (currentState != _state) |
| | | { |
| | | audioIndex = 0; |
| | | currentState = _state; |
| | | } |
| | | |
| | | if (stateFootAudioLastPlayTimes.ContainsKey(stateInt)) |
| | | { |
| | | var lastPlayTime = stateFootAudioLastPlayTimes[stateInt]; |
| | | if ((DateTime.Now - lastPlayTime).TotalSeconds > 2f) |
| | | { |
| | | audioIndex = 0; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | audioIndex = 0; |
| | | } |
| | | |
| | | int[] audios = null; |
| | | switch (stateInt) |
| | | { |
| | | case 1: |
| | | case 3: |
| | | audios = stateFootAudios[(int)_state]; |
| | | break; |
| | | // case 2: |
| | | // if (rideAudios.ContainsKey(_horseId)) |
| | | // { |
| | | // audios = rideAudios[_horseId]; |
| | | // } |
| | | // else |
| | | // { |
| | | // var config = HorseConfig.Get(_horseId); |
| | | // audios = new int[config.RideAudios.Length]; |
| | | // Array.Copy(config.RideAudios, audios, config.RideAudios.Length); |
| | | // rideAudios[_horseId] = audios; |
| | | // } |
| | | // break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | |
| | | if (audioIndex < audios.Length) |
| | | { |
| | | var audio = audios[audioIndex]; |
| | | SoundPlayer.Instance.PlayAudio(_audioSource, audio); |
| | | stateFootAudioLastPlayTimes[stateInt] = DateTime.Now; |
| | | audioIndex++; |
| | | } |
| | | |
| | | if (audioIndex >= audios.Length) |
| | | { |
| | | audioIndex = 0; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.Events; |
| | | using System; |
| | | using vnxbqy.UI; |
| | | using System.Collections; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | |
| | | using LitJson; |
| | | using System.Text.RegularExpressions; |
| | | using System.Text; |
| | | using vnxbqy.UI; |
| | | //任务信息的存储 |
| | | |
| | | /** 任务结构 */ |
| | |
| | | { |
| | | GlobalTimeEvent.Instance.secondEvent -= secondEvent; |
| | | GlobalTimeEvent.Instance.secondEvent += secondEvent; |
| | | TaskAllocation.Instance.TaskTime = TimeUtility.ServerNow; |
| | | isServerPrepare = true; |
| | | TaskOverBool = false; |
| | | } |
| | |
| | | // } |
| | | |
| | | // if (UIManager.Instance.IsOpened<MysteriousMissionWin>()) |
| | | // { |
| | | // yield break; |
| | | // } |
| | | |
| | | // if (CrossServerUtility.IsCrossServer()) |
| | | // { |
| | | // yield break; |
| | | // } |
| | |
| | | using UnityEngine;
|
| | | using vnxbqy.UI;
|
| | |
|
| | | public class GMCommand : SingletonMonobehaviour<GMCommand>
|
| | | {
|
| | |
| | | using vnxbqy.UI; |
| | | using System; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using UnityEngine.EventSystems; |
| | | using vnxbqy.UI; |
| | | |
| | | |
| | | |
| | | public static class UIUtility |