Irgendjemand musste es ja machen...
This commit is contained in:
@ -213,13 +213,16 @@ public class Character : MonoBehaviour
|
||||
switch (item.ItemType)
|
||||
{
|
||||
case ItemType.Coffee:
|
||||
developer.GiveDrink(0.4, WantedConsumable.Drink);
|
||||
developer.GiveDrink(0.45, WantedConsumable.Coffee);
|
||||
_audioSource.PlayOneShot(_data.DrinkCoffe);
|
||||
break;
|
||||
case ItemType.Mate:
|
||||
developer.GiveDrink(0.4, WantedConsumable.Mate);
|
||||
developer.GiveDrink(0.35, WantedConsumable.Mate);
|
||||
_audioSource.PlayOneShot(_data.DrinkMate);
|
||||
break;
|
||||
case ItemType.Pizza:
|
||||
developer.GiveFood(0.25, WantedConsumable.Pizza);
|
||||
developer.GiveFood(0.4, WantedConsumable.Pizza);
|
||||
_audioSource.PlayOneShot(_data.EatPizza);
|
||||
break;
|
||||
default:
|
||||
SayItsImpossible();
|
||||
@ -240,4 +243,25 @@ public class Character : MonoBehaviour
|
||||
{
|
||||
_audioSource.PlayOneShot(_data.VoiceSayItsImpossible.GetRandomElement());
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private bool _canHurt = true;
|
||||
|
||||
public void Hurt()
|
||||
{
|
||||
if (_canHurt)
|
||||
StartCoroutine(HurtRoutine());
|
||||
}
|
||||
|
||||
private IEnumerator HurtRoutine()
|
||||
{
|
||||
_canHurt = false;
|
||||
|
||||
_audioSource.PlayOneShot(_data.Hurt);
|
||||
PickupItem(null);
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
_canHurt = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,5 +7,9 @@ namespace Data
|
||||
public class GottfriedData : ScriptableObject
|
||||
{
|
||||
[FormerlySerializedAs("Say_Impossible")] public AudioClip[] VoiceSayItsImpossible;
|
||||
public AudioClip DrinkMate;
|
||||
public AudioClip DrinkCoffe;
|
||||
public AudioClip EatPizza;
|
||||
public AudioClip Hurt;
|
||||
}
|
||||
}
|
||||
@ -13,11 +13,34 @@ public class VendingMachine : MonoBehaviour
|
||||
|
||||
[SerializeField]
|
||||
private float _shootForce;
|
||||
|
||||
[SerializeField]
|
||||
private bool _isReady;
|
||||
|
||||
[SerializeField] private AudioSource _audioSource;
|
||||
|
||||
[SerializeField] private AudioClip _vendingMachineSound;
|
||||
[SerializeField] private AudioClip _errorSound;
|
||||
|
||||
public void DropPiza()
|
||||
{
|
||||
PickupInteractible pizza = Instantiate(_pizzaPrefab, _pizzaChute.position, _pizzaChute.rotation);
|
||||
if (_isReady)
|
||||
StartCoroutine(DropPizzaRoutine());
|
||||
else
|
||||
_audioSource.PlayOneShot(_errorSound);
|
||||
}
|
||||
|
||||
private IEnumerator DropPizzaRoutine()
|
||||
{
|
||||
_isReady = false;
|
||||
|
||||
_audioSource.PlayOneShot(_vendingMachineSound);
|
||||
|
||||
yield return new WaitForSeconds(2.7f);
|
||||
|
||||
PickupInteractible pizza = Instantiate(_pizzaPrefab, _pizzaChute.position, _pizzaChute.rotation);
|
||||
pizza.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, _shootForce), ForceMode.Impulse);
|
||||
|
||||
_isReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,14 +3,17 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Utility;
|
||||
|
||||
public class MusicManager : MonoBehaviourSingleton<MusicManager>
|
||||
{
|
||||
[SerializeField]
|
||||
private List<AudioClip> _ambientMusic;
|
||||
[FormerlySerializedAs("_showDownMusic")] [SerializeField]
|
||||
private AudioClip _winningMusic;
|
||||
[SerializeField]
|
||||
private AudioClip _showDownMusic;
|
||||
private AudioClip _losingMusic;
|
||||
|
||||
[SerializeField, ShowOnly]
|
||||
private float _musicTimer = 5f;
|
||||
@ -18,9 +21,16 @@ public class MusicManager : MonoBehaviourSingleton<MusicManager>
|
||||
private AudioSource _audioSource;
|
||||
private AudioClip _currentlyPlaying;
|
||||
private float _defaultVolume;
|
||||
private bool _showDownTime = false;
|
||||
private ShowDown _showDown = ShowDown.NotYet;
|
||||
private bool _doneFading = false;
|
||||
private bool _showDownIsPlaying = false;
|
||||
|
||||
private enum ShowDown
|
||||
{
|
||||
NotYet,
|
||||
AlmostFinished,
|
||||
TimesRunningOut
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@ -34,10 +44,10 @@ public class MusicManager : MonoBehaviourSingleton<MusicManager>
|
||||
{
|
||||
CheckForFinalMusic();
|
||||
|
||||
if (!_showDownTime)
|
||||
if (_showDown == ShowDown.NotYet)
|
||||
{
|
||||
_musicTimer -= Time.deltaTime;
|
||||
|
||||
|
||||
if (_musicTimer <= 0)
|
||||
{
|
||||
_musicTimer = _musicCheckInterval;
|
||||
@ -47,18 +57,6 @@ public class MusicManager : MonoBehaviourSingleton<MusicManager>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_doneFading)
|
||||
{
|
||||
if (!_showDownIsPlaying)
|
||||
PlayShowDownMusic();
|
||||
}
|
||||
else
|
||||
{
|
||||
FadeOutMusic();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FadeOutMusic()
|
||||
@ -70,10 +68,64 @@ public class MusicManager : MonoBehaviourSingleton<MusicManager>
|
||||
|
||||
private void CheckForFinalMusic()
|
||||
{
|
||||
float timeLeft = (float)GameManager.Instance.ExpectedRemainingGameDuration;
|
||||
_showDownTime = timeLeft < 0.9 * _showDownMusic.length;
|
||||
ShowDown oldShowDown = _showDown;
|
||||
|
||||
if (TimeManager.Instance.RealLifeSecondsUntilDeadline < 100)
|
||||
{
|
||||
_showDown = ShowDown.TimesRunningOut;
|
||||
}
|
||||
else if (GameManager.Instance.GameProgress > 0.85)
|
||||
{
|
||||
_showDown = ShowDown.AlmostFinished;
|
||||
}
|
||||
else
|
||||
{
|
||||
_showDown = ShowDown.NotYet;
|
||||
}
|
||||
|
||||
if (oldShowDown != _showDown)
|
||||
{
|
||||
switch (_showDown)
|
||||
{
|
||||
case ShowDown.NotYet:
|
||||
FadeToClip(_ambientMusic.GetRandomElement());
|
||||
break;
|
||||
case ShowDown.AlmostFinished:
|
||||
FadeToClip(_winningMusic);
|
||||
break;
|
||||
case ShowDown.TimesRunningOut:
|
||||
FadeToClip(_losingMusic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FadeToClip(AudioClip audioClip)
|
||||
{
|
||||
StartCoroutine(FadeToClipRoutine(audioClip));
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private float _fadeDuration = 1.0f;
|
||||
|
||||
private IEnumerator FadeToClipRoutine(AudioClip audioClip)
|
||||
{
|
||||
float currentTime = 0;
|
||||
float start = _audioSource.volume;
|
||||
while (currentTime < _fadeDuration)
|
||||
{
|
||||
currentTime += Time.deltaTime;
|
||||
_audioSource.volume = Mathf.Lerp(start, 0.0f, currentTime / _fadeDuration);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
_audioSource.Stop();
|
||||
_audioSource.volume = _defaultVolume;
|
||||
_audioSource.clip = audioClip;
|
||||
_audioSource.loop = true;
|
||||
_audioSource.Play();
|
||||
}
|
||||
|
||||
private void PlayNewMusic()
|
||||
{
|
||||
if (_currentlyPlaying == null)
|
||||
@ -90,14 +142,4 @@ public class MusicManager : MonoBehaviourSingleton<MusicManager>
|
||||
_audioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayShowDownMusic()
|
||||
{
|
||||
_showDownIsPlaying = true;
|
||||
_audioSource.Stop();
|
||||
_audioSource.volume = _defaultVolume;
|
||||
_audioSource.clip = _showDownMusic;
|
||||
_audioSource.loop = true;
|
||||
_audioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +34,8 @@ public class TimeManager : MonoBehaviourSingleton<TimeManager>
|
||||
/// Das aktuelle Datum und Uhrzeit im Spiel.
|
||||
/// </summary>
|
||||
public DateTime CurrentDate => _startDate.AddDays(_totalTime);
|
||||
|
||||
public double RealLifeSecondsUntilDeadline => (Deadline - CurrentDate).TotalDays * _secondsPerDay;
|
||||
|
||||
/// <summary>
|
||||
/// Die Deadline des Spiels.
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Utility
|
||||
public MediumDifficulty()
|
||||
{
|
||||
Difficulty = Difficulty.Medium;
|
||||
DaysUntilReleaseFactor = 1.5;
|
||||
DaysUntilReleaseFactor = 1.75;
|
||||
CaffeineDrainScaling = 1.5;
|
||||
HungerDrainScaling = 1.5;
|
||||
UrinationDrainScaling = 1.5;
|
||||
|
||||
@ -118,7 +118,7 @@ void Update()
|
||||
float diff = direction.magnitude;
|
||||
if (diff <= _attackRange + 0.6f)
|
||||
{
|
||||
GameManager.Instance.Player.GetComponent<Character>().PickupItem(null);
|
||||
GameManager.Instance.Player.GetComponent<Character>().Hurt();
|
||||
}
|
||||
_isAttacking = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user