Commit d81fc2c5 authored by Cody A Burchett's avatar Cody A Burchett

local scale enemy changes

parent ff8db197
......@@ -68,7 +68,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1814748107547458}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.061, y: -0.068, z: 0}
m_LocalPosition: {x: 0.067, y: -0.07, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4509028035222262}
......@@ -81,7 +81,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1719364032110612}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.067, y: -0.067, z: 0}
m_LocalPosition: {x: -0.067, y: -0.07, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4509028035222262}
......@@ -94,7 +94,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1364917495186244}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.558, y: -2.319, z: 0}
m_LocalPosition: {x: -1.5628786, y: -2.319, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4435072663916906}
......@@ -155,13 +155,12 @@ MonoBehaviour:
m_GameObject: {fileID: 1364917495186244}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 86480f22ad015d94c847616902fbf09e, type: 3}
m_Script: {fileID: 11500000, guid: f443bc7207d9ea54b8e4ad3858852363, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 2
maxMoveDistance: 1
maxMoveDistance: 3
rightCollisionPos: {fileID: 4435072663916906}
leftCollisionPos: {fileID: 4463245263230422}
hasEnteredView: 0
--- !u!212 &212629259485226998
SpriteRenderer:
......
......@@ -155,13 +155,12 @@ MonoBehaviour:
m_GameObject: {fileID: 1583886293531340}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c75f0a9677652bd4b80f65fbf6681ac9, type: 3}
m_Script: {fileID: 11500000, guid: 39c6ef048ba50f64781a1a45907a03cb, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 2
maxMoveDistance: 2
rightCollisionPos: {fileID: 4985997972421274}
leftCollisionPos: {fileID: 4110681633737894}
hasEnteredView: 0
--- !u!212 &212141967522432748
SpriteRenderer:
......
......@@ -11,33 +11,33 @@ Prefab:
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1712010132832294}
m_IsPrefabParent: 1
--- !u!1 &1526510351862396
--- !u!1 &1244956598026678
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4696422319126882}
- component: {fileID: 61749888789012562}
- component: {fileID: 4853518404556974}
m_Layer: 0
m_Name: FieldOfView
m_TagString: Enemy
m_Name: LeftPosition
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1613800547789904
--- !u!1 &1526510351862396
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4411418237510316}
- component: {fileID: 4696422319126882}
- component: {fileID: 61749888789012562}
m_Layer: 0
m_Name: LeftPosition
m_TagString: Untagged
m_Name: FieldOfView
m_TagString: Enemy
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
......@@ -54,7 +54,7 @@ GameObject:
- component: {fileID: 61019725317334586}
- component: {fileID: 50003621849076114}
- component: {fileID: 114302828278833510}
- component: {fileID: 114830455723863958}
- component: {fileID: 114851485952996640}
m_Layer: 0
m_Name: enemyRanged
m_TagString: Enemy
......@@ -62,14 +62,14 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1725140522497956
--- !u!1 &1982165559208934
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4396477334332260}
- component: {fileID: 4500197461570982}
m_Layer: 0
m_Name: RightPosition
m_TagString: Untagged
......@@ -88,17 +88,17 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4696422319126882}
- {fileID: 4396477334332260}
- {fileID: 4411418237510316}
- {fileID: 4500197461570982}
- {fileID: 4853518404556974}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4396477334332260
--- !u!4 &4500197461570982
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1725140522497956}
m_GameObject: {fileID: 1982165559208934}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.487, y: -0.539, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
......@@ -106,31 +106,31 @@ Transform:
m_Father: {fileID: 4231052512598444}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4411418237510316
--- !u!4 &4696422319126882
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1613800547789904}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.487, y: -0.552, z: 0}
m_GameObject: {fileID: 1526510351862396}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4231052512598444}
m_RootOrder: 2
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4696422319126882
--- !u!4 &4853518404556974
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1526510351862396}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2, y: 0, z: 0}
m_GameObject: {fileID: 1244956598026678}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.487, y: -0.552, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4231052512598444}
m_RootOrder: 0
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &50003621849076114
Rigidbody2D:
......@@ -188,22 +188,21 @@ MonoBehaviour:
m_GameObject: {fileID: 1712010132832294}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 222712d5b54cc7c43a5443c6cd5f9926, type: 3}
m_Script: {fileID: 11500000, guid: 5d0b170db0b8fa0408c07d63ccd8ae89, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 2
maxMoveDistance: 5
rightCollisionPos: {fileID: 4396477334332260}
leftCollisionPos: {fileID: 4411418237510316}
maxMoveDistance: 4
rightCollisionPos: {fileID: 4500197461570982}
hasEnteredView: 0
fieldOfView: {fileID: 61749888789012562}
projectile: {fileID: 1930590740933862, guid: ef3d5c389736f854a8e7439ca389098c, type: 2}
maxDistance: 5
projectileSpeed: 4
maxDistance: 4
projectileSpeed: 3
fireCooldown: 0.5
isFacingRight: 0
angleOfSpread: 0
--- !u!114 &114830455723863958
--- !u!114 &114851485952996640
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
......
......@@ -13,7 +13,6 @@ public class BaseEnemy : MonoBehaviour {
protected float startMoveTime;
public Transform rightCollisionPos;
public Transform leftCollisionPos;
public bool hasEnteredView = false;
......@@ -35,7 +34,6 @@ public class BaseEnemy : MonoBehaviour {
{
RaycastHit2D hitSide = Physics2D.Raycast(collisionPos, dir, .1f);
RaycastHit2D hitDown = Physics2D.Raycast(collisionPos, -transform.up, .1f);
if (hitDown.collider != null && hitSide.collider == null)
{
return true;
......
......@@ -8,9 +8,8 @@ public class HorizontalEnemy : BaseEnemy {
protected virtual void Update () {
//find collision direction and position of enemy
Vector3 collisionDir = transform.localScale.x < 0 ? -transform.right : transform.right;
Vector3 collisionPos = transform.localScale.x < 0 ? leftCollisionPos.position : rightCollisionPos.position;
//check for collision that you have room to move forward and distance left to move
if (CheckCollision(collisionDir, collisionPos) && moveDistanceLeft > 0)
if (CheckCollision(collisionDir, rightCollisionPos.position) && moveDistanceLeft > 0)
{
if (startMoveTime < Time.time)
{
......
......@@ -6,19 +6,20 @@ public class VerticalEnemy : BaseEnemy {
void Update()
{
//find collision direction and position of enemy
Vector3 collisionDir = !sr.flipX ? transform.right : -transform.right;
Vector3 collisionPos = sr.flipX ? leftCollisionPos.position : rightCollisionPos.position;
if (CheckCollisionCharge(collisionDir, collisionPos) && moveDistanceLeft > 0)
Vector3 collisionDir = (transform.localScale.x < 0) ? transform.right : -transform.right;
if (CheckCollisionCharge(collisionDir, rightCollisionPos.position) && moveDistanceLeft > 0)
{
if (startMoveTime < Time.time)
{
Vector3 dir = sr.flipX ? -transform.up : transform.up;
Vector3 dir = transform.localScale.x < 0 ? -transform.up : transform.up;
Move(-dir);
}
}
else
{
sr.flipX = !sr.flipX;
Vector2 locScale = transform.localScale;
locScale.x *= -1;
transform.localScale = locScale;
moveDistanceLeft = maxMoveDistance;
}
}
......
......@@ -32,10 +32,9 @@ public class enemyRanged : HorizontalEnemy
{
base.Update();
if (isFacingRight != sr.flipX)
if ((transform.localScale.x > 0 && isFacingRight == true) || (transform.localScale.x < 0 && isFacingRight == false))
{
isFacingRight = sr.flipX;
gameObject.transform.localScale = new Vector2(-gameObject.transform.localScale.x, gameObject.transform.localScale.y);
isFacingRight = !isFacingRight;
}
if (fieldOfView.IsTouching(GameObject.Find("Player").GetComponent<Collider2D>())) //if the player is in view
{
......
Markdown is supported
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