<commit_before>﻿using UnityEngine;
using System.Collections;

public class AnimalController : MonoBehaviour {

	#region instance variables
	public enum Direction {North, South, East, West};
	const float stepSize = 2f;
	const float attractionRadius = 10.0f;

	// public variables
	[SerializeField]
	public bool attracted;
	[SerializeField]
	public Direction direction;
	[SerializeField]
	public Vector2 velocity;

	// private variables 
	private int randDir;
	private Vector2 tempVector;
	private ArrayList validDirections;
	private Collider2D closestLure;
	private float distToClosestLure;
	private float overlapCheckRadius;
	private float dx, dy;
	private bool respawn;
	#endregion

	#region methods
	// Use this for initialization
	void Start () {
		attracted = false;
		respawn = false;
		direction = Direction.North;
		velocity = new Vector2 (0.0f, 0.03f);
		validDirections = new ArrayList ();
		tempVector = Vector2.zero;
		distToClosestLure = attractionRadius + 50.0f;
	}

	// Update is called once per frame
	// TODO: collision handling for different types of colliders (walls, escape pods, lures)
	void Update () {


		if (GameManager.levelManager.levelLoaded) {

			// respawn if necessary
			if(respawn)
			{
				GameObject respawnPoint = GameObject.FindWithTag("Respawn");
				if(respawnPoint!=null)
				{
					transform.position = respawnPoint.transform.position;
					direction = Direction.North;
					velocity = new Vector2 (0.0f, 0.03f);
					respawn = false;
				}
			}

			// check to see if the animal is in a door
			Vector2 tileCoords = GameManager.map.GetTileCoordFromWorldPos (transform.position + (Vector3)velocity);
			if (GameManager.map.mapTile [(int)tileCoords.x, (int)tileCoords.y].type == Tile.TileType.GenericDoor)
			{
				velocity = Vector2.zero;
				GameManager.levelManager.numAnimalsRescued++;
				respawn = true;
				if(GameManager.levelManager.numAnimalsRescued >=3)
					GameManager.levelManager.Win ();
			} 
			// Check to see if the animal has hit a hazard
			else if (GameManager.map.mapTile [(int)tileCoords.x, (int)tileCoords.y].type == Tile.TileType.Hazard)
			{
				// player loses a life
				GameManager.levelManager.numLives--;<commit_msg>Fixed bug in spawn point.<commit_after>﻿using UnityEngine;
using System.Collections;

public class AnimalController : MonoBehaviour {

	#region instance variables
	public enum Direction {North, South, East, West};
	const float stepSize = 2f;
	const float attractionRadius = 10.0f;

	// public variables
	[SerializeField]
	public bool attracted;
	[SerializeField]
	public Direction direction;
	[SerializeField]
	public Vector2 velocity;

	// private variables 
	private int randDir;
	private Vector2 tempVector;
	private ArrayList validDirections;
	private Collider2D closestLure;
	private float distToClosestLure;
	private float overlapCheckRadius;
	private float dx, dy;
	private bool respawn;
	#endregion

	#region methods
	// Use this for initialization
	void Start () {
		attracted = false;
		respawn = false;
		direction = Direction.North;
		velocity = new Vector2 (0.0f, 0.03f);
		validDirections = new ArrayList ();
		tempVector = Vector2.zero;
		distToClosestLure = attractionRadius + 50.0f;
	}

	// Update is called once per frame
	// TODO: collision handling for different types of colliders (walls, escape pods, lures)
	void Update () {


		if (GameManager.levelManager.levelLoaded) {

			// respawn if necessary
			if(respawn)
			{
				GameObject respawnPoint = GameObject.FindWithTag("Respawn");
				if(respawnPoint!=null)
				{
					transform.position = (Vector3)(new Vector2(respawnPoint.transform.position.x, respawnPoint.transform.position.y));
					direction = Direction.North;
					velocity = new Vector2 (0.0f, 0.03f);
					respawn = false;
				}
			}

			// check to see if the animal is in a door
			Vector2 tileCoords = GameManager.map.GetTileCoordFromWorldPos (transform.position + (Vector3)velocity);
			if (GameManager.map.mapTile [(int)tileCoords.x, (int)tileCoords.y].type == Tile.TileType.GenericDoor)
			{
				velocity = Vector2.zero;
				GameManager.levelManager.numAnimalsRescued++;
				respawn = true;
				if(GameManager.levelManager.numAnimalsRescued >=3)
					GameManager.levelManager.Win ();
			} 
			// Check to see if the animal has hit a hazard
			else if (GameManager.map.mapTile [(int)tileCoords.x, (int)tileCoords.y].type == Tile.TileType.Hazard)
			{
				// player loses a life
				GameManager.levelManager.numLives--;
{'fraction_non_alphanumeric': 0.09710047201618341, 'fraction_numerical': 0.012587098224320073, 'mean_word_length': 3.879385964912281, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5417778', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1382, 'n_words': 375}