void Update() { if (m_ShouldUpdate) { transform.position += (Vector3)m_MoveDir * moveSpeed * Time.deltaTime; transform.position = m_MoveOscillation.GetOscillation(); if (movementDirection == MovementDirection.Left) { if (transform.position.x < -3.2f) { if (GAME_MANAGER == null) { Destroy(gameObject); return; } if (removeWhenLastEnemy && GAME_MANAGER.currentRound.enemiesRemaining == 1) { m_RoundEnemy.EscapedWave(); Destroy(gameObject); } else { transform.position = new Vector2(3.2f, transform.position.y); } } } else { if (transform.position.x > 3.2f) { if (GAME_MANAGER == null) { Destroy(gameObject); return; } if (removeWhenLastEnemy && GAME_MANAGER.currentRound.enemiesRemaining == 1) { m_RoundEnemy.EscapedWave(); Destroy(gameObject); } else { transform.position = new Vector2(-3.2f, transform.position.y); } } } } }
void Update() { if (m_ShouldUpdate) { transform.position += (Vector3)MOVE_DIR_LOOKUP[moveDirection] * moveSpeed * Time.deltaTime; transform.position = m_MoveOscillation.GetOscillation(); if (!m_BecameVisible) { m_BecameVisible = m_SpriteRenderer.isVisible; } if (LeftScreenBounds()) { if (onEscapedWave != null) { onEscapedWave(); } Destroy(gameObject); } } }