85 lines
2.1 KiB
C#
85 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Puzzles/JumpVent.cs")]
|
|
public partial class JumpVent : Node2D
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D[] arc;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private float time = 30f;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private float partyDelay = 20f;
|
|
|
|
private Area2D area;
|
|
|
|
private readonly AudioStream audio = GD.Load<AudioStream>("res://Audio/Sounds/snd_steamworks_13_vent.wav");
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
area = GetChild<Area2D>(0);
|
|
area.BodyEntered += OnTrigger;
|
|
}
|
|
|
|
private void OnTrigger(Node other)
|
|
{
|
|
if (other == Player.instance && Main.inEvent == null)
|
|
{
|
|
Main.inEvent = Coroutine.Start(Event());
|
|
}
|
|
}
|
|
|
|
private IEnumerator Event()
|
|
{
|
|
Party.StopMoving();
|
|
Party.UpdateFollowerEntities();
|
|
Coroutine c = null;
|
|
for (float a = 0f; a < 10f; a += Main.deltaTime)
|
|
{
|
|
for (int i = 0; i < SaveFile.current.activeParty.Count; i++)
|
|
{
|
|
Party.party[SaveFile.current.activeParty[i]].oEntity.GlobalPosition = Party.party[SaveFile.current.activeParty[i]].oEntity.GlobalPosition.Lerp(base.GlobalPosition, Main.deltaTime * 0.15f);
|
|
}
|
|
yield return null;
|
|
}
|
|
for (int j = 0; j < SaveFile.current.activeParty.Count; j++)
|
|
{
|
|
c = Coroutine.Start(Jump(Party.party[SaveFile.current.activeParty[j]].oEntity));
|
|
for (float a = 0f; a < partyDelay; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
while (true)
|
|
{
|
|
Coroutine coroutine = c;
|
|
if (coroutine == null || coroutine.done)
|
|
{
|
|
break;
|
|
}
|
|
yield return null;
|
|
}
|
|
Player.instance.ResetFollowStep();
|
|
}
|
|
|
|
private IEnumerator Jump(Entity entity)
|
|
{
|
|
Audio.PlaySound(audio).Bus = "Reverb";
|
|
Coroutine spin = Coroutine.Start(CommonEvents.SpinEntity(entity, 2f));
|
|
Vector2 s = entity.GlobalPosition;
|
|
for (float a = 0f; a <= time + 1f; a += Main.deltaTime)
|
|
{
|
|
entity.GlobalPosition = Common.Beizier(s, arc[0].GlobalPosition, arc[1].GlobalPosition, Mathf.SmoothStep(0f, 1f, Mathf.Min(a / time, 1f)));
|
|
yield return null;
|
|
}
|
|
Coroutine.Stop(spin);
|
|
}
|
|
|
|
}
|