//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // PUBLIC
    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // @Brief : Csv Load
    // @Param : pPath           => Asset path
    //        : bFromResources  => From resources file
    public static KrCsvData Load(string pPath, bool bFromResources)
    {
        KrCsvData    pCsvData      = new KrCsvData();
        StreamReader pStreamReader = KrResources.LoadText(pPath, bFromResources);

        KrDebug.Log("Load csv. path = " + pPath, typeof(KrCsvData));
        if (pStreamReader.Peek() > -1)
        {
            string pOneLineColumnNames = pStreamReader.ReadLine();
            KrDebug.Log("ColumnName = " + pOneLineColumnNames, typeof(KrCsvData));
            // Setting column names
            string[] pColmnNames = pOneLineColumnNames.Split(new char[] { ',' });
            pCsvData.SetColumnNames(pColmnNames);
        }

        string pOneLineValues = "";

        while (pStreamReader.Peek() > -1)
        {
            pOneLineValues += pStreamReader.ReadLine();
            // Setting values
            string[] pSplit = pOneLineValues.Split(new char[] { ',' });
            if (pSplit.Length >= pCsvData.GetColumnNum())
            {
                //Csv treats " as two minutes
                pOneLineValues = pOneLineValues.Replace("\"\"", "\"");
                KrDebug.Log(pOneLineValues, typeof(KrCsvData));
                pCsvData.SetRow(pSplit);
                pOneLineValues = "";
            }
            else
            {
                pOneLineValues += System.Environment.NewLine;
            }
        }
        pStreamReader.Close();

        return(pCsvData);
    }
Beispiel #2
0
    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // PUBLIC FUNCTION
    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // @Brief : Load scenario
    // @Param : pKey    => Key to register csv
    //          pPath   => Csv path
    public void LoadScenario(string pKey, string pPath)
    {
        KrCsvData pCsvData = KrCsvLoader.Load(KrCharagekiDef.s_pASSET_BASE_PATH + pPath, KrCharagekiDef.IsLoadingFromResources());

        m_pScenarioDataDic.Add(pKey, pCsvData);
    }
Beispiel #3
0
 // @Brief : Set the current scenario
 // @Param : pKey    => csv registered key
 public void SettingScenario(string pKey)
 {
     m_pCurrentScenario = m_pScenarioDataDic[pKey];
 }
Beispiel #4
0
    private KrCsvData m_pCurrentScenario = null;                                // currently set scenario

    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // CONSTRUCTOR
    //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // @Brief  : Constructor
    // @Return : KrCharagekiScenarioContainer instance
    public KrCharagekiScenarioContainer()
    {
        m_pScenarioDataDic = new Dictionary <string, KrCsvData>();
        m_pCurrentScenario = null;
    }