using Cal.DataTable; using ET.EventType; using ET; using System; using System.Collections.Generic; using UnityEngine; namespace ET { public class StartManulEquipFightEvent : AEvent { public override async ETTask Run(StartManulEquipFight args) { try { var list = args.list; Scene scene = args.zoneScene; Game.EventSystem.Publish_Sync(new BattleStart { zoneScene = scene }); //!+固定玩家位置 //!1.记录原位置 GlobalVariable.PlayerPosList_BeforeBattle.Clear(); Team team = TeamComponent.Instance.Get(GlobalVariable.LeaderId); int i = 0; foreach (Unit u in team.GetAll()) { try { Game.EventSystem.Publish_Sync(new ET.EventType.ShowHpBar { zoneScene = scene, unit = u, }); Vector3 playerOldPos = u.Position; GlobalVariable.PlayerPosList_BeforeBattle.Add(new Vector4(playerOldPos.x, playerOldPos.y, playerOldPos.z, u.YAngle)); u.Position = PosHelper.GetPlayerPos(i++); u.YAngle = 180; //!2.改变战斗状态 u.IsFight = true; } catch (Exception e) { Log.Error(e); } } //!+1.隐藏主怪 for (i = 0; i < list.Count; i++) { try { MonsterUnitInfo info = list[i]; long unitId = info.Id; int configId = info.MonsterId; ManulEquipMonsterConfig config = ManulEquipMonsterConfigCategory.Instance.Get(configId); //!加载预制体 Unit unitMonster = await UnitFactory.Create(unitId, config.PrefabId, UnitType.ManulEquipMonster); unitMonster.Position = PosHelper.GetMonsterPos(i); //!初始化Hud ClientUnitCharacterComponent.Instance.Add(unitId, config.Name, config.Level, config.Hp, config.Hp); Game.EventSystem.Publish_Sync(new ET.EventType.SetHudCharacter { zoneScene = scene, unit = unitMonster, hp = config.Hp, maxHp = config.Hp, level = config.Level, name = config.Name, jobType = JobType.UnKnown, progressTitleType = FairyGUI.ProgressTitleType.Percent, }); } catch (Exception e) { Log.Error(e); } } Game.EventSystem.Publish_Sync(new ET.EventType.TranslateSceneEnd { }); } catch (System.Exception e) { Log.Error(e); } } } }