yyl
2025-06-12 5ca88372febc0ebab5cbdb5f922c59a646b8fb94
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections.Generic;
using UnityEngine;
 
 
 
public class BattleManager : GameSystemManager<BattleManager>
{
    protected Dictionary<int, BattleField> battleFields = new Dictionary<int, BattleField>();
 
 
    public override void Init()
    {
        base.Init();
        EventBroadcast.Instance.AddListener<int, int>(EventName.BATTLE_ACTION_OVER, OnActionOver);
    }
 
    public override void Release()
    {
        base.Release();
    }
 
    private void OnActionOver(int battleFieldId, int attackId)
    {
        BattleField battleField = null;
        if (battleFields.TryGetValue(battleFieldId, out battleField))
        {
            battleField.OnActionOver(attackId);
        }
        else
        {
            Debug.LogError("BattleManager OnActionOver battleFieldId:" + battleFieldId + " not find");
        }
    }
 
    public void Run()
    {
        foreach (var battleField in battleFields)
        {
            battleField.Value.Run();
        }
    }
 
}