yyl
2 天以前 eac792dad536d79f233978d7e6da2e714d56e29a
125 命格buff
2个文件已添加
3个文件已修改
299 ■■■■■ 已修改文件
Main/System/Battle/BaseBattleWin.cs 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleObject/BattleObjMgr.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleObject/MinggeBattleObject.cs 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/UIComp/MinggeBuffCell.cs 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/UIComp/MinggeBuffCell.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BaseBattleWin.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -21,8 +22,14 @@
    [SerializeField] protected SkillTips skillTipsRed; // 红方技能提示
    [SerializeField] protected SkillTips skillTipsBlue; // 蓝方技能提示
    [SerializeField] protected Text txtBattleRound; // 回合信息 (Arena的txtWaveInfo, Story/Bone的txtBattleRound)
    [SerializeField] protected GameObject minggeObj;
    private List<MinggeBuffCell> redMinggeBuffCells = new List<MinggeBuffCell>();
    private List<MinggeBuffCell> blueMinggeBuffCells = new List<MinggeBuffCell>();
    protected BattleRootNode battleRootNode = null;
    protected BattleField battleField; // 当前战斗的战场实例
    protected override void InitComponent()
    {
@@ -33,6 +40,120 @@
        if (btnPass != null)
            btnPass.AddListener(OnClickPass);
        InitMingge();
    }
    protected virtual void InitMingge()
    {
        if (null == minggeObj)
            return;
        for (int i = 1; i <= 4; i++)
        {
            GameObject redCell = minggeObj.transform.Find("RedMinggeBuff/MinggeBuffCell" + i).gameObject;
            redMinggeBuffCells.Add(redCell.GetComponent<MinggeBuffCell>());
            GameObject blueCell = minggeObj.transform.Find("BlueMinggeBuff/MinggeBuffCell" + i).gameObject;
            blueMinggeBuffCells.Add(blueCell.GetComponent<MinggeBuffCell>());
        }
    }
    protected virtual void BindMingge()
    {
        if (minggeObj == null)
            return;
        if (battleField == null)
            return;
        MinggeBattleObject redMingge = battleField.battleObjMgr.redMingge;
        if (null != redMingge)
        {
            redMingge.GetBuffMgr().onBuffChanged -= RefreshRedMinggeBuff;
            redMingge.GetBuffMgr().onBuffChanged += RefreshRedMinggeBuff;
        }
        MinggeBattleObject blueMingge = battleField.battleObjMgr.blueMingge;
        if (null != blueMingge)
        {
            blueMingge.GetBuffMgr().onBuffChanged -= RefreshBlueMinggeBuff;
            blueMingge.GetBuffMgr().onBuffChanged += RefreshBlueMinggeBuff;
        }
    }
    protected void RefreshRedMinggeBuff()
    {
        MinggeBattleObject redMingge = battleField.battleObjMgr.redMingge;
        if (null != redMingge)
        {
            RefreshMinggeBuff(redMinggeBuffCells, redMingge.GetBuffMgr().GetBuffIconList());
        }
        else
        {
            RefreshMinggeBuff(redMinggeBuffCells, null);
        }
    }
    protected void RefreshBlueMinggeBuff()
    {
        MinggeBattleObject blueMingge = battleField.battleObjMgr.blueMingge;
        if (null != blueMingge)
        {
            RefreshMinggeBuff(blueMinggeBuffCells, blueMingge.GetBuffMgr().GetBuffIconList());
        }
        else
        {
            RefreshMinggeBuff(blueMinggeBuffCells, null);
        }
    }
    protected void RefreshMinggeBuff(List<MinggeBuffCell> cells, List<HB428_tagSCBuffRefresh> buffList)
    {
        for (int i = 0; i < cells.Count; i++)
        {
            var cell = cells[i];
            if (buffList != null && i < buffList.Count)
            {
                var buff = buffList[i];
                cells[i].gameObject.SetActive(true);
                cells[i].Init(buffList[i], () => OnClickMinggeBuff(cell, buff));
            }
            else
            {
                cells[i].gameObject.SetActive(false);
            }
        }
    }
    private void OnClickMinggeBuff(MinggeBuffCell cell, HB428_tagSCBuffRefresh buff)
    {
        SmallTipWin.showText = Language.Get("SmallTipFomat", SkillConfig.Get((int)buff.SkillID)?.SkillName, SkillConfig.Get((int)buff.SkillID)?.Description);
        SmallTipWin.worldPos = cell.transform.position;
        SmallTipWin.isDownShow = true;
        UIManager.Instance.OpenWindow<SmallTipWin>();
    }
    protected virtual void UnbindMingge()
    {
        if (minggeObj == null)
            return;
        if (battleField == null)
            return;
        MinggeBattleObject redMingge = battleField.battleObjMgr.redMingge;
        if (null != redMingge)
        {
            redMingge.GetBuffMgr().onBuffChanged -= RefreshRedMinggeBuff;
        }
        MinggeBattleObject blueMingge = battleField.battleObjMgr.blueMingge;
        if (null != blueMingge)
        {
            blueMingge.GetBuffMgr().onBuffChanged -= RefreshBlueMinggeBuff;
        }
    }
    protected override void OnPreOpen()
@@ -185,6 +306,10 @@
        battleField.OnRoundChange -= OnRoundChange;
        battleField.OnRoundChange += OnRoundChange;
        OnRoundChange(battleField.round, battleField.turnMax); // 立即执行一次以显示初始回合
        BindMingge();
        RefreshRedMinggeBuff();
        RefreshBlueMinggeBuff();
    }
    /// <summary>
    /// 跳过战斗
Main/System/Battle/BattleObject/BattleObjMgr.cs
@@ -94,6 +94,18 @@
        return null;
    }
    public MinggeBattleObject GetMinggeBattleObject(BattleCamp camp)
    {
        if (camp == BattleCamp.Red)
        {
            return redMingge;
        }
        else
        {
            return blueMingge;
        }
    }
    public List<BattleObject> GetBattleObjList(BattleCamp _Camp)
    {
        if (_Camp == BattleCamp.Red)
Main/System/Battle/BattleObject/MinggeBattleObject.cs
@@ -2,6 +2,7 @@
using System;
using UnityEngine;
using Spine.Unity;
using System.Collections.Generic;
/// <summary>
/// 命格战斗对象 - 没有血量、没有实体,不会被攻击和选中,唯一作用是释放技能
@@ -9,6 +10,12 @@
public class MinggeBattleObject : BattleObject
{
    public TeamMingge teamMingge { get; private set; }
    // Buff 管理器(命格现在也需要 buff 系统)
    public BattleObjectBuffMgr buffMgr;
    // 预留的命格 Buff 显示接口,供外部自定义显示逻辑
    public Action<List<HB428_tagSCBuffRefresh>> OnMinggeBuffRefresh;
    
    public MinggeBattleObject(BattleField _battleField) : base(_battleField)
    {
@@ -20,7 +27,9 @@
        Camp = _camp;
        ObjID = teamMingge.ObjID;
        
        // 命格不需要 buff 管理器(命格释放技能但自身不会有 buff)
        // 初始化 buff 管理器
        buffMgr = new BattleObjectBuffMgr();
        buffMgr.Init(this);
        
        layerMgr = new BattleObjectLayerMgr();
        layerMgr.Init(this);
@@ -28,7 +37,8 @@
    public override void Run()
    {
        // 命格运行逻辑(如果需要)
        // 更新 buff 管理器
        buffMgr?.Run();
    }
    public override void Pause()
@@ -43,12 +53,20 @@
    public override void Destroy()
    {
        // 命格没有需要清理的资源
        // 清理显示回调
        OnMinggeBuffRefresh = null;
        // 清理 buff 管理器
        if (buffMgr != null)
        {
            buffMgr.Release();
            buffMgr = null;
        }
    }
    // ============ 实现抽象访问方法 ============
    
    public override BattleObjectBuffMgr GetBuffMgr() => null; // 命格不有 buff 系统
    public override BattleObjectBuffMgr GetBuffMgr() => buffMgr;
    
    public override int GetPositionNum() => teamMingge.positionNum;
    public override float GetModelScale() => teamMingge.modelScale;
@@ -189,9 +207,10 @@
    public override void HaveRest()
    {
        // 命格不需要休息状态
        // 清理 buff
        buffMgr?.RemoveAllBuff();
    }
    public override void SetSpeedRatio(float ratio)
    {
        // 命格不需要速度控制
Main/System/Battle/UIComp/MinggeBuffCell.cs
New file
@@ -0,0 +1,118 @@
using UnityEngine;
using UnityEngine.UI;
using System;
public class MinggeBuffCell : MonoBehaviour
{
    ImageEx m_buffIcon;
    ImageEx buffIcon
    {
        get
        {
            if (m_buffIcon == null)
            {
                m_buffIcon = this.transform.GetComponent<ImageEx>("Container_BuffCell/Img_Icon");
            }
            return m_buffIcon;
        }
    }
    Button m_buffButton;
    Button buffButton
    {
        get
        {
            if (m_buffButton == null)
            {
                m_buffButton = gameObject.GetComponent<Button>("Container_BuffCell");
            }
            return m_buffButton;
        }
    }
    TextEx m_BuffLayer;
    TextEx buffLayer
    {
        get
        {
            if (m_BuffLayer == null)
            {
                m_BuffLayer = this.transform.GetComponent<TextEx>("Container_BuffCell/Text_Layer");
            }
            return m_BuffLayer;
        }
    }
    void Awake()
    {
        LoadPrefab();
    }
    GameObject cellContainer;
    private void LoadPrefab()
    {
        if (cellContainer != null)
            return;
        var tmp = transform.Find("Container_BuffCell");
        if (tmp != null)
        {
            cellContainer = tmp.gameObject;
            return;
        }
        if (cellContainer == null)
        {
            cellContainer = UIUtility.CreateWidget("MinggeBuffCell", "Container_BuffCell");
            if (cellContainer != null)
            {
                cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
                cellContainer.transform.SetAsFirstSibling();
            }
        }
        //缩放到和父rect一样大
        // var scale = 1f;
        // var rect = cellContainer.GetComponent<RectTransform>();
        // var parentRect = transform.GetComponent<RectTransform>();
        // float width = parentRect.sizeDelta.x;
        // if (width <= 0f)
        // {
        //     //外部控制了尺寸获取为0
        //     GridLayoutGroup grid = GetComponentInParent<GridLayoutGroup>();
        //     if (grid != null)
        //     {
        //         width = grid.cellSize.x;
        //     }
        // }
        // scale = width / rect.sizeDelta.x;
        // cellContainer.transform.localScale = cellContainer.transform.localScale * scale;
    }
    public void Init(HB428_tagSCBuffRefresh buffData, Action onclick = null, bool showType = false)
    {
        if (null == buffData || gameObject == null)
        {
            return;
        }
        LoadPrefab();   //存在被卸载的可能,重新加载
        var config = SkillConfig.Get((int)buffData.SkillID);
        if (config == null)
        {
            Debug.LogErrorFormat("技能未配置 : {0}", buffData.SkillID);
            return;
        }
        buffIcon.SetOrgSprite(config.BuffIconName, "BuffIcon");
        buffButton.AddListener(() =>
        {
            onclick?.Invoke();
        });
        buffLayer.text = buffData.Layer == 0 ? "" : buffData.Layer.ToString();
    }
}
Main/System/Battle/UIComp/MinggeBuffCell.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 97b971e3d3807d94fb3f947350c26143
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant: