// Update is called once per frame void Update() { if (hasPassanger == true && Vector3.Distance(transform.position, NavigationHandler.targetPosition) < 0.1f) { GameNotification.Reset(); GameNotification.Message = dropOffText; displayingNotification = true; GameNotification.ShowNotification(); } else if (!PickUp.displayingNotification) { displayingNotification = false; GameNotification.HideNotification(dropOffText); } else if (hasPassanger == true && Vector3.Distance(transform.position, NavigationHandler.targetPosition) > 0.1f) { displayingNotification = false; GameNotification.HideNotification(dropOffText); } if (DropOff.hasPassanger && Time.time - lastMoneyRemoval > 20.0f) { moneyToGive -= 1.0f; lastMoneyRemoval = Time.time; } if (Vector3.Distance(transform.position, NavigationHandler.targetPosition) < 0.1f && hasPassanger == true && (Time.time - PickUp.lastButtonPress) > InputConstants.MENU_ACTION_DELAY && (Input.GetKey(KeyCode.E) || theController.isButtonPressed(theController.STATE_OPTION1))) { hasPassanger = false; GameNotification.HideNotification(dropOffText); GameObject newHuman = Instantiate(human); newHuman.transform.position = PassengerSystem.NextPassengerDestination; newHuman.transform.rotation = Quaternion.Euler(0, 0, 0); PickUp.lastButtonPress = Time.time; PassengerSystem.PassengerIndex++; NavigationHandler.targetPosition = PassengerSystem.NextPassengerPosition; CashEarnedHandler.notifyCashEarned((int)moneyToGive); } }
// Update is called once per frame void Update() { if (transform.position.Equals(PassengerSystem.NextPassengerPosition)) { anim.SetBool("inRange", Vector3.Distance(transform.position, target.position) < stopRange * 4); if (DropOff.hasPassanger == false && Vector3.Distance(transform.position, target.position) < stopRange) { GameNotification.Reset(); GameNotification.Message = pickUpText; displayingNotification = true; GameNotification.ShowNotification(); } else if (DropOff.displayingNotification) { displayingNotification = false; GameNotification.HideNotification(pickUpText); } else if (DropOff.hasPassanger == false && Vector3.Distance(transform.position, target.position) > stopRange) { displayingNotification = false; GameNotification.HideNotification(pickUpText); } if (DropOff.hasPassanger == false && (Time.time - lastButtonPress) > InputConstants.MENU_ACTION_DELAY && (Input.GetKeyDown(KeyCode.E) || theController.isButtonPressed(theController.STATE_OPTION1)) && (Vector3.Distance(transform.position, target.position) < stopRange)) { GameNotification.HideNotification(pickUpText); DropOff.hasPassanger = true; DropOff.moneyToGive = moneyToGive; print("passanger boarded"); Vector3 destination = PassengerSystem.NextPassengerDestination; NavigationHandler.targetPosition = new Vector3(destination.x, destination.y, destination.z); lastButtonPress = Time.time; Destroy(gameObject); } } }