diff --git a/.idea/.idea.Babushka/.idea/dictionaries/project.xml b/.idea/.idea.Babushka/.idea/dictionaries/project.xml new file mode 100644 index 0000000..4787784 --- /dev/null +++ b/.idea/.idea.Babushka/.idea/dictionaries/project.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/scripts/CSharp/mock/DialogicStarter.cs b/scripts/CSharp/mock/DialogicStarter.cs new file mode 100644 index 0000000..8322db0 --- /dev/null +++ b/scripts/CSharp/mock/DialogicStarter.cs @@ -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 + } +} \ No newline at end of file diff --git a/scripts/CSharp/mock/ObjectLookup.cs b/scripts/CSharp/mock/ObjectLookup.cs new file mode 100644 index 0000000..564fa8c --- /dev/null +++ b/scripts/CSharp/mock/ObjectLookup.cs @@ -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; +} \ No newline at end of file diff --git a/scripts/CSharp/mock/PotatoQuest.cs b/scripts/CSharp/mock/PotatoQuest.cs new file mode 100644 index 0000000..dac80c3 --- /dev/null +++ b/scripts/CSharp/mock/PotatoQuest.cs @@ -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; + } +} \ No newline at end of file diff --git a/scripts/CSharp/mock/PotatoQuest.cs.uid b/scripts/CSharp/mock/PotatoQuest.cs.uid new file mode 100644 index 0000000..b53cdde --- /dev/null +++ b/scripts/CSharp/mock/PotatoQuest.cs.uid @@ -0,0 +1 @@ +uid://dpl5xeuiu7cwg diff --git a/scripts/CSharp/mock/YeliDialog.cs b/scripts/CSharp/mock/YeliDialog.cs new file mode 100644 index 0000000..e64e139 --- /dev/null +++ b/scripts/CSharp/mock/YeliDialog.cs @@ -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 + } + } +} \ No newline at end of file diff --git a/scripts/CSharp/mock/YeliDialog.cs.uid b/scripts/CSharp/mock/YeliDialog.cs.uid new file mode 100644 index 0000000..11ce4da --- /dev/null +++ b/scripts/CSharp/mock/YeliDialog.cs.uid @@ -0,0 +1 @@ +uid://ssob0ssvbskx diff --git a/scripts/CSharp/mock/YeliNpc.cs b/scripts/CSharp/mock/YeliNpc.cs new file mode 100644 index 0000000..4d27348 --- /dev/null +++ b/scripts/CSharp/mock/YeliNpc.cs @@ -0,0 +1,9 @@ +using Babushka.scripts.CSharp.GameEntity.Entities; + +namespace Babushka.scripts.CSharp.mock; + +public partial class YeliNpc : Entity +{ + public bool isSleeping = false; + +} \ No newline at end of file