zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/Hotfix/Logic/Behaviour/Game/Event/Battle/StartManulEquipFightEvent.cs

95 lines
3.4 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
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 scene = args.zoneScene;
Game.EventSystem.Publish_Sync(new BattleStart
{
zoneScene = scene
});
//!+固定玩家位置
//!1.记录原位置
GlobalVariable.PlayerPosList_BeforeBattle.Clear();
Team team = TeamComponent.Instance.Get(GlobalVariable.LeaderId);
int i = 0;
foreach (var u in team.GetAll())
{
try
{
Game.EventSystem.Publish_Sync(new ET.EventType.ShowHpBar
{
zoneScene = scene,
unit = u,
});
Vector3 playerOldPos = u.Position;
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
{
var info = list[i];
var unitId = info.Id;
var configId = info.MonsterId;
ManulEquipMonsterConfig config = ManulEquipMonsterConfigCategory.Instance.Get(configId);
//!加载预制体
var unitMonster = await UnitFactory.Create(unitId, config.PrefabId, UnitType.ManulEquipMonster);
unitMonster.Position = PosHelper.GetMonsterPos(i);
//!初始化Hud
ClientUnitCharacterComponent.Instance.Add(unitId, config.Name, config.Level, config.Hp, config.Hp);
Game.EventSystem.Publish_Sync(new ET.EventType.SetHudCharacter
{
zoneScene = scene,
unit = unitMonster,
hp = config.Hp,
maxHp = config.Hp,
level = config.Level,
name = config.Name,
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);
}
}
}
}