using UnityEngine;
using System.Collections;
public class EnemySlime : EnemyController
{
#region INHERENT METHODS [FixedUpdate]
///
/// Moves the slime forward during each Fixed Update frame based on its max speed
///
void FixedUpdate()
{
if(this.isFacingRight == true)
{
this.rigidbody2D.velocity = new Vector2(maxSpeed, this.rigidbody2D.velocity.y);
}
else
{
this.rigidbody2D.velocity = new Vector2(maxSpeed * -1, this.rigidbody2D.velocity.y);
}
}
#endregion
#region COLLIDER 2D COMPONENT METHODS [OnEnter]
///
/// Causes the slime to invoke the Flip() method if it contacts a wall or other enemy
///
/// The Collider2D that is entering the trigger
void OnTriggerEnter2D(Collider2D collider)
{
if(collider.tag == "Wall")
{
Flip ();
}
else if (collider.tag == "Enemy")
{
EnemyController controller = collider.gameObject.GetComponent();
controller.Flip();
Flip ();
}
}
#endregion
}