149 lines
3.2 KiB
C#
149 lines
3.2 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Bullets/AxisPunch.cs")]
|
|
public partial class AxisPunch : Node2D
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D hand;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D impactFX;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D smoke;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Sprite2D handSpr;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Texture2D[] anim;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private CollisionShape2D collider;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private float time = 60f;
|
|
|
|
private int state;
|
|
|
|
private float cd;
|
|
|
|
private float scd;
|
|
|
|
private float multi = 1f;
|
|
|
|
private Vector2 temp;
|
|
|
|
private const float y = -60f;
|
|
|
|
private const float ty = 25f;
|
|
|
|
private bool canSmoke;
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
if (BattleDR.current.enemies[0].HPPercent() <= 0.5f || BattleDR.current.enemies[0].spare >= 50)
|
|
{
|
|
time /= 1.5f;
|
|
canSmoke = true;
|
|
}
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
switch (state)
|
|
{
|
|
case 0:
|
|
if (cd < time / 2f)
|
|
{
|
|
cd += Main.deltaTime;
|
|
hand.Position = hand.Position.Lerp(new Vector2(ToLocal(BattleDR.current.soul.GlobalPosition).X, -60f), Main.deltaTime * 0.15f);
|
|
break;
|
|
}
|
|
((Blank)hand).grazed = false;
|
|
temp = hand.GlobalPosition;
|
|
state = 1;
|
|
cd = 0f;
|
|
handSpr.Texture = anim[1];
|
|
Audio.PlaySound("snd_boost.wav");
|
|
break;
|
|
case 1:
|
|
cd += Main.deltaTime;
|
|
if (cd < time / 2f)
|
|
{
|
|
hand.GlobalPosition = temp.Lerp(temp + Vector2.Up * 60f, cd / time / 2f);
|
|
break;
|
|
}
|
|
if (cd < time)
|
|
{
|
|
hand.Modulate = ((Common.SinOverTime(2.5f) > 0f) ? Main.colorDark : Main.colorWhite);
|
|
break;
|
|
}
|
|
state = 2;
|
|
hand.Modulate = Main.colorWhite;
|
|
temp = hand.GlobalPosition;
|
|
cd = 0f;
|
|
collider.SetDeferred("disabled", false);
|
|
break;
|
|
case 2:
|
|
{
|
|
cd += Main.deltaTime;
|
|
if (cd < time / 2.2f)
|
|
{
|
|
hand.GlobalPosition = temp.Lerp(new Vector2(hand.GlobalPosition.X, base.GlobalPosition.Y + BattleDR.current.activeBoard.boardSize.Y / 2f - 15f), cd / (time / 2.2f));
|
|
if (canSmoke)
|
|
{
|
|
if (scd <= 0f)
|
|
{
|
|
scd = 5f;
|
|
SpawnSmoke(multi);
|
|
multi += 0.1f;
|
|
}
|
|
else
|
|
{
|
|
scd -= Main.deltaTime;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
scd = 0f;
|
|
state = 3;
|
|
cd = 0f;
|
|
CameraController.Shake(15f);
|
|
Audio.PlaySound("snd_impact_ch1.wav");
|
|
Node2D node2D;
|
|
AddChild(node2D = (Node2D)impactFX.Duplicate(), forceReadableName: false, InternalMode.Disabled);
|
|
node2D.Position = new Vector2(hand.Position.X, BattleDR.current.activeBoard.boardSize.Y / 2f + -4f);
|
|
node2D.ProcessMode = ProcessModeEnum.Inherit;
|
|
if (canSmoke)
|
|
{
|
|
SpawnSmoke(multi);
|
|
}
|
|
multi = 1f;
|
|
break;
|
|
}
|
|
case 3:
|
|
cd += Main.deltaTime;
|
|
if (cd >= time / 2f)
|
|
{
|
|
cd = 0f;
|
|
state = 0;
|
|
handSpr.Texture = anim[0];
|
|
collider.SetDeferred("disabled", true);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void SpawnSmoke(float m = 1f)
|
|
{
|
|
MoveAhead moveAhead = (MoveAhead)BattleDR.NewBullet(in smoke, hand.GlobalPosition, this);
|
|
moveAhead.speed = new Vector2(((moveAhead.GlobalPosition.X < BattleDR.current.soul.GlobalPosition.X) ? 0.25f : (-0.25f)) * m, -0.15f);
|
|
}
|
|
|
|
}
|