76 lines
3.0 KiB
C#
76 lines
3.0 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 zoneScene = args.zoneScene;
|
|
Game.EventSystem.Publish_Sync(new BattleStart
|
|
{
|
|
zoneScene = zoneScene
|
|
});
|
|
//!+固定玩家位置
|
|
//!1.记录原位置
|
|
Team team = args.zoneScene.GetComponent<TeamComponent>().Get(zoneScene.GetComponent<GlobalVariable>().LeaderId);
|
|
zoneScene.GetComponent<GlobalVariable>().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<GlobalVariable>().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<UnitComponent>().MyUnit.IsFight = true;
|
|
|
|
//!+隐藏Boss
|
|
BossComponent.Instance.RemoveBoss();
|
|
|
|
FamilyBossConfig bossBase = DataTableHelper.Get<FamilyBossConfig>(bossId);
|
|
//!加载预制体
|
|
MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(bossBase.MonsterId);
|
|
Unit unitMonster = await UnitFactory.Create(zoneScene,unitId, monsterBase.PrefabId, UnitType.Monster);
|
|
unitMonster.Position = PosHelper.GetMonsterPos(0);
|
|
//!添加怪物属性
|
|
int maxHp = monsterBase.Hp;
|
|
ClientUnitCharacterComponent.Instance.Add(unitId, bossBase.Name, monsterBase.Level, hp, maxHp);
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.SetHudCharacter
|
|
{
|
|
zoneScene = zoneScene,
|
|
unit = unitMonster,
|
|
level = monsterBase.Level,
|
|
name = monsterBase.NickName,
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
} |