//for getting table data
    public void Next(string table, string json)
    {
        switch (table)
        {
        case TableNames.INDUSTRY:
            JsonIndustryData id = (JsonIndustryData)JsonDataManager.FromJson(TableNames.INDUSTRY, json);
            game.jsonIndustryData = id;
            break;

        case TableNames.INDUSTRY_DEMAND:
            JsonIndustryDemandData did = (JsonIndustryDemandData)JsonDataManager.FromJson(TableNames.INDUSTRY_DEMAND, json);
            game.jsonIndustryDemandData = did;
            break;

        case TableNames.SECTOR:
            JsonSectorData sd = (JsonSectorData)JsonDataManager.FromJson(TableNames.SECTOR, json);
            game.jsonSectorData = sd;
            break;

        case TableNames.G_SIMULATION:
            JsonGSimulationData gsd = (JsonGSimulationData)JsonDataManager.FromJson(TableNames.G_SIMULATION, json);
            game.jsonGSimulationData = gsd;
            break;

        case TableNames.U_SIMULATION:
            JsonUSimulationData usd = (JsonUSimulationData)JsonDataManager.FromJson(TableNames.U_SIMULATION, json);
            game.jsonUSimulationData = usd;
            break;

        case TableNames.SITUATION:
            JsonSituationData sitd = (JsonSituationData)JsonDataManager.FromJson(TableNames.SITUATION, json);
            game.jsonSituationData = sitd;
            break;

        case TableNames.STRATEGIC_MOVE:
            JsonStrategicMoveData smd = (JsonStrategicMoveData)JsonDataManager.FromJson(TableNames.STRATEGIC_MOVE, json);
            game.jsonStrategicMoveData = smd;
            break;

        case TableNames.DILEMMA:
            JsonDilemmaData dd = (JsonDilemmaData)JsonDataManager.FromJson(TableNames.DILEMMA, json);
            game.jsonDilemmaData = dd;
            break;

        case TableNames.EVENT:
            JsonEventData ed = (JsonEventData)JsonDataManager.FromJson(TableNames.EVENT, json);
            game.jsonEventData = ed;
            break;

        case TableNames.DILEMMA_EFFECT:
            JsonDilemmaEffectData ded = (JsonDilemmaEffectData)JsonDataManager.FromJson(TableNames.DILEMMA_EFFECT, json);
            game.jsonDilemmaEffectData = ded;
            break;

        case TableNames.INDICATOR:
            JsonIndicatorData ind = (JsonIndicatorData)JsonDataManager.FromJson(TableNames.INDICATOR, json);
            game.jsonIndicatorData = ind;
            break;

        case TableNames.LOCATION:
            JsonLocationData ld = (JsonLocationData)JsonDataManager.FromJson(TableNames.LOCATION, json);
            game.jsonLocationData = ld;
            break;

        case TableNames.INDUSTRY_TOTAL:
            JsonIndustryTotalData itd = (JsonIndustryTotalData)JsonDataManager.FromJson(TableNames.INDUSTRY_TOTAL, json);
            game.jsonIndustryTotalData = itd;
            break;

        case TableNames.INFLUENCE_LIST:
            game.jsonInfluenceListData = (JsonInfluenceListData)JsonDataManager.FromJson(TableNames.INFLUENCE_LIST, json);
            break;

        default:
            Debug.Log("Next() Table not Found: " + table);
            break;
        }

        Load();
    }
