0312 去掉表默认的多线程引用,小游戏不支持多线程;特效分离出UI特效;增加按钮组的控制;特效增加池管理
98个文件已修改
1个文件已删除
13 文件已复制
14个文件已添加
1 文件已重命名
| | |
| | | using System; |
| | | |
| | | |
| | | |
| | | //关联游戏玩法功能按钮,如升星功能 |
| | | public class FunctionButton : Button |
| | | { |
| | | [SerializeField] int m_Order = 0; |
| | |
| | | using UnityEngine.Events; |
| | | using System; |
| | | |
| | | //关联游戏玩法功能按钮,如升星功能 |
| | | public class FunctionButtonGroup : MonoBehaviour |
| | | { |
| | | [SerializeField] ScrollRect m_ScrollRect; |
| | | [SerializeField] RectTransform m_Container; |
| | | |
| | | public int unLockedCount { |
| | | get { |
| | | public int unLockedCount |
| | | { |
| | | get |
| | | { |
| | | var count = 0; |
| | | foreach (var button in functionButtons.Values) |
| | | { |
New file |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 玩个游戏 |
| | | // [ Date ]: Tuesday, October 31, 2017 |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using UnityEngine.EventSystems; |
| | | |
| | | using System; |
| | | |
| | | |
| | | //关联按钮,其中一个亮起,其他按下,文字颜色对应变更 |
| | | //数据更新通过SelectBtn更新 或者 GroupButtonExManager.SelectButton |
| | | public class GroupButtonEx : ButtonEx |
| | | { |
| | | [SerializeField] GroupButtonExManager m_Manager; // 按钮组管理器引用 |
| | | public GroupButtonExManager manager |
| | | { |
| | | get { return m_Manager; } |
| | | set |
| | | { |
| | | if (m_Manager != value) |
| | | { |
| | | // 从旧管理器移除并添加到新管理器 |
| | | if (m_Manager != null) |
| | | { |
| | | m_Manager.RemoveButton(this); |
| | | } |
| | | |
| | | m_Manager = value; |
| | | |
| | | if (m_Manager != null) |
| | | { |
| | | m_Manager.AddButton(this); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | [NonSerialized] TitleBtnState m_State = TitleBtnState.Normal; |
| | | public TitleBtnState state |
| | | { |
| | | get { return m_State; } |
| | | set |
| | | { |
| | | if (m_State != value) |
| | | { |
| | | m_State = value; |
| | | } |
| | | } |
| | | } |
| | | |
| | | [SerializeField] ImageEx m_SelectIcon; |
| | | public ImageEx selectIcon |
| | | { |
| | | get { return this.m_SelectIcon; } |
| | | set { this.m_SelectIcon = value; } |
| | | } |
| | | |
| | | [SerializeField] ImageEx m_UnSelectIcon; |
| | | public ImageEx unSelectIcon |
| | | { |
| | | get { return this.m_UnSelectIcon; } |
| | | set { this.m_UnSelectIcon = value; } |
| | | } |
| | | |
| | | [SerializeField] TextEx m_Title; |
| | | public TextEx title |
| | | { |
| | | get { return this.m_Title; } |
| | | set { this.m_Title = value; } |
| | | } |
| | | |
| | | [SerializeField] UIEffectPlayer m_SelectEffect; //选中特效 |
| | | public UIEffectPlayer selectEffect |
| | | { |
| | | get { return m_SelectEffect; } |
| | | set { m_SelectEffect = value; } |
| | | } |
| | | |
| | | |
| | | protected override void Awake() |
| | | { |
| | | base.Awake(); |
| | | // 确保已添加到管理器 |
| | | if (m_Manager != null) |
| | | { |
| | | m_Manager.AddButton(this); |
| | | } |
| | | } |
| | | |
| | | protected override void OnDestroy() |
| | | { |
| | | if (m_Manager != null) |
| | | { |
| | | m_Manager.RemoveButton(this); |
| | | } |
| | | base.OnDestroy(); |
| | | } |
| | | |
| | | public override void OnPointerClick(PointerEventData eventData) |
| | | { |
| | | base.OnPointerClick(eventData); |
| | | SelectBtn(); |
| | | } |
| | | |
| | | // 选中当前按钮 |
| | | public void SelectBtn(bool forceRefresh = false) |
| | | { |
| | | if (m_State == TitleBtnState.Click && !forceRefresh) |
| | | return; |
| | | |
| | | // 通过管理器处理选中逻辑 |
| | | if (m_Manager != null) |
| | | { |
| | | m_Manager.SelectButton(this); |
| | | } |
| | | |
| | | // 设置当前按钮为选中状态 |
| | | state = TitleBtnState.Click; |
| | | } |
| | | |
| | | // 更新按钮状态 |
| | | public void UpdateButtonState() |
| | | { |
| | | // 更新图标显示 |
| | | if (m_SelectIcon != null) |
| | | m_SelectIcon.SetActive(m_State == TitleBtnState.Click); |
| | | |
| | | if (m_UnSelectIcon != null) |
| | | m_UnSelectIcon.SetActive(m_State != TitleBtnState.Click); |
| | | |
| | | // 更新文字颜色 |
| | | if (m_Title != null && m_Manager != null) |
| | | { |
| | | m_Title.color = m_Manager.GetTextColorForState(m_State); |
| | | } |
| | | |
| | | if (m_SelectEffect != null) |
| | | { |
| | | if (m_State == TitleBtnState.Click) |
| | | { |
| | | //选中,显示特效 |
| | | m_SelectEffect.Play(); |
| | | } |
| | | else |
| | | { |
| | | m_SelectEffect.Stop(); |
| | | } |
| | | } |
| | | } |
| | | } |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/Component/UI/Common/GroupButtonEx.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: 97eda1b97c0fe374f9197d882712f299 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
New file |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 玩个游戏 |
| | | // [ Date ]: Tuesday, October 31, 2017 |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | |
| | | using System; |
| | | |
| | | /// <summary> |
| | | /// 按钮组管理器,负责管理GroupButtonEx组件的组关系和状态切换 |
| | | /// 暂用于预制体中的设置,如果是动态增删按钮需重测试逻辑 |
| | | /// </summary> |
| | | public class GroupButtonExManager : MonoBehaviour |
| | | { |
| | | // 按钮组列表 |
| | | private List<GroupButtonEx> m_Buttons = new List<GroupButtonEx>(); |
| | | |
| | | [SerializeField] Color m_SelectedTextColor = Color.white; // 选中状态文字颜色 |
| | | public Color selectedTextColor { |
| | | get { return m_SelectedTextColor; } |
| | | set { |
| | | m_SelectedTextColor = value; |
| | | } |
| | | } |
| | | |
| | | [SerializeField] Color m_NormalTextColor = new Color(0.7f, 0.7f, 0.7f); // 未选中状态文字颜色 |
| | | public Color normalTextColor { |
| | | get { return m_NormalTextColor; } |
| | | set { |
| | | m_NormalTextColor = value; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 将按钮添加到组 |
| | | /// </summary> |
| | | /// <param name="button">要添加的按钮</param> |
| | | public void AddButton(GroupButtonEx button) |
| | | { |
| | | if (button == null) |
| | | return; |
| | | |
| | | // 如果按钮不在组中,添加到组 |
| | | if (!m_Buttons.Contains(button)) |
| | | { |
| | | m_Buttons.Add(button); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 从组中移除按钮 |
| | | /// </summary> |
| | | /// <param name="button">要移除的按钮</param> |
| | | public void RemoveButton(GroupButtonEx button) |
| | | { |
| | | if (button == null) |
| | | return; |
| | | |
| | | m_Buttons.Remove(button); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选中指定按钮,并取消其他按钮的选中状态 |
| | | /// </summary> |
| | | /// <param name="button">要选中的按钮</param> |
| | | public void SelectButton(GroupButtonEx button) |
| | | { |
| | | if (button == null) |
| | | return; |
| | | |
| | | // 取消其他按钮的选中状态 |
| | | foreach (var btn in m_Buttons) |
| | | { |
| | | if (btn != button) |
| | | { |
| | | btn.state = TitleBtnState.Normal; |
| | | } |
| | | } |
| | | |
| | | UpdateAllButtonsState(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取组中的所有按钮 |
| | | /// </summary> |
| | | /// <returns>按钮列表</returns> |
| | | public List<GroupButtonEx> GetButtons() |
| | | { |
| | | return new List<GroupButtonEx>(m_Buttons); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取组中当前选中的按钮 |
| | | /// </summary> |
| | | /// <returns>选中的按钮,如果没有则返回null</returns> |
| | | public GroupButtonEx GetSelectedButton() |
| | | { |
| | | foreach (var btn in m_Buttons) |
| | | { |
| | | if (btn.state == TitleBtnState.Click) |
| | | return btn; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 清除所有按钮 |
| | | /// </summary> |
| | | public void ClearButtons() |
| | | { |
| | | m_Buttons.Clear(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新所有按钮的状态 |
| | | /// </summary> |
| | | private void UpdateAllButtonsState() |
| | | { |
| | | SortBtns(); |
| | | |
| | | foreach (var btn in m_Buttons) |
| | | { |
| | | btn.UpdateButtonState(); |
| | | } |
| | | } |
| | | |
| | | bool sortyet = false; |
| | | public void SortBtns(bool forceSort = false) |
| | | { |
| | | if (m_Buttons.Count <= 0) |
| | | return; |
| | | |
| | | if (sortyet && !forceSort) |
| | | return; |
| | | |
| | | m_Buttons.Sort((a, b) => { return a.transform.GetSiblingIndex() - b.transform.GetSiblingIndex(); }); |
| | | sortyet = true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取按钮状态对应的文本颜色 |
| | | /// </summary> |
| | | /// <param name="state">按钮状态</param> |
| | | /// <returns>对应的文本颜色</returns> |
| | | public Color GetTextColorForState(TitleBtnState state) |
| | | { |
| | | return state == TitleBtnState.Click ? m_SelectedTextColor : m_NormalTextColor; |
| | | } |
| | | } |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/Component/UI/Common/GroupButtonExManager.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: 25d1a287b0e773443a2231ff104728ad |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | |
| | | using UnityEngine; |
| | | public class ItemBaseEffect : MonoBehaviour |
| | | { |
| | | [SerializeField] EffectPlayer m_SuitEffect; |
| | | [SerializeField] UIEffectPlayer m_SuitEffect; |
| | | |
| | | int itemId = 0; |
| | | |
| | |
| | | using UnityEngine; |
| | | |
| | | public class EffectMgr : SingletonMonobehaviour<EffectMgr> |
| | | public class EffectMgr |
| | | { |
| | | |
| | | |
| | | //玩家是否主动屏蔽了特效 |
| | | public bool IsNotShowBySetting(int id) |
| | | public static bool IsNotShowBySetting(int id) |
| | | { |
| | | var config = EffectConfig.Get(id); |
| | | if (config == null) |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | // public void RecyleUIEffect(int id, GameObject _effectObj) |
| | | // { |
| | | // EffectConfig effectCfg = EffectConfig.Get(id); |
| | | |
| | | // if (null == effectCfg) |
| | | // { |
| | | // return; |
| | | // } |
| | | |
| | | // var _prefab = ResManager.Instance.LoadAsset<GameObject>("UIEffect/" + effectCfg.packageName, effectCfg.fxName); |
| | | // if (_prefab == null) |
| | | // { |
| | | // return; |
| | | // } |
| | | |
| | | // GameObjectPoolManager.GameObjectPool _pool = GameObjectPoolManager.Instance.RequestPool(_prefab); |
| | | // if (_pool != null) |
| | | // { |
| | | // _pool.Release(_effectObj); |
| | | // } |
| | | // } |
| | | } |
| | | |
| | |
| | | using Spine; |
| | | using UnityEngine.UI; |
| | | |
| | | // 特效播放器,对象池管理:unity特效和spine特效都是做好的预制体 |
| | | // unity特效预制体是特效师在制作的时候生成的,unity特效约定挂载设置播放时长脚本 |
| | | // spine特效是特效师制作的动画文件可直接加载用,制作成预制体可增加BoneFollower之类的进行逻辑处理 |
| | | // 非UI特效使用,UI特效UIEffectPlayer继承EffectPlayer,后续如果逻辑冲突大则不用继承 |
| | | public class EffectPlayer : MonoBehaviour |
| | | { |
| | | public int effectId; |
| | | [SerializeField] |
| | | private int m_EffectID; |
| | | public int effectId |
| | | { |
| | | get |
| | | { |
| | | return m_EffectID; |
| | | } |
| | | set |
| | | { |
| | | if (value != m_EffectID) |
| | | { |
| | | isInit = false; |
| | | m_EffectID = value; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public EffectConfig effectConfig; |
| | | |
| | | public Action<EffectPlayer> onDestroy; |
| | | public Action onComplete; |
| | | |
| | | public float speedRate = 1f; |
| | | |
| | | [Header("是否在显示时播放")] |
| | | public bool isPlayOnEnable = false; |
| | | |
| | | [Header("是否立即播放spine特效")] |
| | | public bool isPlaySpineImmediately = false; |
| | | [Header("是否循环播放spine特效")] |
| | | public bool isPlaySpineLoop = false; |
| | | |
| | | |
| | | [Header("播放完毕立即回收")] |
| | | public bool isReleaseImmediately = true; //界面特效一般不需要自我销毁,跟随界面或者父对象销毁就行 |
| | | |
| | | public Action<EffectPlayer> onDestroy; |
| | | |
| | | [HideInInspector] public Canvas canvas = null; |
| | | |
| | |
| | | protected SkeletonGraphic spineComp; |
| | | protected Spine.AnimationState spineAnimationState; |
| | | |
| | | protected void OnEnable() |
| | | public GameObjectPoolManager.GameObjectPool pool; |
| | | |
| | | public Action onComplete; |
| | | |
| | | protected virtual void OnEnable() |
| | | { |
| | | if (isPlayOnEnable) |
| | | if (spineComp != null) |
| | | { |
| | | Play(); |
| | | //隐藏,会有静态显示问题 |
| | | spineComp.enabled = false; |
| | | } |
| | | } |
| | | |
| | | protected bool InitCompnent() |
| | | protected void InitComponent(bool showLog = true) |
| | | { |
| | | if (effectId <= 0) |
| | | { |
| | | effectConfig = null; |
| | | // 根据逻辑需求,动态设置特效的情况 |
| | | // Debug.LogError("EffectPlayer effectId is not set"); |
| | | // #if UNITY_EDITOR |
| | | // UnityEditor.Selection.activeGameObject = gameObject; |
| | | // UnityEditor.EditorGUIUtility.PingObject(gameObject); |
| | | // #endif |
| | | return false; |
| | | #if UNITY_EDITOR |
| | | if (showLog) |
| | | { |
| | | Debug.LogError("EffectPlayer effectId is not set"); |
| | | UnityEditor.Selection.activeGameObject = gameObject; |
| | | UnityEditor.EditorGUIUtility.PingObject(gameObject); |
| | | } |
| | | #endif |
| | | return; |
| | | } |
| | | |
| | | effectConfig = EffectConfig.Get(effectId); |
| | | |
| | | if (null == effectConfig) |
| | | { |
| | | Debug.LogError("could not find effect config, effect id is " + effectId); |
| | | #if UNITY_EDITOR |
| | | Debug.LogError("could not find effect config, effect id is " + effectId); |
| | | UnityEditor.Selection.activeGameObject = gameObject; |
| | | UnityEditor.EditorGUIUtility.PingObject(gameObject); |
| | | #endif |
| | | return false; |
| | | return; |
| | | } |
| | | |
| | | |
| | | Clear(); |
| | | return; |
| | | } |
| | | |
| | | protected virtual void Clear() |
| | | { |
| | | particleList.Clear(); |
| | | animatorList.Clear(); |
| | | rendererList.Clear(); |
| | | spineComp = null; |
| | | |
| | | //spine是加载文件,需要提前挂载脚本,unity特效是已经做好的预制体待加载后收集组件 |
| | | if (effectConfig.isSpine != 0) |
| | | { |
| | | spineComp = gameObject.AddMissingComponent<SkeletonGraphic>(); |
| | | |
| | | } |
| | | // else |
| | | // { |
| | | // // 收集组件 |
| | | // particleList.AddRange(gameObject.GetComponentsInChildren<ParticleSystem>(true)); |
| | | // animatorList.AddRange(gameObject.GetComponentsInChildren<Animator>(true)); |
| | | // } |
| | | // rendererList.AddRange(gameObject.GetComponentsInChildren<Renderer>(true)); |
| | | |
| | | return true; |
| | | pool = null; |
| | | } |
| | | |
| | | public void Stop() |
| | | public virtual void Stop() |
| | | { |
| | | if (null != effectTarget) |
| | | { |
| | | DestroyImmediate(effectTarget); |
| | | // 如果使用了特效预制体池,则归还到池中 |
| | | if (pool != null) |
| | | { |
| | | pool.Release(effectTarget); |
| | | } |
| | | effectTarget = null; |
| | | } |
| | | |
| | | isInit = false; |
| | | |
| | | particleList.Clear(); |
| | | animatorList.Clear(); |
| | | rendererList.Clear(); |
| | | spineComp = null; |
| | | Clear(); |
| | | onComplete?.Invoke(); |
| | | } |
| | | |
| | | public void Play() |
| | | { |
| | | ReStart(); |
| | | } |
| | | |
| | | |
| | | protected void ReStart() |
| | | public virtual void Play(bool showLog = true) |
| | | { |
| | | if (!isInit) |
| | | { |
| | | if (InitCompnent()) |
| | | { |
| | | InitComponent(showLog); |
| | | isInit = true; |
| | | } |
| | | else |
| | | { |
| | | //根据逻辑需求,动态设置特效的情况 |
| | | //避免重复创建 |
| | | if (!this.gameObject.activeSelf) |
| | | { |
| | | this.gameObject.SetActive(true); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | } |
| | | |
| | | if (EffectMgr.Instance.IsNotShowBySetting(effectId)) |
| | | if (EffectMgr.IsNotShowBySetting(effectId)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (null != effectTarget) |
| | | { |
| | | DestroyImmediate(effectTarget); |
| | | if (pool != null) |
| | | pool.Release(effectTarget); |
| | | effectTarget = null; |
| | | } |
| | | |
| | | // YYL TODO |
| | | // 在这里考虑用池的话可能走配置好一点 原本的是无论如何都走池 但是实际上有些特效并不需要 |
| | | |
| | | // 加载spine特效资源 |
| | | if (effectConfig.isSpine != 0) |
| | | if (!this.gameObject.activeSelf) |
| | | { |
| | | spineComp.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("UIEffect/" + effectConfig.packageName, effectConfig.fxName + "_SkeletonData"); |
| | | this.gameObject.SetActive(true); |
| | | } |
| | | |
| | | PlayerEffect(true); |
| | | |
| | | } |
| | | |
| | | |
| | | protected virtual void PlaySpineEffect() |
| | | { |
| | | spineComp = gameObject.GetComponentInChildren<SkeletonGraphic>(true); |
| | | spineComp.raycastTarget = false; |
| | | spineComp.Initialize(true); |
| | | spineAnimationState = spineComp.AnimationState; |
| | | spineAnimationState.Complete -= OnSpineAnimationComplete; |
| | | spineAnimationState.Complete += OnSpineAnimationComplete; |
| | | if (isPlaySpineImmediately) |
| | | { |
| | | //UI特效常用方式 |
| | | spineComp.enabled = true; |
| | | // 播放第一个动画(作为默认动画) |
| | | var skeletonData = spineComp.Skeleton.Data; |
| | | if (skeletonData.Animations.Count > 0) |
| | | { |
| | | string defaultAnimationName = skeletonData.Animations.Items[0].Name; |
| | | spineComp.AnimationState.SetAnimation(0, defaultAnimationName, isPlaySpineLoop); |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("Spine 数据中没有找到任何动画!" + effectConfig.id); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | spineComp.enabled = false; |
| | | } |
| | | |
| | | // 外层控制具体播放哪个动画 |
| | | spineComp.enabled = true; |
| | | |
| | | return; |
| | | } |
| | | |
| | | //加载unity特效 |
| | | protected virtual void PlayerEffect(bool playSpine) |
| | | { |
| | | var effectPrefab = ResManager.Instance.LoadAsset<GameObject>("UIEffect/" + effectConfig.packageName, effectConfig.fxName); |
| | | if (effectPrefab == null) |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | // 实例化特效 |
| | | effectTarget = Instantiate(effectPrefab, transform); |
| | | if (effectConfig.isSpine == 0) |
| | | { |
| | | //unity特效 判断预制体是否挂载EffectTime |
| | | var timeObj = effectPrefab.GetComponent<EffectTime>(); |
| | | if (null == timeObj) |
| | | { |
| | | Debug.LogError($"{effectPrefab.name}预制体没有挂载EffectTime"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | // 从特效预制体池获取特效 |
| | | pool = GameObjectPoolManager.Instance.RequestPool(effectPrefab); |
| | | effectTarget = pool.Request(); |
| | | // 设置父节点和位置 |
| | | effectTarget.transform.SetParent(transform); |
| | | effectTarget.transform.localPosition = Vector3.zero; |
| | | effectTarget.transform.localScale = Vector3.one; |
| | | effectTarget.transform.localRotation = Quaternion.identity; |
| | | effectTarget.name = $"Effect_{effectConfig.fxName}"; |
| | | |
| | | if (effectConfig.isSpine != 0 && playSpine) |
| | | { |
| | | //预制体 |
| | | PlaySpineEffect(); |
| | | } |
| | | else |
| | | { |
| | | //挂载组件后 开始收集 |
| | | particleList.AddRange(gameObject.GetComponentsInChildren<ParticleSystem>(true)); |
| | | animatorList.AddRange(gameObject.GetComponentsInChildren<Animator>(true)); |
| | | rendererList.AddRange(gameObject.GetComponentsInChildren<Renderer>(true)); |
| | | OnUnityAnimationComplete(); |
| | | } |
| | | |
| | | |
| | | // 思考一下在没有挂在节点的时候 |
| | | if (null == canvas) |
| | | canvas = GetComponentInParent<Canvas>(); |
| | | |
| | | |
| | | // 添加特效穿透阻挡器 |
| | | blocker = effectTarget.AddMissingComponent<EffectPenetrationBlocker>(); |
| | |
| | | if (canvas != null) |
| | | { |
| | | blocker.SetParentCanvas(canvas); |
| | | } |
| | | |
| | | // 自动销毁 |
| | | if (effectConfig.autoDestroy != 0) |
| | | { |
| | | Destroy(effectTarget, effectConfig.destroyDelay); |
| | | } |
| | | } |
| | | |
| | |
| | | onDestroy.Invoke(this); |
| | | onDestroy = null; |
| | | } |
| | | // 停止特效并归还到池中 |
| | | Stop(); |
| | | |
| | | if (spineAnimationState != null) |
| | | { |
| | | spineAnimationState.Complete -= OnSpineAnimationComplete; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | //单次播放完毕就会触发,即使是循环 |
| | | protected void OnSpineAnimationComplete(Spine.TrackEntry trackEntry) |
| | | protected virtual void OnSpineAnimationComplete(Spine.TrackEntry trackEntry) |
| | | { |
| | | if (!isPlaySpineLoop) |
| | | { |
| | | if (onComplete == null) |
| | | { |
| | | if (effectConfig.isSpine != 0) |
| | | if (isReleaseImmediately) |
| | | { |
| | | spineComp.enabled = false; |
| | | Stop(); |
| | | } |
| | | } |
| | | |
| | | onComplete?.Invoke(); |
| | | |
| | | private void OnUnityAnimationComplete() |
| | | { |
| | | var timeObj = effectTarget.GetComponent<EffectTime>(); |
| | | if (!timeObj.isLoop) |
| | | { |
| | | this.SetWait(timeObj.playTime); |
| | | this.DoWaitRestart(); |
| | | this.OnWaitCompelete(OnEffectComplete); |
| | | } |
| | | } |
| | | |
| | | private void OnEffectComplete(Component comp) |
| | | { |
| | | this.DoWaitStop(); |
| | | if (isReleaseImmediately) |
| | | Stop(); |
| | | } |
| | | |
| | | |
| | | // 创建后的特效会自动隐藏 需要手动调用Play才能播放 |
| | | public static EffectPlayer Create(int effectId, Transform parent, bool createNewChild = false) |
| | | { |
| | | // 直接创建特效播放器,不使用对象池 |
| | | EffectPlayer effectPlayer = null; |
| | | |
| | | if (createNewChild) |
| | |
| | | else |
| | | { |
| | | effectPlayer = parent.AddMissingComponent<EffectPlayer>(); |
| | | effectPlayer.effectId = effectId; |
| | | } |
| | | |
| | | effectPlayer.effectId = effectId; |
| | | effectPlayer.SetActive(true); |
| | | return effectPlayer; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置游戏对象激活状态 |
| | | // /// </summary> |
| | | // public void SetActive(bool active) |
| | | // { |
| | | // if (gameObject != null) |
| | | // { |
| | | // gameObject.SetActive(active); |
| | | // } |
| | | // } |
| | | |
| | | public void Pause() |
| | | { |
| | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | using System.Runtime.CompilerServices; |
| | | using UnityEngine; |
| | | |
| | | //设置特效播放时间 和 循环,方便代码调用,不用去判断特效内部情况,可以把这个文件给外包 |
| | | public class EffectTime : MonoBehaviour |
| | | { |
| | | //播放时长 |
| | | [Header("单次播放总时长")] |
| | | public float playTime = 1f; |
| | | [Header("是否循环特效")] |
| | | public bool isLoop = false; |
| | | |
| | | } |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/Component/UI/Effect/EffectTime.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: f9909a1ae22dbb74099685649d44aa29 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
New file |
| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using Spine.Unity; |
| | | using UnityEngine; |
| | | using Spine; |
| | | using UnityEngine.UI; |
| | | |
| | | //UI特效播放器,spine特效直接加载无需提前做预制体 |
| | | //UI特效大部分情况不会改变特效,无需销毁 |
| | | public class UIEffectPlayer : EffectPlayer |
| | | { |
| | | |
| | | [Header("是否循环播放spine特效")] |
| | | public bool isPlaySpineLoop = false; |
| | | |
| | | [Header("是否在显示时播放")] |
| | | public bool isPlayOnEnable = false; |
| | | |
| | | protected override void OnEnable() |
| | | { |
| | | if (isPlayOnEnable) |
| | | { |
| | | Play(false); |
| | | } |
| | | else if (spineComp != null) |
| | | { |
| | | //隐藏,会有静态显示问题 |
| | | spineComp.enabled = false; |
| | | } |
| | | } |
| | | |
| | | public override void Play(bool showLog = true) |
| | | { |
| | | if (!isInit) |
| | | { |
| | | InitComponent(showLog); |
| | | isInit = true; |
| | | } |
| | | else |
| | | { |
| | | //避免重复创建 |
| | | if (!this.gameObject.activeSelf) |
| | | { |
| | | this.gameObject.SetActive(true); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | if (EffectMgr.IsNotShowBySetting(effectId)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (null != effectTarget) |
| | | { |
| | | if (pool != null) |
| | | pool.Release(effectTarget); |
| | | effectTarget = null; |
| | | } |
| | | |
| | | if (!this.gameObject.activeSelf) |
| | | { |
| | | this.gameObject.SetActive(true); |
| | | } |
| | | |
| | | // 加载spine特效资源 |
| | | if (effectConfig.isSpine != 0) |
| | | { |
| | | PlaySpineEffect(); |
| | | } |
| | | else |
| | | { |
| | | PlayerEffect(false); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | protected override void PlaySpineEffect() |
| | | { |
| | | if (spineComp.skeletonDataAsset == null) |
| | | { |
| | | //LoadAsset 已经有缓存SkeletonDataAsset |
| | | spineComp.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("UIEffect/" + effectConfig.packageName, effectConfig.fxName + "_SkeletonData"); |
| | | spineComp.raycastTarget = false; |
| | | spineComp.Initialize(true); |
| | | spineAnimationState = spineComp.AnimationState; |
| | | spineAnimationState.Complete -= OnSpineAnimationComplete; |
| | | spineAnimationState.Complete += OnSpineAnimationComplete; |
| | | } |
| | | |
| | | spineComp.enabled = true; |
| | | PlayerFistSpineAnim(); |
| | | } |
| | | |
| | | |
| | | // 播放第一个动画(作为默认动画) |
| | | void PlayerFistSpineAnim() |
| | | { |
| | | spineComp.enabled = true; |
| | | var skeletonData = spineComp.Skeleton.Data; |
| | | if (skeletonData.Animations.Count > 0) |
| | | { |
| | | string defaultAnimationName = skeletonData.Animations.Items[0].Name; |
| | | spineComp.AnimationState.SetAnimation(0, defaultAnimationName, isPlaySpineLoop); |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("Spine 数据中没有找到任何动画!" + effectConfig.id); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //单次播放完毕就会触发,即使是循环 |
| | | protected override void OnSpineAnimationComplete(Spine.TrackEntry trackEntry) |
| | | { |
| | | if (!isPlaySpineLoop) |
| | | { |
| | | spineComp.enabled = false; |
| | | if (isReleaseImmediately) |
| | | { |
| | | Stop(); |
| | | } |
| | | else |
| | | { |
| | | onComplete?.Invoke(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 创建后的特效会自动隐藏 需要手动调用Play才能播放 |
| | | public static UIEffectPlayer CreateEffect(int effectId, Transform parent, bool createNewChild = false) |
| | | { |
| | | UIEffectPlayer effectPlayer = null; |
| | | |
| | | if (createNewChild) |
| | | { |
| | | GameObject newGo = new GameObject("EffectPlayer_" + effectId); |
| | | newGo.transform.SetParent(parent, false); |
| | | effectPlayer = newGo.AddComponent<UIEffectPlayer>(); |
| | | } |
| | | else |
| | | { |
| | | effectPlayer = parent.AddMissingComponent<UIEffectPlayer>(); |
| | | effectPlayer.effectId = effectId; |
| | | } |
| | | effectPlayer.SetActive(true); |
| | | return effectPlayer; |
| | | } |
| | | |
| | | } |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/Component/UI/Effect/UIEffectPlayer.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: d2a4fa811bba97941bd8ed92c750e271 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | |
| | | typeof(GmCmdConfig),
|
| | | typeof(HeroAwakeConfig),
|
| | | typeof(HeroConfig),
|
| | | typeof(HeroLineupHaloConfig),
|
| | | typeof(HeroQualityAwakeConfig),
|
| | | typeof(HeroQualityBreakConfig),
|
| | | typeof(HeroQualityConfig),
|
| | | typeof(HeroQualityLVConfig),
|
| | | typeof(HeroSkinConfig),
|
| | | typeof(ItemConfig),
|
| | | typeof(KickOutReasonConfig),
|
| | |
| | | ClearConfigDictionary<HeroAwakeConfig>();
|
| | | // 清空 HeroConfig 字典
|
| | | ClearConfigDictionary<HeroConfig>();
|
| | | // 清空 HeroLineupHaloConfig 字典
|
| | | ClearConfigDictionary<HeroLineupHaloConfig>();
|
| | | // 清空 HeroQualityAwakeConfig 字典
|
| | | ClearConfigDictionary<HeroQualityAwakeConfig>();
|
| | | // 清空 HeroQualityBreakConfig 字典
|
| | | ClearConfigDictionary<HeroQualityBreakConfig>();
|
| | | // 清空 HeroQualityConfig 字典
|
| | | ClearConfigDictionary<HeroQualityConfig>();
|
| | | // 清空 HeroQualityLVConfig 字典
|
| | | ClearConfigDictionary<HeroQualityLVConfig>();
|
| | | // 清空 HeroSkinConfig 字典
|
| | | ClearConfigDictionary<HeroSkinConfig>();
|
| | | // 清空 ItemConfig 字典
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: 2025年7月22日 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: 2025年7月7日 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: 2025年6月30日 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: 2025年7月18日
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
New file |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
|
| | | public partial class HeroLineupHaloConfig : ConfigBase<int, HeroLineupHaloConfig>
|
| | | {
|
| | |
|
| | | public int Id;
|
| | | public int Country;
|
| | | public int NeedHeroCount;
|
| | | public int[] AttrIDList;
|
| | | public int[] AttrValueList;
|
| | |
|
| | | public override int LoadKey(string _key)
|
| | | {
|
| | | int key = GetKey(_key);
|
| | | return key;
|
| | | }
|
| | |
|
| | | public override void LoadConfig(string input)
|
| | | {
|
| | | try {
|
| | | string[] tables = input.Split('\t');
|
| | | int.TryParse(tables[0],out Id); |
| | |
|
| | | int.TryParse(tables[1],out Country); |
| | |
|
| | | int.TryParse(tables[2],out NeedHeroCount); |
| | |
|
| | | if (tables[3].Contains("[")) |
| | | { |
| | | AttrIDList = JsonMapper.ToObject<int[]>(tables[3]); |
| | | } |
| | | else |
| | | { |
| | | string[] AttrIDListStringArray = tables[3].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); |
| | | AttrIDList = new int[AttrIDListStringArray.Length]; |
| | | for (int i=0;i<AttrIDListStringArray.Length;i++) |
| | | { |
| | | int.TryParse(AttrIDListStringArray[i],out AttrIDList[i]); |
| | | } |
| | | }
|
| | |
|
| | | if (tables[4].Contains("[")) |
| | | { |
| | | AttrValueList = JsonMapper.ToObject<int[]>(tables[4]); |
| | | } |
| | | else |
| | | { |
| | | string[] AttrValueListStringArray = tables[4].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); |
| | | AttrValueList = new int[AttrValueListStringArray.Length]; |
| | | for (int i=0;i<AttrValueListStringArray.Length;i++) |
| | | { |
| | | int.TryParse(AttrValueListStringArray[i],out AttrValueList[i]); |
| | | } |
| | | }
|
| | | }
|
| | | catch (Exception exception)
|
| | | {
|
| | | Debug.LogError(exception);
|
| | | }
|
| | | }
|
| | | }
|
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/Config/Configs/HeroLineupHaloConfig.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: 8226332450e068a418446db4aab9cb01 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
New file |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
|
| | | public partial class HeroQualityLVConfig : ConfigBase<int, HeroQualityLVConfig>
|
| | | {
|
| | |
|
| | | public int Id;
|
| | | public int Quality;
|
| | | public int HeroLV;
|
| | | public int[] UPCostItem;
|
| | |
|
| | | public override int LoadKey(string _key)
|
| | | {
|
| | | int key = GetKey(_key);
|
| | | return key;
|
| | | }
|
| | |
|
| | | public override void LoadConfig(string input)
|
| | | {
|
| | | try {
|
| | | string[] tables = input.Split('\t');
|
| | | int.TryParse(tables[0],out Id); |
| | |
|
| | | int.TryParse(tables[1],out Quality); |
| | |
|
| | | int.TryParse(tables[2],out HeroLV); |
| | |
|
| | | if (tables[3].Contains("[")) |
| | | { |
| | | UPCostItem = JsonMapper.ToObject<int[]>(tables[3]); |
| | | } |
| | | else |
| | | { |
| | | string[] UPCostItemStringArray = tables[3].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); |
| | | UPCostItem = new int[UPCostItemStringArray.Length]; |
| | | for (int i=0;i<UPCostItemStringArray.Length;i++) |
| | | { |
| | | int.TryParse(UPCostItemStringArray[i],out UPCostItem[i]); |
| | | } |
| | | }
|
| | | }
|
| | | catch (Exception exception)
|
| | | {
|
| | | Debug.LogError(exception);
|
| | | }
|
| | | }
|
| | | }
|
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/Config/Configs/HeroQualityLVConfig.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: b0e2a9b5d4828284eb6dad12646b416c |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: 2025年7月18日
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: 2025年7月11日
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: 2025年7月7日 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: 2025年7月7日 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: 2025年7月7日 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: 2025年7月17日 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: 2025年7月7日 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: YYL
|
| | | // [ Date ]: Friday, June 27, 2025
|
| | | // [ Date ]: 2025年7月26日
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: YYL |
| | | // [ Date ]: Friday, June 27, 2025 |
| | | // [ Date ]: 2025年7月26日
|
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Threading; |
| | | using System; |
| | | using UnityEngine; |
| | | using LitJson; |
New file |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | |
| | | public partial class HeroLineupHaloConfig : ConfigBase<int, HeroLineupHaloConfig> |
| | | { |
| | | // 国家 数量 |
| | | public static Dictionary<int, Dictionary<int, HeroLineupHaloConfig>> configDics = new Dictionary<int, Dictionary<int, HeroLineupHaloConfig>>(); |
| | | |
| | | protected override void OnConfigParseCompleted() |
| | | { |
| | | |
| | | Dictionary<int, HeroLineupHaloConfig> tempDic = null; |
| | | if (!configDics.TryGetValue(Country, out tempDic)) |
| | | { |
| | | tempDic = new Dictionary<int, HeroLineupHaloConfig>(); |
| | | configDics.Add(Country, tempDic); |
| | | } |
| | | |
| | | tempDic[NeedHeroCount] = this; |
| | | } |
| | | |
| | | public static HeroLineupHaloConfig GetConfig(int country, int count) |
| | | { |
| | | if (!configDics.ContainsKey(country)) |
| | | { |
| | | return null; |
| | | } |
| | | if (!configDics[country].ContainsKey(count)) |
| | | { |
| | | return null; |
| | | } |
| | | return configDics[country][count]; |
| | | } |
| | | |
| | | } |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/Config/PartialConfigs/HeroLineupHaloConfig.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: 7c4414e0cc0a8594a86f1c6dda522acb |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | |
| | | private static Dictionary<int, List<int>> outputDict = new Dictionary<int, List<int>>(); |
| | | |
| | | public static int[] baseAttrs = { 6, 7, 8 }; //攻防血 |
| | | |
| | | public static int[] basePerAttrs = { 16, 17, 18 }; //攻防血 百分比 |
| | | protected override void OnConfigParseCompleted() |
| | | { |
| | | List<PlayerPropertyConfig> list = null; |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using System; |
| | | |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class GameObjectPoolManager : SingletonMonobehaviour<GameObjectPoolManager> |
| | | { |
| | | #if UNITY_EDITOR |
| | | private Dictionary<int, DebugItem> m_DebugInstIDDict = null; |
| | | private bool m_ShowDebugPanel = false; |
| | | private Vector2 m_ScrollPosition = Vector2.zero; |
| | | |
| | | private void OnGUI() |
| | | { |
| | | if (!m_ShowDebugPanel) return; |
| | | |
| | | GUILayout.BeginArea(new Rect(10, 10, 400, 600)); |
| | | GUILayout.BeginVertical("Box"); |
| | | m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition, GUILayout.Width(380), GUILayout.Height(580)); |
| | | |
| | | GUILayout.Label("对象池调试面板", GUILayout.Height(30)); |
| | | GUILayout.Space(10); |
| | | |
| | | foreach (var poolEntry in m_PoolDict) |
| | | { |
| | | int prefabInstanceId = poolEntry.Key; |
| | | GameObjectPool pool = poolEntry.Value; |
| | | |
| | | GUILayout.BeginVertical("Box"); |
| | | GUILayout.Label($"池名称: {pool.Prefab.name}"); |
| | | GUILayout.Label($"活跃对象数: {pool.m_ActiveHashSet.Count}"); |
| | | GUILayout.Label($"空闲对象数: {pool.m_FreeQueue.Count}"); |
| | | int count = m_PoolUsageFrequency.TryGetValue(prefabInstanceId, out int frequency) ? frequency : 0; |
| | | GUILayout.Label($"使用频率: {count}"); |
| | | GUILayout.EndVertical(); |
| | | GUILayout.Space(5); |
| | | } |
| | | |
| | | GUILayout.EndScrollView(); |
| | | GUILayout.EndVertical(); |
| | | GUILayout.EndArea(); |
| | | } |
| | | |
| | | [UnityEditor.MenuItem("Tools/对象池/显示调试面板")] |
| | | private static void ToggleDebugPanel() |
| | | { |
| | | if (Instance != null) |
| | | { |
| | | Instance.m_ShowDebugPanel = !Instance.m_ShowDebugPanel; |
| | | } |
| | | } |
| | | #endif |
| | | // 池统计数据 |
| | | public Dictionary<int, PoolStats> PoolStatistics { get; private set; } = new Dictionary<int, PoolStats>(); |
| | | |
| | | public class PoolStats |
| | | { |
| | | public int TotalObjects { get; set; } |
| | | public int ActiveObjects { get; set; } |
| | | public int FreeObjects { get; set; } |
| | | public int UsageFrequency { get; set; } |
| | | } |
| | | |
| | | // 更新池统计数据 |
| | | private void UpdatePoolStats() |
| | | { |
| | | if (m_PoolDict == null) |
| | | return; |
| | | |
| | | foreach (var poolEntry in m_PoolDict) |
| | | { |
| | | int prefabInstanceId = poolEntry.Key; |
| | | GameObjectPool pool = poolEntry.Value; |
| | | |
| | | if (!PoolStatistics.ContainsKey(prefabInstanceId)) |
| | | { |
| | | PoolStatistics[prefabInstanceId] = new PoolStats(); |
| | | } |
| | | |
| | | PoolStats stats = PoolStatistics[prefabInstanceId]; |
| | | stats.TotalObjects = pool.m_ActiveHashSet.Count + pool.m_FreeQueue.Count; |
| | | stats.ActiveObjects = pool.m_ActiveHashSet.Count; |
| | | stats.FreeObjects = pool.m_FreeQueue.Count; |
| | | stats.UsageFrequency = m_PoolUsageFrequency.TryGetValue(prefabInstanceId, out int frequency) ? frequency : 0; |
| | | } |
| | | } |
| | | |
| | | |
| | | private Dictionary<int, GameObjectPool> m_PoolDict = null; |
| | | |
| | | // 不需要销毁的对象列表 |
| | | private List<int> dontDestoryGoInstIDList = null; |
| | | |
| | | private Transform m_TargetContainer; |
| | | |
| | | // 定期检查池的时间间隔(秒) |
| | | private float m_PoolCheckInterval = 600f; |
| | | |
| | | // 记录每个池的使用频率 |
| | | private Dictionary<int, int> m_PoolUsageFrequency = new Dictionary<int, int>(); |
| | | |
| | | //需要动态卸载的预制体,例如切换场景时 |
| | | public List<GameObject> needDestroyPrefabList = new List<GameObject>(); |
| | |
| | | dontDestoryGoInstIDList = new List<int>(); |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | if (m_DebugInstIDDict == null) |
| | | { |
| | | m_DebugInstIDDict = new Dictionary<int, DebugItem>(); |
| | | // 启动定期检查池的协程 |
| | | CheckPoolUsage(); |
| | | } |
| | | #endif |
| | | |
| | | private async UniTask CheckPoolUsage() |
| | | { |
| | | while (true) |
| | | { |
| | | await UniTask.Delay(TimeSpan.FromSeconds(m_PoolCheckInterval)); |
| | | |
| | | foreach (var poolEntry in m_PoolDict) |
| | | { |
| | | int prefabInstanceId = poolEntry.Key; |
| | | GameObjectPool pool = poolEntry.Value; |
| | | |
| | | // 如果池的使用频率低于阈值,减少池的大小 |
| | | if (m_PoolUsageFrequency.TryGetValue(prefabInstanceId, out int usageCount) && usageCount < 5) |
| | | { |
| | | // 保留至少一个对象,避免频繁创建和销毁 |
| | | int targetSize = Mathf.Max(1, pool.m_FreeQueue.Count / 2); |
| | | while (pool.m_FreeQueue.Count > targetSize) |
| | | { |
| | | GameObject obj = pool.m_FreeQueue.Dequeue(); |
| | | if (!dontDestoryGoInstIDList.Contains(obj.GetInstanceID())) |
| | | { |
| | | Destroy(obj); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 重置使用频率 |
| | | m_PoolUsageFrequency[prefabInstanceId] = 0; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void AddDontDestroyGoInstID(int id) |
| | |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 传入的为预制体,而非组件,否则会导致GetInstanceID管理混乱,每次实例化都会改变 |
| | | /// </summary> |
| | | /// <param name="prefab"></param> |
| | | /// <returns></returns> |
| | | public GameObjectPool RequestPool(GameObject prefab) |
| | | { |
| | | if (prefab == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | if (UnityEditor.PrefabUtility.GetPrefabAssetType(prefab) == UnityEditor.PrefabAssetType.NotAPrefab) |
| | | { |
| | | Debug.LogError($"{prefab.name}不是一个预制体!"); |
| | | return null; |
| | | } |
| | | #endif |
| | | |
| | | |
| | | int _prefabInstanceId = prefab.GetInstanceID(); |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | if (UnityEditor.PrefabUtility.GetPrefabAssetType(prefab) == UnityEditor.PrefabAssetType.NotAPrefab) |
| | | { |
| | | Debug.LogError($"{prefab.name}不是一个预制体!"); |
| | | return null; |
| | | } |
| | | #endif |
| | | return RequestPool(prefab).Request(); |
| | | } |
| | | |
| | | |
| | | //特定情况下需要动态卸载的,如切换场景时 |
| | | public void UnLoadAll(bool force = false) |
| | |
| | | } |
| | | |
| | | public HashSet<GameObject> m_ActiveHashSet = new HashSet<GameObject>(); |
| | | private Queue<GameObject> m_FreeQueue = null; |
| | | private int Pool_FreeList_Warning_Threshold = 8; |
| | | public Queue<GameObject> m_FreeQueue = null; |
| | | private int Pool_FreeList_Warning_Threshold = 10; //当空闲对象高于此值时,会进行日志输出提醒 |
| | | |
| | | Action<GameObject> releaseCallBack; |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | private Transform m_DebugContainer; |
| | | private Transform m_DebugActive; |
| | | private Transform m_DebugFree; |
| | | #endif |
| | | |
| | | |
| | | public string assetBundleName; |
| | | public string assetName; |
| | |
| | | m_ActiveHashSet = new HashSet<GameObject>(); |
| | | m_FreeQueue = new Queue<GameObject>(); |
| | | |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | m_DebugContainer = new GameObject(prefab.name).transform; |
| | | m_DebugActive = new GameObject("Active").transform; |
| | | m_DebugFree = new GameObject("Free").transform; |
| | | m_DebugActive.SetParent(m_DebugContainer); |
| | | m_DebugFree.SetParent(m_DebugContainer); |
| | | m_DebugContainer.SetParent(Instance.transform); |
| | | #endif |
| | | } |
| | | |
| | | public void AddReleaseListener(Action<GameObject> _callBack) |
| | |
| | | _go.transform.position = Constants.Special_Hide_Position; |
| | | |
| | | |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | #if UNITY_EDITOR |
| | | // 检查空闲列表数量是否超过阈值 |
| | | if (m_FreeList.Count > Pool_FreeList_Warning_Threshold) |
| | | if (m_FreeQueue.Count > Pool_FreeList_Warning_Threshold) |
| | | { |
| | | Debug.LogWarning($"GameObjectPool {m_Prefab.name} 的空闲对象数量 ({m_FreeList.Count}) 超过阈值 ({Pool_FreeList_Warning_Threshold}),请检查是否需要清理。"); |
| | | Debug.LogWarning($"GameObjectPool {m_Prefab.name} 的空闲对象数量 ({m_FreeQueue.Count}) 超过阈值 ({Pool_FreeList_Warning_Threshold}),请检查是否需要清理。"); |
| | | } |
| | | |
| | | DebugItem _debugItem = new GameObject(_go.GetInstanceID().ToString()).AddMissingComponent<DebugItem>(); |
| | | _debugItem.transform.SetParent(m_DebugFree); |
| | | _debugItem.target = _go; |
| | | Instance.m_DebugInstIDDict[_go.GetInstanceID()] = _debugItem; |
| | | #endif |
| | | var animator = _go.GetComponent<Animator>(); |
| | | if (animator != null) |
| | |
| | | |
| | | m_ActiveHashSet.Add(_go); |
| | | |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | if (Instance.m_DebugInstIDDict.ContainsKey(_go.GetInstanceID())) |
| | | // 统计池的使用频率 |
| | | if (Instance.m_PoolUsageFrequency.ContainsKey(m_Prefab.GetInstanceID())) |
| | | { |
| | | DebugItem _debugItem = Instance.m_DebugInstIDDict[_go.GetInstanceID()]; |
| | | _debugItem.transform.SetParent(m_DebugActive); |
| | | Instance.m_PoolUsageFrequency[m_Prefab.GetInstanceID()]++; |
| | | } |
| | | #endif |
| | | else |
| | | { |
| | | Instance.m_PoolUsageFrequency[m_Prefab.GetInstanceID()] = 1; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | _go = Instantiate(m_Prefab, Constants.Special_Hide_Position, Quaternion.identity); |
| | | m_ActiveHashSet.Add(_go); |
| | | |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | DebugItem _debugItem = new GameObject(_go.GetInstanceID().ToString()).AddMissingComponent<DebugItem>(); |
| | | _debugItem.transform.SetParent(m_DebugActive); |
| | | _debugItem.target = _go; |
| | | Instance.m_DebugInstIDDict[_go.GetInstanceID()] = _debugItem; |
| | | #endif |
| | | } |
| | | |
| | | _go.transform.SetParent(null); |
| | | _go.transform.localScale = Vector3.one; |
| | | |
| | | // 更新池统计数据 |
| | | Instance.UpdatePoolStats(); |
| | | |
| | | return _go; |
| | | } |
| | | |
| | | |
| | | public void Release(GameObject go) |
| | | { |
| | |
| | | |
| | | m_FreeQueue.Enqueue(go); |
| | | go.transform.SetParent(Instance.m_TargetContainer); |
| | | |
| | | go.transform.position = Constants.Special_Hide_Position; |
| | | |
| | | |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | #if UNITY_EDITOR |
| | | // 检查空闲列表数量是否超过阈值 |
| | | if (m_FreeList.Count > Pool_FreeList_Warning_Threshold) |
| | | if (m_FreeQueue.Count > Pool_FreeList_Warning_Threshold) |
| | | { |
| | | Debug.LogWarning($"GameObjectPool {m_Prefab.name} 的空闲对象数量 ({m_FreeList.Count}) 超过阈值 ({Pool_FreeList_Warning_Threshold}),请检查是否需要清理。"); |
| | | } |
| | | if (Instance.m_DebugInstIDDict.ContainsKey(go.GetInstanceID())) |
| | | { |
| | | DebugItem _debugItem = Instance.m_DebugInstIDDict[go.GetInstanceID()]; |
| | | _debugItem.transform.SetParent(m_DebugFree); |
| | | Debug.LogWarning($"GameObjectPool {m_Prefab.name} 的空闲对象数量 ({m_FreeQueue.Count}) 超过阈值 ({Pool_FreeList_Warning_Threshold}),请检查是否需要清理。"); |
| | | } |
| | | #endif |
| | | |
| | |
| | | { |
| | | releaseCallBack(go); |
| | | } |
| | | |
| | | // 更新池统计数据 |
| | | Instance.UpdatePoolStats(); |
| | | } |
| | | |
| | | public void ReleaseAll() |
| | |
| | | go.transform.SetParent(Instance.m_TargetContainer); |
| | | go.transform.position = Constants.Special_Hide_Position; |
| | | |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | if (Instance.m_DebugInstIDDict.ContainsKey(go.GetInstanceID())) |
| | | { |
| | | DebugItem _debugItem = Instance.m_DebugInstIDDict[go.GetInstanceID()]; |
| | | _debugItem.transform.SetParent(m_DebugFree); |
| | | } |
| | | #endif |
| | | if (releaseCallBack != null) |
| | | { |
| | | releaseCallBack(go); |
| | |
| | | |
| | | } |
| | | m_ActiveHashSet.Clear(); |
| | | |
| | | // 更新池统计数据 |
| | | Instance.UpdatePoolStats(); |
| | | } |
| | | |
| | | public void Clear() |
| | |
| | | |
| | | } |
| | | |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | #if UNITY_EDITOR |
| | | if (m_ActiveHashSet.Count != 0) |
| | | { |
| | | Debug.LogWarningFormat("{0} 池清理后, 还有 {1} 个活跃对象. ", m_Prefab.name, m_ActiveHashSet.Count); |
| | |
| | | m_FreeQueue = tempQueue; |
| | | |
| | | |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | if (m_FreeList.Count != 0) |
| | | #if UNITY_EDITOR |
| | | if (m_FreeQueue.Count != 0) |
| | | { |
| | | Debug.LogWarningFormat("{0} 池清理后, 还有 {1} 个空闲对象. ", m_Prefab.name, m_FreeList.Count); |
| | | Debug.LogWarningFormat("{0} 池清理后, 还有 {1} 个空闲对象. ", m_Prefab.name, m_FreeQueue.Count); |
| | | // for (int i = 0; i < m_FreeList.Count; ++i) |
| | | // { |
| | | // Debug.LogWarningFormat(" |-- {0}", m_FreeList[i].name); |
| | |
| | | if (IsEmpty()) |
| | | { |
| | | m_Prefab = null; |
| | | #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS |
| | | Destroy(m_DebugContainer.gameObject); |
| | | #endif |
| | | |
| | | } |
| | | |
| | | if (!string.IsNullOrEmpty(assetBundleName) && !string.IsNullOrEmpty(assetName)) |
| | |
| | | |
| | | |
| | | //上阵属性:攻防血 |
| | | public int GetGoBattleAddPer() |
| | | public int GetOnBattleAddPer() |
| | | { |
| | | return qualityConfig.InitAddPer + qualityConfig.LVAddPer * heroLevel + qualityConfig.BreakLVAddPer * breakLevel + qualityConfig.StarAddPer * heroStar; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | //是否主线上阵 81 # 所在阵容信息列表 [阵容类型*10000+阵型类型*100+位置编号, ...] |
| | | public bool isInMainBattle |
| | | { |
| | | get |
| | | { |
| | | //从列表中找到 阵容为1的 主线阵容 |
| | | var list = itemHero.GetUseData(81); |
| | | if (list != null && list.Count > 0) |
| | | { |
| | | var index = list.FindIndex((item) => item / 10000 == 1); |
| | | if (index >= 0) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | // 优先功能提醒类型:1觉醒 2升级 3突破 4升星 |
| | | // 优先顺序: |
| | | public int funcState |
| | |
| | | { |
| | | return heroConfig.GetInheritPercent(attrType); |
| | | } |
| | | |
| | | //是否上x阵 81 # 所在阵容信息列表 [阵容类型*10000+阵型类型*100+位置编号, ...] |
| | | public bool IsInTeamByTeamType(TeamType teamType) |
| | | { |
| | | var list = itemHero.GetUseData(81); |
| | | if (list != null && list.Count > 0) |
| | | { |
| | | var index = list.FindIndex((item) => item / 10000 == (int)teamType); |
| | | if (index >= 0) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | |
| | | //初始创建(0725),后续跟随背包事件增加删除 key = guid |
| | | protected Dictionary<string, HeroInfo> heroInfoDict = new Dictionary<string, HeroInfo>(); |
| | | |
| | | //武将列表界面 |
| | | public List<string> heroSortList = new List<string>(); |
| | | |
| | | |
| | | //武将红点 |
| | | //MainRedDot.HeroCardRedpoint * 1000 + hero.itemHero.gridIndex; |
| | |
| | | |
| | | void OnBeforePlayerDataInitialize() |
| | | { |
| | | heroSortList.Clear(); |
| | | |
| | | heroInfoDict.Clear(); |
| | | } |
| | | |
| | |
| | | return heroInfoDict.Values.ToList(); |
| | | } |
| | | |
| | | public List<string> GetHeroGuidList() |
| | | { |
| | | return heroInfoDict.Keys.ToList(); |
| | | } |
| | | |
| | | public List<HeroInfo> GetPowerfulHeroList() |
| | | { |
| | | List<HeroInfo> heroList = new List<HeroInfo>(heroInfoDict.Values); |
| | |
| | | return retList; |
| | | } |
| | | |
| | | public bool waitResortHeroList = false; |
| | | |
| | | |
| | | //刷新时机, 打开武将界面 或者 关闭功能界面 |
| | | public void SortHeroList() |
| | | { |
| | | heroSortList = heroInfoDict.Keys.ToList(); |
| | | heroSortList.Sort(CmpHero); |
| | | } |
| | | |
| | | |
| | | int CmpHero(string guidA, string guidB) |
| | | { |
| | | HeroInfo heroA = heroInfoDict[guidA]; |
| | | HeroInfo heroB = heroInfoDict[guidB]; |
| | | if (heroA == null || heroB == null) |
| | | { |
| | | return 0; |
| | | } |
| | | // 排序规则:上阵>武将等级>突破等级>武将觉醒阶级>武将品质>武将吞噬星级>武将ID |
| | | if (heroA.isInMainBattle != heroB.isInMainBattle) |
| | | { |
| | | return heroA.isInMainBattle ? -1 : 1; |
| | | } |
| | | if (heroA.heroLevel != heroB.heroLevel) |
| | | { |
| | | return heroA.heroLevel > heroB.heroLevel ? -1 : 1; |
| | | } |
| | | if (heroA.breakLevel != heroB.breakLevel) |
| | | { |
| | | return heroA.breakLevel > heroB.breakLevel ? -1 : 1; |
| | | } |
| | | if (heroA.awakeLevel != heroB.awakeLevel) |
| | | { |
| | | return heroA.awakeLevel > heroB.awakeLevel ? -1 : 1; |
| | | } |
| | | if (heroA.Quality != heroB.Quality) |
| | | { |
| | | return heroA.Quality > heroB.Quality ? -1 : 1; |
| | | } |
| | | if (heroA.heroStar != heroA.heroStar) |
| | | { |
| | | return heroA.heroStar > heroB.heroStar ? -1 : 1; |
| | | } |
| | | |
| | | return heroA.heroId.CompareTo(heroB.heroId); |
| | | } |
| | | |
| | | } |
| | |
| | | using UnityEngine.EventSystems; |
| | | public class UIHeroController : MonoBehaviour |
| | | { |
| | | private GameObjectPoolManager.GameObjectPool pool; |
| | | private int skinID; |
| | | protected SkeletonGraphic skeletonGraphic; |
| | | |
| | | protected Spine.AnimationState spineAnimationState; |
| | | private GameObject instanceGO; |
| | | |
| | | private Action onComplete; |
| | | public void Create(int _skinID, float scale = 1f, Action _onComplete = null) |
| | | { |
| | | if (skinID == _skinID) |
| | | { |
| | | //避免重复创建 |
| | | return; |
| | | } |
| | | |
| | | skinID = _skinID; |
| | | onComplete = _onComplete; |
| | | GameObject battleGO = UILoader.LoadPrefab("UIHero"); |
| | | GameObject instanceGO = null; |
| | | pool = GameObjectPoolManager.Instance.RequestPool(UILoader.LoadPrefab("UIHero")); |
| | | |
| | | if (!transform.gameObject.activeSelf) |
| | | { |
| | | transform.SetActive(true); |
| | | } |
| | | instanceGO = GameObject.Instantiate(battleGO, transform); |
| | | if (instanceGO == null) |
| | | { |
| | | instanceGO = pool.Request(); |
| | | instanceGO.transform.SetParent(transform); |
| | | //transform 的Pivot Y是0,让instanceGO 居中 |
| | | instanceGO.transform.localPosition = new Vector3(0, transform.GetComponent<RectTransform>().sizeDelta.y * 0.5f); |
| | | |
| | | //instanceGO.transform.localPosition = Vector3.zero; |
| | | instanceGO.transform.localScale = Vector3.one; |
| | | instanceGO.transform.localRotation = Quaternion.identity; |
| | | } |
| | | |
| | | skeletonGraphic = instanceGO.GetComponentInChildren<SkeletonGraphic>(true); |
| | | var skinConfig = HeroSkinConfig.Get(skinID); |
| | | skeletonGraphic.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinConfig.SpineRes + "_SkeletonData"); |
| | |
| | | this.transform.localScale = Vector3.one * scale; |
| | | spineAnimationState = skeletonGraphic.AnimationState; |
| | | PlayAnimation(MotionName.idle, true); |
| | | |
| | | spineAnimationState.Complete -= OnAnimationComplete; |
| | | spineAnimationState.Complete += OnAnimationComplete; |
| | | } |
| | | private int skinID; |
| | | protected SkeletonGraphic skeletonGraphic; |
| | | |
| | | protected Spine.AnimationState spineAnimationState; |
| | | |
| | | private Spine.TrackEntry currentTrackEntry; |
| | | private Action onComplete; |
| | | |
| | | |
| | | |
| | | void Destroy() |
| | | |
| | | protected void OnDestroy() |
| | | { |
| | | if (spineAnimationState != null) |
| | | { |
| | | spineAnimationState.Complete -= OnAnimationComplete; |
| | | } |
| | | if (pool != null) |
| | | pool.Release(instanceGO); |
| | | skeletonGraphic = null; |
| | | pool = null; |
| | | } |
| | | |
| | | |
| | | public virtual Spine.TrackEntry PlayAnimation(MotionName motionName, bool loop = false) |
| | | public virtual void PlayAnimation(MotionName motionName, bool loop = false) |
| | | { |
| | | if (spineAnimationState == null) return null; |
| | | if (spineAnimationState == null) return; |
| | | |
| | | // 直接使用 ToString() 而不是调用 GetAnimationName |
| | | currentTrackEntry = spineAnimationState.SetAnimation(0, motionName.ToString(), loop); |
| | | return currentTrackEntry; |
| | | spineAnimationState.SetAnimation(0, motionName.ToString(), loop); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | public void Display(int index) |
| | | { |
| | | var hero = HeroManager.Instance.GetHero(HeroManager.Instance.heroSortList[index]); |
| | | var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.heroSortList[index]); |
| | | if (hero == null) |
| | | { |
| | | this.gameObject.SetActive(false); |
| | |
| | | countryImg.SetSprite("herocountry" + heroConfig.Country); |
| | | jobImg.SetSprite("herojob" + heroConfig.Class); |
| | | heroModel.Create(heroConfig.SkinIDList[hero.SkinIndex], heroConfig.UIScale); |
| | | onStateImg.SetActive(hero.isInMainBattle); |
| | | onStateImg.SetActive(hero.IsInTeamByTeamType(TeamType.Story)); |
| | | |
| | | redpoint.redpointId = MainRedDot.HeroCardRedpoint * 1000 + hero.itemHero.gridIndex; |
| | | var funcState = hero.funcState; |
| | |
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | | |
| | | public class HeroCardLineCell : CellView |
| | | { |
| | | [SerializeField] List<HeroCardCell> cardList; |
| | | [SerializeField] HeroCardCell[] cardList; |
| | | |
| | | public void Display(int index) |
| | | { |
| | | for (int i = 0; i < cardList.Count; i++) |
| | | for (int i = 0; i < cardList.Length; i++) |
| | | { |
| | | if (i + index < HeroManager.Instance.heroSortList.Count) |
| | | if (i + index < HeroUIManager.Instance.heroSortList.Count) |
| | | { |
| | | cardList[i].SetActive(true); |
| | | cardList[i].Display(index + i); |
New file |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | //羁绊模块 |
| | | public class HeroConnectionCell : MonoBehaviour |
| | | { |
| | | [SerializeField] HeroConnectionHeadCell[] heros; |
| | | [SerializeField] Text connAttrText; |
| | | |
| | | public void Display() |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/System/HeroUI/HeroConnectionCell.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: d9e6754a2b2ddd242a8da5b215186a22 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
New file |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | //羁绊中的武将 |
| | | public class HeroConnectionHeadCell : MonoBehaviour |
| | | { |
| | | [SerializeField] Image qualityImg; |
| | | [SerializeField] Image heroIcon; |
| | | [SerializeField] Text nameText; |
| | | [SerializeField] Image connMarkImg; //链接的锁图标,第一个不显示 |
| | | |
| | | public void Display(int heroID, int index, string guid = "") |
| | | { |
| | | int skinID = 0; |
| | | HeroConfig heroConfig; |
| | | if (!string.IsNullOrEmpty(guid)) |
| | | { |
| | | var hero = HeroManager.Instance.GetHero(guid); |
| | | skinID = hero.SkinID; |
| | | heroConfig = hero.heroConfig; |
| | | } |
| | | else |
| | | { |
| | | heroConfig = HeroConfig.Get(heroID); |
| | | skinID = heroConfig.SkinIDList[0]; //默认第一个图鉴展示 |
| | | |
| | | } |
| | | |
| | | nameText.text = heroConfig.Name; |
| | | qualityImg.SetSprite("heroheadBG" + heroConfig.Quality); |
| | | var sprite = UILoader.LoadSprite("HeroHead", HeroSkinConfig.Get(skinID).SquareIcon); |
| | | if (sprite == null) |
| | | { |
| | | // 内网未配置时 |
| | | heroIcon.SetSprite("herohead_default"); |
| | | } |
| | | else |
| | | { |
| | | heroIcon.overrideSprite = sprite; |
| | | } |
| | | |
| | | connMarkImg.SetActive(index != 0); |
| | | } |
| | | } |
| | | |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/System/HeroUI/HeroConnectionHeadCell.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: 82e5125576855304da53130b59ab10c3 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | |
| | | var sprite = UILoader.LoadSprite("HeroHead", HeroSkinConfig.Get(skinID).SquareIcon); |
| | | if (sprite == null) |
| | | { |
| | | // 内网未配置时 |
| | | heroIcon.SetSprite("herohead_default"); |
| | | } |
| | | else |
| | |
| | | [SerializeField] GameObject attrOnTip; |
| | | [SerializeField] Button attrOnTipBtn; |
| | | |
| | | [SerializeField] GameObject foldObject; |
| | | [SerializeField] Button unFoldBtn; //展开按钮 |
| | | [SerializeField] List<Button> countryBtnList; |
| | | [SerializeField] GameObject unFoldObject; |
| | | [SerializeField] Button foldBtn; //收起按钮 |
| | | [SerializeField] List<Button> jobBtnList; //全部,输出、肉盾、辅助、控制 |
| | | [SerializeField] Button changeHeroPosBtn; //布阵按钮 |
| | | |
| | | |
| | | private List<Image> countrySelectImgList; |
| | | private List<Image> jobSelectImgList; |
| | | |
| | | SinglePack singlePack; |
| | | |
| | | /// </summary> |
| | | protected override void InitComponent() |
| | | { |
| | | heroPackBtn.onClick.AddListener(() => |
| | | heroPackBtn.AddListener(() => |
| | | { |
| | | HeroUIManager.Instance.QueryUnLockHeroPack(); |
| | | }); |
| | | changeHeroPosBtn.AddListener(() => |
| | | { |
| | | HeroUIManager.Instance.selectTeamType = TeamType.Story; |
| | | UIManager.Instance.OpenWindow<HeroPosWin>(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | singlePack = PackManager.Instance.GetSinglePack(PackType.Hero); |
| | | heroListScroller.OnRefreshCell += OnRefreshCell; |
| | | //需要考虑调整为武将的事件,而不是背包 |
| | | PackManager.Instance.RefreshItemEvent += RefreshPakCount; |
| | | HeroManager.Instance.SortHeroList(); |
| | | HeroUIManager.Instance.SortHeroList(); |
| | | CreateScroller(); |
| | | Refresh(); |
| | | } |
| | |
| | | |
| | | public override void Refresh() |
| | | { |
| | | SinglePack singlePack = PackManager.Instance.GetSinglePack(PackType.Hero); |
| | | if (singlePack == null || singlePack.GetAllItems().Count <= 0) |
| | | { |
| | | heroListEmpty.SetActive(true); |
| | |
| | | heroListScroller.SetActive(true); |
| | | } |
| | | |
| | | OnBattleTeamAttrPer(); |
| | | |
| | | RefreshPakCount(PackType.Hero, 0, 0); |
| | | } |
| | | |
| | | //上阵加成 |
| | | void OnBattleTeamAttrPer() |
| | | { |
| | | var valuePer = 0; |
| | | var team = TeamManager.Instance.GetTeam(TeamType.Story); |
| | | if (team != null) |
| | | { |
| | | for (int i = 0; i < team.serverData.Length; i++) |
| | | { |
| | | var hero = HeroManager.Instance.GetHero(team.serverData[i].guid); |
| | | if (hero != null) |
| | | { |
| | | valuePer += hero.GetOnBattleAddPer(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | //上阵属性 |
| | | for (int i = 0; i < attrOnList.Count; i++) |
| | | { |
| | | attrOnList[i].text = PlayerPropertyConfig.GetFullDescription(new Int2(PlayerPropertyConfig.baseAttrs[i], 1)); |
| | | attrOnList[i].text = PlayerPropertyConfig.GetFullDescription(new Int2(PlayerPropertyConfig.basePerAttrs[i], valuePer)); |
| | | } |
| | | |
| | | RefreshPakCount(PackType.Hero, 0, 0); |
| | | } |
| | | |
| | | void OnRefreshCell(ScrollerDataType type, CellView cell) |
| | |
| | | void CreateScroller() |
| | | { |
| | | heroListScroller.Refresh(); |
| | | for (int i = 0; i < HeroManager.Instance.heroSortList.Count; i++) |
| | | for (int i = 0; i < HeroUIManager.Instance.heroSortList.Count; i++) |
| | | { |
| | | if (i % 4 == 0) |
| | | { |
| | |
| | | { |
| | | if (type != PackType.Hero) |
| | | return; |
| | | SinglePack singlePack = PackManager.Instance.GetSinglePack(PackType.Hero); |
| | | if (singlePack == null) |
| | | return; |
| | | |
New file |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | public class HeroPosHeadCell : MonoBehaviour |
| | | { |
| | | [SerializeField] HeroHeadBaseCell heroHeadBaseCell; |
| | | [SerializeField] Image jobImg; |
| | | [SerializeField] Text nameText; |
| | | [SerializeField] Transform selectRect; |
| | | |
| | | public void Display(int index) |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
File was renamed from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: 85d03e47b5934534baabc6d5091adaa5 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
New file |
| | |
| | | using UnityEngine; |
| | | |
| | | public class HeroPosLineCell : CellView |
| | | { |
| | | [SerializeField] HeroPosHeadCell[] cardList; |
| | | |
| | | public void Display(int index) |
| | | { |
| | | for (int i = 0; i < cardList.Length; i++) |
| | | { |
| | | if (i + index < HeroUIManager.Instance.heroOnTeamSortList.Count) |
| | | { |
| | | cardList[i].SetActive(true); |
| | | cardList[i].Display(index + i); |
| | | } |
| | | else |
| | | { |
| | | cardList[i].SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/System/HeroUI/HeroPosLineCell.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: 22807977a993b4b438ca473603f2494e |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
New file |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | /// <summary> |
| | | /// 武将布阵: functionOrder:布阵类型 |
| | | /// </summary> |
| | | public class HeroPosWin : UIBase |
| | | { |
| | | [SerializeField] Text[] attrOnList; //上阵属性加成 |
| | | [SerializeField] Image countryOnImg; //上阵阵型激活国家 |
| | | [SerializeField] List<Image> OnCountImgs; //上阵数量激活 |
| | | [SerializeField] List<Image> scenePosImgs; //场景布阵位置 |
| | | [SerializeField] HeroScenePosCell[] sceneHero; |
| | | |
| | | [SerializeField] GroupButtonEx attackTeamBtn; |
| | | [SerializeField] GroupButtonEx defendTeamBtn; |
| | | |
| | | [SerializeField] Text fightPowerText; //由客户端自己预算的战力 |
| | | [SerializeField] ScrollerController heroListScroller; |
| | | [SerializeField] Transform heroListEmpty; |
| | | [SerializeField] Toggle showConnTipToggleBtn; |
| | | [SerializeField] HeroSelectBehaviour fiterManager; //武将筛选 |
| | | |
| | | [SerializeField] Button oneKeyOnBtn; //一键上阵 |
| | | [SerializeField] Button saveBtn; //保存阵型 |
| | | [SerializeField] Button backBtn; //退出界面 |
| | | [SerializeField] GroupButtonEx jjcBtn; //竞技场 |
| | | [SerializeField] GroupButtonEx tttBtn; //通天塔 |
| | | [SerializeField] GroupButtonEx mainFBBtn; //主线副本 |
| | | |
| | | //羁绊 |
| | | [SerializeField] HeroConnectionCell connetionForm; |
| | | |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | attackTeamBtn.AddListener(() => |
| | | { |
| | | if (HeroUIManager.Instance.selectTeamType == TeamType.Arena) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | HeroUIManager.Instance.selectTeamType = TeamType.Arena; |
| | | Refresh(); |
| | | }); |
| | | defendTeamBtn.AddListener(() => |
| | | { |
| | | if (HeroUIManager.Instance.selectTeamType == TeamType.ArenaDefense) |
| | | { |
| | | return; |
| | | } |
| | | HeroUIManager.Instance.selectTeamType = TeamType.ArenaDefense; |
| | | Refresh(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | heroListScroller.OnRefreshCell += OnRefreshCell; |
| | | CreateScroller(); |
| | | Refresh(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | heroListScroller.OnRefreshCell -= OnRefreshCell; |
| | | } |
| | | |
| | | |
| | | public override void Refresh() |
| | | { |
| | | OnBattleTeamAttrPer(); |
| | | RefreshOnTeamCountry(); |
| | | RefreshOnTeamBtn(); |
| | | } |
| | | |
| | | |
| | | |
| | | void OnRefreshCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell as HeroCardLineCell; |
| | | _cell.Display(cell.index); |
| | | } |
| | | |
| | | void CreateScroller() |
| | | { |
| | | heroListScroller.Refresh(); |
| | | for (int i = 0; i < HeroUIManager.Instance.heroSortList.Count; i++) |
| | | { |
| | | if (i % 4 == 0) |
| | | { |
| | | heroListScroller.AddCell(ScrollerDataType.Header, i); |
| | | } |
| | | } |
| | | heroListScroller.Restart(); |
| | | } |
| | | |
| | | //上阵加成 |
| | | void OnBattleTeamAttrPer() |
| | | { |
| | | var valuePer = 0; |
| | | var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType); |
| | | if (team != null) |
| | | { |
| | | for (int i = 0; i < team.serverData.Length; i++) |
| | | { |
| | | var hero = HeroManager.Instance.GetHero(team.serverData[i].guid); |
| | | if (hero != null) |
| | | { |
| | | valuePer += hero.GetOnBattleAddPer(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | //上阵属性 |
| | | for (int i = 0; i < attrOnList.Length; i++) |
| | | { |
| | | attrOnList[i].text = PlayerPropertyConfig.GetFullDescription(new Int2(PlayerPropertyConfig.basePerAttrs[i], valuePer)); |
| | | } |
| | | } |
| | | |
| | | //上阵武将国家光环激活 |
| | | void RefreshOnTeamCountry() |
| | | { |
| | | Int2 result = HeroUIManager.Instance.GetMaxCountHeroCountry(HeroUIManager.Instance.selectTeamType); |
| | | |
| | | var config = HeroLineupHaloConfig.GetConfig(result.x, result.y); |
| | | if (config == null) |
| | | { |
| | | countryOnImg.SetSprite("heroTeamCountry" + result.x); |
| | | for (int i = 0; i < OnCountImgs.Count; i++) |
| | | { |
| | | OnCountImgs[i].SetActive(false); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | countryOnImg.SetSprite("heroTeamCountry" + result.x); |
| | | for (int i = 0; i < OnCountImgs.Count; i++) |
| | | { |
| | | if (i < result.y) |
| | | { |
| | | OnCountImgs[i].SetActive(true); |
| | | OnCountImgs[i].SetSprite("heroTeamCountryPoint" + result.x); |
| | | } |
| | | else |
| | | { |
| | | OnCountImgs[i].SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | //管理布阵入口按钮:如竞技场是否根据功能显隐,通天塔和主线只有进攻方布阵默认不显示 |
| | | void RefreshOnTeamBtn() |
| | | { |
| | | if (HeroUIManager.Instance.selectTeamType == TeamType.Arena || |
| | | HeroUIManager.Instance.selectTeamType == TeamType.ArenaDefense) |
| | | { |
| | | attackTeamBtn.SetActive(true); |
| | | defendTeamBtn.SetActive(true); |
| | | if (HeroUIManager.Instance.selectTeamType == TeamType.Arena) |
| | | { |
| | | attackTeamBtn.SelectBtn(true); |
| | | } |
| | | else |
| | | { |
| | | defendTeamBtn.SelectBtn(true); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | attackTeamBtn.SetActive(false); |
| | | defendTeamBtn.SetActive(false); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/System/HeroUI/HeroPosWin.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: c8849c7f1a741cc438948b5f03557325 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
New file |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | //布阵中的 武将角色 |
| | | public class HeroScenePosCell : MonoBehaviour |
| | | { |
| | | [SerializeField] Button heroBtn; |
| | | [SerializeField] Text jobTip; |
| | | [SerializeField] Text posTip; |
| | | [SerializeField] Image countryImg; |
| | | [SerializeField] Text nameText; |
| | | [SerializeField] Text lvText; |
| | | [SerializeField] UIHeroController heroModel; |
| | | [SerializeField] Image posCircleImg; |
| | | |
| | | public void Display(string guid) |
| | | { |
| | | var hero = HeroManager.Instance.GetHero(guid); |
| | | |
| | | lvText.text = Language.Get("L1094") + hero.heroLevel.ToString(); |
| | | var heroConfig = hero.heroConfig; |
| | | countryImg.SetSprite("herocountry" + heroConfig.Country); |
| | | heroModel.Create(heroConfig.SkinIDList[hero.SkinIndex], heroConfig.UIScale); |
| | | |
| | | |
| | | nameText.text = hero.breakLevel == 0 ? heroConfig.Name : Language.Get("herocardbreaklv", heroConfig.Name, hero.breakLevel); |
| | | |
| | | } |
| | | } |
| | | |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/System/HeroUI/HeroScenePosCell.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: 5568cf8758fcecf45ac471d4b4bbd6fe |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | //武将筛选 |
| | | public class HeroSelectBehaviour : MonoBehaviour |
| | | { |
| | | [SerializeField] Transform unFoldForm; //展开后的容器 |
| | | [SerializeField] Button foldBtn; //收起按钮 |
| | | [SerializeField] Transform foldForm; //收起容器 |
| | | [SerializeField] Button unFoldBtn; //展开按钮 |
| | | [SerializeField] GroupButtonEx[] jobsBtn; |
| | | [SerializeField] GroupButtonEx[] countrysBtn; |
| | | [SerializeField] GroupButtonExManager jobManager; |
| | | [SerializeField] GroupButtonExManager countryManager; |
| | | |
| | | int m_Job = 0; |
| | | int m_Country = 0; |
| | | int foldState = 0; //0 收起,1 展开 |
| | | |
| | | //点击按钮需通知响应外部事件 |
| | | public Action<int, int> selectAction; |
| | | |
| | | |
| | | |
| | | |
| | | void Awake() |
| | | { |
| | | foldBtn.AddListener(() => |
| | | { |
| | | foldState = 0; |
| | | RefreshFolState(); |
| | | }); |
| | | unFoldBtn.AddListener(() => |
| | | { |
| | | foldState = 1; |
| | | RefreshFolState(); |
| | | }); |
| | | |
| | | for (int i = 0; i < jobsBtn.Length; i++) |
| | | { |
| | | int index = i; |
| | | jobsBtn[i].AddListener(() => |
| | | { |
| | | m_Job = index; |
| | | RefreshJobsBtn(); |
| | | selectAction?.Invoke(m_Job, m_Country); |
| | | }); |
| | | } |
| | | |
| | | for (int i = 0; i < countrysBtn.Length; i++) |
| | | { |
| | | int index = i; |
| | | countrysBtn[i].AddListener(() => |
| | | { |
| | | m_Country = index; |
| | | RefreshCountryBtn(); |
| | | selectAction?.Invoke(m_Job, m_Country); |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void Display(int state, int job, int country, Action<int, int> onRefresh) |
| | | { |
| | | foldState = state; |
| | | m_Job = job; |
| | | m_Country = country; |
| | | |
| | | RefreshFolState(); |
| | | RefreshJobsBtn(); |
| | | RefreshCountryBtn(); |
| | | selectAction = onRefresh; |
| | | |
| | | } |
| | | |
| | | |
| | | //刷新全部分类 |
| | | void RefreshJobsBtn() |
| | | { |
| | | jobManager.SelectButton(jobsBtn[m_Job]); |
| | | } |
| | | //刷新全部分类 |
| | | void RefreshCountryBtn() |
| | | { |
| | | countryManager.SelectButton(countrysBtn[m_Country]); |
| | | } |
| | | //刷新展开收起状态 |
| | | void RefreshFolState() |
| | | { |
| | | unFoldBtn.SetActive(foldState == 1); |
| | | foldBtn.SetActive(foldState == 0); |
| | | } |
| | | } |
| | | |
copy from Main/Utility/GameObjectPool.cs.meta
copy to Main/System/HeroUI/HeroSelectBehaviour.cs.meta
File was copied from Main/Utility/GameObjectPool.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 99e41fbb2b3832c41b1575b72c946cca |
| | | timeCreated: 1504310243 |
| | | licenseType: Pro |
| | | guid: 81701dbe94ee5914c97bbc39aa5a418f |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | |
| | | |
| | | using UnityEngine; |
| | | |
| | | //武将相关界面的操作数据管理 |
| | | public class HeroUIManager : GameSystemManager<HeroUIManager> |
| | | { |
| | | //武将列表界面 |
| | | public List<string> heroSortList { get; private set; } = new List<string>(); //上阵为主线的列表 |
| | | |
| | | public List<string> heroOnTeamSortList { get; private set; } = new List<string>(); //不同上阵的列表排序 |
| | | |
| | | public TeamType selectTeamType = TeamType.Story; //当前选中的是哪个阵容, 布阵相关逻辑使用 |
| | | |
| | | public void OnBeforePlayerDataInitialize() |
| | | { |
| | | |
| | | heroSortList.Clear(); |
| | | heroOnTeamSortList.Clear(); |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | |
| | | |
| | | } |
| | | |
| | | void ParseConfig() |
| | | public bool waitResortHeroList = false; |
| | | |
| | | |
| | | //刷新时机, 打开武将界面 或者 关闭功能界面 |
| | | public void SortHeroList() |
| | | { |
| | | heroSortList = HeroManager.Instance.GetHeroGuidList(); |
| | | heroSortList.Sort(CmpHero); |
| | | } |
| | | |
| | | |
| | | int CmpHero(string guidA, string guidB) |
| | | { |
| | | HeroInfo heroA = HeroManager.Instance.GetHero(guidA); |
| | | HeroInfo heroB = HeroManager.Instance.GetHero(guidB); |
| | | if (heroA == null || heroB == null) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | // 排序规则:上阵>武将等级>突破等级>武将觉醒阶级>武将品质>武将吞噬星级>武将ID |
| | | bool isInTeamA = heroA.IsInTeamByTeamType(TeamType.Story); |
| | | bool isInTeamB = heroB.IsInTeamByTeamType(TeamType.Story); |
| | | if (isInTeamA != isInTeamB) |
| | | { |
| | | return isInTeamA ? -1 : 1; |
| | | } |
| | | if (heroA.heroLevel != heroB.heroLevel) |
| | | { |
| | | return heroA.heroLevel > heroB.heroLevel ? -1 : 1; |
| | | } |
| | | if (heroA.breakLevel != heroB.breakLevel) |
| | | { |
| | | return heroA.breakLevel > heroB.breakLevel ? -1 : 1; |
| | | } |
| | | if (heroA.awakeLevel != heroB.awakeLevel) |
| | | { |
| | | return heroA.awakeLevel > heroB.awakeLevel ? -1 : 1; |
| | | } |
| | | if (heroA.Quality != heroB.Quality) |
| | | { |
| | | return heroA.Quality > heroB.Quality ? -1 : 1; |
| | | } |
| | | if (heroA.heroStar != heroA.heroStar) |
| | | { |
| | | return heroA.heroStar > heroB.heroStar ? -1 : 1; |
| | | } |
| | | |
| | | return heroA.heroId.CompareTo(heroB.heroId); |
| | | } |
| | | |
| | | |
| | | public void SortHeroOnTeamList() |
| | | { |
| | | heroOnTeamSortList = HeroManager.Instance.GetHeroGuidList(); |
| | | heroOnTeamSortList.Sort(CmpHeroByTeamType); |
| | | } |
| | | |
| | | |
| | | int CmpHeroByTeamType(string guidA, string guidB) |
| | | { |
| | | HeroInfo heroA = HeroManager.Instance.GetHero(guidA); |
| | | HeroInfo heroB = HeroManager.Instance.GetHero(guidB); |
| | | if (heroA == null || heroB == null) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | // 排序规则:上阵>武将等级>突破等级>武将觉醒阶级>武将品质>武将吞噬星级>武将ID |
| | | bool isInTeamA = heroA.IsInTeamByTeamType(selectTeamType); |
| | | bool isInTeamB = heroB.IsInTeamByTeamType(selectTeamType); |
| | | if (isInTeamA != isInTeamB) |
| | | { |
| | | return isInTeamA ? -1 : 1; |
| | | } |
| | | if (heroA.heroLevel != heroB.heroLevel) |
| | | { |
| | | return heroA.heroLevel > heroB.heroLevel ? -1 : 1; |
| | | } |
| | | if (heroA.breakLevel != heroB.breakLevel) |
| | | { |
| | | return heroA.breakLevel > heroB.breakLevel ? -1 : 1; |
| | | } |
| | | if (heroA.awakeLevel != heroB.awakeLevel) |
| | | { |
| | | return heroA.awakeLevel > heroB.awakeLevel ? -1 : 1; |
| | | } |
| | | if (heroA.Quality != heroB.Quality) |
| | | { |
| | | return heroA.Quality > heroB.Quality ? -1 : 1; |
| | | } |
| | | if (heroA.heroStar != heroA.heroStar) |
| | | { |
| | | return heroA.heroStar > heroB.heroStar ? -1 : 1; |
| | | } |
| | | |
| | | return heroA.heroId.CompareTo(heroB.heroId); |
| | | } |
| | | |
| | | |
| | | |
| | | public void QueryUnLockHeroPack() |
| | | { |
| | | //解锁更多的武将背包 |
| | | } |
| | | |
| | | //上阵队伍中各个国家的武将数量 |
| | | public Dictionary<HeroCountry, int> GetCountryHeroCountByTeamType(TeamType teamType) |
| | | { |
| | | Dictionary<HeroCountry, int> heroCountryCount = new Dictionary<HeroCountry, int>(); |
| | | |
| | | var team = TeamManager.Instance.GetTeam(teamType); |
| | | if (team != null) |
| | | { |
| | | for (int i = 0; i < team.serverData.Length; i++) |
| | | { |
| | | var hero = HeroManager.Instance.GetHero(team.serverData[i].guid); |
| | | if (hero != null) |
| | | { |
| | | if (!heroCountryCount.ContainsKey(hero.heroCountry)) |
| | | { |
| | | heroCountryCount.Add(hero.heroCountry, 1); |
| | | } |
| | | else |
| | | { |
| | | heroCountryCount[hero.heroCountry] += 1; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return heroCountryCount; |
| | | } |
| | | |
| | | //获得上阵中武将数量最大的国家和数量 |
| | | public Int2 GetMaxCountHeroCountry(TeamType teamType) |
| | | { |
| | | var countryCount = GetCountryHeroCountByTeamType(teamType); |
| | | //找到最大的国家和数量 |
| | | HeroCountry country = HeroCountry.None; |
| | | int maxValue = 0; |
| | | foreach (var data in countryCount) |
| | | { |
| | | if (data.Value > maxValue) |
| | | { |
| | | country = data.Key; |
| | | maxValue = data.Value; |
| | | } |
| | | } |
| | | return new Int2((int)country, maxValue); |
| | | } |
| | | |
| | | //AttackType 0 攻击阵容 1 防守阵容 |
| | | int GetSelectTeamTypeByAttackType(int AttackType) |
| | | { |
| | | if (selectTeamType == TeamType.Arena) |
| | | { |
| | | if (AttackType == 0) |
| | | { |
| | | return (int)TeamType.Arena; |
| | | } |
| | | else if (AttackType == 1) |
| | | { |
| | | return (int)TeamType.ArenaDefense; |
| | | } |
| | | } |
| | | else if (selectTeamType == TeamType.ArenaDefense) |
| | | { |
| | | if (AttackType == 0) |
| | | { |
| | | return (int)TeamType.ArenaDefense; |
| | | } |
| | | else if (AttackType == 1) |
| | | { |
| | | return (int)TeamType.Arena; |
| | | } |
| | | } |
| | | |
| | | return (int)TeamType.Story; |
| | | } |
| | | } |
| | |
| | | index = serverItem.ItemPlace;
|
| | | count = (int)serverItem.ItemCount;
|
| | | remainHour = (int)serverItem.RemainHour;
|
| | | userData = serverItem.UserData;
|
| | | guid = serverItem.ItemGUID;
|
| | | userData = serverItem.UserData.Trim().Replace("\0", "");
|
| | | guid = serverItem.ItemGUID.Trim().Replace("\0", "");
|
| | | isAuction = serverItem.IsBind;
|
| | | gearScore = (int)serverItem.GearScore;
|
| | | isLock = serverItem.IsLocked > 0;
|
| | |
| | | index = serverItem.ItemPlace;
|
| | | count = (int)serverItem.ItemCount;
|
| | | remainHour = (int)serverItem.RemainHour;
|
| | | userData = serverItem.UserData;
|
| | | guid = serverItem.ItemGUID;
|
| | | //字符串后面有空字符问题,经常会导致不可预料的bug
|
| | | userData = serverItem.UserData.Trim().Replace("\0", "");
|
| | | guid = serverItem.ItemGUID.Trim().Replace("\0", "");
|
| | | isAuction = serverItem.IsBind;
|
| | | gearScore = (int)serverItem.GearScore;
|
| | | isLock = serverItem.IsLocked > 0;
|
| | |
| | | [SerializeField] Text taskNumText; |
| | | [SerializeField] Image awardIcon; |
| | | [SerializeField] Text awardCnt; |
| | | [SerializeField] EffectPlayer taskEffect; |
| | | [SerializeField] UIEffectPlayer taskEffect; |
| | | |
| | | |
| | | //关卡 |
| | |
| | | TaskManager.Instance.OnTaskUpdate += UpdateTask; |
| | | Refresh(); |
| | | UIManager.Instance.OpenWindow<BattleWin>(); |
| | | |
| | | taskEffect.effectId = Random.Range(1007, 1008); |
| | | taskEffect.Play(); |
| | | } |
| | | protected override void OnOpen() |
| | | { |
| | |
| | | }
|
| | | }
|
| | |
|
| | | EffectPlayer m_AvatarUIEffect;
|
| | | private EffectPlayer avatarUIEffect
|
| | | UIEffectPlayer m_AvatarUIEffect;
|
| | | private UIEffectPlayer avatarUIEffect
|
| | | {
|
| | | get
|
| | | {
|
| | | if (m_AvatarUIEffect == null)
|
| | | {
|
| | | m_AvatarUIEffect = this.GetComponent<EffectPlayer>("AvatarCell/Img_Avatar");
|
| | | m_AvatarUIEffect = this.GetComponent<UIEffectPlayer>("AvatarCell/Img_Avatar");
|
| | | }
|
| | | return m_AvatarUIEffect;
|
| | | }
|
| | | }
|
| | |
|
| | | EffectPlayer m_AvatarFrameUIEffect;
|
| | | private EffectPlayer avatarFrameUIEffect
|
| | | UIEffectPlayer m_AvatarFrameUIEffect;
|
| | | private UIEffectPlayer avatarFrameUIEffect
|
| | | {
|
| | | get
|
| | | {
|
| | | if (m_AvatarFrameUIEffect == null)
|
| | | {
|
| | | m_AvatarFrameUIEffect = this.GetComponent<EffectPlayer>("AvatarCell/Img_AvatarFrame");
|
| | | m_AvatarFrameUIEffect = this.GetComponent<UIEffectPlayer>("AvatarCell/Img_AvatarFrame");
|
| | | }
|
| | | return m_AvatarFrameUIEffect;
|
| | | }
|
| | |
| | | { |
| | | // 英雄当前所有在的队伍 |
| | | List<int> heroTeams = heroInfo.itemHero.GetUseData(81); |
| | | if (heroTeams == null || heroTeams.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | Dictionary<TeamType, KeyValuePair<int, int>> teamTypeShapeTypePositionDict = new Dictionary<TeamType, KeyValuePair<int, int>>(); |
| | | foreach (var teamMsg in heroTeams) |
| | |
| | | |
| | | if (!teamDict.TryGetValue(teamType, out team)) |
| | | { |
| | | team = new TeamBase(teamType); |
| | | team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList()); |
| | | teamDict.Add(teamType, team); |
| | | // 测试用 |
| | | // team = new TeamBase(teamType); |
| | | // team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList()); |
| | | // teamDict.Add(teamType, team); |
| | | } |
| | | |
| | | return team; |
| | |
| | | |
| | | |
| | | //与服务端的约定 对应函数GetSelectTeamTypeByAttackType |
| | | public enum TeamType |
| | | { |
| | | None = 0, |
| | | // PVE |
| | | Story = 1, |
| | | |
| | | |
| | | // PVP |
| | | Arena = 101, |
| | | // PVP 进攻 |
| | | Arena = 21, |
| | | // PVP 防守 |
| | | ArenaDefense = 22, |
| | | Tower = 3, |
| | | } |
| | | |
| | |
| | | [SerializeField] RichText marqueeText; |
| | | [SerializeField] RectTransform marqueeBg; |
| | | [SerializeField] TweenCurve tweenCurve; |
| | | [SerializeField] EffectPlayer m_Effect; |
| | | [SerializeField] UIEffectPlayer m_Effect; |
| | | |
| | | Vector3 fromPos; |
| | | Vector3 toPos; |
| | |
| | | /// <summary> |
| | | /// 播放UI特效 |
| | | /// </summary> |
| | | /// <param name="effectName">特效资源名称</param> |
| | | /// <param name="id">特效资源名称</param> |
| | | /// <param name="parent">特效父节点,默认为当前UI</param> |
| | | /// <param name="autoDestroy">是否自动销毁,默认为true</param> |
| | | /// <param name="destroyDelay">自动销毁延迟时间,默认为5秒</param> |
| | | /// <returns>特效游戏对象</returns> |
| | | public EffectPlayer PlayUIEffect(int id, Transform parent = null) |
| | | public UIEffectPlayer PlayUIEffect(int id, Transform parent = null) |
| | | { |
| | | // 使用默认值 |
| | | if (parent == null) parent = transform; |
| | | |
| | | return EffectPlayer.Create(id, parent, false); |
| | | return UIEffectPlayer.CreateEffect(id, parent, false); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | |
| | | public enum TitleBtnState |
| | | { |
| | | Normal, |
| | | Click, |
| | | Normal, //非点击状态 |
| | | Click, //点击后状态 |
| | | Locked, |
| | | } |
| | | |