|
Search for "FIX_ME". I need to know what to do with the var inventory : Array, because only Javascript can use that class. And there's one issue with FIX_ME newItem= new InventoryItem(). I think that might need "InventoryItem" before it, but I'm not sure. Original Javascipt C#
(comments are locked)
|
|
They are implicitly creating an array of arrays, so you have a few options:
If you using a list then you will have to make some other adjustments to match the syntax of a list. Just looking at the js, it doesn't look like they resize the array except for the beginning so I would choose any of the first three. Numbers 4 and 5 though would be a little confusing for what you are trying to do so I would probably avoid them since there isn't really any reason in your example to switch types so it would just look strange. And your other line looks ok since type inference should be able to figure out the type from the right hand side of the assignment operator. Deserves a good review. Thanks CSDG
May 26 '11 at 08:38 PM
UniteMage
(comments are locked)
|
|
in C# you need to strictly type your array- from what I saw, it's an array of type InventoryItem, so you'd define it like: InventoryItem [] inventory; // this will create an uninitialized InventoryItem array. Although for something like this that may have dynamic sizes attributed to it, you may want to consider using a list instead. Also, here's a useful read on arrays/lists/hashtables, etc:
(comments are locked)
|
|
This is a conversion of Der Dude's JavaScript code. I noticed you removed/changed some things in the OnGUI function. But here is his code converted for C#. The only addition I made was the "isInventoryOpen" boolean which you'll have to implement somewhere with a keypress or what have you. (You'll notice the class name is different, InventoryTestCS) Also...this is a bit clunky. Lists would work best, but As long as you don't edit the size of the inventory in real-time, you should be okay. Also, if you are looking for a conversion of the InventoryWorldItem here it is: Thank you so much Thunder, saved me a lot of time ! you are awesome !
Jan 19 at 11:09 PM
ElectroSphere
(comments are locked)
|

You may want to repost/re-format your code. Not many are going to look at it like that so spaced out.
It's only really two lines that need looked at: "var inventory : Array;" to C#, and "var newItem = new InventoryItem();" to C#.