85 lines
1.6 KiB
C#
85 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Bullets/PencellerDuo.cs")]
|
|
public partial class PencellerDuo : Control
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private AudioStream[] sounds;
|
|
|
|
private Node2D[] bullets = new Node2D[3];
|
|
|
|
private int[] order = new int[3];
|
|
|
|
private int[] state = new int[3];
|
|
|
|
private float[] cd = new float[3];
|
|
|
|
private const float startY = -31f;
|
|
|
|
private const float showY = -15f;
|
|
|
|
private const float speed = 1f;
|
|
|
|
public override void _Ready()
|
|
{
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
bullets[i] = GetChild<Node2D>(i);
|
|
if (i == 0)
|
|
{
|
|
order[i] = Main.RandomRange(0, 2);
|
|
}
|
|
else
|
|
{
|
|
order[i] = (int)Main.Repeat(order[i - 1] + 1, order.Length);
|
|
}
|
|
cd[order[i]] = 100 * i;
|
|
}
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
int num = order[i];
|
|
float y = bullets[num].Position.Y;
|
|
cd[num] -= Main.deltaTime;
|
|
if (!(cd[num] < 0f))
|
|
{
|
|
continue;
|
|
}
|
|
if (cd[num] > -30f)
|
|
{
|
|
if (state[num] == 0)
|
|
{
|
|
Audio.PlaySound(sounds[0]);
|
|
state[num] = 1;
|
|
}
|
|
y = Mathf.Lerp(y, -15f, Main.deltaTime * 0.1f);
|
|
}
|
|
else
|
|
{
|
|
if (state[num] == 1)
|
|
{
|
|
Audio.PlaySound(sounds[1]);
|
|
state[num] = 2;
|
|
}
|
|
y += 1f;
|
|
}
|
|
bullets[num].Position = new Vector2(bullets[num].Position.X, y);
|
|
if (bullets[num].Position.Y > 140f)
|
|
{
|
|
state[num] = 0;
|
|
cd[num] = Main.RandomRange(30, 60);
|
|
((IBullet)bullets[num]).grazed = false;
|
|
bullets[num].Position = new Vector2(bullets[num].Position.X, -31f);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|