96 lines
3.7 KiB
C#
96 lines
3.7 KiB
C#
using Cal.DataTable;
|
|
using ET.EventType;
|
|
using ET;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace ET
|
|
{
|
|
public class StartManulEquipFightEvent : AEvent<StartManulEquipFight>
|
|
{
|
|
public override async ETTask Run(StartManulEquipFight args)
|
|
{
|
|
try
|
|
{
|
|
var list = args.list;
|
|
Scene zoneScene = args.zoneScene;
|
|
Game.EventSystem.Publish_Sync(new BattleStart
|
|
{
|
|
zoneScene = zoneScene
|
|
});
|
|
//!+固定玩家位置
|
|
//!1.记录原位置
|
|
zoneScene.GetComponent<GlobalVariable>().PlayerPosList_BeforeBattle.Clear();
|
|
Team team = args.zoneScene.GetComponent<TeamComponent>().Get(zoneScene.GetComponent<GlobalVariable>().LeaderId);
|
|
int i = 0;
|
|
foreach (Unit u in team.GetAll())
|
|
{
|
|
try
|
|
{
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.ShowHpBar
|
|
{
|
|
zoneScene = zoneScene,
|
|
unit = u,
|
|
});
|
|
Vector3 playerOldPos = u.Position;
|
|
zoneScene.GetComponent<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);
|
|
//!加载预制体
|
|
|
|
MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(config.MonsterId);
|
|
Unit unitMonster = await UnitFactory.Create(zoneScene,unitId, monsterBase.PrefabId, UnitType.Monster);
|
|
unitMonster.Position = PosHelper.GetMonsterPos(i);
|
|
//!初始化Hud
|
|
ClientUnitCharacterComponent.Instance.Add(unitId, config.Name, monsterBase.Level, monsterBase.Hp, monsterBase.Hp);
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.SetHudCharacter
|
|
{
|
|
zoneScene = zoneScene,
|
|
unit = unitMonster,
|
|
hp = monsterBase.Hp,
|
|
maxHp = monsterBase.Hp,
|
|
level = monsterBase.Level,
|
|
name = monsterBase.NickName,
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|