2023-10-29 15:27:13 +08:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2023-10-30 01:25:53 +08:00
|
|
|
using System.Data.OleDb;
|
2023-10-29 15:27:13 +08:00
|
|
|
using BITFALL.Bullet;
|
|
|
|
using BITFALL.Guns;
|
2023-10-30 01:25:53 +08:00
|
|
|
using BITFALL.Items.Melee;
|
2023-10-29 15:27:13 +08:00
|
|
|
using BITKit;
|
|
|
|
using BITKit.Entities.Melee;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace BITFALL.Entities.Equipment
|
|
|
|
{
|
|
|
|
public class AIMeleeController : AIEquipController
|
|
|
|
{
|
|
|
|
[SerializeReference,SubclassSelector] private IMeleeService meleeService;
|
|
|
|
[SerializeField] private bool forceAttack;
|
|
|
|
|
|
|
|
private readonly IntervalUpdate interval = new(1);
|
2023-10-30 01:25:53 +08:00
|
|
|
private AssetableMelee assetableMelee=>assetableItem as AssetableMelee;
|
2023-10-29 15:27:13 +08:00
|
|
|
public override void Entry()
|
|
|
|
{
|
|
|
|
base.Entry();
|
|
|
|
UnityEntity.AddListener<BITConstant.Command.AttackCommand>(OnAttack);
|
|
|
|
}
|
|
|
|
public override void Exit()
|
|
|
|
{
|
|
|
|
base.Exit();
|
|
|
|
UnityEntity.RemoveListener<BITConstant.Command.AttackCommand>(OnAttack);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnUpdate(float deltaTime)
|
|
|
|
{
|
|
|
|
if (forceAttack && interval.AllowUpdate)
|
|
|
|
{
|
|
|
|
OnAttack(new BITConstant.Command.AttackCommand());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnAttack(BITConstant.Command.AttackCommand obj)
|
|
|
|
{
|
|
|
|
UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.Melee);
|
|
|
|
}
|
2023-10-30 01:25:53 +08:00
|
|
|
|
|
|
|
protected override void OnAnimationEvent(string animationEventName)
|
|
|
|
{
|
|
|
|
switch (animationEventName)
|
|
|
|
{
|
|
|
|
case BITConstant.Player.Attack:
|
|
|
|
case BITConstant.Player.Melee:
|
|
|
|
meleeService.Melee(new MeleeCommand()
|
|
|
|
{
|
|
|
|
Damage = assetableMelee.MeleeDamage,
|
|
|
|
Force = assetableMelee.MeleeForce,
|
|
|
|
PlayerId = Entity.Id,
|
|
|
|
Position = transform.position,
|
|
|
|
Range = assetableMelee.MeleeRange,
|
|
|
|
Forward = UnityEntity.transform.forward,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-10-29 15:27:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|