2025-05-13 19:22:01 +08:00

35 lines
730 B
C#

using System.Collections.Generic;
using System.ComponentModel;
using Godot;
using Godot.Bridge;
using Godot.NativeInterop;
[ScriptPath("res://Scripts/Envirioment/AudioOnTouch.cs")]
public partial class AudioOnTouch : Node2D
{
[Export(PropertyHint.None, "")]
private AudioStreamPlayer player;
[Export(PropertyHint.None, "")]
private VisibleOnScreenNotifier2D screen;
[Export(PropertyHint.None, "")]
private float screenShake = 1f;
[Export(PropertyHint.None, "")]
private float shakeTime = 20f;
public void Sound()
{
if ((screen == null || screen.IsOnScreen()) && !TextSystem.instance.Visible)
{
if (screenShake > 0f)
{
CameraController.Shake(shakeTime, screenShake);
}
player?.Play();
}
}
}