Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Birb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gadig
Birb
Commits
13bfd6a8
Commit
13bfd6a8
authored
Apr 06, 2017
by
Cody A Burchett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merging horizontal enemy and ranged enemy
parent
24be4a20
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
17 deletions
+97
-17
Assets/Prefabs/enemyRanged.prefab
Assets/Prefabs/enemyRanged.prefab
+82
-10
Assets/Scripts/Enemy/BaseEnemy.cs
Assets/Scripts/Enemy/BaseEnemy.cs
+1
-1
Assets/Scripts/Enemy/HorizontalEnemy.cs
Assets/Scripts/Enemy/HorizontalEnemy.cs
+1
-1
Assets/Scripts/Enemy/enemyRanged.cs
Assets/Scripts/Enemy/enemyRanged.cs
+13
-5
No files found.
Assets/Prefabs/enemyRanged.prefab
View file @
13bfd6a8
...
...
@@ -27,6 +27,21 @@ GameObject:
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&1613800547789904
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4411418237510316
}
m_Layer
:
0
m_Name
:
LeftPosition
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&1712010132832294
GameObject
:
m_ObjectHideFlags
:
0
...
...
@@ -39,6 +54,7 @@ GameObject:
-
component
:
{
fileID
:
61019725317334586
}
-
component
:
{
fileID
:
50003621849076114
}
-
component
:
{
fileID
:
114302828278833510
}
-
component
:
{
fileID
:
114830455723863958
}
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
&1725140522497956
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4396477334332260
}
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,41 @@ 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
:
4396477334332260
}
-
{
fileID
:
4411418237510316
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&4396477334332260
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1725140522497956
}
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
&4411418237510316
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_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!4
&4696422319126882
Transform
:
m_ObjectHideFlags
:
1
...
...
@@ -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,32 @@ MonoBehaviour:
m_GameObject
:
{
fileID
:
1712010132832294
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
1916ded6ac0e8c846863536f9eaf16d
6
,
type
:
3
}
m_Script
:
{
fileID
:
11500000
,
guid
:
222712d5b54cc7c43a5443c6cd5f992
6
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
speed
:
2
rightCollisionPos
:
{
fileID
:
0
}
leftCollisionPos
:
{
fileID
:
0
}
maxMoveDistance
:
5
rightCollisionPos
:
{
fileID
:
4396477334332260
}
leftCollisionPos
:
{
fileID
:
4411418237510316
}
hasEnteredView
:
0
fieldOfView
:
{
fileID
:
61749888789012562
}
projectile
:
{
fileID
:
1930590740933862
,
guid
:
1654d4bca4b48ea4489be0e10ada70d5
,
type
:
2
}
maxDistance
:
4
projectileSpeed
:
1
fireCooldown
:
1
isFacingRight
:
1
projectile
:
{
fileID
:
1930590740933862
,
guid
:
ef3d5c389736f854a8e7439ca389098c
,
type
:
2
}
maxDistance
:
5
projectileSpeed
:
4
fireCooldown
:
0.5
isFacingRight
:
0
angleOfSpread
:
0
---
!u!114
&114830455723863958
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
...
...
Assets/Scripts/Enemy/BaseEnemy.cs
View file @
13bfd6a8
...
...
@@ -17,7 +17,7 @@ public class BaseEnemy : MonoBehaviour {
public
bool
hasEnteredView
=
false
;
void
Start
()
protected
virtual
void
Start
()
{
body
=
GetComponent
<
Rigidbody2D
>();
sr
=
GetComponent
<
SpriteRenderer
>();
...
...
Assets/Scripts/Enemy/HorizontalEnemy.cs
View file @
13bfd6a8
...
...
@@ -5,7 +5,7 @@ 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
=
sr
.
flipX
?
-
transform
.
right
:
transform
.
right
;
Vector3
collisionPos
=
sr
.
flipX
?
leftCollisionPos
.
position
:
rightCollisionPos
.
position
;
...
...
Assets/Scripts/Enemy/enemyRanged.cs
View file @
13bfd6a8
...
...
@@ -2,7 +2,7 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
enemyRanged
:
Base
Enemy
public
class
enemyRanged
:
Horizontal
Enemy
{
[
Tooltip
(
"Checks if player is overlapping trigger"
)]
...
...
@@ -20,15 +20,23 @@ 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
(
isFacingRight
!=
sr
.
flipX
)
{
isFacingRight
=
sr
.
flipX
;
gameObject
.
transform
.
localScale
=
new
Vector2
(-
gameObject
.
transform
.
localScale
.
x
,
gameObject
.
transform
.
localScale
.
y
);
}
if
(
fieldOfView
.
IsTouching
(
GameObject
.
Find
(
"Player"
).
GetComponent
<
Collider2D
>()))
//if the player is in view
{
if
(
fireTimer
<=
0
)
...
...
@@ -62,7 +70,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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment