// Interrupts an enemy if that enemy is in the process of eating a crop // That enemy will run away(toward the edge of the map) public void Scare() { if (LockingInput()) { return; } // Don't scare if it is on cooldown if (_scareTimer.IsStarted() && _scareTimer.GetTicks() < SCARE_COOLDOWN) { ShowPopupWithDelay(MSG_SCARE_COOLDOWN); return; } // Otherwise, proceed with scaring attack this._scaring = true; this.ScareAllEnemies(); PopupMessageCreator.PopupMessage(MSG_SCARE, transform, new Vector3(0, 2, 0)); SoundController.PlaySound(SoundType.PlayerScare); // Emit scaring particle effect Vector3 particlePos = new Vector3(transform.position.x, 2, transform.position.z); ParticleCreator.Emit("ParticlesPlayerScare", particlePos); // Start the cooldown timer _scareTimer.StartTimer(); }
// Movement transition between tiles // Call this to update once per frame void KeepMoving() { if (Vector3.Distance(transform.position, _moveTargetPos) > 0.1f) { // Gradually move toward the target position if (_movementTime < 1.0f) { _movementTime += 1.0f * MovementSpeed * Time.deltaTime; Vector3 m1 = Vector3.Lerp(_moveStartPos, _moveMidPos, _movementTime); Vector3 m2 = Vector3.Lerp(_moveMidPos, _moveTargetPos, _movementTime); transform.position = Vector3.Lerp(m1, m2, _movementTime); } } else { // Unlock input reading after reaching target position _movingLock = false; // Emit player jump particle effect ParticleCreator.Emit("ParticlesPlayerJump", transform.position); // Snap to the proper position transform.position = _moveTargetPos; // Reset the movement time _movementTime = 0; } }