136 lines
2.8 KiB
C#
136 lines
2.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Bullets/PenniltonSpin.cs")]
|
|
public partial class PenniltonSpin : Node2D
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private Blank obj;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node warning;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Area2D col;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private AudioStream appear;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private AudioStream spin;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private AudioStream coinSound;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private PackedScene coinPrefab;
|
|
|
|
private float grow;
|
|
|
|
private float spd;
|
|
|
|
private float cd = 15f;
|
|
|
|
private float midTime;
|
|
|
|
private float coinCD;
|
|
|
|
private bool set;
|
|
|
|
private bool flip;
|
|
|
|
private bool weak;
|
|
|
|
private Coroutine flipping;
|
|
|
|
private List<PenniltonSimple.Coins> coins = new List<PenniltonSimple.Coins>();
|
|
|
|
public override void _Ready()
|
|
{
|
|
obj.Modulate = Main.colorClear;
|
|
midTime = BattleDR.current.activeBoard.timer / 2f;
|
|
weak = BattleDR.current.enemies[0].GetProgress() >= 0.5f;
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if (GodotObject.IsInstanceValid(warning))
|
|
{
|
|
return;
|
|
}
|
|
PenniltonSimple.PennyCoinLogic(this, in coins, coinSound, 80f, -1f, 0.9f, 20f);
|
|
if (weak)
|
|
{
|
|
coinCD -= Main.deltaTime;
|
|
if (coinCD <= 0f && coins.Count < 3)
|
|
{
|
|
coinCD = Main.RandomRange(40, 80);
|
|
IBullet bullet = (IBullet)BattleDR.NewBullet(in coinPrefab, new Vector2(200f, (coins.Count == 0) ? BattleDR.current.soul.GlobalPosition.Y : (base.GlobalPosition.Y + Main.RandomRange(0f - BattleDR.current.activeBoard.boardSize.Y, BattleDR.current.activeBoard.boardSize.Y) * 0.4f)));
|
|
bullet.type = IBullet.Type.Yellow;
|
|
bullet.node.Modulate = Main.colorYellow;
|
|
coins.Add(new PenniltonSimple.Coins
|
|
{
|
|
obj = bullet.node
|
|
});
|
|
Audio.PlaySound(coinSound);
|
|
}
|
|
}
|
|
if (grow < 30f)
|
|
{
|
|
grow += Main.deltaTime;
|
|
obj.Modulate = Main.colorClear.Lerp(Main.colorWhite, grow / 30f);
|
|
return;
|
|
}
|
|
if (!set)
|
|
{
|
|
col.CollisionLayer = 4u;
|
|
}
|
|
if (!flip && weak && flipping == null && BattleDR.current.activeBoard.timer < midTime)
|
|
{
|
|
flipping = Coroutine.Start(Flip());
|
|
}
|
|
if (flip)
|
|
{
|
|
if (spd > -1.25f)
|
|
{
|
|
spd -= Main.deltaTime * 0.05f;
|
|
}
|
|
}
|
|
else if (spd < 1.25f)
|
|
{
|
|
spd += Main.deltaTime * 0.05f;
|
|
}
|
|
obj.RotationDegrees += spd * Main.deltaTime;
|
|
if (cd <= 0f)
|
|
{
|
|
Audio.PlaySound(spin);
|
|
obj.grazed = false;
|
|
cd = 120f;
|
|
}
|
|
else
|
|
{
|
|
cd -= Main.deltaTime;
|
|
}
|
|
}
|
|
|
|
private IEnumerator Flip()
|
|
{
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
Audio.PlaySound("snd_bombfall.wav");
|
|
obj.Modulate = Main.colorDark;
|
|
for (float a = 0f; a < 10f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
obj.Modulate = Main.colorWhite;
|
|
}
|
|
flip = true;
|
|
}
|
|
|
|
}
|