Ejemplo n.º 1
0
    public void Init()
    {
        List <NarrationInfo> narrationInfoList = CsvUtil.LoadObjects <NarrationInfo>("narration.csv");

        narrationDictionary = new Dictionary <string, List <NarrationInfo> >();
        foreach (NarrationInfo info in narrationInfoList)
        {
            if (!info.isVisibleForTest && CheatSettings.Instance.skipTestingNarrations)
            {
                continue;
            }
            string   identifier      = info.identifier;
            string[] splitIdentifier = info.identifier.Split('_');
            if (splitIdentifier.Length > 2)
            {
                Debug.LogError("narration identifier format is wrong " + info.identifier);
            }
            if (splitIdentifier.Length == 2)
            {
                identifier = splitIdentifier[0];
            }
            if (!narrationDictionary.ContainsKey(identifier))
            {
                narrationDictionary[identifier] = new List <NarrationInfo>();
            }
            narrationDictionary[identifier].Add(info);
        }
    }
Ejemplo n.º 2
0
    public void TestLoadMultiWithSpacesInHeader()
    {
        // Header first, then N values
        // #Field headers are ignored
        // This time we don't want any prefixing since not trimmed
        string csvData = @"String Field, FloatField ,#Description, Int  Field ,   EnumField
""This,has,commas,in it"",2.34,Something ignored,35,Red
Hello World,256.25,""Notes here"",10003,Purple
Zaphod Beeblebrox,3.1,""Amazingly amazing"",000359,Green";

        List <TestObject> objs;

        using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(csvData)))
        {
            using (var sr = new StreamReader(ms))
            {
                objs = CsvUtil.LoadObjects <TestObject>(sr);
            }
        }

        TestObject t = objs[0];

        t = objs[1];
        t = objs[2];
    }
Ejemplo n.º 3
0
    public void Init()
    {
        List <NarrativeInfo> narrativeInfoList = CsvUtil.LoadObjects <NarrativeInfo>("narrative.csv");

        narrativeActionDictionary   = new Dictionary <string, HashSet <NarrativeAction> >();
        narrativeInfoDictionary     = new Dictionary <string, NarrativeInfo>();
        enabledNarrativeActionNames = new HashSet <string>();
        enabledNarrativeActions     = new HashSet <NarrativeAction>();
        activeNarrativeActions      = new List <NarrativeAction>();
        foreach (NarrativeInfo info in narrativeInfoList)
        {
            narrativeInfoDictionary[info.identifier] = info;
            System.Type     narrativeType = System.Type.GetType(info.narrativeAction);
            NarrativeAction action        = (NarrativeAction)System.Activator.CreateInstance(narrativeType, info);
            Achievement     achievement   = AchievementManager.Instance.achievementDictionary[info.achievement];
            if (achievement.state == AchievementState.complete)
            {
                continue;
            }
            if (achievement.state == AchievementState.active)
            {
                activeNarrativeActions.Add(action);
            }
            if (!narrativeActionDictionary.ContainsKey(info.achievement))
            {
                narrativeActionDictionary[info.achievement] = new HashSet <NarrativeAction>();
            }
            narrativeActionDictionary[info.achievement].Add(action);
        }
    }
    public void ReadCSV()
    {
        bugableObjectFunctionInfoList           = CsvUtil.LoadObjects <BugableObjectFunctionInfo>("bugableObjectFunction.csv");
        enabledBugableObjectFunctionInfoDict    = new Dictionary <string, List <BugableObjectFunctionInfo> >();
        notEnabledBugableObjectFunctionInfoDict = new Dictionary <string, List <BugableObjectFunctionInfo> >();
        foreach (BugableObjectFunctionInfo info in bugableObjectFunctionInfoList)
        {
            if (!enabledBugableObjectFunctionInfoDict.ContainsKey(info.objectId))
            {
                enabledBugableObjectFunctionInfoDict[info.objectId]    = new List <BugableObjectFunctionInfo>();
                notEnabledBugableObjectFunctionInfoDict[info.objectId] = new List <BugableObjectFunctionInfo>();
            }

            //ReadDatabase(info);
            string prerequisiteString = info.prerequisite;
            if (prerequisiteString.Length != 0)
            {
                //Debug.Log("prerequisite for function " + info.identifier + " is " + prerequisiteString);
                Achievement prerequisite = AchievementManager.Instance.achievementDictionary[prerequisiteString];
                if (prerequisite.state != AchievementState.complete)
                {
                    notEnabledBugableObjectFunctionInfoDict[info.objectId].Add(info);
                    continue;
                }
            }
            enabledBugableObjectFunctionInfoDict[info.objectId].Add(info);
        }
        //Debug.Log("finish load bugableObjectFunction.csv");
    }
