Commit 5dc804b2 authored by Luke A Smith's avatar Luke A Smith

Merge branch 'verticalChange' into 'master'

Vertical change

See merge request !53
parents cfa915df 9b8b21ac
......@@ -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,6 +11,21 @@ Prefab:
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1712010132832294}
m_IsPrefabParent: 1
--- !u!1 &1244956598026678
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4853518404556974}
m_Layer: 0
m_Name: LeftPosition
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1526510351862396
GameObject:
m_ObjectHideFlags: 0
......@@ -39,6 +54,7 @@ GameObject:
- component: {fileID: 61019725317334586}
- component: {fileID: 50003621849076114}
- component: {fileID: 114302828278833510}
- component: {fileID: 114851485952996640}
m_Layer: 0
m_Name: enemyRanged
m_TagString: Enemy
......@@ -46,6 +62,21 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1982165559208934
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4500197461570982}
m_Layer: 0
m_Name: RightPosition
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4231052512598444
Transform:
m_ObjectHideFlags: 1
......@@ -53,13 +84,28 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1712010132832294}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -6.46, y: -1.62, z: 0}
m_LocalPosition: {x: 2.7856216, y: -1.8278143, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4696422319126882}
- {fileID: 4500197461570982}
- {fileID: 4853518404556974}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4500197461570982
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
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}
m_Children: []
m_Father: {fileID: 4231052512598444}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4696422319126882
Transform:
m_ObjectHideFlags: 1
......@@ -73,6 +119,19 @@ Transform:
m_Father: {fileID: 4231052512598444}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4853518404556974
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
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: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &50003621849076114
Rigidbody2D:
serializedVersion: 4
......@@ -87,7 +146,7 @@ Rigidbody2D:
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
......@@ -129,19 +188,31 @@ MonoBehaviour:
m_GameObject: {fileID: 1712010132832294}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1916ded6ac0e8c846863536f9eaf16d6, type: 3}
m_Script: {fileID: 11500000, guid: 5d0b170db0b8fa0408c07d63ccd8ae89, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 2
rightCollisionPos: {fileID: 0}
leftCollisionPos: {fileID: 0}
maxMoveDistance: 4
rightCollisionPos: {fileID: 4500197461570982}
hasEnteredView: 0
fieldOfView: {fileID: 61749888789012562}
projectile: {fileID: 1930590740933862, guid: 1654d4bca4b48ea4489be0e10ada70d5, type: 2}
projectile: {fileID: 1930590740933862, guid: ef3d5c389736f854a8e7439ca389098c, type: 2}
maxDistance: 4
projectileSpeed: 1
fireCooldown: 1
isFacingRight: 1
projectileSpeed: 3
fireCooldown: 0.5
isFacingRight: 0
angleOfSpread: 0
--- !u!114 &114851485952996640
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1712010132832294}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 763513e1173772545a16c3cb1a4d40d5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!212 &212475790191283200
SpriteRenderer:
m_ObjectHideFlags: 1
......
......@@ -9,18 +9,15 @@ public class BaseEnemy : MonoBehaviour {
public float maxMoveDistance = 5f;
protected float moveDistanceLeft;
Rigidbody2D body;
protected SpriteRenderer sr;
protected float startMoveTime;
public Transform rightCollisionPos;
public Transform leftCollisionPos;
public bool hasEnteredView = false;
void Start()
protected virtual void Start()
{
body = GetComponent<Rigidbody2D>();
sr = GetComponent<SpriteRenderer>();
startMoveTime = Time.time + .4f;
moveDistanceLeft = maxMoveDistance;
}
......@@ -35,7 +32,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;
......
......@@ -5,12 +5,11 @@ using UnityEngine;
public class HorizontalEnemy : BaseEnemy {
// Update is called once per frame
void Update () {
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;
}
}
......
......@@ -2,7 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
public class enemyRanged : BaseEnemy
public class enemyRanged : HorizontalEnemy
{
[Tooltip("Checks if player is overlapping trigger")]
......@@ -20,15 +20,22 @@ public class enemyRanged : BaseEnemy
public float angleOfSpread; //the greatest possible angle from the center projectiles can randomly spread; ******entered in radians*******
void Start ()
protected override void Start ()
{
base.Start();
fireTimer = 0;
if (!isFacingRight) fieldOfView.gameObject.transform.localPosition = new Vector2(-fieldOfView.gameObject.transform.localPosition.x, fieldOfView.gameObject.transform.localPosition.y);
if (isFacingRight) fieldOfView.gameObject.transform.localPosition = new Vector2(-fieldOfView.gameObject.transform.localPosition.x, fieldOfView.gameObject.transform.localPosition.y);
}
void Update ()
protected override void Update ()
{
base.Update();
if ((transform.localScale.x > 0 && isFacingRight == true) || (transform.localScale.x < 0 && isFacingRight == false))
{
isFacingRight = !isFacingRight;
}
if (fieldOfView.IsTouching(GameObject.Find("Player").GetComponent<Collider2D>())) //if the player is in view
{
if (fireTimer <= 0)
......@@ -62,7 +69,7 @@ public class enemyRanged : BaseEnemy
projectileInstance.transform.localScale = locScale;
if (!isFacingRight)
if (isFacingRight)
{
projectileInstance.GetComponent<enemyProjectile>().ProjectileExpiration(new Vector2(-projectileSpeed * directionModifier.x, projectileSpeed * directionModifier.y), maxDistance);
}
......
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