Kaffe Trinken mit c, overdose mit o, mad mit m und Klo mit t

This commit is contained in:
jankaminski1 2024-04-07 15:55:37 +02:00
parent 82216fa8a7
commit 7c127ac68e
3 changed files with 70 additions and 9 deletions

View File

@ -11,6 +11,7 @@ public class NPCAnimationController : MonoBehaviour
public Transform toiletTransform; public Transform toiletTransform;
public Transform dancePlace;
public Transform toiletLookAtTransform;// Die Transform-Position der Toilette public Transform toiletLookAtTransform;// Die Transform-Position der Toilette
private NavMeshAgent agent; private NavMeshAgent agent;
private Animator animator; private Animator animator;
@ -20,7 +21,22 @@ public class NPCAnimationController : MonoBehaviour
agent = GetComponent<NavMeshAgent>(); agent = GetComponent<NavMeshAgent>();
animator = GetComponent<Animator>(); animator = GetComponent<Animator>();
HandCup.SetActive(false); 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)
@ -72,7 +88,7 @@ public class NPCAnimationController : MonoBehaviour
private IEnumerator GoToToiletRoutine() private IEnumerator GoToToiletRoutine()
{ {
animator.SetLayerWeight(animator.GetLayerIndex("Typing"), 0); yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Typing"), 0, 1f));
// Beginne mit dem Laufen zur Toilette. // Beginne mit dem Laufen zur Toilette.
animator.SetTrigger("Walk"); animator.SetTrigger("Walk");
yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("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")); yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("WalkBack"));
MoveTo(workPosition.position); MoveTo(workPosition.position);
yield return new WaitUntil(() => agent.remainingDistance <= agent.stoppingDistance); yield return new WaitUntil(() => agent.remainingDistance <= agent.stoppingDistance);
transform.rotation = workPosition.rotation;
animator.ResetTrigger("Walk"); // Setze den Lauf-Trigger zurück animator.ResetTrigger("Walk"); // Setze den Lauf-Trigger zurück
animator.SetTrigger("SitDown"); animator.SetTrigger("SitDown");
yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("Sit")); 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. // Hier kannst du entscheiden, ob der Charakter wieder sitzt oder steht.
// Beispiel: Setze IsSitting oder IsStanding entsprechend. // Beispiel: Setze IsSitting oder IsStanding entsprechend.
public void GettingMad()
public void AskForMoney()
{ {
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 // Prüft, ob der Buchstabe 'M' gedrückt wurde
if (Input.GetKeyDown(KeyCode.M)) if (Input.GetKeyDown(KeyCode.M))
{ {
AskForMoney(); GettingMad();
}
// Prüft, ob der Buchstabe 'C' gedrückt wurde
if (Input.GetKeyDown(KeyCode.O))
{
CaffeinOverdose();
} }
} }

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
<<<<<<<< HEAD:3d Prototyp/Assets/Animations.meta <<<<<<<< HEAD:3d Prototyp/Assets/Animations.meta
guid: dbfdad9da5148a044b3876906e80bd1b guid: 6bc4a457dc2707f498400ffd8852bc42
======== ========
guid: b5a1bf502fb00de4da1ab0b10ff7ca3f guid: b5a1bf502fb00de4da1ab0b10ff7ca3f
>>>>>>>> 561a11e6d01bf2df9669da9e53bbf93264bb5dcb:3d Prototyp/Assets/Models/Consumables/Bottle.meta >>>>>>>> 561a11e6d01bf2df9669da9e53bbf93264bb5dcb:3d Prototyp/Assets/Models/Consumables/Bottle.meta