46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Xml;
|
|
using BITKit.Entities.Melee;
|
|
using Unity.Mathematics;
|
|
using UnityEngine;
|
|
namespace BITKit.Entities
|
|
{
|
|
public interface IEntityMelee
|
|
{
|
|
void Execute();
|
|
}
|
|
public class EntityMelee : EntityComponent
|
|
{
|
|
[Header(Constant.Header.Settings)]
|
|
public int damage=50;
|
|
public bool singleTarget;
|
|
|
|
[SerializeReference, SubclassSelector, Inject(true)] private IMeleeService meleeService;
|
|
public override void OnStart()
|
|
{
|
|
entity.AddListener<int>("Melee", Melee);
|
|
entity.AddListener<string>(AIAction);
|
|
}
|
|
private void AIAction(string actionName)
|
|
{
|
|
switch (actionName)
|
|
{
|
|
case "Melee":
|
|
break;
|
|
}
|
|
}
|
|
private void Melee(int _damage)
|
|
{
|
|
meleeService.Melee(new MeleeCommand()
|
|
{
|
|
PlayerId = Entity.Id,
|
|
Position = Transform.position + Vector3.up,
|
|
Force = Transform.forward * 128,
|
|
Range = 1.6f,
|
|
Damage = _damage,
|
|
});
|
|
entity.Invoke(Constant.Animation.Play, "Melee");
|
|
}
|
|
}
|
|
} |