BloodAndGore/Assets/Scripts/Enemies/Stompy.cs

59 lines
2.2 KiB
C#
Raw Permalink Normal View History

2019-08-22 23:14:55 +02:00
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
2019-08-22 23:21:12 +02:00
if (StompBehaviour.PreparingStomp) {
Anim.Play("Prepare");
} else if (StompBehaviour.Stomping) {
Anim.Play("Stomp");
2019-08-22 23:14:55 +02:00
} else {
Anim.Play("Walk");
}
Anim.SetFloat("Speed", Enemy.Movement.AnimationSpeed);*/
}
}
}