Compare commits

...

2 Commits

Author SHA1 Message Date
6dc42a05cc feat: Apply an audio effect to every manageable audio on a gameobject
A new AudioManager Method triggers a signal which is received by every
ManageableAudio instance. If the causer of the signal is the same transform as the parent of the ManageableAudio, a change in AudioEffects is caused.
2024-04-13 15:56:20 +02:00
e444ebf950 fix: consume boost capacity when only boosting, double play field exit trigger 2024-04-13 15:54:23 +02:00
17 changed files with 557 additions and 62 deletions

View File

@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 6423719894035945655}
- component: {fileID: 3310727599597512245}
- component: {fileID: 7696877450501702533}
- component: {fileID: 6827936618995316794}
m_Layer: 0
m_Name: Boost Sound 1
m_TagString: Untagged
@ -61,7 +62,7 @@ AudioSource:
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: d6edf602b3baa0741bd59cce098f05d5, type: 3}
m_PlayOnAwake: 0
m_Volume: 0.09
m_Volume: 0.07
m_Pitch: 0.9
Loop: 0
Mute: 0
@ -145,3 +146,28 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!169 &6827936618995316794
AudioLowPassFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
m_Enabled: 1
serializedVersion: 3
m_LowpassResonanceQ: 1
lowpassLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0.06775807
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 6423719894035945655}
- component: {fileID: 3310727599597512245}
- component: {fileID: 7696877450501702533}
- component: {fileID: 4941378086240168845}
m_Layer: 0
m_Name: Critical Tackle 1
m_TagString: Untagged
@ -62,7 +63,7 @@ AudioSource:
m_audioClip: {fileID: 8300000, guid: 029b2e37eed317c49841bf21a7a69233, type: 3}
m_PlayOnAwake: 0
m_Volume: 0.2
m_Pitch: 1
m_Pitch: 1.2
Loop: 0
Mute: 0
Spatialize: 0
@ -145,3 +146,28 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!169 &4941378086240168845
AudioLowPassFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
m_Enabled: 0
serializedVersion: 3
m_LowpassResonanceQ: 1
lowpassLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0.13597089
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -47,6 +47,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
id: 1
audioTag: main_menu_music
pitchRange: 0.3
volumeRange: 0.3
--- !u!82 &7696877450501702533
AudioSource:
m_ObjectHideFlags: 0
@ -60,7 +62,7 @@ AudioSource:
m_audioClip: {fileID: 8300000, guid: f03afcd094e19824e8549f6fec3655ef, type: 3}
m_PlayOnAwake: 0
m_Volume: 0.092
m_Pitch: 0.95
m_Pitch: 1.13
Loop: 0
Mute: 0
Spatialize: 0

View File

@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 6423719894035945655}
- component: {fileID: 3310727599597512245}
- component: {fileID: 7696877450501702533}
- component: {fileID: 6298175476027011211}
m_Layer: 0
m_Name: Normal Tackle 1
m_TagString: Untagged
@ -145,3 +146,28 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!169 &6298175476027011211
AudioLowPassFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
m_Enabled: 0
serializedVersion: 3
m_LowpassResonanceQ: 1
lowpassLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0.13597089
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 6423719894035945655}
- component: {fileID: 3310727599597512245}
- component: {fileID: 7696877450501702533}
- component: {fileID: 7797534259601864668}
m_Layer: 0
m_Name: Thruster Sound 1
m_TagString: Untagged
@ -47,7 +48,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
id: 1
audioTag: thruster
pitchRange: 0.4
pitchRange: 0.5
volumeRange: 0.3
--- !u!82 &7696877450501702533
AudioSource:
@ -63,7 +64,7 @@ AudioSource:
m_PlayOnAwake: 0
m_Volume: 0.08
m_Pitch: 1
Loop: 0
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
@ -145,3 +146,28 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!169 &7797534259601864668
AudioLowPassFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
m_Enabled: 0
serializedVersion: 3
m_LowpassResonanceQ: 1
lowpassLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0.045020465
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -0,0 +1,147 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4479628772504131522
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6423719894035945655}
- component: {fileID: 3310727599597512245}
- component: {fileID: 7696877450501702533}
m_Layer: 0
m_Name: Zone Change In
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6423719894035945655
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3310727599597512245
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 887650ff1f3850a43aa8d1281fc70528, type: 3}
m_Name:
m_EditorClassIdentifier:
id: 1
audioTag: thruster
pitchRange: 0.4
volumeRange: 0.3
--- !u!82 &7696877450501702533
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 025361f5b3f97a445ad89bc9ac61c30b, type: 3}
m_PlayOnAwake: 0
m_Volume: 0.08
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 0
MinDistance: 1
MaxDistance: 100
Pan2D: 0
rolloffMode: 1
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 28db476bf8ba56c4bacea4ad2070bcad
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,147 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4479628772504131522
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6423719894035945655}
- component: {fileID: 3310727599597512245}
- component: {fileID: 7696877450501702533}
m_Layer: 0
m_Name: Zone Change Out
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6423719894035945655
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3310727599597512245
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 887650ff1f3850a43aa8d1281fc70528, type: 3}
m_Name:
m_EditorClassIdentifier:
id: 1
audioTag: thruster
pitchRange: 0.4
volumeRange: 0.3
--- !u!82 &7696877450501702533
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4479628772504131522}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 025361f5b3f97a445ad89bc9ac61c30b, type: 3}
m_PlayOnAwake: 0
m_Volume: 0.08
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 0
MinDistance: 1
MaxDistance: 100
Pan2D: 0
rolloffMode: 1
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f35afa6dbb3e6d346a9fa1d98032d910
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -51,8 +51,8 @@ SphereCollider:
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Radius: 0.5
m_Center: {x: 0, y: 0.05, z: 0}
m_Radius: 0.4
m_Center: {x: 0, y: 0.3, z: -0.13130158}
--- !u!1 &950156585708023501
GameObject:
m_ObjectHideFlags: 0
@ -281,7 +281,7 @@ BoxCollider:
m_Bits: 256
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Bits: 8
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 1

View File

@ -51,8 +51,8 @@ SphereCollider:
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Radius: 0.5
m_Center: {x: 0, y: 0.05, z: 0}
m_Radius: 0.4
m_Center: {x: 0, y: 0.3, z: 0}
--- !u!1 &1372816401649438144
GameObject:
m_ObjectHideFlags: 0
@ -171,7 +171,7 @@ BoxCollider:
m_Bits: 256
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Bits: 8
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 1

View File

@ -1,12 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using log4net;
using Managers;
using PrimeTween;
using Unity.VisualScripting;
using UnityEngine;
public enum AudioEffects
{
LowPass
}
public class ManageableAudio : MonoBehaviour
{
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -39,6 +46,11 @@ public class ManageableAudio : MonoBehaviour
}
}
void Start()
{
AudioManager.G.AudioEffectBroadcasted += SwitchAudioEffect;
}
/// <summary>
/// Start playing the sound source.
/// </summary>
@ -131,4 +143,31 @@ public class ManageableAudio : MonoBehaviour
WasOneShotTriggered = false;
}
}
public void SwitchAudioEffect(AudioEffectBroadCastEventArgs args)
{
if (args.AffectedParent != transform.parent)
{
return;
}
switch (args.Effect)
{
case AudioEffects.LowPass:
SwitchLowPassFilter(args.Activate);
break;
}
}
public void SwitchLowPassFilter(bool activate)
{
if (TryGetComponent(out AudioLowPassFilter filter))
{
filter.enabled = activate;
}
}
void OnDestroy()
{
AudioManager.G.AudioEffectBroadcasted -= SwitchAudioEffect;
}
}

View File

@ -21,6 +21,9 @@ namespace Managers
private Dictionary<ManageableAudio, GameObject> audioDictionary =
new Dictionary<ManageableAudio, GameObject>();
public delegate void OnAudioEffectBroadcast(AudioEffectBroadCastEventArgs args);
public event OnAudioEffectBroadcast AudioEffectBroadcasted;
// Start is called before the first frame update
void Awake()
{
@ -197,6 +200,22 @@ namespace Managers
}
public void BroadcastAudioEffect(AudioEffects effect, Transform t, bool activate)
{
AudioEffectBroadcasted.Invoke(new AudioEffectBroadCastEventArgs
{
AffectedParent = t,
Effect = effect,
Activate = activate
});
}
}
public class AudioEffectBroadCastEventArgs : EventArgs
{
public Transform AffectedParent { get; set; }
public AudioEffects Effect { get; set; }
public bool Activate { get; set; }
}
}

View File

@ -9,6 +9,40 @@ using UnityEngine;
using GameLogic;
using System.Threading.Tasks;
/// <summary>
/// States the match can be in.
/// </summary>
public enum MatchState
{
CharacterSelect,
Pause,
Starting,
Match,
End
}
/// <summary>
/// Update data relevant to this matches rules.
/// </summary>
public class MatchConditionUpdate
{
public WinCondition Condition { get; set; }
public Ship Ship { get; set; }
public int Count { get; set; }
}
/// <summary>
/// The properties a player is assigned at the start
/// of the match, according to the rules.
/// </summary>
public class MatchPlayerStatistic
{
public bool IsOut { get; set; }
public int Lives { get; set; }
public int Score { get; set; }
public int Time { get; set; }
}
namespace Managers
{
/// <summary>
@ -79,24 +113,24 @@ namespace Managers
Player updatedPlayer = null;
foreach (Player p in matchPlayers)
{
if (p.character.shipName == update.ship.props.shipName)
if (p.character.shipName == update.Ship.props.shipName)
{
updatedPlayer = p;
Log.Debug($"Players: {p.name} match statistic will be updated.");
}
}
// TODO: Match Result should contain progression over multiple rounds.
MatchResult mr = MatchLogic.UpdateMatchResult(updatedPlayer, update, matchPlayerStatistics);
if (updatedPlayer != null && mr != null)
MatchResult result = MatchLogic.UpdateMatchResult(updatedPlayer, update, matchPlayerStatistics);
if (updatedPlayer != null && result != null)
{
matchState = MatchState.End;
Log.Info("Match has ended, winner will be declared.");
// TODO: Take player decisions into account before restarting the match
// TODO: Include the statistics and match round progression in announcements
AnnounceWinner(mr);
AnnounceWinner(result);
return;
}
Log.Error($"Ship: {update.ship.props.shipName} does not belong to a player in this match."
Log.Error($"Ship: {update.Ship.props.shipName} does not belong to a player in this match."
+ " Can't update match.");
}
@ -327,37 +361,3 @@ namespace Managers
}
}
/// <summary>
/// States the match can be in.
/// </summary>
public enum MatchState
{
CharacterSelect,
Pause,
Starting,
Match,
End
}
/// <summary>
/// Update data relevant to this matches rules.
/// </summary>
public class MatchConditionUpdate
{
public WinCondition Condition { get; set; }
public Ship ship { get; set; }
public int count { get; set; }
}
/// <summary>
/// The properties a player is assigned at the start
/// of the match, according to the rules.
/// </summary>
public class MatchPlayerStatistic
{
public bool IsOut { get; set; }
public int Lives { get; set; }
public int Score { get; set; }
public int Time { get; set; }
}

View File

@ -24,13 +24,13 @@ namespace GameLogic
switch (args.Condition)
{
case WinCondition.Lives:
UpdateLives(mps[p], args.count);
UpdateLives(mps[p], args.Count);
break;
case WinCondition.Score:
UpdateScore(mps[p], args.count);
UpdateScore(mps[p], args.Count);
break;
case WinCondition.Time:
UpdateTime(mps[p], args.count);
UpdateTime(mps[p], args.Count);
break;
}
return DetectMatchResult(mps);

View File

@ -13,9 +13,11 @@ public class PlayingFieldDetection : MonoBehaviour
/// <param name="collider"></param>
private void OnTriggerExit(Collider collider)
{
// TODO: This depends on a collider leaving the field which has only one
// instance with the same tag on the ship object.
if (collider.tag == "Ship")
{
if (!collider.TryGetComponent(out Ship ship))
if (!collider.TryGetComponent(out Ship shipComponent))
{
Log.Error($"Collider: {collider} was tagged as Ship, but has no Ship component.");
return;
@ -23,8 +25,8 @@ public class PlayingFieldDetection : MonoBehaviour
MatchManager.G.UpdateMatchCondition(new MatchConditionUpdate
{
Condition = WinCondition.Lives,
ship = ship,
count = -1
Ship = shipComponent,
Count = -1
});
}
}

View File

@ -26,10 +26,13 @@ public class Ship : MonoBehaviour
private float tackledTime = 0f;
// Current Zone the player occupies
private Zone zone = Zone.NimbleZone;
// Upcoming zone change
private Zone newZone = Zone.NimbleZone;
private ManageableAudio ThrusterSound;
private ManageableAudio BoosterSound;
private ManageableAudio ZoneChangeSound;
private ManageableAudio LeaveZoneSound;
private ManageableAudio EnterZoneSound;
private ManageableAudio TackleOpponentSound;
private ManageableAudio CriticalTackleOpponentSound;
private ManageableAudio BeingTackledSound;
@ -48,7 +51,8 @@ public class Ship : MonoBehaviour
BoosterSound = AudioManager.G.GetLocalSound("booster", 1, gameObject.transform);
BeingTackledSound = AudioManager.G.GetLocalSound("normal_tackle", 1, gameObject.transform);
BeingCriticallyTackledSound = AudioManager.G.GetLocalSound("critical_tackle", 1, gameObject.transform);
//ZoneChangeSound = AudioManager.G.GetLocalSound("thruster_sound", 1, gameObject.transform);
LeaveZoneSound = AudioManager.G.GetLocalSound("thruster_sound", 1, gameObject.transform);
EnterZoneSound = AudioManager.G.GetLocalSound("thruster_sound", 1, gameObject.transform);
}
// Start is called before the first frame update
@ -94,12 +98,16 @@ public class Ship : MonoBehaviour
}
body.constraints = RigidbodyConstraints.None;
// TODO: This belongs in the state object
zone = forceManager.GetZoneOfInstance(InstanceID);
newZone = forceManager.GetZoneOfInstance(InstanceID);
//BoostStateUpdate(Time.deltaTime);
// Rotate the vehicle with the current steer velocity
// Calculate the magnitude of the acceleration with the current thrust
UpdateMovement();
UpdateSounds();
if (zone != newZone)
{
zone = newZone;
}
UpdateMovement();
BoostStateUpdate(Time.deltaTime);
UpdateTackleResponse(isCriticalTackle);
}
@ -258,7 +266,7 @@ public class Ship : MonoBehaviour
void BoostStateUpdate(float deltaTime)
{
boostUI.UpdateFill(Math.Min(state.boostCapacity / props.maxBoostCapacity, 1));
if (IsBoosting() && state.thrustInput != 0)
if (IsBoosting())
{
state.boostCapacity -= deltaTime;
}
@ -271,7 +279,7 @@ public class Ship : MonoBehaviour
canBoost = false;
}
if ((state.boostInput <= 0 || state.thrustInput == 0 || !canBoost)
if ((state.boostInput <= 0 || !canBoost)
&& zone == Zone.NimbleZone
&& state.boostCapacity <= props.maxBoostCapacity)
{
@ -372,6 +380,19 @@ public class Ship : MonoBehaviour
BeingCriticallyTackledSound.ResetOneShot();
BeingTackledSound.ResetOneShot();
}
if (newZone != zone)
{
if (newZone != Zone.NimbleZone)
{
//LeaveZoneSound?.PlayAudio(false);
AudioManager.G.BroadcastAudioEffect(AudioEffects.LowPass, transform, true);
}
else
{
//EnterZoneSound?.PlayAudio(false);
AudioManager.G.BroadcastAudioEffect(AudioEffects.LowPass, transform, false);
}
}
}
}