| | |
| | | using DG.Tweening; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class BattleField |
| | |
| | | { |
| | | guid = _guid; |
| | | |
| | | #pragma warning disable CS0618 // Obsolete — sync legacy constructor, use CreateAsync for new code |
| | | GameObject go = ResManager.Instance.LoadAsset<GameObject>("Battle/Prefabs", "BattleRootNode"); |
| | | #pragma warning restore CS0618 |
| | | GameObject battleRootNodeGO = GameObject.Instantiate(go); |
| | | battleRootNode = battleRootNodeGO.GetComponent<BattleRootNode>(); |
| | | battleRootNodeGO.name = this.GetType().Name; |
| | |
| | | recordPlayer = new RecordPlayer(); |
| | | soundManager = new BattleSoundManager(this); |
| | | |
| | | processingDeathObjIds = new HashSet<uint>(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// US2: Static async factory method. Creates BattleField with async resource loading. |
| | | /// </summary> |
| | | public static async UniTask<BattleField> CreateAsync(string _guid) |
| | | { |
| | | var field = new BattleField(_guid, skipResourceLoad: true); |
| | | GameObject go = await ResManager.Instance.LoadAssetAsync<GameObject>("Battle/Prefabs", "BattleRootNode"); |
| | | GameObject battleRootNodeGO = GameObject.Instantiate(go); |
| | | field.battleRootNode = battleRootNodeGO.GetComponent<BattleRootNode>(); |
| | | battleRootNodeGO.name = field.GetType().Name; |
| | | return field; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// US2: Protected constructor without resource loading (for async factory). |
| | | /// </summary> |
| | | protected BattleField(string _guid, bool skipResourceLoad) |
| | | { |
| | | guid = _guid; |
| | | battleObjMgr = new BattleObjMgr(); |
| | | battleEffectMgr = new BattleEffectMgr(); |
| | | battleTweenMgr = new BattleTweenMgr(); |
| | | recordPlayer = new RecordPlayer(); |
| | | soundManager = new BattleSoundManager(this); |
| | | processingDeathObjIds = new HashSet<uint>(); |
| | | } |
| | | |
| | |
| | | BattleMapConfig battleMapConfig = BattleMapConfig.Get(mapID); |
| | | if (battleMapConfig != null) |
| | | { |
| | | #pragma warning disable CS0618 // Obsolete — sync legacy fallback, use LoadMapAsync |
| | | Texture texture = ResManager.Instance.LoadAsset<Texture>("Texture/FullScreenBg", battleMapConfig.MapBg); |
| | | #pragma warning restore CS0618 |
| | | battleRootNode.SetBackground(texture); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// US2: Async map loading. |
| | | /// </summary> |
| | | protected virtual async UniTask LoadMapAsync(int mapID) |
| | | { |
| | | BattleMapConfig battleMapConfig = BattleMapConfig.Get(mapID); |
| | | if (battleMapConfig != null) |
| | | { |
| | | Texture texture = await ResManager.Instance.LoadAssetAsync<Texture>("Texture/FullScreenBg", battleMapConfig.MapBg); |
| | | battleRootNode.SetBackground(texture); |
| | | } |
| | | } |