public void Decision() { if (ai.currentState != Case.AVAILABLE) { return; } cases = ai.caseDatas.OrderByDescending(x => (int)x.priority).ToList(); for (var i = 0; i < cases.Count; i++) { if (cases[i].value > cases[i].criticalTreshold) { ai.HandleSpeed(SpeedPhase.SPRINT); MakeDecision(i); return; } } for (var i = 0; i < cases.Count; i++) { if (cases[i].value > cases[i].valueTreshold) { ai.HandleSpeed(SpeedPhase.RUN); MakeDecision(i); return; } } cases.Clear(); ai.HandleSpeed(SpeedPhase.WALK); ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.WANDER)); }
private void Stop() { flee = false; target = null; ai.Stop(); ai.HandleSpeed(SpeedPhase.WALK); ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.WANDER)); }
private void OnCaseChanged(object sender, CaseChangedEventArgs e) { if (e.state == Case.REPRODUCTION) { if (e.data != null) { e.data.SetData(this); } if (target == null) { target = FindPartner(); } if (target != null) { ai.currentState = Case.REPRODUCTION; Run(); } else { ai.HandleSpeed(SpeedPhase.WALK); ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.WANDER)); } } else if (e.state == Case.AVAILABLE) { CaseContainer.Adjust(ai.caseDatas, Case.REPRODUCTION, reproductionUrge); } else if (e.state == Case.IDENTITY_UPDATE) { UpdateData(); } else if (e.state == Case.RESET) { reproductionUrge = 0; alerted = false; isRunning = false; canReproduce = false; } }
public void OnCaseChanged(object sender, CaseChangedEventArgs e) { print(e.state); if (e.state == Case.HUNGER) { if (e.data != null) { SetReportedData(e.data); return; } target = FindFood(); if (target != null) { ai.currentState = Case.HUNGER; Run(); } else { ai.HandleSpeed(SpeedPhase.WALK); ai.OnCaseChanged(new CaseChangedEventArgs(null, Case.WANDER)); } } else if (e.state == Case.IDENTITY_UPDATE) { vision = ai.Identity.Vision; print("1"); } else if (e.state == Case.AVAILABLE) { CaseContainer.Adjust(ai.caseDatas, Case.HUNGER, hunger); } else if (e.state == Case.RESET) { isRunning = false; hunger = 0; alerted = false; } }
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; } }