AkiraPixelWind/Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs

118 lines
3.6 KiB
C#
Raw Normal View History

using Axibug;
using Axibug.Event;
using Axibug.Resources;
using Axibug.Runtime;
using Codice.CM.WorkspaceServer.DataStore;
using Game.Config;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Game
{
public class BattleMgrComponent : GameComponent
{
private void Start()
{
AppEntry.Event.Subscribe(AttackHitEventArgs.EventId, OnAttackHitEventArgs);
}
private void OnAttackHitEventArgs(object sender, LogicEventArgs e)
{
AttackHitEventArgs msg = (AttackHitEventArgs)e;
if (msg == null) throw new GameException("AttackHitEventArgs is null");
RoleBase Attacker = GamePlayEntry.RoleMgr.FindRole(msg.Attacker_Type, msg.Attacker_RoleID);
if (Attacker == null)
{
AxibugLog.Error("Attacker Ϊ<><CEAA>");
return;
}
RoleBase UnderAttack = GamePlayEntry.RoleMgr.FindRole(msg.UnderAtk_Type, msg.UnderAtk_RoleID);
if (UnderAttack == null)
{
AxibugLog.Error("UnderAttack Ϊ<><CEAA>");
return;
}
DoAttack(Attacker, UnderAttack);
}
private void DoAttack(RoleBase Attacker,RoleBase UnderAttack,int AttackId = 0)
{
bool CanAttack = false;
AxibugLog.Debug($"<22><><EFBFBD><EFBFBD>һ<EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{Attacker.name} <20>ܻ<EFBFBD><DCBB><EFBFBD>{UnderAttack.name}");
//<2F>˴<EFBFBD><CBB4><EFBFBD>
if (Attacker.RoleType == E_NODE_TYPE.N_MAINPLAYER && UnderAttack.RoleType == E_NODE_TYPE.N_MONSTER)
{
//TODO <20>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
AppEntry.Event.Fire(null, CameraShakeEventArgs.Create());
CanAttack = true;
int Damage = 40;
2023-01-09 23:13:17 +08:00
if (GamePlayEntry.MainPlayer.Player.IsFastSkillMode)
Damage = 200;
SetDamage(UnderAttack, Damage, out bool IsDead);
GamePlayEntry.Tips.ShowHint($"<22><><EFBFBD><EFBFBD>һ<EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{Attacker.name} <20>ܻ<EFBFBD><DCBB><EFBFBD>{UnderAttack.name},<2C><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>{Damage}", eHintType.Warn);
}
//<2F>ִ<EFBFBD><D6B4><EFBFBD>
else if (Attacker.RoleType == E_NODE_TYPE.N_MONSTER && UnderAttack.RoleType == E_NODE_TYPE.N_MAINPLAYER)
{
//TODO <20>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
AppEntry.Event.Fire(null, CameraShakeEventArgs.Create());
CanAttack = true;
int Damage = 40;
2023-01-09 23:13:17 +08:00
SetDamage(UnderAttack, Damage,out bool IsDead);
}
if (CanAttack)
{
//TODO
}
}
/// <summary>
/// <20>ܻ<EFBFBD>
/// </summary>
/// <param name="role"></param>
/// <param name="Damage"></param>
2023-01-09 23:13:17 +08:00
private void SetDamage(RoleBase UnderAttack, int DamageHP,out bool IsDead)
{
2023-01-09 23:13:17 +08:00
IsDead = false;
//TODO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>˺<EFBFBD><CBBA><EFBFBD><EFBFBD>ɸ<EFBFBD><C9B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UnderAttack.BaseData.life.curHP -= DamageHP;
UnderAttack.BaseData.life.curHP = Math.Max(UnderAttack.BaseData.life.curHP, 0);
if (UnderAttack.BaseData.life.curHP > 0)
UnderAttack.Anime.PlayHit();
else
{
2023-01-09 23:13:17 +08:00
IsDead = true;
//<2F><><EFBFBD><EFBFBD>
UnderAttack.Anime.PlayDead();
2023-01-09 23:13:17 +08:00
GamePlayEntry.Tips.ShowHint($"<22>ܻ<EFBFBD><DCBB><EFBFBD>{UnderAttack.name},<2C><><EFBFBD><EFBFBD>", eHintType.Warn);
AppEntry.Event.Fire(null, RoleDeadEventArgs.Create(UnderAttack.RoleType, UnderAttack.RoleID));
}
}
}
}