Commit d1a99a7f authored by Hao Chen (hac185)'s avatar Hao Chen (hac185)
Browse files

decisionTree script for enemy

parent b3f7268a
fileFormatVersion: 2
guid: 287391dbe3cd9471a9c3a9ae5aa99354
folderAsset: yes
timeCreated: 1475018641
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 7580e7a14bdec4cf3a38f24b94dfae3f
guid: 122249f9de258406bbaab645c0fbd4a5
folderAsset: yes
timeCreated: 1476045420
licenseType: Free
......
fileFormatVersion: 2
guid: 90486bb225777485fab91ea48a030704
guid: d67d8611cbb544cc3891cd0c6faf3809
folderAsset: yes
timeCreated: 1479924870
licenseType: Free
......
fileFormatVersion: 2
guid: 4d89df6e8927247f2b76ad062384eed2
guid: 4c94a20efe0dc4788888bb996c758a01
folderAsset: yes
timeCreated: 1477333893
licenseType: Free
......
......@@ -75,16 +75,35 @@ public class enemyScript : MonoBehaviour {
}
public void WalkTowardsHero()
{
MoveTowards (this.player.transform.position);
}
public void MoveTowards(Vector3 targetPos, bool isInverse = false)
{
float speed = this.speed;
if (isInverse)
speed *= -1;
/* Walk towards target */
Vector3 newPos = Vector3.MoveTowards(this.transform.position, targetPos, speed);
this.transform.position = newPos;
// void OnCollisionEnter2D(Collision2D other){
// if (other.CompareTag ("Projectile")) {
// //get damage
// ProjectileController projCtrl = other.gameObject.GetComponent<ProjectileController>();
// int damagae = projCtrl.getDamage ();
// //health script, take damage
// //send message with calling recieveDamage(Will have int damage) within health script
//pass damage to sendMessage, Destroy other
// Destroy(other.gameobject)
/* Rotate facing towards target */
Vector2 direction = Vector2.zero;
if (speed > 0)
direction = targetPos - this.transform.position;
else
direction = this.transform.position - targetPos;
float directionAngle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
this.transform.rotation = Quaternion.AngleAxis(directionAngle, Vector3.forward);
}
}
fileFormatVersion: 2
guid: 6e6bb3fc140db4e89aa90cbcf53eaf25
guid: 254a700a0e4b640e5abe9f7c157fd377
folderAsset: yes
timeCreated: 1479924870
licenseType: Free
......
fileFormatVersion: 2
guid: 6fcb17d7f421f4bc69fd8f40826ee566
guid: 760e656a65ae44f6698b835261977947
folderAsset: yes
timeCreated: 1477333793
licenseType: Free
......
fileFormatVersion: 2
guid: b8193b9e1ae094b7cb3ebd58a74cd6ed
guid: 3b148c2899d3a40d0b66ce776c70b89e
folderAsset: yes
timeCreated: 1477334519
licenseType: Free
......
fileFormatVersion: 2
guid: 5110b838530ca41e496f777295e2b20b
guid: 490e44a80fe8a420b846ed75236c4da8
folderAsset: yes
timeCreated: 1477334496
licenseType: Free
......
fileFormatVersion: 2
guid: 6a89423bd0e704867a110f8fc3d7fc24
guid: af413dbac5f22404db43788b04858697
folderAsset: yes
timeCreated: 1477334496
licenseType: Free
......
fileFormatVersion: 2
guid: d990fd53501dc4f2e89984a74ca738a2
guid: e80e84d84f8b14e71a2ab683139f68d8
folderAsset: yes
timeCreated: 1477692351
licenseType: Free
......
fileFormatVersion: 2
guid: 7580e7a14bdec4cf3a38f24b94dfae3f
folderAsset: yes
timeCreated: 1476045420
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6fcb17d7f421f4bc69fd8f40826ee566
folderAsset: yes
timeCreated: 1477333793
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b8193b9e1ae094b7cb3ebd58a74cd6ed
folderAsset: yes
timeCreated: 1477334519
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 5110b838530ca41e496f777295e2b20b
folderAsset: yes
timeCreated: 1477334496
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6a89423bd0e704867a110f8fc3d7fc24
folderAsset: yes
timeCreated: 1477334496
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 4d89df6e8927247f2b76ad062384eed2
folderAsset: yes
timeCreated: 1477333893
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ceab396aba0f448a1afd887c6af4c45f
folderAsset: yes
timeCreated: 1479924372
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 8f5d0c8af3adc4e1e817ea7eb8376bdc
folderAsset: yes
timeCreated: 1477334496
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f8e7dfa6232cb4fd595e00659318e7e9
folderAsset: yes
timeCreated: 1477334496
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment