Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gadig
four
Commits
1c55fbcd
Commit
1c55fbcd
authored
Nov 19, 2016
by
Andrew Van Buren
Browse files
Added water boss damage/danger and boss music.
parent
0cb36019
Changes
6
Show whitespace changes
Inline
Side-by-side
Assets/Scenes/water_boss.unity
View file @
1c55fbcd
No preview for this file type
Assets/prefabs/Player.prefab
View file @
1c55fbcd
No preview for this file type
Assets/prefabs/WaterBoss.prefab
View file @
1c55fbcd
No preview for this file type
Assets/script/Boss.cs
View file @
1c55fbcd
...
...
@@ -4,7 +4,9 @@ using System.Collections;
public
class
Boss
:
MonoBehaviour
{
private
Rigidbody2D
rb
;
public
float
speed
=
1f
;
public
float
speed
=
75f
;
public
float
dangerSpeedMultiplier
=
2f
;
public
int
dangerTheshold
=
10
;
public
GameObject
[]
waypoints
;
private
Transform
currentWaypoint
;
public
float
distanceThreshold
=
0.5f
;
...
...
@@ -17,9 +19,13 @@ public class Boss : MonoBehaviour {
public
GameObject
diety
;
public
Color
damageColor
;
public
float
damageColorSpeed
=
8
;
public
Color
dangerColor
;
private
SpriteRenderer
sr
;
private
Animator
animator
;
public
AudioClip
bossMusic
;
private
AudioSource
bgm
;
GameObject
player
;
private
bool
triggered
=
false
;
...
...
@@ -34,6 +40,7 @@ public class Boss : MonoBehaviour {
player
=
GameObject
.
FindGameObjectWithTag
(
"Player"
);
PickWaypoint
();
rb
.
isKinematic
=
true
;
bgm
=
Camera
.
main
.
GetComponentInChildren
<
AudioSource
>();
}
// Update is called once per frame
...
...
@@ -43,18 +50,24 @@ public class Boss : MonoBehaviour {
PickWaypoint
();
}
else
{
Vector2
dir
=
currentWaypoint
.
position
-
transform
.
position
;
Vector2
force
=
new
Vector2
(
dir
.
x
,
dir
.
y
)
*
speed
;
rb
.
AddForce
(
Vector2
.
ClampMagnitude
(
force
,
speed
));
Vector2
force
=
new
Vector2
(
dir
.
x
,
dir
.
y
)
*
speed
*
(
health
<
dangerTheshold
?
dangerSpeedMultiplier
:
1
)
;
rb
.
AddForce
(
Vector2
.
ClampMagnitude
(
force
,
speed
*
(
health
<
dangerTheshold
?
dangerSpeedMultiplier
:
1
)
));
}
}
if
(
Time
.
time
>
lastAttack
)
{
lastAttack
=
Time
.
time
+
attackCooldown
+
Random
.
Range
(
0
,
attackRandom
);
lastAttack
=
Time
.
time
+
(
attackCooldown
+
Random
.
Range
(
0
,
attackRandom
)
)
/
(
health
<
dangerTheshold
?
dangerSpeedMultiplier
:
1
)
;
StartCoroutine
(
Attack
());
}
sr
.
color
=
Color
.
Lerp
(
sr
.
color
,
Color
.
white
,
Time
.
deltaTime
*
damageColorSpeed
);
// Set color
sr
.
color
=
Color
.
Lerp
(
sr
.
color
,
(
health
<
dangerTheshold
?
dangerColor
:
Color
.
white
),
Time
.
deltaTime
*
damageColorSpeed
);
if
(
Vector2
.
Distance
(
player
.
transform
.
position
,
transform
.
position
)
<
triggerDist
)
{
if
(!
triggered
)
{
bgm
.
clip
=
bossMusic
;
bgm
.
Play
();
}
triggered
=
true
;
animator
.
SetBool
(
"Moving"
,
true
);
rb
.
isKinematic
=
false
;
...
...
@@ -76,7 +89,7 @@ public class Boss : MonoBehaviour {
void
GetHit
(
int
amount
)
{
if
(
triggered
)
{
health
-=
health
;
health
-=
amount
;
sr
.
color
=
damageColor
;
if
(
health
<=
0
)
{
Die
();
...
...
@@ -85,6 +98,7 @@ public class Boss : MonoBehaviour {
}
void
Die
()
{
bgm
.
Stop
();
Instantiate
(
diety
,
transform
.
position
,
Quaternion
.
identity
);
Destroy
(
gameObject
);
}
...
...
Assets/sound/Water_Dungeon_Boss.wav
0 → 100644
View file @
1c55fbcd
File added
Assets/sound/Water_Dungeon_Boss.wav.meta
0 → 100644
View file @
1c55fbcd
fileFormatVersion: 2
guid: 85eee806e25b00c42bd485a380e2d51d
timeCreated: 1479602249
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
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