Shiny shiny golem animations + attack
This commit is contained in:
parent
c74ebe3225
commit
ffb1f1caa1
14 changed files with 169 additions and 38 deletions
|
@ -7,7 +7,7 @@ public enum DeathSate
|
|||
QueenBDead = 2,
|
||||
|
||||
}
|
||||
|
||||
// For compatibility with the other team units, only contains things that need to be in common
|
||||
public abstract class AbstractUnit : MonoBehaviour
|
||||
{
|
||||
public float price;
|
||||
|
|
|
@ -17,6 +17,12 @@ public class ArrowHandler : MonoBehaviour
|
|||
_rigidBody = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Destroy after 8s, in all case
|
||||
Destroy(this.gameObject, 8.0f);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Align with speed
|
||||
|
|
|
@ -56,6 +56,14 @@ public class AttackHandler : MonoBehaviour
|
|||
MinecraftUnit minecraftTarget = (MinecraftUnit)targetUnit;
|
||||
minecraftTarget.StartCoroutine(minecraftTarget.MovementHandler.TakeImpulse(knockbackVector));
|
||||
}
|
||||
|
||||
// Attack animation
|
||||
if (_minecraftUnit.Animator)
|
||||
{
|
||||
_minecraftUnit.Animator.SetTrigger("Attack");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ public class NeutralBehaviour : AbstractBehaviour
|
|||
|
||||
protected override void AttackAction()
|
||||
{
|
||||
Unit.AttackHandler.Attack();
|
||||
//Unit.AttackHandler.Attack();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
[RequireComponent(typeof(Rigidbody), typeof(HealthHandler), typeof(AttackHandler))]
|
||||
[RequireComponent(typeof(MovementHandler))]
|
||||
public class MinecraftUnit : AbstractUnit
|
||||
{
|
||||
[field: SerializeField] public Rigidbody Body { get; private set; }
|
||||
[field: SerializeField] public HealthHandler HealthHandler { get; private set; }
|
||||
[field: SerializeField] public AttackHandler AttackHandler { get; private set; }
|
||||
[field: SerializeField] public MovementHandler MovementHandler { get; private set; }
|
||||
// Not required
|
||||
[field: SerializeField] public Animator Animator { get; private set; }
|
||||
|
||||
|
||||
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
Debug.Assert(Body != null);
|
||||
Debug.Assert(HealthHandler != null);
|
||||
Debug.Assert(AttackHandler != null);
|
||||
Debug.Assert(MovementHandler != null);
|
||||
}
|
||||
|
||||
// Abstract implementation for compatibility with other team
|
||||
|
|
|
@ -12,9 +12,8 @@ public class MovementHandler : MonoBehaviour
|
|||
[SerializeField] public float speed;
|
||||
[SerializeField] private NavMeshAgent agent;
|
||||
[SerializeField] private Transform defaultMoveTarget;
|
||||
|
||||
private float knockbackTime = 1.2f;
|
||||
private float noNavMeshDeadTime = 6.0f;
|
||||
[SerializeField] private float knockbackTime = 1.2f;
|
||||
private float _noNavMeshDeadTime = 6.0f;
|
||||
|
||||
[HideInInspector] public AbstractUnit TargetUnit {get; private set; }
|
||||
|
||||
|
@ -103,7 +102,7 @@ public class MovementHandler : MonoBehaviour
|
|||
noSurfaceTime += 0.5f;
|
||||
|
||||
// Die if exited navMesh for to long
|
||||
if (noSurfaceTime > noNavMeshDeadTime)
|
||||
if (noSurfaceTime > _noNavMeshDeadTime)
|
||||
{
|
||||
_minecraftUnit.HealthHandler.Death();
|
||||
yield break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue