Ludum Dare 50
Theme: Delay the inevitable
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using Enemies.States;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace Enemies
|
|
|
|
{
|
|
|
|
public class FollowState: IState
|
|
|
|
{
|
|
|
|
private Enemy context;
|
|
|
|
public FollowState(Enemy context)
|
|
|
|
{
|
|
|
|
this.context = context;
|
|
|
|
}
|
|
|
|
public void Enter()
|
|
|
|
{
|
|
|
|
Debug.Log("Entering Follow State");
|
|
|
|
context.currentState = Enemy.States.Follow;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Execute()
|
|
|
|
{
|
|
|
|
//Determine direction to target
|
|
|
|
Vector2 direction = context.target.transform.position - context.transform.position;
|
|
|
|
|
|
|
|
//Move in desired direction
|
|
|
|
context.transform.Translate(direction.normalized * context.speed * Time.deltaTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Exit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|