void Update() { agent.speed = startSpeed * shop.GetTimeScale(); agent.angularSpeed = startAngularSpeed * shop.GetTimeScale(); if (GetTargetComplated(2f, BuyPointPosition) && Stay == BuyerStay.ChangeProducts) { if (ChangeTime < 0f) { ChangedCashBox = shop.GetOptimalCashBox(); agent.destination = ChangedCashBox.transform.position; Stay = BuyerStay.GoToCashBox; return; } if (BuyPointSwithTimeout < 0f) { GoToBuyPoint(); BuyPointSwithTimeout = BuyPointSwithTime; } ChangeTime -= Time.deltaTime * shop.GetTimeScale(); BuyPointSwithTimeout -= Time.deltaTime * shop.GetTimeScale(); } else if (Stay == BuyerStay.GoToCashBox && !WasInCashBox && GetTargetComplated(2f, ChangedCashBox.transform.position)) { ChangedCashBox.Queue.Add(this); WasInCashBox = true; } else if (Stay == BuyerStay.GoToHome && GetTargetComplated(2f, HomePosition)) { Destroy(gameObject); } }
public void GoToHome() { HomePosition = shop.ExitPoint.position; agent.destination = HomePosition; Stay = BuyerStay.GoToHome; }