I'm trying to figure out how to implement C# scripting into my XNA game. How do I call functions that take more than one frame to finish?
For example:
class UserScript : Script
{
public override void execute(Game game)
{
//script must wait for dialog to be closed
game.openDialog("This is a dialog");
//script should'nt wait for this
int goldToGive = 100;
goldToGive += 100;
game.addGold(goldToGive);
//
//script should wait for cinematic to end
game.startCinematic("name_of_cinematic");
//doesn't wait
game.addGold(100);
}
}
I found a question that suggests you can do it with yield
, but I'm not sure if it's the correct way, as the referenced article is from 2010, and no longer exists. Is using yield
the answer? If so, how do I use it? If not, should I take a differant approach, or am I better off with multi-threading?