Ejemplo n.º 5
0
    bool LoadAll(string path)
    {
        // load & make a table with GreetingWords csv
        var loadGreetingWords = CsvUtil.LoadObjects <GreetingWords>(path + "TestDataForCSV - GreetingWords.csv");

        _greetingWords = new Dictionary <string, GreetingWords>();
        for (int i = 0; i < loadGreetingWords.Count; i++)
        {
            _greetingWords.Add(loadGreetingWords[i].Key, loadGreetingWords[i]);
        }

        // load & make a table with defaultValue csv
        var LoadDefault = CsvUtil.LoadObjects <DefaultValue>(path + "TestDataForCSV - DefaultValue.csv");

        _defaultValue = new Dictionary <int, DefaultValue>();
        foreach (var info in LoadDefault)
        {
            _defaultValue.Add(info.id, info);
        }

        //ksh
        var loadKshWords = CsvUtil.LoadObjects <KshWords>(path + "TestDataKSH.csv");

        _kshWords = new Dictionary <string, KshWords>();
        for (int i = 0; i < loadKshWords.Count; i++)
        {
            _kshWords.Add(loadKshWords[i].Key, loadKshWords[i]);
        }

        return(true);
    }
Ejemplo n.º 6
0
 public void Reload()
 {
     m_UseStars.Clear();
     if (File.Exists(m_ArchiveFilePath))
     {
         m_UseStars = CsvUtil.LoadObjects <UseStarInfo>(m_ArchiveFilePath);
     }
 }
Ejemplo n.º 7
0
 void InitCSV()
 {
     todoListInfoDictionary = new Dictionary <string, TodoListInfo>();
     todoListList           = CsvUtil.LoadObjects <TodoListInfo>("todoList.csv");
     foreach (TodoListInfo todoListInfo in todoListList)
     {
         todoListInfoDictionary[todoListInfo.identifier] = todoListInfo;
     }
 }
Ejemplo n.º 8
0
    void InitAchievementStep()
    {
        achievementStepInfoDictionary = new Dictionary <string, AchievementStepInfo>();
        List <AchievementStepInfo> achievementStepInfoList = CsvUtil.LoadObjects <AchievementStepInfo>("achievementStep.csv");

        foreach (AchievementStepInfo info in achievementStepInfoList)
        {
            achievementStepInfoDictionary[info.identifier] = info;
        }
    }
Ejemplo n.º 9
0
 //private void Start()
 //{
 //    ReadCSV();
 //    //ReadDatabase();
 //}
 void ReadCSV()
 {
     //Debug.Log("read csv for bugableObjectManager");
     bugableObjectInfoList = CsvUtil.LoadObjects <BugableObjectInfo>("bugableObject.csv");
     bugableObjectInfoDict = new Dictionary <string, BugableObjectInfo>();
     foreach (BugableObjectInfo info in bugableObjectInfoList)
     {
         bugableObjectInfoDict[info.identifier] = info;
     }
     Debug.Log("finish load bugableObject.csv");
 }
Ejemplo n.º 10
0
    void InitAchievements()
    {
        achievementDictionary     = new Dictionary <string, Achievement>();
        achievementStepDictionary = new Dictionary <string, AchievementStep>();
        List <AchievementInfo> achievementInfoList = CsvUtil.LoadObjects <AchievementInfo>("achievement.csv");

        foreach (AchievementInfo achievementInfo in achievementInfoList)
        {
            Achievement achievement = new Achievement(achievementInfo);
            achievementDictionary[achievementInfo.identifier] = achievement;
        }
    }
