You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/CSharp/mock/YeliDialog.cs

66 lines
2.6 KiB

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
}
}
}