using ET; using Cal.DataTable; using UnityEngine; using ET.EventType; namespace ET { public class StartTrialCopyFightEvent : AEvent { public override async ETTask Run(StartTrialCopyFight args) { try { int copyId = args.copyId; var list = args.list; Scene scene = args.zoneScene; Game.EventSystem.Publish_Sync(new BattleStart { zoneScene = scene }); //!+固定玩家位置 //!1.记录原位置 GlobalVariable.PlayerPosList_BeforeBattle.Clear(); Unit unit = UnitComponent.MyUnit; Game.EventSystem.Publish_Sync(new ET.EventType.ShowHpBar { zoneScene = scene, unit = unit, }); Vector3 playerOldPos = unit.Position; 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.隐藏主怪 TrialCopyMonsterTeamComponent.Instance.SetAllVisile(); MonsterUnitComponent monsterUnitComponent = MainStoryMonsterTeamComponent.Instance.GetOrAddComponent(); TrialCopy trialCopy = DataTableHelper.Get(copyId); MonsterBase monsterBase = DataTableHelper.Get(trialCopy.MonsterId); for (int i = 0; i < list.Count; i++) { long unitId = list[i]; //!加载预制体 Unit unitMonster =await UnitFactory.Create(unitId, monsterBase.PrefabId, UnitType.TrialCopyMonster); 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 = scene, 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); } } } }