| | |
| | | { |
| | | public int renderQueue = 3000; |
| | | |
| | | public Canvas canvas; |
| | | |
| | | public int sortingOrderOffset = 1; |
| | | public int sortingOrder = 0; |
| | | |
| | | public string customSortingLayer = "UI"; |
| | | |
| | | public List<Renderer> renderers = new List<Renderer>(); |
| | | |
| | | public Action<string, int> onSortingChanged; |
| | | |
| | | public void SetSortingOrder(int sortingOrder) |
| | | { |
| | | this.sortingOrder = sortingOrder; |
| | | UpdateComps(); |
| | | UpdateSortingOrder(); |
| | | } |
| | | |
| | | public void Awake() |
| | | { |
| | | UpdateComps(); |
| | | } |
| | | |
| | | protected void OnEnable() |
| | | { |
| | | UpdateComps(); |
| | | UpdateSortingOrder(); |
| | | } |
| | | |
| | | protected void UpdateComps() |
| | | { |
| | | renderers.Clear(); |
| | | renderers.AddRange(gameObject.GetComponentsInChildren<Renderer>(true)); |
| | | |
| | | canvas = GetComponentInParent<Canvas>(); |
| | | } |
| | | |
| | | public void SetParentCanvas(Canvas _canvas) |
| | | { |
| | | canvas = _canvas; |
| | | this.DelayFrame(UpdateSortingOrder); |
| | | } |
| | | |
| | | public void UpdateSortingOrder() |
| | | { |
| | | int canvasSortingOrder = 0; |
| | | |
| | | // 获取父级Canvas的排序顺序 |
| | | if (canvas != null) |
| | | { |
| | | canvasSortingOrder = canvas.sortingOrder; |
| | | } |
| | | else |
| | | { |
| | | // 如果没有找到父级Canvas,则使用默认值 |
| | | canvasSortingOrder = 0; |
| | | } |
| | | |
| | | // 将特效的排序顺序设置为Canvas排序顺序加上偏移量 |
| | | ApplySortingSettings(canvasSortingOrder + sortingOrderOffset, customSortingLayer); |
| | | ApplySortingSettings(sortingOrder, customSortingLayer); |
| | | } |
| | | |
| | | private void ApplySortingSettings(int sortingOrder, string sortingLayer) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | onSortingChanged?.Invoke(sortingLayer, sortingOrder); |
| | | } |
| | | } |
| | |
| | | private int currentRound = 0; |
| | | |
| | | // 缓存层级对应的排序顺序 |
| | | private Dictionary<UILayer, int> layerSortingOrderCache = new Dictionary<UILayer, int>(); |
| | | private static Dictionary<UILayer, int> layerSortingOrderCache = new Dictionary<UILayer, int>(); |
| | | |
| | | // 缓存层级对应的Transform |
| | | private Dictionary<UILayer, Transform> layerTransformCache = new Dictionary<UILayer, Transform>(); |
| | |
| | | #region 辅助方法 |
| | | |
| | | // 获取UI层级对应的基础排序顺序 |
| | | private int GetBaseSortingOrderForLayer(UILayer layer) |
| | | public static int GetBaseSortingOrderForLayer(UILayer layer) |
| | | { |
| | | // 尝试从缓存中获取排序顺序 |
| | | if (layerSortingOrderCache.TryGetValue(layer, out int order)) |
| | |
| | | public const int skillMotionFps = 30; |
| | | |
| | | public const int BattlePointItemID = 3;//战锤ID |
| | | |
| | | |
| | | // 1000~10000之间的战斗层级 |
| | | // 需要考虑根据UI 特效 战斗角色三方的层级关系 |
| | | // 确立基本的层级范围 后往上累加 |
| | | // 1.不能在BattleWin之下 否则就看不见了 |
| | | // 2.处理EffectPenetrationBlocker的自动调整排序 |
| | | // 3.要联动EffectConfig的前后的问题 |
| | | // BattleWin.Canvas.sortingOrder是最低值 |
| | | // 还需要确立黑色的Mask的层级 |
| | | |
| | | |
| | | // UI界面|非激活英雄|挡板|激活英雄 |
| | | |
| | | // 非激活英雄后特效|非激活英雄|非激活英雄前 |
| | | |
| | | // 激活英雄后特效|激活英雄|激活英雄前特效 |
| | | |
| | | public const int BattleBlackTransparentMaskOffset = 100; |
| | | |
| | | |
| | | public static int BattleWinSortingOrder |
| | | { |
| | | get |
| | | { |
| | | |
| | | BattleWin battleWin = UIManager.Instance.GetUI<BattleWin>(); |
| | | if (battleWin != null) |
| | | { |
| | | return battleWin.GetSortingOrder(); |
| | | } |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | // 非激活英雄的层级 |
| | | public static int UnactiveHeroSortingOrder |
| | | { |
| | | get |
| | | { |
| | | return BattleWinSortingOrder + BattleBlackTransparentMaskOffset - 50; |
| | | } |
| | | } |
| | | |
| | | // 非激活英雄的后特效 |
| | | public static int UnactiveHeroBackSortingOrder |
| | | { |
| | | get |
| | | { |
| | | return UnactiveHeroSortingOrder - 1; |
| | | } |
| | | } |
| | | |
| | | // 非激活英雄的前特效 |
| | | public static int UnactiveHeroFrontSortingOrder |
| | | { |
| | | get |
| | | { |
| | | return UnactiveHeroSortingOrder + 1; |
| | | } |
| | | } |
| | | |
| | | // 挡板的层级 |
| | | public static int BlockerSortingOrder |
| | | { |
| | | get |
| | | { |
| | | return UnactiveHeroFrontSortingOrder + 1; |
| | | } |
| | | } |
| | | |
| | | // 激活英雄的层级 |
| | | public static int ActiveHeroSortingOrder |
| | | { |
| | | get |
| | | { |
| | | return BattleWinSortingOrder + BattleBlackTransparentMaskOffset + 50; |
| | | } |
| | | } |
| | | |
| | | // 激活英雄的后特效 |
| | | public static int ActiveHeroBackSortingOrder |
| | | { |
| | | get |
| | | { |
| | | return ActiveHeroSortingOrder - 1; |
| | | } |
| | | } |
| | | |
| | | // 激活英雄的前特效 |
| | | public static int ActiveHeroFrontSortingOrder |
| | | { |
| | | get |
| | | { |
| | | return ActiveHeroSortingOrder + 1; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | RendererAdjuster[] adjusters = battleRootNode.GetComponentsInChildren<RendererAdjuster>(true); |
| | | if (null != adjusters) |
| | | { |
| | | foreach (var adjuster in adjusters) |
| | | { |
| | | adjuster.SetParentCanvas(canvas); |
| | | } |
| | | } |
| | | // RendererAdjuster[] adjusters = battleRootNode.GetComponentsInChildren<RendererAdjuster>(true); |
| | | // if (null != adjusters) |
| | | // { |
| | | // foreach (var adjuster in adjusters) |
| | | // { |
| | | // adjuster.SetParentCanvas(canvas); |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | public void StartBattle(Action onMoveComplete) |
| | |
| | | private Dictionary<int, BattleObject> redCampDict = new Dictionary<int, BattleObject>(); |
| | | private Dictionary<int, BattleObject> blueCampDict = new Dictionary<int, BattleObject>(); |
| | | |
| | | protected Dictionary<int, BattleObject> allBattleObjDict = new Dictionary<int, BattleObject>(); |
| | | public Dictionary<int, BattleObject> allBattleObjDict = new Dictionary<int, BattleObject>(); |
| | | |
| | | protected BattleField battleField; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public int sortingOrder = 0; |
| | | |
| | | protected Action onDeathAnimationComplete; |
| | | |
| | | protected Renderer[] renderers; |
| | |
| | | var heroInfoBarScale = heroInfoBar.transform.localScale; |
| | | heroInfoBarScale.x *= Camp == BattleCamp.Red ? 1 : -1; |
| | | heroInfoBar.transform.localScale = heroInfoBarScale; |
| | | |
| | | |
| | | heroInfoBar.SetActive(true); |
| | | SetToFront(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | motionBase.PlayAnimation(MotionName.hit, false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void SuckHp(uint suckHP, SkillConfig skillConfig) |
| | | { |
| | |
| | | |
| | | public void HurtByReflect(uint bounceHP, SkillConfig skillConfig) |
| | | { |
| | | |
| | | |
| | | } |
| | | |
| | | // 闪避开始 |
| | |
| | | heroRectTrans.anchoredPosition = Vector2.zero; |
| | | |
| | | heroInfoBar.SetActive(false); |
| | | SetToFront(); |
| | | } |
| | | |
| | | public void PushDropItems(BattleDrops _battleDrops) |
| | |
| | | battleDrops = null; |
| | | } |
| | | |
| | | public void SetToBack() |
| | | { |
| | | sortingOrder = BattleConst.UnactiveHeroSortingOrder; |
| | | UpdateSortingOrder(); |
| | | } |
| | | |
| | | public void SetToFront() |
| | | { |
| | | sortingOrder = BattleConst.ActiveHeroSortingOrder; |
| | | UpdateSortingOrder(); |
| | | } |
| | | |
| | | private void UpdateSortingOrder() |
| | | { |
| | | if (null == renderers) return; |
| | | |
| | | foreach (var renderer in renderers) |
| | | { |
| | | if (renderer != null) |
| | | { |
| | | renderer.sortingOrder = sortingOrder; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public int GetSortingOrder() |
| | | { |
| | | return sortingOrder; |
| | | } |
| | | |
| | | |
| | | #if UNITY_EDITOR_STOP_USING |
| | |
| | | protected void HighLightAllTargets() |
| | | { |
| | | // 高亮所有目标 |
| | | HashSet<BattleObject> highlightList = new HashSet<BattleObject>(battleField.battleObjMgr.GetBattleObjList(tagUseSkillAttack)); |
| | | List<BattleObject> highlightList = battleField.battleObjMgr.GetBattleObjList(tagUseSkillAttack); |
| | | highlightList.Add(caster); |
| | | |
| | | List<BattleObject> allList = battleField.battleObjMgr.allBattleObjDict.Values.ToList<BattleObject>(); |
| | | |
| | | for (int i = 0; i < allList.Count; i++) |
| | | { |
| | | BattleObject bo = allList[i]; |
| | | if (highlightList.Contains(bo)) |
| | | { |
| | | bo.SetToFront(); |
| | | } |
| | | else |
| | | { |
| | | bo.SetToBack(); |
| | | } |
| | | } |
| | | |
| | | // battleField.skillMask.SetActive(true); |
| | | |
| | | // caster.battleField.skillMask |
| | | // 把这些BO全高亮 或者说把除了这些的都放在遮罩后面 |
| | | // YYL TODO |
| | |
| | | if (effectId <= 0) |
| | | return; |
| | | |
| | | var effect = caster.battleField.battleEffectMgr.PlayEffect(0, effectId, parent, camp); |
| | | var effect = caster.battleField.battleEffectMgr.PlayEffect(caster.ObjID, effectId, parent, camp); |
| | | if (effect != null) |
| | | { |
| | | effect.transform.localRotation = parent.localRotation; |
| | |
| | | |
| | | if (skillConfig.ExplosionEffectId > 0) |
| | | { |
| | | caster.battleField.battleEffectMgr.PlayEffect(0, skillConfig.ExplosionEffectId, targetTransform, caster.Camp); |
| | | caster.battleField.battleEffectMgr.PlayEffect(caster.ObjID, skillConfig.ExplosionEffectId, targetTransform, caster.Camp); |
| | | } |
| | | |
| | | if (skillConfig.ExplosionEffect2 > 0) |
| | | { |
| | | caster.battleField.battleEffectMgr.PlayEffect(0, skillConfig.ExplosionEffect2, targetTransform, caster.Camp); |
| | | caster.battleField.battleEffectMgr.PlayEffect(caster.ObjID, skillConfig.ExplosionEffect2, targetTransform, caster.Camp); |
| | | } |
| | | |
| | | for (int i = 0; i < tagUseSkillAttack.HurtList.Length; i++) |
| | |
| | | |
| | | return UIEffectPlayer.CreateEffect(id, parent, false); |
| | | } |
| | | |
| | | public int GetSortingOrder() |
| | | { |
| | | if (null != canvas) |
| | | { |
| | | return canvas.sortingOrder; |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | #endregion |
| | | |