Hot answers tagged

9

Im late to the party here but I spent A-LOT of time researching this. First why I don't use the following: XML: Excessively verbose. Tons of redundancy. Repeating field names? GROSS JSON: I think JSON is great for a UI layout but for a database, hell no. It will have the same problems as XML, redundancy, and deep nesting. GROSS. SQL: This is a great ...


5

You'll want to use a List. Probably a List<InventoryItem> or similar. The documentation for List<T> is here. Here is a set of answers on how to serialize a list to XML (you didn't say how you were saving your XML - this link gives you some options). An XML file can store the list of items "inline", so it might end up something like: <...


3

I would look heavily into state machines and deserializing the XML data into state instances. You can create class definition for a condition, be that an integer on an item for it's int brightness = 4; value or a string name = "torch"; in the inventory. Something along these lines: public enum ConditionType{ default, itemLevelReq, itemEquip, ...


3

We can't answer questions like "how do they do it" because, well, we don't know, and they won't tell us. We can help you figure out a few things, though. In software development in general, unless one has prior knowledge, an approach is to build a feature that works, in isolation from the rest of the software as much as possible (i.e. reduce ...


2

Theres two basic ways to do this: The Magic Bag Containers themselves have fixed sizes, but there's no limit to your ability to put "bags" inside other "bags". Thus the only practical limit on your inventory is your ability to get more "Bags" This has the advantage that containers have fixed capacity (which might be easier to implement), and that you can "...


2

For XNA you can use isolated storage to be able to store data in a cross-platform manner. You can find the documentation here: http://msdn.microsoft.com/en-us/library/ff604992.aspx it includes an example that works on both Windows, Xbox 360 and PC. If you're only developing for Windows you can also use the normal C# IO functions like File.Create, File.Open ...


2

XML is just a data storage (or transfer) format. The XML file itself has nothing to do with rendering tilemaps. You actually need to have the data in memory in a better format suited for rendering tile maps. I think you should tackle the problem from another direction. Rather than trying to figure out how to render XML data as tile map, you should just ...


2

One wav for the whole scene can turn into a big headache if you want to alter the scene later, even a minor one. And if any of the players have a problem during the playback (memory, CPU, bug...etc), the rest of the audio will be asynchronous. Players will skip the scene or close the game without you knowing about that. Which will throw away all your ...


2

You are trying to write code to deserialize your xml file. The Xml deserialization in Xna is automatic so you do not need your XmlManager class at all. Add your Xml file (myXmlFile.xml) to your content project just like you would a texture or model. This will allow the build process to convert it from xml to serialized xnb. Now your project is aware of ...


2

Firstly, I see no issue (in principle) with the first approach, the XML file. Easily editable, easily extendable. Secondly, I would still recommend not using XML, and using JSON instead, since it's going to make the saving/loading of the stats significantly easier: [System.Serializable] public class TowerStats2 { public TowerType type; public int ...


2

Well, either one of them can be authored with existing tools, which is always a good thing. When I was making a rhythm game, I determined that it would be easier for me to just make my own format with only what I needed and no more. I actually did my transcription with Audacity label tracks, and wrote a Lua script to convert it to a Lua table that I could ...


2

LINQ expressions (Where, Select etc.) are a .NET 3.5 feature. By default, Unity only supports .NET 2.0. You could change the used version of the .NET framework in the project settings of MonoDevelop / Visual Studio. But that will prevent your game from working on certain platforms. When you want to keep compatibility with all available build targets, you ...


2

You are missing: using System.Linq; While a little out of date at this point I find the Mono Compatibility page form the 4.10 documentation to be useful. It lists IEnumarable.Where() as compatible with both .NET 2.0 and .NET 2.0 Subset.


2

The first thing to do here is consider yourself. You, just like your end users, will want to add functionality to blocks. So, think how you would most like to add the functionality. Most likely, if you find it simple and efficient, then the modders will too. JAR Files Pros More possibilities for functionality. Linking in of 3rd party libraries. Lots of ...


