示例#1
0
            public void Generate(string json, Dictionary <string, Data> baseTable)
            {
                if (mEntries != null)
                {
                    return;
                }

                List <Entry> tableEntries = EntryList.FromJSON(json);

                mEntries = new Dictionary <string, Data>(tableEntries.Count);

                foreach (Entry entry in tableEntries)
                {
                    string[] parms = null;

                    //if no params, grab from base
                    if (entry.param == null && baseTable != null)
                    {
                        Data dat;
                        if (baseTable.TryGetValue(entry.key, out dat))
                        {
                            parms = dat.param;
                        }
                    }
                    else
                    {
                        parms = entry.param;
                    }

                    mEntries.Add(entry.key, new Data(entry.text, parms));
                }

                //append platform specific entries
                if (platforms != null)
                {
                    TableDataPlatform platform = null;
                    foreach (TableDataPlatform platformDat in platforms)
                    {
                        if (platformDat.platform == Application.platform)
                        {
                            platform = platformDat;
                            break;
                        }
                    }

                    //override entries based on platform
                    if (platform != null)
                    {
                        List <Entry> platformEntries = EntryList.FromJSON(platform.file.text);

                        foreach (Entry platformEntry in platformEntries)
                        {
                            Data dat;
                            if (mEntries.TryGetValue(platformEntry.key, out dat))
                            {
                                dat.text = platformEntry.text;
                                if (platformEntry.param != null)
                                {
                                    dat.param = platformEntry.param;
                                }

                                mEntries[platformEntry.key] = dat;
                            }
                            else
                            {
                                mEntries.Add(platformEntry.key, new Data(platformEntry.text, platformEntry.param));
                            }
                        }
                    }
                }
            }