Compare commits

...

1 Commits

Author SHA1 Message Date
jonathan bfe1be0145 added quick and dirty mock quest
2 months ago

@ -0,0 +1,3 @@
<component name="ProjectDictionaryState">
<dictionary name="project" />
</component>

@ -0,0 +1,16 @@
using System.Threading.Tasks;
namespace Babushka.scripts.CSharp.mock;
public static class DialogicStarter
{
public static async Task Dialog(string dialog)
{
// implement
}
public static void SetValue(string key, int value)
{
// implement
}
}

@ -0,0 +1,12 @@
namespace Babushka.scripts.CSharp.mock;
public static class ObjectLookup
{
// Referenzen werden bei startup gesetzt
// Quests
public static PotatoQuest potatoQuest;
// NPCs
public static YeliNpc yeliNpc;
}

@ -0,0 +1,31 @@
using Babushka.scripts.CSharp.Common.Inventory;
using Babushka.scripts.CSharp.GameEntity.Entities;
using Godot;
namespace Babushka.scripts.CSharp.mock;
public partial class PotatoQuest:Node
{
// Yeli will 5 kartoffeln haben.
// Man kann Yeli auch erstmal weniger geben.
// Yeli sagt dir dann, wie viele kartoffeln noch fehlen.
public enum State
{
Unavailable, // bevor die quest verfügbar ist
YeliRequest, // Yeli fragt nach kartoffeln
BringPotato, // Vesna soll kartoffeln bringen
Done // kartoffeln abgegeben
}
public State state = State.Unavailable;
public int potatoesWanted = 5;
public int potatoesBrought = 0;
public ItemResource itemBlueprint; // potato item
public void Activate() // wird von woanders aufgerufen
{
if (state == State.Unavailable)
state = State.YeliRequest;
}
}

@ -0,0 +1,66 @@
using System;
using Babushka.scripts.CSharp.Common.Inventory;
using Babushka.scripts.CSharp.Common.NPC;
using Godot;
namespace Babushka.scripts.CSharp.mock;
// Dieses script enthält ALLE möglichen dialogoptionen die Yeli in der gesamten Demo hat.
// Das script ist dafür verantwortlich den richtigen Dialog zu starten.
public partial class YeliDialog : Node
{
public async void StartDialog() // kann zu jedem zeitpunkt vom spieler getriggert werden
{
var potato = ObjectLookup.potatoQuest;
var yeli = ObjectLookup.yeliNpc;
var inventory = InventoryManager.Instance.playerInventory!;
if (yeli.isSleeping) // wenn yeli schläft kann keine quest von ihr angenommen werden, auch wenn die quest verfügbar ist
{
await DialogicStarter.Dialog("YeliSleep"); // "ZZZ"
}
else if (potato.state == PotatoQuest.State.YeliRequest)
{
await DialogicStarter.Dialog("YeliAskForPotato"); // "Can you bring me 5 potatoes?"
potato.state = PotatoQuest.State.BringPotato;
}
else if (potato.state == PotatoQuest.State.BringPotato)
{
var potatoesTodo = potato.potatoesWanted - potato.potatoesBrought;
var potatoesAvailable = inventory.TotalItemsOfBlueprint(potato.itemBlueprint);
var takePotatoes = Math.Min(potatoesTodo, potatoesAvailable);
inventory.TryRemoveAllItems(new ItemInstance
{ blueprint = potato.itemBlueprint, amount = takePotatoes }); // should not fail
potato.potatoesWanted -= takePotatoes;
potatoesTodo = potato.potatoesWanted - potato.potatoesBrought;
var isComplete = potatoesTodo <= 0;
var wasSomeDelivered = takePotatoes > 0;
if (isComplete)
{
await DialogicStarter.Dialog("YeliPotatoThankYou"); // "thanks for bringing me all the potatoes"
potato.state = PotatoQuest.State.Done;
}
else
{
DialogicStarter.SetValue("potatoes", potatoesTodo); // setzt die Dialogic variable
if (wasSomeDelivered)
{
await DialogicStarter.Dialog("YeliPotatoThanksButMore"); // "thank you but i need {potatoes} more potatoes"
}
else
{
await DialogicStarter.Dialog("YeliPotatoMore"); // "I still need {potatoes} more potatoes"
}
}
}
else
{
await DialogicStarter.Dialog("YeliDefault"); // "I'm happy to have you around" oder so
}
}
}

@ -0,0 +1,9 @@
using Babushka.scripts.CSharp.GameEntity.Entities;
namespace Babushka.scripts.CSharp.mock;
public partial class YeliNpc : Entity
{
public bool isSleeping = false;
}
Loading…
Cancel
Save