59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Saltosion.OneWeapon.AI.Behaviours;
|
|
using Saltosion.OneWeapon.AI.Triggers;
|
|
|
|
namespace Saltosion.OneWeapon.Enemies {
|
|
[RequireComponent(typeof(Enemy))]
|
|
[RequireComponent(typeof(PlayerSighted))]
|
|
[RequireComponent(typeof(Wander))]
|
|
[RequireComponent(typeof(Follow))]
|
|
[RequireComponent(typeof(Stomp))]
|
|
public class Stompy : MonoBehaviour {
|
|
public Animator Anim;
|
|
|
|
private Enemy Enemy;
|
|
private PlayerSighted FollowTrigger;
|
|
private Wander WanderBehaviour;
|
|
private Follow FollowBehaviour;
|
|
private Stomp StompBehaviour;
|
|
|
|
private void Start() {
|
|
Enemy = GetComponent<Enemy>();
|
|
FollowTrigger = GetComponent<PlayerSighted>();
|
|
WanderBehaviour = GetComponent<Wander>();
|
|
FollowBehaviour = GetComponent<Follow>();
|
|
StompBehaviour = GetComponent<Stomp>();
|
|
}
|
|
|
|
private void Update() {
|
|
Enemy.CurrentBehaviour = "";
|
|
if (FollowTrigger.IsTriggered()) {
|
|
FollowBehaviour.Target = FollowTrigger.Player.transform;
|
|
if (StompBehaviour.CanBehave()) {
|
|
// If seeing the player and stomping is possible, stomp
|
|
StompBehaviour.Execute();
|
|
} else if (!StompBehaviour.Stomping) {
|
|
// If seeing the player but stomping was not possible, and am currently not stomping,
|
|
// get closer to the player.
|
|
FollowBehaviour.TryExecute();
|
|
}
|
|
Enemy.CurrentBehaviour = "Stomp:" + StompBehaviour.CurrentStatus + ", " + "Follow:" + FollowBehaviour.CurrentStatus;
|
|
} else if (WanderBehaviour.TryExecute()) {
|
|
Enemy.CurrentBehaviour = "Wander:" + WanderBehaviour.CurrentStatus;
|
|
}
|
|
|
|
/* TODO: Implement animations for Stompy
|
|
if (StompBehaviour.PreparingStomp) {
|
|
Anim.Play("Prepare");
|
|
} else if (StompBehaviour.Stomping) {
|
|
Anim.Play("Stomp");
|
|
} else {
|
|
Anim.Play("Walk");
|
|
}
|
|
Anim.SetFloat("Speed", Enemy.Movement.AnimationSpeed);*/
|
|
}
|
|
}
|
|
}
|