// Update is called once per frame void Update() { if (serviceOpen) { //Update service timer serviceTimer -= Time.deltaTime; if (UIServiceTimer != null) { UIServiceTimer.SetValue(serviceTimer / serviceTime); } if (serviceTimer < 0) { endService(); } } //Temporary manual slowmode toggle if (Input.GetButtonDown("Fire2")) { toggleSlowMode(); Debug.Log("Time scale: " + Time.timeScale); } if (Input.GetButtonDown("Fire3")) { toggleSlowMode(2.0f); Debug.Log("Time scale: " + Time.timeScale); } }
// Update is called once per frame void Update() { //Life time update lifeTimer -= Time.deltaTime; if (lifeTimer < 0) { Destroy(gameObject); } //Player interactions update if (user_renderer != null && !playerInteracting) { user_renderer.color = Color.white; //User reappear if there's one } if (playerInteracting) { //Continue stopping fight if (stopTimer < stopTime) { stopTimer += Time.deltaTime; } //Update interaction CD cdTimer -= Time.deltaTime; if (cdTimer < 0) { playerInteracting = false; //Reset interaction indicator } } else if (stopTimer > 0) //Decrease fight stopping jauge if not interacting { stopTimer -= Time.deltaTime * 0.5f; } //UI update if (UIStopTimer != null) { UIStopTimer.SetValue(stopTimer / stopTime); UIStopTimer.gameObject.SetActive(stopTimer > 0); //Set active if timer>0 } }
//LateUpdate is called after classic Updates protected virtual void LateUpdate() { if (playerInteracting) { //Continue Preparation if (prepTimer < prepTime) //Update UI Prep timer { prepTimer += Time.deltaTime; if (UIPrepTimer != null) { UIPrepTimer.SetValue(prepTimer / prepTime); } } //Update interaction CD cdTimer -= Time.deltaTime; if (cdTimer < 0) { playerInteracting = false; //Reset interaction indicator } } }
// Update is called once per frame protected virtual void Update() { //Update status if it was requested if (_lastStatusRequest != null) { _prevStatus = _status; _status = _lastStatusRequest; animator.SetTrigger(_status); //Update status in animator updateStatus(_status); _lastStatusRequest = null; // Debug.Log(gameObject.name+" "+_status); } //Navigation // Debug.Log(gameObject.name + " navigation : "+ agent.isStopped + " " + agent.remainingDistance); Debug.DrawLine(gameObject.transform.position, agent.destination, Color.blue, 0.0f); if (status == "entering" && !agent.pathPending && agent.remainingDistance == 0) //Reached seat ? { status = "waiting"; waitTimer = waitingTime; order = ClientManager.Instance.assignOrder(); if (UIWaitingTimer != null) //Update UI Waiting timer Icon { UIWaitingTimer.DisplayIcon(StockManager.Instance.consumableSprite(order)); } } else if (status == "waiting") { waitTimer -= Time.deltaTime; if (waitTimer < 0) //Waited too long { //Leave tavern status = "leaving"; currentObjective = assigedPos = ClientManager.Instance.assignTarget(assigedPos, true); //Assign leaving target and set it as current objective } else if (UIWaitingTimer != null) //Update UI Waiting timer { UIWaitingTimer.SetValue(waitTimer / waitingTime); } } //Consume Timer else if (status == "consuming") //Consuming mug if there's one and reached destination { consumeTimer -= Time.deltaTime; if (consumeTimer < 0) //Finished consuming mug ? { Mug obj = currentMug.GetComponent <Mug>(); if (obj != null) { //Reward Consumable content = obj.consume(); int money = (int)(content.Value * (1.0f + waitTimer / waitingTime)); //Reward = value order + Tips (value * waitTime) ClientManager.Instance.clientReward(money); //Drop mug Transform dropPos = gameObject.transform; dropPos.position += (Vector3)Vector2.down * 0.2f; obj.drop(dropPos); currentMug = null; } //Leave tavern status = "leaving"; currentObjective = assigedPos = ClientManager.Instance.assignTarget(assigedPos, true); //Assign leaving target and set it as current objective } } else if (status == "leaving" && !agent.pathPending && agent.remainingDistance < 0.5) //Reached exit ? { Destroy(gameObject); } else if (status == "event" && !agent.pathPending && agent.remainingDistance == 0) //Reached event ? { assignToEvent(); //In case events already finished, come back to normal } }