// Update is called once per frame void Update() { if (!HUDController.Instance.IsPaused) { switch (state) { case LadybugState.Entering: Move(true, enteringSpeed); if (Mathf.Abs(transform.position.x - finalDestination.x) < 25 && (transform.position.y < flowerRect.sizeDelta.y + flowerRect.transform.position.y && transform.position.y > flowerRect.transform.position.y)) { state = LadybugState.Sitting; Activate(); } break; case LadybugState.Blowing: if (IsOffScreen()) { this.Complete(); Destroy(this.gameObject); } else if (timeTraveled > blowTime) { state = LadybugState.Entering; } Blow(); break; } } }
public void OnSwipe(Vector2 swipe) { if (IsOnScreen()) { if (state == LadybugState.Sitting) { this.Complete(); this.wasActivated = false; } state = LadybugState.Blowing; blowDirection = Quaternion.Euler(0, 0, Random.Range(-5, 5)) * swipe.normalized; blowTime += 1f; timeTraveled = 0; } }