zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/Hotfix/Logic/Behaviour/Game/Event/Battle/StartTrialCopyFightEvent.cs

76 lines
3.0 KiB
C#

using ET;
using Cal.DataTable;
using UnityEngine;
using ET.EventType;
namespace ET
{
public class StartTrialCopyFightEvent : AEvent<StartTrialCopyFight>
{
public override async ETTask Run(StartTrialCopyFight args)
{
try
{
int copyId = args.copyId;
var list = args.list;
Scene zoneScene = args.zoneScene;
Game.EventSystem.Publish_Sync(new BattleStart
{
zoneScene = zoneScene
});
//!+固定玩家位置
//!1.记录原位置
zoneScene.GetComponent<GlobalVariable>().PlayerPosList_BeforeBattle.Clear();
Unit unit =args.zoneScene.GetComponent<UnitComponent>().MyUnit;
Game.EventSystem.Publish_Sync(new ET.EventType.ShowHpBar
{
zoneScene = zoneScene,
unit = unit,
});
Vector3 playerOldPos = unit.Position;
zoneScene.GetComponent<GlobalVariable>().PlayerPosList_BeforeBattle.Add(new Vector4(playerOldPos.x, playerOldPos.y, playerOldPos.z, unit.YAngle));
unit.Position = PosHelper.GetPlayerPos(0);
unit.YAngle = 180;
//!2.改变战斗状态
unit.IsFight = true;
//!+1.隐藏主怪
zoneScene.GetComponent<TrialCopyMonsterTeamComponent>().SetAllVisile();
TrialCopy trialCopy = DataTableHelper.Get<TrialCopy>(copyId);
MonsterBase monsterBase = DataTableHelper.Get<MonsterBase>(trialCopy.MonsterId);
for (int i = 0; i < list.Count; i++)
{
long unitId = list[i];
//!加载预制体
Unit unitMonster =await UnitFactory.Create(zoneScene,unitId, monsterBase.PrefabId, UnitType.Monster);
unitMonster.Position = PosHelper.GetMonsterPos(i);
//!初始化Hud
ClientUnitCharacterComponent.Instance.Add(unitId, monsterBase.NickName, monsterBase.Level, monsterBase.Hp, monsterBase.Hp);
Game.EventSystem.Publish_Sync(new ET.EventType.SetHudCharacter
{
zoneScene = zoneScene,
unit = unitMonster,
hp = monsterBase.Hp,
maxHp = monsterBase.Hp,
level = monsterBase.Level,
name = monsterBase.NickName,
jobType = JobType.UnKnown,
progressTitleType = FairyGUI.ProgressTitleType.Percent,
});
}
Game.EventSystem.Publish_Sync(new ET.EventType.TranslateSceneEnd
{
});
}
catch (System.Exception e)
{
Log.Error(e);
}
}
}
}