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
S
seedling
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
Tommé Nöll
seedling
Commits
367bb7f2
Commit
367bb7f2
authored
Oct 06, 2019
by
Tommé Nöll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tomme'
parents
1bde28e2
d0599b57
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
Assets/Scripts/Audio/BackgroundMusic.cs
Assets/Scripts/Audio/BackgroundMusic.cs
+16
-1
Assets/Scripts/Audio/MusicObject.cs
Assets/Scripts/Audio/MusicObject.cs
+7
-0
Assets/Scripts/Enemies/BossAI.cs
Assets/Scripts/Enemies/BossAI.cs
+7
-1
No files found.
Assets/Scripts/Audio/BackgroundMusic.cs
View file @
367bb7f2
...
...
@@ -14,6 +14,7 @@ public class BackgroundMusic : MonoBehaviour {
private
bool
inTransition
=
false
;
private
int
preTransitionSample
=
0
;
private
double
lastUpdate
=
0
;
private
float
fadePerSecond
=
-
1f
;
// Use this for initialization
void
Start
()
{
...
...
@@ -34,10 +35,18 @@ public class BackgroundMusic : MonoBehaviour {
if
(
AS
[
current
].
timeSamples
!=
preTransitionSample
)
{
inTransition
=
false
;
AS
[
1
-
current
].
volume
=
1
;
fadePerSecond
=
-
1
;
Debug
.
Log
(
"Music transition complete, playing "
+
AS
[
current
].
clip
.
name
+
"\nSample new: "
+
AS
[
current
].
timeSamples
+
", Sample old: "
+
AS
[
1
-
current
].
timeSamples
+
"\nCurrent global time: "
+
AudioSettings
.
dspTime
+
", Last update at "
+
lastUpdate
);
}
if
(
fadePerSecond
>=
0
&&
AS
[
1
-
current
].
isPlaying
)
{
AS
[
1
-
current
].
volume
-=
fadePerSecond
*
Time
.
deltaTime
;
}
/*else
{
lastUpdate = AudioSettings.dspTime;
...
...
@@ -72,7 +81,7 @@ public class BackgroundMusic : MonoBehaviour {
"\nCurrent Global Time: "
+
AudioSettings
.
dspTime
);
}
public
void
TransitionTo
(
MusicObject
target
)
public
void
TransitionTo
(
MusicObject
target
,
float
fadeDuration
=
-
1
)
{
if
(
inTransition
)
{
...
...
@@ -86,6 +95,12 @@ public class BackgroundMusic : MonoBehaviour {
}
inTransition
=
true
;
if
(
fadeDuration
>=
0
)
{
fadePerSecond
=
1
/
fadeDuration
;
Play
(
target
,
AS
[
current
].
clip
.
samples
+
(
int
)(
AS
[
current
].
clip
.
frequency
*
fadeDuration
),
0
);
}
int
iTarget
;
for
(
iTarget
=
0
;
iTarget
<
currentMusic
.
targets
.
Length
;
iTarget
++)
//search for TransitionTarget that matches target
...
...
Assets/Scripts/Audio/MusicObject.cs
View file @
367bb7f2
...
...
@@ -20,4 +20,11 @@ public class MusicObject : ScriptableObject {
public
bool
isLoop
=
false
;
[
Tooltip
(
"The non-looped version if this song is looped (required), the looped version otherwise (optional)."
)]
public
MusicObject
loopCounterpiece
;
public
MusicObject
()
{}
public
MusicObject
(
AudioClip
clip
)
{
this
.
clip
=
clip
;
isLoop
=
false
;
}
}
Assets/Scripts/Enemies/BossAI.cs
View file @
367bb7f2
...
...
@@ -54,6 +54,8 @@ public class BossAI : MonoBehaviour
//CameraShake der MainCamera
public
CameraShake
cameraShake
;
private
BackgroundMusic
bgMusic
;
//Events, die während des Phasenwechsels screen shake den Bildschirm schwarz und wieder sichtbar machen
public
UnityEvent
screenShake
;
public
UnityEvent
fadeToBlack
;
...
...
@@ -71,7 +73,8 @@ public class BossAI : MonoBehaviour
[
SerializeField
]
private
AudioSource
audioSource
;
[
SerializeField
]
private
SoundVolume
soundVolumeHit
;
[
SerializeField
]
private
SoundVolume
soundVolumeScream1
;
[
SerializeField
]
private
SoundVolume
soundVolumeScream2
;
[
SerializeField
]
private
SoundVolume
soundVolumeScream2
;
[
SerializeField
]
private
AudioClip
[]
music
;
private
void
Awake
()
{
...
...
@@ -79,6 +82,7 @@ public class BossAI : MonoBehaviour
health
=
bossHealth
.
healthPoints
;
player
=
GameObject
.
FindGameObjectWithTag
(
"Player"
);
bgMusic
=
GameObject
.
FindGameObjectWithTag
(
"MainCamera"
).
GetComponent
<
BackgroundMusic
>();
shootingPoint
=
transform
.
position
+
horizontalOffset
*
Vector3
.
right
+
verticalOffset
*
Vector3
.
up
;
...
...
@@ -160,10 +164,12 @@ public class BossAI : MonoBehaviour
if
(
health
==
3
)
{
audioSource
.
PlayOneShot
(
soundVolumeScream1
.
clip
,
soundVolumeScream1
.
volume
);
bgMusic
.
TransitionTo
(
new
MusicObject
(
music
[
1
]),
2f
);
}
else
if
(
health
==
2
)
{
audioSource
.
PlayOneShot
(
soundVolumeScream2
.
clip
,
soundVolumeScream2
.
volume
);
bgMusic
.
TransitionTo
(
new
MusicObject
(
music
[
2
]),
2f
);
}
yield
return
new
WaitForSeconds
(
timeBetweenShakeAndFade
);
...
...
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