75 lines
2.8 KiB
C#
75 lines
2.8 KiB
C#
|
using ET;
|
|||
|
using Cal.DataTable;
|
|||
|
using UnityEngine;
|
|||
|
using ET.EventType;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public class StartFamilyBossFightEvent : AEvent<StartFamilyBossFight>
|
|||
|
{
|
|||
|
public override async ETTask Run(StartFamilyBossFight args)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
int bossId = args.BossId;
|
|||
|
long unitId = args.Id;
|
|||
|
int hp = args.hp;
|
|||
|
Scene scene = args.zoneScene;
|
|||
|
Game.EventSystem.Publish_Sync(new BattleStart
|
|||
|
{
|
|||
|
zoneScene = scene
|
|||
|
});
|
|||
|
//!+固定玩家位置
|
|||
|
//!1.记录原位置
|
|||
|
Team team = TeamComponent.Instance.Get(GlobalVariable.LeaderId);
|
|||
|
GlobalVariable.PlayerPosList_BeforeBattle.Clear();
|
|||
|
int index = 0;
|
|||
|
foreach (var unit in team.GetAll())
|
|||
|
{
|
|||
|
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(index++);
|
|||
|
unit.YAngle = 180;
|
|||
|
}
|
|||
|
//!2.改变战斗状态
|
|||
|
UnitComponent.MyUnit.IsFight = true;
|
|||
|
|
|||
|
//!+隐藏Boss
|
|||
|
BossComponent.Instance.RemoveBoss();
|
|||
|
|
|||
|
var bossBase = DataTableHelper.Get<FamilyBossConfig>(bossId);
|
|||
|
//!加载预制体
|
|||
|
var unitMonster = await UnitFactory.Create(unitId, bossBase.PrefabId, UnitType.FamilyBossMonster);
|
|||
|
unitMonster.Position = PosHelper.GetMonsterPos(0);
|
|||
|
//!添加怪物属性
|
|||
|
int maxHp = bossBase.Hp;
|
|||
|
ClientUnitCharacterComponent.Instance.Add(unitId, bossBase.Name, bossBase.Level, hp, maxHp);
|
|||
|
Game.EventSystem.Publish_Sync(new ET.EventType.SetHudCharacter
|
|||
|
{
|
|||
|
zoneScene = scene,
|
|||
|
unit = unitMonster,
|
|||
|
level = bossBase.Level,
|
|||
|
name = bossBase.Name,
|
|||
|
hp = hp,
|
|||
|
maxHp = maxHp,
|
|||
|
jobType = JobType.UnKnown,
|
|||
|
progressTitleType = FairyGUI.ProgressTitleType.Percent
|
|||
|
});
|
|||
|
//!怪物加入队伍
|
|||
|
Game.EventSystem.Publish_Sync(new ET.EventType.TranslateSceneEnd
|
|||
|
{
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
catch (System.Exception e)
|
|||
|
{
|
|||
|
Log.Error(e);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|