77 lines
3.0 KiB
C#
77 lines
3.0 KiB
C#
|
using ET;
|
|||
|
using Cal.DataTable;
|
|||
|
using UnityEngine;
|
|||
|
using ET.EventType;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public class StartBossFightEvent : AEvent<StartBossFight>
|
|||
|
{
|
|||
|
public override async ETTask Run(StartBossFight 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();
|
|||
|
|
|||
|
MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(bossId);
|
|||
|
//!加载预制体
|
|||
|
var unitMonster =await UnitFactory.Create(unitId, monsterBase.PrefabId, UnitType.BossMonster);
|
|||
|
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 = scene,
|
|||
|
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|