c# scripting execution with xna (actions take more than 1 frame)
Posted
by
user658091
on Game Development
See other posts from Game Development
or by user658091
Published on 2012-12-08T13:01:22Z
Indexed on
2012/12/08
17:21 UTC
Read the original article
Hit count: 264
I'm trying to figure out how to implement c# scripting into my game (XNA with C#). I will be using C# as the scripting language.
My question is, how to call functions that take more than 1 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 that you can do that with yield, but I'm not sure if it's the correct way (It's from 2010, the article mentioned no longer exists). http://stackoverflow.com/questions/3540231/implementing-a-simple-xml-based-scripting-language-for-an-xna-game
Is yield the answer? If so, can anyone point me any examples/tutorials/books? I haven't found any regarding my situation.
If not, what approach should I take? or am I better off with multi-threading?
© Game Development or respective owner