简体   繁体   中英

Dynamically Loading Settings In Silverlight

I have a simple game I'm working on, written in Silverlight. What I'm trying to do is allow changes to the games appearance (the images used, the sounds played, and the location of objects in the game) without modifying or recompiling any of the Silverlight code.

The approach I'm trying to take is passing in an 'ID' to the Silverlight object. That ID gets injected into the URLs for all of the resources.

http://myServer.com/MyGame/1/Images/1.png

If I make another HTML page and pass in a GameID of 2 I get an entirely different set of images and sounds. That part appears to be working correctly (even if it is misguided).

But I also have some configuration items like the position of certain things on the screen and some rules that affect gameplay. I wanted to throw this into a XML file and have the game load the file using the same approach for Images and Sounds - but I can't seem to get it to work. I haven't found any way to download a file synchronously.

I had some ideas - making my own 'Loading screen' downloading the file asynchronously, reading the file/setting up the game, letting the game start. But it I get the feeling I might be reinventing the wheel or doing something that's just silly.

Is there a better way to accomplish this?

To some degree yes you would be re-inventing the wheel but the wheel you're re-inventing is not a particularly complex one. If you were creating a line of business app you would probably use the BusyIndicator control for the Silverlight toolkit. This control allows some "Loading..." UI to be presented while significant background activity runs.

You could use this as a starting point, however you would probably want to replace its default style and specifically the default template in the style to present UI in keeping with your game's graphics.

However including the toolkit just for this function may not be a good trade-off. Having created your own template it would be very easy to then re-create the very simple control that sits behind the template. So yes you would have re-created the wheel but most of the effort would be in the graphics unique to your game anyway and the rest might be a worthwhile trade off for not having to include a toolkit dll in your project.

只要用户知道“事情”正在进展/继续他们会很高兴的,我认为加载屏幕是完全可以接受的,尤其是在游戏社区,几乎每个游戏都要求您等待地图等加载时

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM