Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actuallmbarns

Posted 08 January 2013 - 10:43 AM

Thanks for the responses.  I ended up with 2 arrays before coming back here, but should probably rewrite it to use a list and just add/remove the reference from the single list.

 

The array just holds 30 integers, 0-29, of the possible objects. If it's the first time the player loads the game it will load all 30 objects. As the player "activates" them, the number of that object is added to the second array, then I simply sort it, loop through and set that model's reference in the first array to null, then when it loads I simply loop through the first and for each model index that isn't null, instantiate the object.

 

So say i've activated activatedArray[ 5, 3, 8, 9,], then in the other array I go potentialArray[activatedArray[5]] = null, for each of 5,3,8,9.  ...seems to work. Maybe it's slow but it only runs once when the game is loaded only.

 

I am using a string so I can store the entire thing in 1 entry in either memory or xml, then I split it at the commas and int.Parse() it when I read it back into the game...is that really really really slow or just potential for it to mess up? This is for android.

 

Yesterday I got an xml storage working so I might switch to that, but I'm wondering if memory on mobiles is alright to use for storage...can users edit that like they can on a PC? I was under the impression the values stay in memory even if the app is uninstalled on mobile, so it's not likely for a player to delete/edit the values...??


#1lmbarns

Posted 08 January 2013 - 10:42 AM

I ended up with 2 arrays, but should probably rewrite it to use a list and just add/remove the reference from the single list.

 

The array just holds 30 integers, 0-29, of the possible objects. If it's the first time the player loads the game it will load all 30 objects. As the player "activates" them, the number of that object is added to the second array, then I simply sort it, loop through and set that model's reference in the first array to null, then when it loads I simply loop through the first and for each model index that isn't null, instantiate the object.

 

So say i've activated activatedArray[ 5, 3, 8, 9,], then in the other array I go potentialArray[activatedArray[5]] = null, for each of 5,3,8,9.  ...seems to work. Maybe it's slow but it only runs once when the game is loaded only.

 

I am using a string so I can store the entire thing in 1 entry in either memory or xml, then I split it at the commas and int.Parse() it when I read it back into the game...is that really really really slow or just potential for it to mess up? This is for android.

 

Yesterday I got an xml storage working so I might switch to that, but I'm wondering if memory on mobiles is alright to use for storage...can users edit that like they can on a PC? I was under the impression the values stay in memory even if the app is uninstalled on mobile, so it's not likely for a player to delete/edit the values...??


PARTNERS