Entwickler machen ein paar Sachen
This commit is contained in:
@ -16,6 +16,11 @@ public class NPCAnimationController : MonoBehaviour
|
||||
private NavMeshAgent agent;
|
||||
private Animator animator;
|
||||
|
||||
public Developer Developer;
|
||||
|
||||
[SerializeField]
|
||||
private bool _canTakeNewJob;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
@ -25,21 +30,23 @@ public class NPCAnimationController : MonoBehaviour
|
||||
}
|
||||
private IEnumerator GetToWorkRoutine()
|
||||
{
|
||||
yield return TakeLock();
|
||||
|
||||
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<75>ck
|
||||
animator.ResetTrigger("Walk"); // Setze den Lauf-Trigger zur<75>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));
|
||||
|
||||
ReleaseLock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
@ -56,15 +63,25 @@ public class NPCAnimationController : MonoBehaviour
|
||||
|
||||
public void DrinkCoffee()
|
||||
{
|
||||
|
||||
|
||||
StartCoroutine(DrinkCoffeeRoutine());
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator TakeLock()
|
||||
{
|
||||
yield return new WaitUntil(() => _canTakeNewJob);
|
||||
|
||||
_canTakeNewJob = false;
|
||||
}
|
||||
|
||||
private void ReleaseLock()
|
||||
{
|
||||
_canTakeNewJob = true;
|
||||
}
|
||||
|
||||
private IEnumerator DrinkCoffeeRoutine()
|
||||
{
|
||||
|
||||
yield return TakeLock();
|
||||
|
||||
yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Coffee"), 1, 1f)); // 1 Sekunde zum Einblenden
|
||||
animator.SetTrigger("DrinkCoffee");
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
@ -78,7 +95,7 @@ public class NPCAnimationController : MonoBehaviour
|
||||
animator.ResetTrigger("DrinkCoffee");
|
||||
Cup.SetActive(true);
|
||||
|
||||
|
||||
ReleaseLock();
|
||||
}
|
||||
|
||||
public void GoToToilet()
|
||||
@ -88,7 +105,17 @@ public class NPCAnimationController : MonoBehaviour
|
||||
|
||||
private IEnumerator GoToToiletRoutine()
|
||||
{
|
||||
yield return TakeLock();
|
||||
|
||||
yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Typing"), 0, 1f));
|
||||
|
||||
while (ToiletManager.Instance.IsOccupied)
|
||||
{
|
||||
yield return new WaitForSeconds(2);
|
||||
}
|
||||
|
||||
ToiletManager.Instance.IsOccupied = true;
|
||||
|
||||
// Beginne mit dem Laufen zur Toilette.
|
||||
animator.SetTrigger("Walk");
|
||||
yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("Walk"));
|
||||
@ -97,24 +124,33 @@ public class NPCAnimationController : MonoBehaviour
|
||||
yield return new WaitUntil(() => agent.remainingDistance <= agent.stoppingDistance);
|
||||
|
||||
|
||||
// H<>rt auf zu laufen und beginnt zu sitzen.
|
||||
animator.ResetTrigger("Walk"); // Es ist wichtig, den vorherigen Trigger zur<75>ckzusetzen
|
||||
// H<>rt auf zu laufen und beginnt zu sitzen.
|
||||
animator.ResetTrigger("Walk"); // Es ist wichtig, den vorherigen Trigger zur<75>ckzusetzen
|
||||
transform.LookAt(new Vector3(toiletLookAtTransform.position.x, toiletLookAtTransform.position.y, toiletLookAtTransform.position.z));
|
||||
animator.SetTrigger("SitDown");
|
||||
|
||||
transform.LookAt(new Vector3(toiletLookAtTransform.position.x, toiletLookAtTransform.position.y, toiletLookAtTransform.position.z));
|
||||
yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("Ready"));
|
||||
// Stehe auf und gehe zur<75>ck zum Ausgangspunkt.
|
||||
|
||||
Developer.Pee(1.0, true);
|
||||
|
||||
// Stehe auf und gehe zur<75>ck zum Ausgangspunkt.
|
||||
transform.LookAt(new Vector3(toiletLookAtTransform.position.x, toiletLookAtTransform.position.y, toiletLookAtTransform.position.z));
|
||||
animator.ResetTrigger("SitDown"); // Setze den Sitzen-Trigger zur<75>ck
|
||||
animator.ResetTrigger("SitDown"); // Setze den Sitzen-Trigger zur<75>ck
|
||||
|
||||
ToiletManager.Instance.IsOccupied = false;
|
||||
|
||||
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<75>ck
|
||||
animator.ResetTrigger("Walk"); // Setze den Lauf-Trigger zur<75>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));
|
||||
|
||||
ReleaseLock();
|
||||
}
|
||||
// Hier kannst du entscheiden, ob der Charakter wieder sitzt oder steht.
|
||||
// Beispiel: Setze IsSitting oder IsStanding entsprechend.
|
||||
@ -126,12 +162,15 @@ public class NPCAnimationController : MonoBehaviour
|
||||
|
||||
private IEnumerator GettingMadRoutine()
|
||||
{
|
||||
yield return TakeLock();
|
||||
|
||||
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");
|
||||
|
||||
|
||||
ReleaseLock();
|
||||
}
|
||||
|
||||
public void CaffeinOverdose()
|
||||
@ -141,6 +180,8 @@ public class NPCAnimationController : MonoBehaviour
|
||||
|
||||
private IEnumerator CaffeinRoutine()
|
||||
{
|
||||
yield return TakeLock();
|
||||
|
||||
yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Typing"), 0, 1f));
|
||||
// Beginne mit dem Laufen zur Toilette.
|
||||
animator.SetTrigger("Walk");
|
||||
@ -149,24 +190,23 @@ public class NPCAnimationController : MonoBehaviour
|
||||
yield return new WaitUntil(() => agent.remainingDistance <= agent.stoppingDistance);
|
||||
animator.ResetTrigger("Walk");
|
||||
animator.SetTrigger("TooMuchCaffein");
|
||||
yield return new WaitForSeconds(8f);
|
||||
|
||||
yield return new WaitWhile(() => Developer.IsOvercaffeinated);
|
||||
|
||||
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<75>ck
|
||||
animator.ResetTrigger("Walk"); // Setze den Lauf-Trigger zur<75>ck
|
||||
animator.SetTrigger("SitDown");
|
||||
yield return new WaitUntil(() => animator.GetCurrentAnimatorStateInfo(0).IsName("Sit"));
|
||||
yield return StartCoroutine(FadeLayerWeight(animator.GetLayerIndex("Typing"), 1, 1f));
|
||||
|
||||
|
||||
|
||||
|
||||
ReleaseLock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void MoveTo(Vector3 destination)
|
||||
{
|
||||
agent.destination = destination;
|
||||
@ -175,28 +215,27 @@ public class NPCAnimationController : MonoBehaviour
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Pr<50>ft, ob der Buchstabe 'C' gedr<64>ckt wurde
|
||||
// Pr<50>ft, ob der Buchstabe 'C' gedr<64>ckt wurde
|
||||
if (Input.GetKeyDown(KeyCode.C))
|
||||
{
|
||||
DrinkCoffee();
|
||||
}
|
||||
|
||||
// Pr<50>ft, ob der Buchstabe 'T' gedr<64>ckt wurde
|
||||
// Pr<50>ft, ob der Buchstabe 'T' gedr<64>ckt wurde
|
||||
if (Input.GetKeyDown(KeyCode.T))
|
||||
{
|
||||
GoToToilet();
|
||||
}
|
||||
|
||||
// Pr<50>ft, ob der Buchstabe 'M' gedr<64>ckt wurde
|
||||
// Pr<50>ft, ob der Buchstabe 'M' gedr<64>ckt wurde
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
GettingMad();
|
||||
}
|
||||
// Pr<50>ft, ob der Buchstabe 'C' gedr<64>ckt wurde
|
||||
// Pr<50>ft, ob der Buchstabe 'C' gedr<64>ckt wurde
|
||||
if (Input.GetKeyDown(KeyCode.O))
|
||||
{
|
||||
CaffeinOverdose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user