deldam
started a topic on Sun, 08 March 2015 at 11:53 PM
I am trying to do async pvp in my game, the same way as clash of clan where you visit Cities
i have setup my game in unity this way:
Cities have Houses, Houses have guard spot
I have a database that allow me to instantiate a city prefab with all the city and guard spot already setup, only thing is guard spots are empty and i need to populate my guardspot list using a int[] guardIDList, I use the ID to have the prefab reference id my guard Database, now my problem is the docs do not explain how to use JSON in unity: https://api.playfab.com/Documentation/Client/method/UpdateUserData
using UnityEngine;
using System.Collections;
public class LoadPlayerCity : MonoBehaviour
{
private Manager _m;
void Start()
{
_m = Manager.Instance;
}
public class CityData
{
}
public void LoadPlayerCityPvp(int cityID,CityData cityData)
{
GameObject newCity = Instantiate (_m.db_City.GetByID (cityID).prefab);
City cityScript = newShip.GetComponent<City> ();
//do serialization stuff here with cityData
int serializedValue; //need to write a list of int here if value= 0 we considere it null so we do not load module
//populate the rooms
for (int i =0; i<cityScript.houseList.Count; i++)
{
//populate the slots
for (int s =0; s<cityScript.houseList[i].slotList.Count; s++)
{
if(serializedValue != 0)
{
cityScript.houseList[i].slotList[s].currentGuard = Instantiate (_m.db_guard.GetByID (serializedValue).prefab) as guardSlots;
}
}
}
}
}