Beispiel #2
0
    //Return value is generic JsonData so that any kind of extended class Json___Data can be returned
    public static JsonData FromJson(string table, string json)
    {
        //String table nalang (kasi obtainable thru DB sya) wag na yung TYPE shits ganun rin naman, extend options here maybe.
        //Transform from GENERIC to SPECIFIC
        // JsonData jsonData = null;

        json = RevertPrimaryKey(json, table);
        Debug.Log("getting from table..: " + table);
        try
        {
            switch (table)
            {
            case "books":
                json = "{\"booksData\":" + json + "}";
                JsonBookData jsonbData = JsonUtility.FromJson <JsonBookData>(json);
                return(jsonbData);

            case TableNames.INDUSTRY:
                json = "{\"industryData\":" + json + "}";
                JsonIndustryData jsonIndustryData = JsonUtility.FromJson <JsonIndustryData>(json);
                return(jsonIndustryData);

            case TableNames.INDUSTRY_DEMAND:
                json = "{\"industryDemandData\":" + json + "}";
                JsonIndustryDemandData jsonIndustryDemandData = JsonUtility.FromJson <JsonIndustryDemandData>(json);
                return(jsonIndustryDemandData);

            case TableNames.SECTOR:
                json = "{\"sectorData\":" + json + "}";
                JsonSectorData jsonSectorData = JsonUtility.FromJson <JsonSectorData>(json);
                return(jsonSectorData);

            case TableNames.G_SIMULATION:
                json = "{\"gSimulationData\":" + json + "}";
                JsonGSimulationData jsonGSimulationData = JsonUtility.FromJson <JsonGSimulationData>(json);
                return(jsonGSimulationData);

            case TableNames.U_SIMULATION:
                json = "{\"uSimulationData\":" + json + "}";
                JsonUSimulationData jsonUSimulationData = JsonUtility.FromJson <JsonUSimulationData>(json);
                return(jsonUSimulationData);

            case TableNames.SITUATION:
                json = "{\"situationData\":" + json + "}";
                JsonSituationData jsonSituationData = JsonUtility.FromJson <JsonSituationData>(json);
                return(jsonSituationData);

            case TableNames.STRATEGIC_MOVE:
                json = "{\"strategicMoveData\":" + json + "}";
                JsonStrategicMoveData jsonStrategicMoveData = JsonUtility.FromJson <JsonStrategicMoveData>(json);
                return(jsonStrategicMoveData);

            case TableNames.DILEMMA:
                json = "{\"dilemmaData\":" + json + "}";
                JsonDilemmaData jsonDilemmaData = JsonUtility.FromJson <JsonDilemmaData>(json);
                return(jsonDilemmaData);

            case TableNames.EVENT:
                json = "{\"eventData\":" + json + "}";
                JsonEventData jsonEventData = JsonUtility.FromJson <JsonEventData>(json);
                return(jsonEventData);

            case TableNames.DILEMMA_EFFECT:
                json = "{\"dilemmaEffectData\":" + json + "}";
                JsonDilemmaEffectData jsonDilemmaEffectData = JsonUtility.FromJson <JsonDilemmaEffectData>(json);
                return(jsonDilemmaEffectData);

            case TableNames.INDICATOR:
                json = "{\"indicatorData\":" + json + "}";
                JsonIndicatorData jsonIndicatorData = JsonUtility.FromJson <JsonIndicatorData>(json);
                return(jsonIndicatorData);

            case TableNames.LOCATION:
                json = "{\"locationData\":" + json + "}";
                JsonLocationData jsonLocationData = JsonUtility.FromJson <JsonLocationData>(json);
                return(jsonLocationData);

            case TableNames.INDUSTRY_TOTAL:
                json = "{\"industryTotalData\":" + json + "}";
                JsonIndustryTotalData jsonIndustryTotalData = JsonUtility.FromJson <JsonIndustryTotalData>(json);
                return(jsonIndustryTotalData);

            case TableNames.INFLUENCE_LIST:
                json = "{\"influenceListData\":" + json + "}";
                JsonInfluenceListData jsonInfluenceListData = JsonUtility.FromJson <JsonInfluenceListData>(json);
                return(jsonInfluenceListData);

            default:
                Debug.Log("Table not Found: " + table);
                return(null);
            }
            ;
        }
        catch
        {
            Debug.Log("error during database get: " + table);
            return(null);
        }
    }