453 lines
10 KiB
C#
453 lines
10 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Events/PenGuyEvents.cs")]
|
|
public partial class PenGuyEvents : Node2D
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private Entity[] entities;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Node2D[] markers;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D[] objects;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private MemoryGame memoryGame;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private AudioStream theme;
|
|
|
|
private int streak;
|
|
|
|
public void EventBeforeGame()
|
|
{
|
|
if (SaveFile.current.flags.Contains(SaveFile.Flags.BeatMemoryGame))
|
|
{
|
|
TextSystem.GetText("PenGuy3");
|
|
Player.instance.canInput = false;
|
|
}
|
|
else if (!SaveFile.current.flags.Contains(SaveFile.Flags.PenGuyFirstTalk))
|
|
{
|
|
Main.inEvent = Coroutine.Start(PenGuyFirstTalk());
|
|
}
|
|
else
|
|
{
|
|
Main.inEvent = Coroutine.Start(PenGuyMinigame());
|
|
}
|
|
}
|
|
|
|
private IEnumerator PenGuyFirstTalk()
|
|
{
|
|
TextSystem.GetText("PenGuy1");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
TextSystem.GetText("PenGuy2");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
SaveFile.AddFlag(SaveFile.Flags.PenGuyFirstTalk);
|
|
SaveFile.AddFlag(SaveFile.Flags.KanakoMemoryGameRoomBefore);
|
|
}
|
|
|
|
private IEnumerator PenGuyMinigame()
|
|
{
|
|
if (memoryGame.running)
|
|
{
|
|
TextSystem.GetText("PenGuyGameRunning");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
TextSystem.GetText("PenGuyGamePrompt");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
if (TextSystem.lastPrompt == 1)
|
|
{
|
|
TextSystem.GetText("PenGuyRefuse");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
Party.MoveTo(new Vector2[2]
|
|
{
|
|
markers[0].GlobalPosition,
|
|
markers[1].GlobalPosition
|
|
}, 0.7f, align: true);
|
|
while (!Party.IsStopped())
|
|
{
|
|
yield return null;
|
|
}
|
|
Party.LookAt(Vector2.Up);
|
|
TextSystem.GetText("PenGuyMinigameStart");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
Main.inEvent = Coroutine.Start(memoryGame.StartGame());
|
|
Player.instance.ResetFollowStep();
|
|
}
|
|
|
|
public void EndGame()
|
|
{
|
|
if (MemoryGame.result)
|
|
{
|
|
Main.inEvent = Coroutine.Start(GameEndEvent());
|
|
if (SaveFile.HasFlag(SaveFile.Flags.PenGuyReturn))
|
|
{
|
|
streak++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
streak = 0;
|
|
}
|
|
}
|
|
|
|
public IEnumerator GameEndEvent()
|
|
{
|
|
if (!SaveFile.current.flags.Contains(SaveFile.Flags.BeatMemoryGame))
|
|
{
|
|
Party.MoveTo(new Vector2[2]
|
|
{
|
|
markers[0].GlobalPosition,
|
|
markers[1].GlobalPosition
|
|
}, 1.5f, align: true);
|
|
while (!Party.IsStopped())
|
|
{
|
|
yield return null;
|
|
}
|
|
Party.LookAt(Vector2.Up);
|
|
SaveFile.AddFlag(SaveFile.Flags.BeatMemoryGame);
|
|
TextSystem.GetText("PenGuyEvent3");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
Vector2 p = objects[0].GlobalPosition;
|
|
Vector2 p2 = new Vector2(205f, -355f);
|
|
Audio.PlaySound("snd_slidewhistle.wav");
|
|
float a = 0f;
|
|
for (float b = 60f; a <= b + 1f; a += Main.deltaTime)
|
|
{
|
|
objects[0].GlobalPosition = p.Lerp(p2, Mathf.SmoothStep(0f, 1f, a / b));
|
|
yield return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Party.MoveTo(new Vector2[2]
|
|
{
|
|
markers[4].GlobalPosition,
|
|
markers[5].GlobalPosition
|
|
}, 1.5f, align: true);
|
|
while (!Party.IsStopped())
|
|
{
|
|
yield return null;
|
|
}
|
|
Party.LookAt(Vector2.Up);
|
|
TextSystem.GetText("PenGuyReturnWon");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
SaveFile.current.values[8] = Mathf.Clamp(streak, 0, 5) * 3;
|
|
TextSystem.GetText("MoneyReward");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
Player.instance.ResetFollowStep();
|
|
}
|
|
|
|
private IEnumerator Rematch()
|
|
{
|
|
if (memoryGame.running)
|
|
{
|
|
TextSystem.GetText("PenGuyGameRunning");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
yield break;
|
|
}
|
|
if (!SaveFile.HasFlag(SaveFile.Flags.PenGuyReturn))
|
|
{
|
|
TextSystem.GetText("PenGuyReturn");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
SaveFile.AddFlag(SaveFile.Flags.PenGuyReturn);
|
|
}
|
|
TextSystem.GetText("PenGuyGamePrompt");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
if (TextSystem.lastPrompt == 0)
|
|
{
|
|
TextSystem.GetText("PenGuyMinigameStart");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
Main.inEvent = Coroutine.Start(memoryGame.StartGame());
|
|
Player.instance.ResetFollowStep();
|
|
Player.instance.canInput = true;
|
|
}
|
|
else
|
|
{
|
|
TextSystem.GetText("PenGuyRefuse");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void YellowPaint()
|
|
{
|
|
Main.inEvent = Coroutine.Start(YellowPaintEvent());
|
|
}
|
|
|
|
private IEnumerator YellowPaintEvent()
|
|
{
|
|
if (SaveFile.current.flags.Contains(SaveFile.Flags.WeirdStart))
|
|
{
|
|
TextSystem.GetText("YellowPaintEvent2");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TextSystem.GetText("YellowPaintEvent1");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
Audio.PlaySound("snd_slidewhistle.wav");
|
|
}
|
|
Vector2 p = entities[1].GlobalPosition;
|
|
Vector2 tp = new Vector2(-62f, -850f);
|
|
float a = 0f;
|
|
for (float b = 100f; a < b; a += Main.deltaTime)
|
|
{
|
|
entities[1].GlobalPosition = p.Lerp(tp, Mathf.SmoothStep(0f, 1f, a / b));
|
|
yield return null;
|
|
}
|
|
entities[1].QueueFree();
|
|
SaveFile.AddFlag(SaveFile.Flags.YellowPaintEvent);
|
|
}
|
|
|
|
public void ClimbOnWindow()
|
|
{
|
|
Main.inEvent = Coroutine.Start(ClimbPrompt());
|
|
}
|
|
|
|
private IEnumerator ClimbPrompt()
|
|
{
|
|
TextSystem.GetText("ClimbPrompt");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
if (TextSystem.lastPrompt != 0)
|
|
{
|
|
yield break;
|
|
}
|
|
Audio.PlaySound("snd_escaped.wav");
|
|
CameraController.Transition(Main.colorBlack, 30f);
|
|
while (!CameraController.transitionRoutine.done)
|
|
{
|
|
yield return null;
|
|
}
|
|
yield return null;
|
|
Room.LoadRoom(Room.IDs.SchoolDWFortressRightmost, reparent: true);
|
|
yield return null;
|
|
Party.SetPosition(new Vector2(160f, 0f));
|
|
Room.current.DoMusic();
|
|
Party.LookAt(Vector2.Down);
|
|
for (float a = 0f; a < 30f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
CameraController.Transition(Main.colorClearB, 30f);
|
|
while (!CameraController.transitionRoutine.done)
|
|
{
|
|
yield return null;
|
|
}
|
|
if (!SaveFile.current.flags.Contains(SaveFile.Flags.BearingFortFirstPuzzle))
|
|
{
|
|
TextSystem.GetText("KanakoInsideFort");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
Player.instance.ResetFollowStep();
|
|
}
|
|
|
|
public void GameRematch()
|
|
{
|
|
if (SaveFile.HasFlag(SaveFile.Flags.BearingFortMainGate) && !SaveFile.HasFlag(SaveFile.Flags.WeirdStart))
|
|
{
|
|
Main.inEvent = Coroutine.Start(Rematch());
|
|
}
|
|
else
|
|
{
|
|
Player.instance.canInput = true;
|
|
}
|
|
}
|
|
|
|
public void Pennilton()
|
|
{
|
|
Main.inEvent = Coroutine.Start(PenniltonEvent());
|
|
}
|
|
|
|
private IEnumerator PenniltonEvent()
|
|
{
|
|
SaveFile.current.values[10] = 3;
|
|
Party.MoveTo(new Vector2[2]
|
|
{
|
|
markers[2].GlobalPosition,
|
|
markers[3].GlobalPosition
|
|
}, 0.7f);
|
|
while (!Party.IsStopped())
|
|
{
|
|
yield return null;
|
|
}
|
|
Party.LookAt(Vector2.Up);
|
|
for (float a = 0f; a < 30f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
TextSystem.GetText("Pennilton1");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
Coroutine.Start(BattleDR.StartBattle(null, useOWBG: false, new Entity.IDs[1] { Entity.IDs.Pennilton }, new List<Entity> { entities[2] }, "Pennilton", new Audio.AudioBlock
|
|
{
|
|
stream = Room.current.music[1],
|
|
pitch = 0.9f
|
|
}));
|
|
yield return null;
|
|
while (BattleDR.current != null)
|
|
{
|
|
yield return null;
|
|
}
|
|
string sound = null;
|
|
if (BattleDR.lastResult != BattleDR.EndState.Spared)
|
|
{
|
|
entities[2].QueueFree();
|
|
for (float a = 0f; a < 30f; a += Main.deltaTime)
|
|
{
|
|
yield return null;
|
|
}
|
|
if (BattleDR.lastResult == BattleDR.EndState.Executed)
|
|
{
|
|
TextSystem.GetText("PenniltonExecuted");
|
|
sound = "snd_ominous.wav";
|
|
SaveFile.current.values[10]--;
|
|
Party.party[0].title = 5;
|
|
Party.party[1].title = 6;
|
|
if (TextSystem.lastPrompt == 1)
|
|
{
|
|
SaveFile.current.values[7]++;
|
|
}
|
|
}
|
|
else if (BattleDR.lastResult == BattleDR.EndState.Defeated)
|
|
{
|
|
if (SaveFile.current.flags.Contains(SaveFile.Flags.WeirdStart))
|
|
{
|
|
SaveFile.current.flags.Remove(SaveFile.Flags.WeirdStart);
|
|
TextSystem.GetText("PenniltonWeirdAbort");
|
|
sound = "snd_ominous_cancel.wav";
|
|
}
|
|
else
|
|
{
|
|
TextSystem.GetText("PenniltonEscaped");
|
|
}
|
|
}
|
|
else if (BattleDR.lastResult == BattleDR.EndState.Apprehended)
|
|
{
|
|
if (SaveFile.current.flags.Contains(SaveFile.Flags.WeirdStart))
|
|
{
|
|
SaveFile.current.flags.Remove(SaveFile.Flags.WeirdStart);
|
|
TextSystem.GetText("PenniltonWeirdAbort");
|
|
sound = "snd_ominous_cancel.wav";
|
|
}
|
|
else
|
|
{
|
|
TextSystem.GetText("PenniltonApprehended");
|
|
SaveFile.AddFlag(SaveFile.Flags.PenniltonCaught);
|
|
}
|
|
}
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TextSystem.GetText("PenniltonSpared");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
Vector2 p = entities[2].GlobalPosition;
|
|
Vector2 d = new Vector2(400f, p.Y);
|
|
Audio.PlaySound("snd_slidewhistle.wav", 1f, 1.1f);
|
|
float a = 0f;
|
|
for (float b = 60f; a < b; a += Main.deltaTime)
|
|
{
|
|
entities[2].GlobalPosition = p.Lerp(d, a / b);
|
|
yield return null;
|
|
}
|
|
TextSystem.GetText("PenniltonSpared2");
|
|
while (TextSystem.instance.Visible)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
if (sound != null)
|
|
{
|
|
Audio.PlaySound(sound);
|
|
}
|
|
if (!SaveFile.current.flags.Contains(SaveFile.Flags.WeirdStart))
|
|
{
|
|
Room.current.DoMusic();
|
|
}
|
|
SaveFile.AddFlag(SaveFile.Flags.PenniltonFought);
|
|
SaveFile.AddFlag(SaveFile.Flags.KanakoMemoryGameRoomAfter);
|
|
Player.instance.ResetFollowStep();
|
|
if (GodotObject.IsInstanceValid(entities[0]))
|
|
{
|
|
entities[0].QueueFree();
|
|
}
|
|
if (SaveFile.HasFlag(SaveFile.Flags.WeirdStart))
|
|
{
|
|
SaveFile.AddFlag(SaveFile.Flags.WeirdedOnce);
|
|
}
|
|
}
|
|
|
|
}
|