97 lines
2.4 KiB
C#
97 lines
2.4 KiB
C#
using cfg.LegionBattleCfg;
|
|
using Cysharp.Threading.Tasks;
|
|
using Framework;
|
|
using Gameplay.AI;
|
|
using Gameplay.Buff;
|
|
using Gameplay.LegionBattle.Unit;
|
|
using Gameplay.Level;
|
|
using Gameplay.Skill;
|
|
using Gameplay.SubSystems;
|
|
using Gameplay.Unit;
|
|
using LTGame;
|
|
using PhxhSDK;
|
|
using PhxhSDK.Res;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Gameplay.LegionBattle
|
|
{
|
|
public sealed partial class LegionBattle : IUpdatable, ILoadable
|
|
{
|
|
/// <summary>
|
|
/// 军团战状态
|
|
/// </summary>
|
|
private NStateMachine<BaseLegionBattleState> fsm;
|
|
|
|
public LegionBattle()
|
|
{
|
|
fsm = new();
|
|
|
|
fsm.Add(new LegionBattleStatePrepare(this));
|
|
fsm.Add(new LegionBattleStateBattle(this));
|
|
}
|
|
|
|
public async UniTask Load()
|
|
{
|
|
await LoadMap(); // 加载地图
|
|
await LoadLevelData(); // 加载关卡数据
|
|
await LoadActor(); // 加载玩家
|
|
}
|
|
|
|
public void Update(float deltaTime)
|
|
{
|
|
fsm.LogicUpdate(deltaTime);
|
|
}
|
|
|
|
public async UniTask Unload()
|
|
{
|
|
CameraManager.Instance.RevertMainCamera();
|
|
MapUtils.UnLoadMap(Map);
|
|
if (null != dicActorUnit)
|
|
{
|
|
foreach (var i in dicActorUnit.Values)
|
|
{
|
|
i.Dispose();
|
|
}
|
|
|
|
dicActorUnit.Clear();
|
|
dicActorUnit = null;
|
|
}
|
|
|
|
await GameSceneManager.Instance.UnLoadSceneAsync(MapCfg.Path);
|
|
}
|
|
|
|
public void Release()
|
|
{
|
|
fsm.Exit();
|
|
fsm = null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 进入军团战
|
|
/// </summary>
|
|
public void EnterLegionBattle()
|
|
{
|
|
//fsm.SetForceChangeState((int)E_LegionBattleState.Prepare);
|
|
BeginLegionBattle();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始军团战
|
|
/// </summary>
|
|
public void BeginLegionBattle()
|
|
{
|
|
fsm.SetForceChangeState((int)E_LegionBattleState.Battle);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击屏幕
|
|
/// </summary>
|
|
/// <param name="screenPos"></param>
|
|
public void ClickFromScreen(Vector2 screenPos)
|
|
{
|
|
fsm.currentState?.ClickFromScreen(screenPos);
|
|
}
|
|
}
|
|
} |