2

You could use JSON and zip it with a password (encrypt), then use a runtime zip library like DotNetZip to extract it for inspection by the game only, no-one else. Or you could access it on a secured server that requires login to get the file. The question boils down to, How do I secure plain text? - perhaps this form of the question will help you find the ...


2

1: TOTAL overhead. Like driving a 40 ton truck to your weekly shopping for you and your spouse. Adds a lot of memory eating high end functionality into what is essentially a configuration file. If you consider that the best fit to store some small amount of data - you really need a reality check. Or have thousands of weapons. 3: you start hating it the ...


1

You could use a datacontract. So below is how to use a datacontract with two versions of FileData ( v1 & v2 ). Comment in filedata version 1 and call testV1(). This will cause filedata version 1 to be saved Then comment in filedata version 2 and call testV2() this will cause filedata version 1 to be loaded as filedata version 2 using System.Runtime....


1

Typically, if you just want to retrieve one specific datum in an XML file (such as, e.g., the text of one specific dialog) a SAX parser will give you faster access times because it does not have to instantiate as many objects as the DOM parser does when it builds a complete tree-representation of the XML document. You say that the SAX parser has to go ...


1

Although I think @sh code 's answer is the correct way to go, I wanted to add that Unity's new prefab variant workflow is really useful for making related objects have slightly different properties. It also works great when the visuals need to match the variations in internal state, since each variant can have a different meshes or effects. You could also ...


1

I solved the problem. i removed all playstore plugin from my project, then i select Edit -> Reimport all. then I import admob plugin. them in AndroidMainfest.xml i changed "android:value="true" to android:value="false" ". <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name"> <intent-filter> &...


1

What you are trying to do is "load an asset". Here's how: http://docs.unity3d.com/Manual/AssetDatabase.html using UnityEngine; using UnityEditor; public class ImportAsset { [MenuItem ("AssetDatabase/LoadAssetExample")] static void ImportExample () { Texture2D t = AssetDatabase.LoadAssetAtPath("Assets/Textures/texture.jpg", typeof(...


1

If you want to define the positions of the buttons independant of the screen resolution, you might want to use a relative coordinate system. So a single screen is defined as a 0 (left border) to 1 (right border) and 0 (top) and 1 (bottom). So a button halfway to the screen is at 0.5 , 0.5. To calculate the actual position, multiply the axis by the screen ...


1

For the question of how to deserialize an xml file in c#, this question on stack overflow explains it pretty well: How to Deserialize XML document The gist of it is, you need to create a class for each type you are going to represent in the xml files, in the example you gave it would be event, item, item_modify and possibly battle, and define for each ...


1

Overall, yes. The answer nodes should contain the sub-questions rather than the <ops> section. The objectAction and questActivate should be sub-nodes of answers rather than attributes as one answer could have more than one action. Conditions should also be sub-nodes of questions or answers as there could be multiple conditions and can become complex....


1

Using a separate file for each line is going to be much easier to deal with. Here's why: Typically, several segments will require multiple takes, since actors stutter or misspeak. If the actors are being recorded together, you'll need to merge these takes into a final cut. If you need to change something, you'll have to edit the entire sequence (changing ...


1

Found a solution so to use the same code for both Windows and Web Player deployment (disclamer: I'm just reading these XML files): you can put the XMLs in the Resources located into the Project Assets folder. This basically tells to Unity to keep these files into the final build and you can load them at runtime using (in case of xmls for example): ...


1

In case you are using C#, you can use the XML classes from .NET. I tend to use the XPathNavigator, since most of the time you need only to read out data, and don't have to write data back. Snippet from my actual code: XPathDocument xmlFile; try { xmlFile = new XPathDocument (filePath); } catch (FileNotFoundException ex) { UnityEngine.Debug....


Only top voted, non community-wiki answers of a minimum length are eligible