From eac792dad536d79f233978d7e6da2e714d56e29a Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 30 一月 2026 19:21:43 +0800
Subject: [PATCH] 125 命格buff
---
Main/System/Battle/UIComp/MinggeBuffCell.cs.meta | 11 ++
Main/System/Battle/BattleObject/BattleObjMgr.cs | 12 ++
Main/System/Battle/BattleObject/MinggeBattleObject.cs | 31 +++++-
Main/System/Battle/UIComp/MinggeBuffCell.cs | 118 +++++++++++++++++++++++
Main/System/Battle/BaseBattleWin.cs | 127 +++++++++++++++++++++++++
5 files changed, 292 insertions(+), 7 deletions(-)
diff --git a/Main/System/Battle/BaseBattleWin.cs b/Main/System/Battle/BaseBattleWin.cs
index 7d3a226..b5c0add 100644
--- a/Main/System/Battle/BaseBattleWin.cs
+++ b/Main/System/Battle/BaseBattleWin.cs
@@ -1,4 +1,5 @@
-锘縰sing System.Collections.Generic;
+锘縰sing 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鐨則xtWaveInfo, Story/Bone鐨則xtBattleRound)
+
+ [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>
/// 璺宠繃鎴樻枟
diff --git a/Main/System/Battle/BattleObject/BattleObjMgr.cs b/Main/System/Battle/BattleObject/BattleObjMgr.cs
index 5913231..1fd926f 100644
--- a/Main/System/Battle/BattleObject/BattleObjMgr.cs
+++ b/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)
diff --git a/Main/System/Battle/BattleObject/MinggeBattleObject.cs b/Main/System/Battle/BattleObject/MinggeBattleObject.cs
index 2737918..078f3bc 100644
--- a/Main/System/Battle/BattleObject/MinggeBattleObject.cs
+++ b/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)
{
// 鍛芥牸涓嶉渶瑕侀�熷害鎺у埗
diff --git a/Main/System/Battle/UIComp/MinggeBuffCell.cs b/Main/System/Battle/UIComp/MinggeBuffCell.cs
new file mode 100644
index 0000000..bd49b47
--- /dev/null
+++ b/Main/System/Battle/UIComp/MinggeBuffCell.cs
@@ -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();
+ }
+ }
+
+ //缂╂斁鍒板拰鐖秗ect涓�鏍峰ぇ
+ // 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();
+ }
+}
+
diff --git a/Main/System/Battle/UIComp/MinggeBuffCell.cs.meta b/Main/System/Battle/UIComp/MinggeBuffCell.cs.meta
new file mode 100644
index 0000000..5e2553b
--- /dev/null
+++ b/Main/System/Battle/UIComp/MinggeBuffCell.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 97b971e3d3807d94fb3f947350c26143
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
--
Gitblit v1.8.0