diff --git a/Assets/Animations.meta b/Assets/Animations.meta deleted file mode 100644 index b2a79e2..0000000 --- a/Assets/Animations.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ef3d86d84c224344a94715cdfa9fe32c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Animators.meta b/Assets/Animators.meta deleted file mode 100644 index 7ff80b8..0000000 --- a/Assets/Animators.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 043f304edcc831c4ea9fcf0e1a2e520d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Assets.meta b/Assets/Assets.meta deleted file mode 100644 index 4eba494..0000000 --- a/Assets/Assets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0460346d99d385241a6d87bbd10aceb8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/PhysMats.meta b/Assets/PhysMats.meta deleted file mode 100644 index bc5b1b2..0000000 --- a/Assets/PhysMats.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e823a56cb429e4b49becdc740fba66b9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Monster.cs b/Assets/Scripts/Monster.cs index e9efb1a..976a1d3 100644 --- a/Assets/Scripts/Monster.cs +++ b/Assets/Scripts/Monster.cs @@ -14,27 +14,45 @@ public class Monster : MonoBehaviour public Sprite sprite; private Map map; + + private Player player; // Start is called before the first frame update private void Start() { map = GameObject.FindGameObjectWithTag("Map").GetComponent(); + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); hasSpottedPlayer = false; } void Turn(){ - int direction = Random.Range(0, 4); - if (direction == 0 && map.CanMoveTo(Vector2Int.left)){ - transform.Translate(Vector3.left); + IsPlayerNear(); + if (!hasSpottedPlayer){ + int direction = Random.Range(0, 4); + if (direction == 0 && map.CanMoveTo(Vector2Int.left)){ + transform.Translate(Vector3.left); + } + else if (direction == 1 && map.CanMoveTo(Vector2Int.right)){ + transform.Translate(Vector3.right); + } + else if (direction == 2 && map.CanMoveTo(Vector2Int.up)){ + transform.Translate(Vector3.up); + } + else if (direction == 3 && map.CanMoveTo(Vector2Int.left)){ + transform.Translate(Vector3.left); + } } - else if (direction == 1 && map.CanMoveTo(Vector2Int.right)){ - transform.Translate(Vector3.right); + else{ + //Put here pathfinding code } - else if (direction == 2 && map.CanMoveTo(Vector2Int.up)){ - transform.Translate(Vector3.up); + } + + void IsPlayerNear(){ + if ((player.transform.position.x-transform.position.x)<=3 || (transform.position.x-player.transform.position.x)>=-3){ + hasSpottedPlayer=true; } - else if (direction == 3 && map.CanMoveTo(Vector2Int.left)){ - transform.Translate(Vector3.left); + if ((player.transform.position.y-transform.position.y)<=3 || (transform.position.y-player.transform.position.y)>=-3){ + hasSpottedPlayer=true; } } } diff --git a/Assets/Sounds.meta b/Assets/Sounds.meta deleted file mode 100644 index 5fd147f..0000000 --- a/Assets/Sounds.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 19c0d85909aede34bb371863f187b9e0 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: