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

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