42 lines
1.1 KiB
Plaintext
42 lines
1.1 KiB
Plaintext
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
namespace Piano
|
|
{
|
|
public class PianoBehaviour : AnvilBehaviour
|
|
{
|
|
private AudioClip pianoClip;
|
|
|
|
public override void OnLoad()
|
|
{
|
|
pianoClip = AGDAPI.Audio.LoadClip("assets/pianodrop.mp3");
|
|
}
|
|
|
|
public override void OnUse(ItemUseContext ctx)
|
|
{
|
|
AGDAPI.Audio.PlayClip(pianoClip, ctx.Player);
|
|
ctx.StartCoroutine(TimedDrop(ctx));
|
|
}
|
|
|
|
private IEnumerator TimedDrop(ItemUseContext ctx)
|
|
{
|
|
float hoverTime = 2.5f;
|
|
float hoverHeight = 8f;
|
|
|
|
var thrown = ctx.SpawnThrownObject(suspend: true);
|
|
if (thrown == null)
|
|
yield break;
|
|
|
|
thrown.transform.position = ctx.Player.transform.position + Vector3.up * hoverHeight;
|
|
|
|
yield return new WaitForSeconds(hoverTime);
|
|
|
|
thrown.Release();
|
|
}
|
|
|
|
public override float GetImpactDamage()
|
|
{
|
|
return base.GetImpactDamage() * 2.0f;
|
|
}
|
|
}
|
|
} |