diff --git a/3d Prototyp/Assets/Animations/NPCAnimationController.cs b/3d Prototyp/Assets/Animations/NPCAnimationController.cs index 7c8a5926..2e131175 100644 --- a/3d Prototyp/Assets/Animations/NPCAnimationController.cs +++ b/3d Prototyp/Assets/Animations/NPCAnimationController.cs @@ -11,6 +11,7 @@ public class NPCAnimationController : MonoBehaviour public Transform toiletTransform; + public Transform dancePlace; public Transform toiletLookAtTransform;// Die Transform-Position der Toilette private NavMeshAgent agent; private Animator animator; @@ -20,10 +21,25 @@ public class NPCAnimationController : MonoBehaviour agent = GetComponent(); animator = GetComponent(); HandCup.SetActive(false); + StartCoroutine(GetToWorkRoutine()); + } + private IEnumerator GetToWorkRoutine() + { + animator.SetLayerWeight(animator.GetLayerIndex("Typing"), 0); + animator.SetTrigger("Walk"); + yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("WalkBack")); + MoveTo(workPosition.position); + yield return new WaitUntil(() => agent.remainingDistance <= agent.stoppingDistance); + animator.ResetTrigger("Walk"); // Setze den Lauf-Trigger zurück + animator.SetTrigger("SitDown"); + yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("Sit")); + transform.rotation = workPosition.rotation; + yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Typing"), 1, 1f)); } - private IEnumerator FadeLayerWeight(int layerIndex, float targetWeight, float duration) + + private IEnumerator FadeLayerWeight(int layerIndex, float targetWeight, float duration) { float time = 0; float startWeight = animator.GetLayerWeight(layerIndex); @@ -72,7 +88,7 @@ public class NPCAnimationController : MonoBehaviour private IEnumerator GoToToiletRoutine() { - animator.SetLayerWeight(animator.GetLayerIndex("Typing"), 0); + yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Typing"), 0, 1f)); // Beginne mit dem Laufen zur Toilette. animator.SetTrigger("Walk"); yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("Walk")); @@ -94,19 +110,59 @@ public class NPCAnimationController : MonoBehaviour yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("WalkBack")); MoveTo(workPosition.position); yield return new WaitUntil(() => agent.remainingDistance <= agent.stoppingDistance); - transform.rotation = workPosition.rotation; animator.ResetTrigger("Walk"); // Setze den Lauf-Trigger zurück animator.SetTrigger("SitDown"); yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("Sit")); - animator.SetLayerWeight(animator.GetLayerIndex("Typing"), 1); + transform.rotation = workPosition.rotation; + yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Typing"), 1, 1f)); } // Hier kannst du entscheiden, ob der Charakter wieder sitzt oder steht. // Beispiel: Setze IsSitting oder IsStanding entsprechend. - - public void AskForMoney() + public void GettingMad() { - return; + StartCoroutine(GettingMadRoutine()); + } + + private IEnumerator GettingMadRoutine() + { + animator.SetTrigger("GetMad"); + yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Coffee"), 1, 2f)); // 1 Sekunde zum Einblenden + yield return new WaitForSeconds(8f); + yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Coffee"), 0, 1f)); // 1 Sekunde zum Ausblenden + animator.ResetTrigger("GetMad"); + + } + + public void CaffeinOverdose() + { + StartCoroutine(CaffeinRoutine()); + } + + private IEnumerator CaffeinRoutine() + { + yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Typing"), 0, 1f)); + // Beginne mit dem Laufen zur Toilette. + animator.SetTrigger("Walk"); + yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("Walk")); + MoveTo(dancePlace.position); + yield return new WaitUntil(() => agent.remainingDistance <= agent.stoppingDistance); + animator.ResetTrigger("Walk"); + animator.SetTrigger("TooMuchCaffein"); + yield return new WaitForSeconds(8f); + animator.ResetTrigger("TooMuchCaffein"); + animator.SetTrigger("Walk"); + yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("WalkBack")); + MoveTo(workPosition.position); + yield return new WaitUntil(() => agent.remainingDistance <= agent.stoppingDistance); + transform.rotation = workPosition.rotation; + animator.ResetTrigger("Walk"); // Setze den Lauf-Trigger zurück + animator.SetTrigger("SitDown"); + yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("Sit")); + yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Typing"), 1, 1f)); + + + } @@ -134,7 +190,12 @@ public class NPCAnimationController : MonoBehaviour // Prüft, ob der Buchstabe 'M' gedrückt wurde if (Input.GetKeyDown(KeyCode.M)) { - AskForMoney(); + GettingMad(); + } + // Prüft, ob der Buchstabe 'C' gedrückt wurde + if (Input.GetKeyDown(KeyCode.O)) + { + CaffeinOverdose(); } } diff --git a/3d Prototyp/Assets/Models/Consumables/Bottle.meta b/3d Prototyp/Assets/Models/Consumables/Bottle.meta index 5cf35e1f..722d7b3c 100644 --- a/3d Prototyp/Assets/Models/Consumables/Bottle.meta +++ b/3d Prototyp/Assets/Models/Consumables/Bottle.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 <<<<<<<< HEAD:3d Prototyp/Assets/Animations.meta -guid: dbfdad9da5148a044b3876906e80bd1b +guid: 6bc4a457dc2707f498400ffd8852bc42 ======== guid: b5a1bf502fb00de4da1ab0b10ff7ca3f >>>>>>>> 561a11e6d01bf2df9669da9e53bbf93264bb5dcb:3d Prototyp/Assets/Models/Consumables/Bottle.meta diff --git a/3d Prototyp/Assets/Scenes/GameJamScene/NavMesh-toon__office_tile_ground_low_4x4 (2).asset b/3d Prototyp/Assets/Scenes/GameJamScene/NavMesh-toon__office_tile_ground_low_4x4 (2).asset index 211e8bfe..55c8fd96 100644 Binary files a/3d Prototyp/Assets/Scenes/GameJamScene/NavMesh-toon__office_tile_ground_low_4x4 (2).asset and b/3d Prototyp/Assets/Scenes/GameJamScene/NavMesh-toon__office_tile_ground_low_4x4 (2).asset differ