This commit is contained in:
CortexCore
2023-10-24 23:37:59 +08:00
parent 325f63d6bc
commit 3e39e627bc
388 changed files with 29043 additions and 889 deletions

View File

@@ -1,27 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using BITFALL.Combat;
using BITKit.Animations;
using BITKit.Entities.Melee;
using Unity.Mathematics;
using UnityEngine;
namespace BITKit.Entities
{
public interface IEntityMelee
{
void Execute();
}
public class EntityMelee : EntityComponent
[CustomType(typeof(IMeleeCombat))]
public class EntityMelee : EntityComponent,IMeleeCombat
{
[SerializeField] private UnityAnimator unityAnimator;
[Header(Constant.Header.Settings)]
public int damage=50;
public bool singleTarget;
[SerializeField] private int damage=50;
[SerializeReference, SubclassSelector, Inject(true)] private IMeleeService meleeService;
[Inject(true)] private IEntityOverride entityOverride;
public override void OnStart()
{
entity.AddListener<int>("Melee", Melee);
entity.AddListener<string>(AIAction);
unityAnimator[0].onStateEnter += OnStateEnter;
}
private void OnStateEnter(string obj)
{
if(entityOverride is null)return;
if (obj is "HitStun")
{
entityOverride.AddOverride(this);
}
else
{
entityOverride.RemoveOverride(this);
}
}
private void AIAction(string actionName)
{
switch (actionName)
@@ -40,7 +59,14 @@ namespace BITKit.Entities
Range = 1.6f,
Damage = _damage,
});
entity.Invoke(Constant.Animation.Play, "Melee");
unityAnimator.Play("Attack");
//entity.Invoke(Constant.Animation.Play, "Melee");
}
public void Execute() => Melee(damage);
public void HitStun()
{
unityAnimator.Play("HitStun");
}
}
}