Ejemplo n.º 11
0
        static void test01()
        {
            System.IO.Directory.SetCurrentDirectory("D:\\Dpan\\workspace\\C#\\ConsoleApp1\\ConsoleApp1\\");
            CsvUtil <Student> csvUtil = new CsvUtil <Student>();
            List <Student>    list    = csvUtil.LoadObjects("student.csv");

            foreach (Student stu in list)
            {
                //Console.Write("id:" + stu.Id + " name :" + stu.Name+"\n" );
            }
            csvUtil.SaveObjects(list, "student2.csv");
        }
Ejemplo n.º 12
0
 public void Reload()
 {
     m_Days.Clear();
     if (File.Exists(m_ArchiveFilePath))
     {
         m_Days = CsvUtil.LoadObjects <DayInfo>(m_ArchiveFilePath);
     }
     foreach (DayInfo day in m_Days)
     {
         day.Init();
     }
 }
Ejemplo n.º 13
0
    public void Init()
    {
        List <NarrativeInfo> narrativeInfoList = CsvUtil.LoadObjects <NarrativeInfo>("narrative.csv");

        narrativeActionDictionary = new Dictionary <string, HashSet <NarrativeAction> >();
        enabledNarrativeActions   = new HashSet <string>();
        activeNarrativeActions    = new List <NarrativeAction>();
        foreach (NarrativeInfo info in narrativeInfoList)
        {
            System.Type     narrativeType = System.Type.GetType(info.narrativeAction);
            NarrativeAction action        = (NarrativeAction)System.Activator.CreateInstance(narrativeType, info);
            if (!narrativeActionDictionary.ContainsKey(info.achievement))
            {
                narrativeActionDictionary[info.achievement] = new HashSet <NarrativeAction>();
            }
            narrativeActionDictionary[info.achievement].Add(action);
        }
    }
Ejemplo n.º 14
0
    // Start is called before the first frame update
    public void Init()
    {
        DontDestroyOnLoad(gameObject);
        stageInfoList = CsvUtil.LoadObjects <StageInfo>("stage.csv");
        List <LevelInfo> levelInfoList = CsvUtil.LoadObjects <LevelInfo>("level.csv");

        levelInfoByStageId    = new Dictionary <string, List <LevelInfo> >();
        levelInfoByIdentifier = new Dictionary <string, LevelInfo>();
        stageInfoByIdentifier = new Dictionary <string, StageInfo>();
        stageUnlockDict       = new Dictionary <string, bool>();
        levelUnlockDict       = new Dictionary <string, bool>();
        levelToNextLevel      = new Dictionary <string, string>();
        string lastLevelId = null;

        foreach (StageInfo stageInfo in stageInfoList)
        {
            levelInfoByStageId[stageInfo.identifier]    = new List <LevelInfo>();
            stageInfoByIdentifier[stageInfo.identifier] = stageInfo;
        }
        foreach (LevelInfo levelInfo in levelInfoList)
        {
            if (!levelInfoByStageId.ContainsKey(levelInfo.stageIdentifier))
            {
                Debug.LogError("stage id " + levelInfo.stageIdentifier + " does not exist on level " + levelInfo.identifier);
                continue;
            }

            levelInfoByIdentifier[levelInfo.identifier] = levelInfo;
            levelInfoByStageId[levelInfo.stageIdentifier].Add(levelInfo);

            if (lastLevelId != null)
            {
                levelToNextLevel[lastLevelId] = levelInfo.identifier;
            }
            lastLevelId = levelInfo.identifier;
        }
    }
Ejemplo n.º 15
0
 void ReadCSV()
 {
     levelInfoList = CsvUtil.LoadObjects <LevelInfo>("level.csv");
 }
Ejemplo n.º 16
0
 void ReadCSV()
 {
     monsterInfoList = CsvUtil.LoadObjects <MonsterInfo>("monster.csv");
 }
Ejemplo n.º 17
0
 void ReadCSV()
 {
     abilityInfoList = CsvUtil.LoadObjects <AbilityInfo>("ability.csv");
 }
Ejemplo n.º 18
0
 void ReadCSV()
 {
     itemInfoList = CsvUtil.LoadObjects <ItemInfo>("item.csv");
 }