171 lines
4.0 KiB
C#
171 lines
4.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Puzzles/KanakoGate.cs")]
|
|
public partial class KanakoGate : Node2D
|
|
{
|
|
private int[] party;
|
|
|
|
public void EventTrigger()
|
|
{
|
|
Main.inEvent = Coroutine.Start(Event());
|
|
}
|
|
|
|
public void JumpBack()
|
|
{
|
|
Main.inEvent = Coroutine.Start(Jumping());
|
|
}
|
|
|
|
private IEnumerator Jumping()
|
|
{
|
|
if (Player.instance.splitEntity != null)
|
|
{
|
|
Player.instance.splitEntity.CollisionLayer = 0u;
|
|
Player.instance.splitEntity.CollisionMask = 0u;
|
|
Coroutine c = Coroutine.Start(CommonEvents.EntityJump(Player.instance.splitEntity, Player.instance.GlobalPosition));
|
|
while (!c.done)
|
|
{
|
|
yield return null;
|
|
}
|
|
Player.AssumeControl(Player.instance, playParticle: false);
|
|
Player.instance.ResetFollowStep();
|
|
Player.UpdateSplitEntity();
|
|
}
|
|
else
|
|
{
|
|
Player.instance.canInput = true;
|
|
}
|
|
}
|
|
|
|
private IEnumerator Event()
|
|
{
|
|
if (Player.instance.splitEntity != null && Player.instance.controlling == Player.instance)
|
|
{
|
|
Player.instance.StopMoving();
|
|
yield return null;
|
|
yield break;
|
|
}
|
|
Party.LookAt(base.GlobalPosition);
|
|
if (!SaveFile.current.activeParty.Contains(1))
|
|
{
|
|
TextSystem.GetText("KanakoGateNoKanako");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
if (!SaveFile.current.flags.Contains(SaveFile.Flags.KanakoGateNote))
|
|
{
|
|
TextSystem.GetText("KanakoGateBefore");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
if (!SaveFile.current.flags.Contains(SaveFile.Flags.KanakoGateEvent))
|
|
{
|
|
if (SaveFile.HasFlag(SaveFile.Flags.WeirdStart))
|
|
{
|
|
TextSystem.GetText("KanakoGateEventWeird");
|
|
}
|
|
else
|
|
{
|
|
TextSystem.GetText("KanakoGateEvent");
|
|
}
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
Player.instance.LookAt(Vector2.Up);
|
|
}
|
|
Entity k = Party.GetOWEntityByID(Entity.IDs.Kanako);
|
|
Vector2 e;
|
|
Vector2 ap;
|
|
if (k.GlobalPosition.Y > base.GlobalPosition.Y)
|
|
{
|
|
e = base.GlobalPosition + Vector2.Up * 20f;
|
|
ap = base.GlobalPosition + Vector2.Down * 20f;
|
|
}
|
|
else
|
|
{
|
|
e = base.GlobalPosition + Vector2.Down * 20f;
|
|
ap = base.GlobalPosition + Vector2.Up * 20f;
|
|
}
|
|
Party.ChangeCollider(state: false);
|
|
k.DoAutoAlign(ap);
|
|
while (k.moving != null)
|
|
{
|
|
yield return null;
|
|
}
|
|
CameraController.instance.follow = k;
|
|
k.currentAnim = Entity.Animations.Walk;
|
|
bool sound = false;
|
|
float a = 0f;
|
|
for (float b = (SaveFile.HasFlag(SaveFile.Flags.KanakoGateEvent) ? 30 : 60); a <= b + 1f; a += Main.deltaTime)
|
|
{
|
|
Vector2 to = ap.Lerp(e, a / b);
|
|
k.GlobalPosition = k.GlobalPosition.Lerp(to, Main.deltaTime * 0.2f);
|
|
k.LookAt(e);
|
|
if (!sound && a / b > 0.5f)
|
|
{
|
|
Audio.PlaySound("snd_shadowpendant_ch1.wav");
|
|
sound = true;
|
|
}
|
|
yield return null;
|
|
}
|
|
k.currentAnim = Entity.Animations.Idle;
|
|
if (Player.instance.controlling == Player.instance)
|
|
{
|
|
Player.AssumeControl(k, playParticle: false);
|
|
Player.instance.CollisionLayer = 0u;
|
|
}
|
|
else if (Player.instance.controlling.GlobalPosition.DistanceTo(Player.instance.GlobalPosition) > 80f)
|
|
{
|
|
Coroutine cc = Coroutine.Start(Jumping());
|
|
while (!cc.done)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Player.AssumeControl(Player.instance, playParticle: false);
|
|
Player.instance.ResetFollowStep();
|
|
}
|
|
Player.UpdateSplitEntity();
|
|
Party.ChangeCollider(state: true);
|
|
if (!SaveFile.current.flags.Contains(SaveFile.Flags.KanakoGateEvent))
|
|
{
|
|
for (float b = 0f; b < 30f; b += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
k.LookAt(Player.instance.GlobalPosition);
|
|
for (float b = 0f; b < 30f; b += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
if (SaveFile.HasFlag(SaveFile.Flags.WeirdStart))
|
|
{
|
|
TextSystem.GetText("KanakoGateEvent2Weird");
|
|
}
|
|
else
|
|
{
|
|
TextSystem.GetText("KanakoGateEvent2");
|
|
}
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
SaveFile.AddFlag(SaveFile.Flags.KanakoGateEvent);
|
|
}
|
|
}
|
|
|
|
}
|