private IEnumerator ResetToFreeState() { m_timerStarted = true; yield return(new WaitForSeconds(m_mortalTime)); m_state = WasteState.FREE; m_timerStarted = false; }
private void Update() { if ((m_oldState == WasteState.FREE || m_oldState == WasteState.MORTAL) && m_state == WasteState.TRACKED) { Debug.Log("Reducing velocity"); m_rigidbody.velocity /= 3.0f; } if (m_rigidbody.velocity.magnitude >= m_velocityLimitForBeingMortal && m_state == WasteState.TRACKED) { m_state = WasteState.MORTAL; StopCoroutine("ResetToFreeState"); m_timerStarted = false; } if (m_rigidbody.velocity.magnitude < m_velocityLimitForBeingMortal && m_state == WasteState.MORTAL) { m_state = WasteState.FREE; } if (m_state == WasteState.MORTAL && !m_timerStarted) { StartCoroutine("ResetToFreeState", m_mortalTime); } // // if (m_state == WasteState.TRACKED && !m_timerStarted) // StartCoroutine("ResetToFreeState", m_trackedTime); if (m_life <= 0) { if (AudioManager.instance != null) { AudioManager.instance.SetIsExplosion(true); } Instantiate(m_explosionPrefabs[Random.Range(0, m_explosionPrefabs.Count - 1)], transform.position, Quaternion.identity); Destroy(gameObject); } if (m_state == WasteState.MORTAL) { m_particles.SetActive(true); m_particles2.SetActive(true); } else { m_particles.SetActive(false); m_particles2.SetActive(false); } m_oldState = m_state; }