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

57 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using Godot;
using Godot.Bridge;
using Godot.NativeInterop;
[ScriptPath("res://Scripts/Bullets/PenniltonPush.cs")]
public partial class PenniltonPush : Node2D
{
[Export(PropertyHint.None, "")]
private Blank one;
private float speed;
private float cd;
private const float max = 180f;
public override void _EnterTree()
{
Blank blank = one;
blank.onShot = (Action<Node>)Delegate.Combine(blank.onShot, new Action<Node>(Push));
}
public override void _Process(double delta)
{
if (cd > 0f)
{
cd -= Main.deltaTime;
}
if (speed > -1f)
{
speed -= Main.deltaTime * 0.05f;
}
one.Position = new Vector2(Mathf.Clamp(one.Position.X + speed, 0f, 180f), 0f);
one.Modulate = one.Modulate.Lerp(Main.colorYellow, Main.deltaTime * 0.05f);
}
public void Push(Node node)
{
if (speed < 1f)
{
one.Modulate = Main.colorWhite;
speed += ((cd <= 0f) ? 1f : 0.75f);
cd = 5f;
}
}
public override void _ExitTree()
{
Blank blank = one;
blank.onShot = (Action<Node>)Delegate.Remove(blank.onShot, new Action<Node>(Push));
}
}