private void Update() { if (m_IsBlocked && m_BlockedTimeCounter <= 0) { m_IsBlocked = false; m_Thief.Stun(false); } if (!thiefObject) { SetupThief(); return; } if (!m_PhotonView.IsMine) { return; } if (!m_IsSetup) { Setup(); } // Continuous noise change // if (m_Thief.currentNoise < 1 && m_IsMoving && !m_IsBlocked) // { // m_Thief.currentNoise += 0.1f * Time.deltaTime; // } m_Thief.currentNoise = Mathf.Clamp01(m_Thief.currentNoise); if (m_IsBlocked) { m_BlockedTimeCounter -= Time.deltaTime; return; } if (m_Thief.currentNoise >= 1.0f) { m_IsMoving = false; m_IsMovingTowardsExit = false; m_IsMovingTowardsLootObject = false; m_ThiefPathfindingAgent.SetDestination(thiefObject.transform.position); m_IsBlocked = true; m_Thief.Stun(true); m_BlockedTimeCounter = m_BlockedTime; return; } if (levelIndex != LevelIndex.None) { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); if (Physics.Raycast(ray, out RaycastHit hit, float.MaxValue)) { if (hit.collider.tag == "Ground") { m_IsMovingTowardsLootObject = false; m_IsMovingTowardsExit = false; m_IsMoving = true; m_Thief.atExit = false; m_IsMoving = m_ThiefPathfindingAgent.SetDestination(hit.point, true); } else if (hit.collider.tag == "Exit") { m_IsMovingTowardsLootObject = false; m_IsMovingTowardsExit = true; m_IsMoving = true; m_IsMoving = m_ThiefPathfindingAgent.SetDestination(hit.point, true); } else if (hit.collider.GetComponent <Loot>()) { Loot loot = hit.collider.GetComponent <Loot>(); if (loot.Collectable) { Debug.Log("Object : " + loot.GetPosition().ToString()); m_IsMoving = true; m_IsMovingTowardsExit = true; m_IsMovingTowardsLootObject = true; m_Thief.atExit = false; m_currentLootTarget = loot; m_ThiefPathfindingAgent.SetDestination(loot.GetPosition()); } } if (m_ClickFeedback.isPlaying) { m_ClickFeedback.Clear(); } m_ClickFeedback.transform.position = hit.point; m_ClickFeedback.Play(); } } } }