using ET; using Cal.DataTable; using UnityEngine; using ET.EventType; namespace ET { public class StartBossFightEvent : AEvent { public override async ETTask Run(StartBossFight args) { try { int bossId = args.BossId; long unitId = args.Id; int hp = args.hp; Scene zoneScene = args.zoneScene; Game.EventSystem.Publish_Sync(new BattleStart { zoneScene = zoneScene }); //!+固定玩家位置 //!1.记录原位置 Team team = args.zoneScene.GetComponent().Get(zoneScene.GetComponent().LeaderId); zoneScene.GetComponent().PlayerPosList_BeforeBattle.Clear(); int index = 0; foreach (Unit unit in team.GetAll()) { Game.EventSystem.Publish_Sync(new ET.EventType.ShowHpBar { zoneScene = zoneScene, unit = unit, }); Vector3 playerOldPos = unit.Position; zoneScene.GetComponent().PlayerPosList_BeforeBattle.Add(new Vector4(playerOldPos.x, playerOldPos.y, playerOldPos.z, unit.YAngle)); unit.Position = PosHelper.GetPlayerPos(index++); unit.YAngle = 180; } //!2.改变战斗状态 args.zoneScene.GetComponent().MyUnit.IsFight = true; //!+隐藏Boss BossComponent.Instance.RemoveBoss(); MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(bossId); //!加载预制体 Unit unitMonster =await UnitFactory.Create(zoneScene,unitId, monsterBase.PrefabId, UnitType.Monster); unitMonster.Position = PosHelper.GetMonsterPos(0); //!添加怪物属性 int difficultIndex = team.MemberCount - 1; float hpDifficult = 1 + StartMainStoryFightEventClass.HpDifficultyArr[difficultIndex]; hp = hp != -1 ? hp : Mathf.RoundToInt(monsterBase.Hp * hpDifficult); ClientUnitCharacterComponent.Instance.Add(unitId, monsterBase.NickName, monsterBase.Level, hp, hp); Game.EventSystem.Publish_Sync(new ET.EventType.SetHudCharacter { zoneScene = zoneScene, unit = unitMonster, hp = hp, maxHp = hp, level = monsterBase.Level, jobType = JobType.UnKnown, name = monsterBase.NickName, progressTitleType = FairyGUI.ProgressTitleType.Percent }); //!怪物加入队伍 Game.EventSystem.Publish_Sync(new ET.EventType.TranslateSceneEnd { }); } catch (System.Exception e) { Log.Error(e); } } } }