Beispiel #1
0
    public static bool Save(string tableName, SteamMode saveMode = SteamMode.AppData)
    {
        bool ReturnValue = false;

        if (!tableMap.ContainsKey(tableName))
        {
            //Warning!
            return(ReturnValue);
        }

        switch (saveMode)
        {
        case SteamMode.AppData:
            ReturnValue = tableMap[tableName].Save(string.Format("{0}{1}.csv", AppDataPath, tableName));
            break;

        case SteamMode.FireBase:
        case SteamMode.Resource:
        case SteamMode.Sample:
            Debug.Log("Not Supported : (" + tableName + ") " + saveMode);
            break;
        }

        return(ReturnValue);
    }
Beispiel #2
0
 public static Table Get(string tableName, SteamMode LoadSteam)
 {
     if (!tableMap.ContainsKey(tableName))
     {
         Table newTable = GenerateTable(tableName, LoadSteam);
         tableMap.Add(tableName, newTable);
     }
     else
     {
         if (LoadSteam == SteamMode.AppData)
         {
             Table newTable = GenerateTable(tableName, LoadSteam);
             tableMap[tableName] = newTable;
         }
     }
     return(tableMap[tableName]);
 }
Beispiel #3
0
        public bool Save(SteamMode SaveMode = SteamMode.AppData)
        {
            switch (SaveMode)
            {
            case SteamMode.AppData:
                path = (AppDataPath + name + ".csv");
                break;

            case SteamMode.Resource:
            case SteamMode.FireBase:
            case SteamMode.Sample:
                return(false);
                //break; // I know but consistency
            }

            return(Save(path));
        }
    private void _setupParticleSystems()
    {
        //some sanity checks
        if (steamPrefab == null)
        {
            return;
        }
        if (steamSpawnPoints == null || steamSpawnPoints.Length == 0)
        {
            return;
        }

        //attach a particle system on every spawnpoint
        _particleSystems = new List <ParticleSystem>();
        for (int i = 0; i < steamSpawnPoints.Length; i++)
        {
            _particleSystems.Add(Instantiate(steamPrefab, steamSpawnPoints[i], false));
        }
        if (_particleSystems.Count == 0)
        {
            steamMode = SteamMode.PLAY_NEVER;
        }
    }
Beispiel #5
0
 private static Table GenerateTable(string tableName, SteamMode LoadSteam)
 {
     return(new Table(tableName, LoadSteam));
 }
Beispiel #6
0
        public Table(string TableName, SteamMode LoadMode)
        {
            //if (Application.platform == RuntimePlatform.Android)
            //{
            //}
            //else if (Application.platform == RuntimePlatform.IPhonePlayer)
            //{
            //}
            //else
            //{
            //}

            name = TableName;

            //if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
            //{
            //    ResourcePath = "Table/";
            //    SamplePath = "Table/Sample/";
            //}
            //else
            //{
            //    ResourcePath = "Assets/StarShip/Resources/Table/";
            //    SamplePath = "Assets/StarShip/Resources/Table/Sample/";
            //}

            switch (LoadMode)
            {
            case SteamMode.FireBase:
                break;

            case SteamMode.AppData:
                path = AppDataPath;
                break;

            case SteamMode.Resource:
                path = ResourcePath;
                break;

            case SteamMode.Sample:
                path = SamplePath;
                break;
            }

            path += (TableName); //+ ".csv" );



            if (!System.IO.File.Exists(path + ".csv"))
            {
                // Create
                // 테이블 참조하는 스타일이 다르다. 지금 가정은 무조건 ㅇ=
                switch (LoadMode)
                {
                case SteamMode.FireBase:
                    // Not implemented
                    break;

                case SteamMode.AppData:
                    // 엡데이타에 없으면 샘플을 불러오자.
                    path     = SamplePath + TableName;// + ".csv";
                    LoadMode = SteamMode.Sample;
                    break;

                case SteamMode.Resource:
                    // Error! break;
                    //UnityEngine.Debug.LogWarning("The table not exist in Resource! " + TableName);
                    break;
                }
            }

            CsvFile.CsvFileReader reader;// = new CsvFile.CsvFileReader(stream)

            //Stream stream = new MemoryStream();
            //FileStream file = new FileStream();
            if (LoadMode == SteamMode.AppData)
            {
                FileStream file = new FileStream(path + ".csv", FileMode.Open);
                //file.CopyTo(stream);
                reader = new CsvFile.CsvFileReader(file);
            }
            else
            {
                TextAsset table  = Resources.Load <TextAsset>(path);
                Stream    stream = new MemoryStream(table.bytes);
                reader = new CsvFile.CsvFileReader(stream);
            }

            //CsvFile.CsvFileReader asdasd = new CsvFile.CsvFileReader(file);

            using (reader)
            {
                int           index  = 0;
                List <string> column = new List <string>();
                while (reader.ReadRow(column))
                {
                    // Column Header.
                    if (index == 0)
                    {
                        for (int i = 0; i < column.Count; i++)
                        {
                            if (column[i].Contains("s_"))
                            {
                                columnHeader.Add(column[i].Replace("s_", ""), new ColumnInfo()
                                {
                                    Index = i, Type = "string", name = column[i]
                                });
                            }
                            else if (column[i].Contains("i_"))
                            {
                                columnHeader.Add(column[i].Replace("i_", ""), new ColumnInfo()
                                {
                                    Index = i, Type = "int", name = column[i]
                                });
                            }
                            else if (column[i].Contains("f_"))
                            {
                                columnHeader.Add(column[i].Replace("f_", ""), new ColumnInfo()
                                {
                                    Index = i, Type = "float", name = column[i]
                                });
                            }
                            else if (column[i].Contains("b_"))
                            {
                                columnHeader.Add(column[i].Replace("b_", ""), new ColumnInfo()
                                {
                                    Index = i, Type = "bool", name = column[i]
                                });
                            }
                            else
                            {
                                columnHeader.Add(column[i], new ColumnInfo()
                                {
                                    Index = i, Type = "string", name = column[i]
                                });
                            }
                        }
                    }
                    // Datas
                    else
                    {
                        rows.Add(new Row(this, column));
                    }
                    index++;
                }
            }
        }