diff --git a/Assets/AIScripts/hover.cs b/Assets/AIScripts/hover.cs deleted file mode 100644 index f8342f9..0000000 --- a/Assets/AIScripts/hover.cs +++ /dev/null @@ -1,107 +0,0 @@ -using UnityEngine; -using System.Collections; - -public class hover : MonoBehaviour -{ - - public LayerMask enemyMask; - public float speed = 1; - public bool flyPattern; // false is x-axis, true is y axis YOU HAPPY???? good - public float maxFlightDistance = 0; // if flight distance is 0, fly foreva, probably should never do.. lol - float distanceFlown; - Rigidbody2D myBody; - Transform myTrans; - float myWidth, myHeight; - float lastPos; - - - // Use this for initialization - void Start() - { - myTrans = this.transform; - myBody = this.GetComponent(); - SpriteRenderer mySprite = this.GetComponent(); - myWidth = mySprite.bounds.extents.x; - myHeight = mySprite.bounds.extents.y; - - } - - - // Update is called once per frame - void FixedUpdate() - { - Vector2 lineCastPos; - //check to see if there's something in front of us before moving forward - if (flyPattern == false) - { - lineCastPos = myTrans.position.toVector2() - myTrans.right.toVector2() * myWidth + Vector2.up * myHeight; - lineCastPos.y = lineCastPos.y - (myHeight * 1.2f); - } - - - else - { - lineCastPos = myTrans.position.toVector2() - myTrans.up.toVector2() * myWidth + Vector2.right * myHeight; - lineCastPos.x -= myWidth; - } - - - - Debug.DrawLine(lineCastPos, lineCastPos + Vector2.down * 0.05f); - bool isBlockedY = Physics2D.Linecast(lineCastPos, lineCastPos + Vector2.down * 0.05f, enemyMask); - Debug.DrawLine(lineCastPos, lineCastPos - myTrans.right.toVector2() * 0.05f); - bool isBlockedX = Physics2D.Linecast(lineCastPos, lineCastPos - myTrans.right.toVector2() * 0.05f, enemyMask); - - //if hit wall on x-axis ground turn around - if ((isBlockedX && flyPattern == false) || (distanceFlown > maxFlightDistance && maxFlightDistance != 0 && flyPattern == false)) - { - Vector3 currentRot = myTrans.eulerAngles; - currentRot.y += 180; - print(currentRot.x); - myTrans.eulerAngles = currentRot; - distanceFlown = 0; - print("did it"); - } - - //if hit wall on y-axis ground turn around - else if((isBlockedY && flyPattern == true) || (distanceFlown > maxFlightDistance && maxFlightDistance != 0 && flyPattern == true)) - { - Vector3 currentRot = myTrans.eulerAngles; - currentRot.x += 180; - print(currentRot.x); - myTrans.eulerAngles = currentRot; - print(myTrans.eulerAngles); - distanceFlown = 0; - print("did it"); - } - - - - - - //Horizontal movement - if (flyPattern == false) - { - Vector2 myVel = myBody.velocity; - myVel.x = -myTrans.right.x * speed; - distanceFlown += Mathf.Abs(lastPos - transform.position.x); - //print(distanceFlown); - myBody.velocity = myVel; - lastPos = transform.position.x; - - } - //Vertickle movement - if(flyPattern == true) - { - Vector2 myVel = myBody.velocity; - myVel.y = -myTrans.up.y * speed; - distanceFlown += Mathf.Abs(lastPos - transform.position.y); - //print(distanceFlown); - myBody.velocity = myVel; - lastPos = transform.position.y; - } - - - } - -} \ No newline at end of file diff --git a/Assets/AIScripts/hover.cs.meta b/Assets/AIScripts/hover.cs.meta deleted file mode 100644 index f9a56b9..0000000 --- a/Assets/AIScripts/hover.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7feb214d1ef985b4dac3410715f7e42c -timeCreated: 1454129535 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Cloud [moving]/CloudMove11_0.controller b/Assets/Cloud [moving]/CloudMove11_0.controller index 45a686a..a951f4d 100644 Binary files a/Assets/Cloud [moving]/CloudMove11_0.controller and b/Assets/Cloud [moving]/CloudMove11_0.controller differ diff --git a/Assets/Resources/Scripts/AIScripts/Enemy.cs b/Assets/Resources/Scripts/AIScripts/Enemy.cs index ccc6642..9fa4b00 100644 --- a/Assets/Resources/Scripts/AIScripts/Enemy.cs +++ b/Assets/Resources/Scripts/AIScripts/Enemy.cs @@ -3,18 +3,21 @@ using System.Collections; using GameUtils; using System; -public class Enemy : Controller, ISceneObject{ - +public class Enemy : Controller{ + public bool isAir; private state currentState; - // Use this for initialization - void Start () + public LayerMask enemyMask; + // Use this for initialization + void Start () { + + isAir = false; print("start"); changestate(new idle()); + } - // Update is called once per frame - void Update () + void FixedUpdate () { currentState.Execute(); } @@ -25,13 +28,4 @@ public class Enemy : Controller, ISceneObject{ currentState = newstate; currentState.Enter(this); } - - public void ObjectUpdate() - { - } - - public void Initialize() - { - - } } diff --git a/Assets/Resources/Scripts/AIScripts/idle.cs b/Assets/Resources/Scripts/AIScripts/idle.cs index 199c240..0602f49 100644 --- a/Assets/Resources/Scripts/AIScripts/idle.cs +++ b/Assets/Resources/Scripts/AIScripts/idle.cs @@ -1,29 +1,28 @@ using UnityEngine; using System.Collections; using System; +using GameUtils; -public class idle : state { +public class idle : state +{ + private ISceneObject manager; private Enemy enemy; private float time = 0; public void Execute() { - time += Time.deltaTime; - if (time >= 1) - enemy.changestate(new wander()); + Idle(); } - public void Enter(Enemy enemy) { Debug.Log("idle"); - time = 0; this.enemy = enemy; } - - public void Exit() - { - } - - public void onTriggerEnter(Collider2D other) + public void Exit(){} + public void onTriggerEnter(Collider2D other){} + public void Idle() { + time += Time.deltaTime; + if (time >= 3) + enemy.changestate(new wander()); } } diff --git a/Assets/Resources/Scripts/AIScripts/seeking.cs b/Assets/Resources/Scripts/AIScripts/seeking.cs index e885141..01b6b19 100644 --- a/Assets/Resources/Scripts/AIScripts/seeking.cs +++ b/Assets/Resources/Scripts/AIScripts/seeking.cs @@ -1,8 +1,10 @@ using UnityEngine; using System.Collections; using System; +using GameUtils; -public class seeking : state { +public class seeking : state +{ private Enemy enemy; public void Enter(Enemy enemy) { diff --git a/Assets/Resources/Scripts/AIScripts/wander.cs b/Assets/Resources/Scripts/AIScripts/wander.cs index 8382f7e..75c298c 100644 --- a/Assets/Resources/Scripts/AIScripts/wander.cs +++ b/Assets/Resources/Scripts/AIScripts/wander.cs @@ -1,11 +1,13 @@ using UnityEngine; using System.Collections; using System; +using GameUtils; -public class wander : state { +public class wander : state +{ private Enemy enemy; public LayerMask enemyMask; - public float speed = 5; + public float speed; Rigidbody2D myBody; Transform myTrans; float myWidth, myHeight; @@ -14,8 +16,29 @@ public class wander : state { public void Execute() { time += Time.deltaTime; - if (time >= 5) + if (time >= 10) enemy.changestate(new idle()); + CheckHead(); + Move(); + } + + public void Enter(Enemy enemy) + { + Debug.Log("Wander"); + time = 0; + this.enemy = enemy; + this.enemyMask = enemy.enemyMask; + myTrans = enemy.transform; + myBody = enemy.GetComponent(); + SpriteRenderer mySprite = enemy.GetComponent(); + myWidth = mySprite.bounds.extents.x; + myHeight = mySprite.bounds.extents.y; + speed = enemy.movementSpeed; + } + public void Exit(){} + public void onTriggerEnter(Collider2D other){} + public void CheckHead() + { //check to see if there's ground in front of us before moving forward Vector2 lineCastPos = myTrans.position.toVector2() - myTrans.right.toVector2() * myWidth + Vector2.up * myHeight; lineCastPos.y = lineCastPos.y - (myHeight * 1.2f); @@ -30,29 +53,13 @@ public class wander : state { currentRot.y += 180; myTrans.eulerAngles = currentRot; } + } + public void Move() + { //always move forward Vector2 myVel = myBody.velocity; myVel.x = -myTrans.right.x * speed; myBody.velocity = myVel; } - public void Enter(Enemy enemy) - { - Debug.Log("Wander"); - time = 0; - this.enemy = enemy; - myTrans = enemy.transform; - myBody = enemy.GetComponent(); - SpriteRenderer mySprite = enemy.GetComponent(); - myWidth = mySprite.bounds.extents.x; - myHeight = mySprite.bounds.extents.y; - } - - public void Exit() - { - } - - public void onTriggerEnter(Collider2D other) - { - } } diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 7ef9727..0a4d8bb 100644 Binary files a/ProjectSettings/TagManager.asset and b/ProjectSettings/TagManager.asset differ