Bär wartet nach aufwachen etc
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b189680510e30354285296dad28315cb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SoundEffectLibrary : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private SoundEffectGroup[] soundEffectGroups;
|
||||
private Dictionary<string, List<AudioClip>> soundDictionary;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitializeDictionary();
|
||||
}
|
||||
|
||||
private void InitializeDictionary()
|
||||
{
|
||||
soundDictionary = new Dictionary<string, List<AudioClip>>();
|
||||
foreach (SoundEffectGroup soundEffectGroup in soundEffectGroups)
|
||||
{
|
||||
soundDictionary[soundEffectGroup.name] = soundEffectGroup.audioClips;
|
||||
}
|
||||
}
|
||||
|
||||
public AudioClip GetRandomClip(string name)
|
||||
{
|
||||
if (!soundDictionary.ContainsKey(name))
|
||||
{
|
||||
List<AudioClip> audioClips = soundDictionary[name];
|
||||
if(audioClips.Count > 0)
|
||||
{
|
||||
return audioClips[UnityEngine.Random.Range(0, audioClips.Count)];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct SoundEffectGroup
|
||||
{
|
||||
public string name;
|
||||
public List<AudioClip> audioClips;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 423f4b81219a67a41be9c759a8db5448
|
||||
@@ -20,7 +20,7 @@ public class BearAwareness : MonoBehaviour
|
||||
awareness = 0;
|
||||
awarenessSlider.value = 0;
|
||||
Noice.OnMakeNoice += IncreaseAwareness;
|
||||
StartCoroutine(Decrease(10));
|
||||
StartCoroutine(Decrease(2));
|
||||
|
||||
}
|
||||
|
||||
@@ -36,8 +36,10 @@ public class BearAwareness : MonoBehaviour
|
||||
|
||||
if (awareness >= awarenessSlider.maxValue)
|
||||
{
|
||||
StopAllCoroutines();
|
||||
Debug.Log("Bear is awake now!");
|
||||
HasWokenUp.Invoke(timeToWakeUp);
|
||||
StartCoroutine(Decrease(2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,25 +48,25 @@ public class BearAwareness : MonoBehaviour
|
||||
|
||||
while (true)
|
||||
{
|
||||
yield return new WaitForSeconds(5);
|
||||
yield return new WaitForSeconds(delay);
|
||||
|
||||
awarenessSlider.value -= 5;
|
||||
awareness -= 5;
|
||||
awarenessSlider.value -= 2;
|
||||
awareness -= 2;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeSliderColor()
|
||||
{
|
||||
if (awareness >= (awarenessSlider.maxValue - 10))
|
||||
if (awarenessSlider.value >= (awarenessSlider.maxValue - 10))
|
||||
{
|
||||
SilderColor.color = Color.red;
|
||||
}
|
||||
else if (awareness >= (awarenessSlider.maxValue / 2))
|
||||
else if (awarenessSlider.value >= (awarenessSlider.maxValue / 2))
|
||||
{
|
||||
SilderColor.color = Color.orange;
|
||||
}
|
||||
else if (awareness <= (awarenessSlider.maxValue / 2) )
|
||||
else if (awarenessSlider.value <= (awarenessSlider.maxValue / 2) )
|
||||
{
|
||||
SilderColor.color = Color.darkGreen;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ public class BearIsAwake : MonoBehaviour
|
||||
public BearAwareness bearAwareness;
|
||||
|
||||
public PositionReset[] thingstoReset;
|
||||
|
||||
private bool isWaiting = false;
|
||||
private void Start()
|
||||
{
|
||||
BearAwareness.HasWokenUp += IsAwake;
|
||||
@@ -43,7 +45,9 @@ public class BearIsAwake : MonoBehaviour
|
||||
|
||||
Vector3 direction = Penguin.position - transform.position;
|
||||
float distance = direction.magnitude;
|
||||
direction.Normalize(); // Wichtig: Raycast braucht eine normierte Richtung
|
||||
direction.Normalize();
|
||||
|
||||
|
||||
|
||||
|
||||
if (Physics.Raycast(transform.position, direction, out RaycastHit hit, distance))
|
||||
@@ -59,16 +63,20 @@ public class BearIsAwake : MonoBehaviour
|
||||
|
||||
bearAwareness.awareness = 0;
|
||||
bearAwareness.awarenessSlider.value = 0;
|
||||
|
||||
wakingUp = false;
|
||||
timer = 0f;
|
||||
bearTimer.fillAmount = 0;
|
||||
}
|
||||
else
|
||||
else if(!isWaiting)
|
||||
{
|
||||
Debug.Log("What?");
|
||||
StartCoroutine(DelayedAction());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
wakingUp = false;
|
||||
timer = 0f;
|
||||
bearTimer.fillAmount = 0;
|
||||
|
||||
Debug.DrawLine(transform.position, Penguin.position, Color.red, 10f);
|
||||
}
|
||||
|
||||
@@ -78,4 +86,17 @@ public class BearIsAwake : MonoBehaviour
|
||||
bearAwareness.awarenessSlider.value = bearAwareness.awarenessSlider.maxValue;
|
||||
IsAwake(bearAwareness.timeToWakeUp);
|
||||
}
|
||||
|
||||
IEnumerator DelayedAction()
|
||||
{
|
||||
isWaiting = true;
|
||||
wakingUp = false;
|
||||
timer = 0f;
|
||||
|
||||
yield return new WaitForSeconds(2f);
|
||||
bearTimer.fillAmount = 0;
|
||||
isWaiting = false;
|
||||
Debug.Log("Back to Sleep");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Goal : MonoBehaviour
|
||||
{
|
||||
public GameObject WinUI;
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.tag == "IceBlock")
|
||||
{
|
||||
Debug.Log("Win");
|
||||
WinUI.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayerMove : MonoBehaviour
|
||||
{
|
||||
@@ -24,7 +25,10 @@ public class PlayerMove : MonoBehaviour
|
||||
[SerializeField] private string inputNameVertical;
|
||||
|
||||
public Transform player;
|
||||
|
||||
|
||||
public Slider awarenessSlider;
|
||||
|
||||
private bool walking = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -104,7 +108,11 @@ public class PlayerMove : MonoBehaviour
|
||||
}
|
||||
}
|
||||
transform.Translate(moveDirection * speed * Time.deltaTime, Space.World);
|
||||
|
||||
|
||||
if (moveDirection != Vector3.zero && walking)
|
||||
{
|
||||
StartCoroutine(Step(0.3f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,8 +125,15 @@ public class PlayerMove : MonoBehaviour
|
||||
speed = basespeed;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
IEnumerator Step(float delay)
|
||||
{
|
||||
walking = false;
|
||||
yield return new WaitForSeconds(delay);
|
||||
awarenessSlider.value += 1f;
|
||||
walking = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user