Compare commits
2 Commits
0cc9ddba16
...
7a477817fe
Author | SHA1 | Date |
---|---|---|
jankaminski1 | 7a477817fe | |
jankaminski1 | 7c127ac68e |
|
@ -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<NavMeshAgent>();
|
||||
animator = GetComponent<Animator>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue