private void RunAway() { Vector3 dirToPlayer = transform.position - target.position; Vector3 newPos = transform.position + dirToPlayer; _animationManager.SetState(AnimationType.Walk); ai.Move(newPos); }
private void Update() { hunger += Time.deltaTime; if (isRunning) { if (!isVFXUsed) { isVFXUsed = true; vfx = VFXManager.Instance.GetStateVFX(transform.position, ai, VFXType.HUNGER); } if (target != null) { _animationManager.SetState(AnimationType.Walk); ai.Move(target.position); if (Vector3.Distance(target.position, transform.position) < targetRange) { if (target.tag == "Chicken") { AnimalAI targetAi = target.GetComponent <AnimalAI>(); // vfx = VFXManager.Instance.GetDeadVFX(transform.position, targetAi, VFXType.EATDEAD); // VFXManager.Instance.WaitPush(vfx, VFXType.EATDEAD); target.GetComponent <AnimalAI>().OnCaseChanged(new CaseChangedEventArgs(null, Case.DEATH)); } hunger = 0; isRunning = false; alerted = false; target = null; isVFXUsed = false; VFXManager.Instance.Push(vfx, VFXType.HUNGER); ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.IDLE)); } } else { isRunning = false; ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.IDLE)); } } if (!alerted && hunger > hungerTreshold) { alerted = true; ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.AVAILABLE)); } if (hunger > deathTreshold) { // vfx = VFXManager.Instance.GetDeadVFX(transform.position, ai, VFXType.HUNGERDEAD); // VFXManager.Instance.WaitPush(vfx, VFXType.HUNGERDEAD); ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.DEATH)); } }
// Update is called once per frame void Update() { if (!canReproduce) { return; } reproductionUrge += Time.deltaTime; if (isRunning && target != null) { if (!isVFXUsed) { isVFXUsed = true; vfx = VFXManager.Instance.GetStateVFX(transform.position, ai, VFXType.LOVE); } _animationManager.SetState(AnimationType.Walk); ai.Move(target.transform.position); if (Vector3.Distance(target.transform.position, transform.position) < targetRange) { reproductionUrge = 0; isRunning = false; alerted = false; // ÖNEMLİ NOT : DİREK HAMİLELİĞE GEÇİLDİĞİNDEN HAMİLELİĞİ BİRAZDA IDLE SÜRESİ EKLENMELİ! if (sex == Sex.FEMALE) { ai.OnCaseChanged(new CaseChangedEventArgs(new PregnancyCaseData(target.Identity.GeneticCode), Case.PREGNANCY)); } else { ai.OnCaseChanged(new CaseChangedEventArgs(new IdleCaseData(10f), Case.IDLE)); } target = null; isVFXUsed = false; VFXManager.Instance.Push(vfx, VFXType.LOVE); } } if (!alerted && reproductionUrge > reproductionTreshold) { alerted = true; ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.AVAILABLE)); } }
public void OnCaseChanged(object sender, CaseChangedEventArgs e) { if (e.state == Case.THIRST) { if (e.data != null) { SetReportedData(e.data); return; } target = FindWater(); if (target != null) { ai.currentState = Case.THIRST; Run(); _animationManager.SetState(AnimationType.Walk); ai.Move(target.position); } else { ai.HandleSpeed(SpeedPhase.WALK); ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.WANDER)); } } else if (e.state == Case.IDENTITY_UPDATE) { vision = ai.Identity.Vision; } else if (e.state == Case.AVAILABLE) { CaseContainer.Adjust(ai.caseDatas, Case.THIRST, thirst); } else if (e.state == Case.RESET) { thirst = 0; alerted = false; isRunning = false; target = null; } }
private void Wander() { target = ai.RandomNavSphere(ai.transform.position, wanderDistance); _animationManager.SetState(AnimationType.Walk); ai.Move(target); }