Saturday, June 7, 2014

Project "You Are A CEO"

It's my first project to do native integration. Have you played Mafia Wars ?  Its a point and click RPG. And mix this game with a little modern farmville. And what product you get out of it polish it and integrate this with android ios and web. That's my project. Its called "You Are A CEO".
       
                                               
                                And my part in this project was to make a "Estate" where the person can see his assets. Can see what level he has reached. And there are some perks which get unlocked when he gradually progress in game.
      A 2D isometric game scene, where the user can place the buildings. It's my first very successful attempt for a 2D isometric scene. Here are few steps I would like to share:
  • Use Orthographic camera projection. And make sure you have all the building assets as a 2D art(.PNG). Yeha! one more point make sure this art is created considering the isometric projection. If you get a good artist around you he will be aware of that. And what next ? 
  • As there is no depth of field. You have to use sorting order for overlapping. And yeah for rendering those building sprites use a Sprite Renderer component.   
  • And how are we suppose to detect the user touch/click ? We use a box collider which covers whole of the sprite and the sprite object is the child of the box collider object. See the picture. 

                             
Box Collider in the empty gameobject for User input detection




Sprite Renderer component in a child object of the parent. Note the rotation of the sprite.


  • Rotate the sprite accordingly. I rotated the sprite for 53 deg on y axis. Also rotate the camera 45, 45 on x, y axis.




After fixing up everything in place. The look of the game feels great. I coded some panning and pinch and zoom functions as well. So I can plan around the plain to see where I want my building to be placed. 


Now the user data will be coming from outside. (Web, IOS, Android) So I have to make a json script where I can save the information about user. I gone through forums researching about it. Got help from some of my friends as well. And here  I share my conclusion.

  • Json is a javascript object notion. Its a convention used to exchange data and its independent of the platform. In this project I was receiving json from android, ios and web. So I made a script which takes the json string as a parameter and parse it accordingly. 
  • I attach this script to one of the object, which will be called specifically from the Native end.
Lets see how I parse the Json string.  





  

  • Firstly, deserialize whole of the data. Use IDictionary data type for that. Always remember to deserialize the data in same order the elements in the json script are coming. 
  • Create a list for each element and add the data respectively. 
  • Here by, you can start the constructors to load the user information and his buildings , unlockables, accordingly. 
                                                      There is lot of other customization and optimization I've done. Due to shortage of time I can't put all the stuff here. Still if anyone have any questions ? Please shoot at pranavpaharia@gmail.com. Thanks Renuka for coordinating in the Web version of YAAC and Smriti and Saurav in IOS version and Harminder in Android version. 





No comments:

Post a Comment