89 lines
1.6 KiB
C#
89 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Puzzles/SteamSpewer.cs")]
|
|
public partial class SteamSpewer : Node2D
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private PackedScene bullet;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private float delay = 60f;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private float delayPerBullet = 10f;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private int bulletAmt = 3;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private VisibleOnScreenNotifier2D[] visibles;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private AudioStreamPlayer sound;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D[] points;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Vector2 direction = Vector2.Down * 0.75f;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private SaveFile.Flags needsFlag = SaveFile.Flags.None;
|
|
|
|
private float cd;
|
|
|
|
private float bcd;
|
|
|
|
private int cb;
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
cd = delay;
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if (needsFlag != SaveFile.Flags.None && !SaveFile.HasFlag(needsFlag))
|
|
{
|
|
return;
|
|
}
|
|
if (cd > 0f)
|
|
{
|
|
cd -= Main.deltaTime;
|
|
return;
|
|
}
|
|
if (bcd > 0f)
|
|
{
|
|
bcd -= Main.deltaTime;
|
|
return;
|
|
}
|
|
for (int i = 0; i < visibles.Length; i++)
|
|
{
|
|
if (visibles[i].IsOnScreen())
|
|
{
|
|
sound.Play();
|
|
break;
|
|
}
|
|
}
|
|
for (int j = 0; j < points.Length; j++)
|
|
{
|
|
((MoveAhead)BattleDR.NewBullet(in bullet, points[j].GlobalPosition, this)).speed = direction;
|
|
}
|
|
cb++;
|
|
if (cb >= bulletAmt)
|
|
{
|
|
cd = delay;
|
|
cb = 0;
|
|
}
|
|
else
|
|
{
|
|
bcd = delayPerBullet;
|
|
}
|
|
}
|
|
|
|
}
|