123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using UnityEngine;
- using wf;
- public class ScenarioSelectMgr
- {
- public ScenarioData[] AddedScenario
- {
- get
- {
- if (this.m_AddedScenerio == null)
- {
- this.IsEventAdded();
- }
- return this.m_AddedScenerio;
- }
- }
- public bool DeserializeFiled { get; private set; }
- public float nSaveVer { get; private set; }
- private void ReadConvertData(CsvParser csv, int cy)
- {
- this.m_PersonalConvertData.Add(csv.GetCellAsString(0, cy), csv.GetCellAsString(1, cy));
- }
- public void InitScenarioData()
- {
- if (this.m_AllScenarioData.Count > 0)
- {
- return;
- }
- HashSet<int> enabled_id_list = new HashSet<int>();
- Action<string> action = delegate(string file_name)
- {
- file_name += ".nei";
- if (!GameUty.FileSystem.IsExistentFile(file_name))
- {
- return;
- }
- using (AFileBase afileBase2 = GameUty.FileSystem.FileOpen(file_name))
- {
- using (CsvParser csvParser2 = new CsvParser())
- {
- bool condition2 = csvParser2.Open(afileBase2);
- NDebug.Assert(condition2, file_name + "\nopen failed.");
- for (int k = 1; k < csvParser2.max_cell_y; k++)
- {
- if (csvParser2.IsCellToExistData(0, k))
- {
- int cellAsInteger2 = csvParser2.GetCellAsInteger(0, k);
- if (!enabled_id_list.Contains(cellAsInteger2))
- {
- enabled_id_list.Add(cellAsInteger2);
- }
- }
- }
- }
- }
- };
- action("selectable_scenario_id");
- for (int i = 0; i < GameUty.PathList.Count; i++)
- {
- action("selectable_scenario_id_" + GameUty.PathList[i]);
- }
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen("select_scenario_data.nei"))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, "select_scenario_data.nei]");
- for (int j = 1; j < csvParser.max_cell_y; j++)
- {
- if (csvParser.IsCellToExistData(0, j))
- {
- int cellAsInteger = csvParser.GetCellAsInteger(0, j);
- if (enabled_id_list.Contains(cellAsInteger))
- {
- if (!this.m_AllScenarioData.ContainsKey(cellAsInteger))
- {
- this.m_AllScenarioData.Add(cellAsInteger, new ScenarioData(csvParser, j));
- }
- }
- }
- }
- }
- }
- KasaiUtility.CsvReadY("personal_convert_data.nei", new Action<CsvParser, int>(this.ReadConvertData), 2, null);
- }
- public bool IsEventAdded()
- {
- List<ScenarioData> list = (from e in this.m_AllScenarioData.Values
- where e.ImportantPlayable
- select e).ToList<ScenarioData>();
- ScenarioData[] array = (from e in list
- where !this.m_ImportantScenarioList.Contains(e)
- select e).ToArray<ScenarioData>();
- this.m_AddedScenerio = array;
- this.m_ImportantScenarioList = list;
- return array.Length > 0;
- }
- public ScenarioData GetScenarioData(string title)
- {
- foreach (ScenarioData scenarioData in this.m_AllScenarioData.Values)
- {
- if (scenarioData.NotLineTitle == title)
- {
- return scenarioData;
- }
- }
- return null;
- }
- public ScenarioData GetScenarioData(int id)
- {
- return (!this.m_AllScenarioData.ContainsKey(id)) ? null : this.m_AllScenarioData[id];
- }
- public ScenarioData[] GetAllScenarioData()
- {
- return this.m_AllScenarioData.Values.ToArray<ScenarioData>();
- }
- public bool ExistConvertData(string check_data)
- {
- return this.m_PersonalConvertData.ContainsValue(check_data);
- }
- public string GetConvertPersonal(Maid maid)
- {
- if (this.m_PersonalConvertData.ContainsKey(maid.status.personal.uniqueName))
- {
- return this.m_PersonalConvertData[maid.status.personal.uniqueName];
- }
- return string.Empty;
- }
- public string GetConvertPersonalTerm(Maid maid)
- {
- if (this.m_PersonalConvertData.ContainsKey(maid.status.personal.uniqueName))
- {
- return "SceneScenarioSelect/性格名/" + this.m_PersonalConvertData[maid.status.personal.uniqueName];
- }
- return string.Empty;
- }
- public void Serialize(BinaryWriter writer)
- {
- writer.Write("COM3D2_SCENARIO_SELECT");
- writer.Write(1.3f);
- writer.Write("CM3D2_SCENARIO_ID_START");
- foreach (ScenarioData scenarioData in this.m_AllScenarioData.Values)
- {
- writer.Write(scenarioData.ID.ToString());
- }
- writer.Write("CM3D2_SCENARIO_ID_END");
- writer.Write("CM3D2_SELECTABLE_START");
- foreach (ScenarioData scenarioData2 in this.m_ImportantScenarioList)
- {
- writer.Write(scenarioData2.ID.ToString());
- }
- writer.Write("CM3D2_SELECTABLE_END");
- foreach (ScenarioData scenarioData3 in this.m_AllScenarioData.Values)
- {
- scenarioData3.Serialize(writer);
- }
- }
- public void Deserialize(BinaryReader reader)
- {
- string a = reader.ReadString();
- NDebug.Assert(a == "CM3D2_SCENARIO_SELECT" || a == "COM3D2_SCENARIO_SELECT", "セーブデータファイルのヘッダーが不正です。");
- if (a == "COM3D2_SCENARIO_SELECT")
- {
- this.nSaveVer = reader.ReadSingle();
- }
- else
- {
- this.nSaveVer = -1f;
- }
- this.DeserializeFiled = false;
- int count = this.m_AllScenarioData.Count;
- foreach (ScenarioData scenarioData in this.m_AllScenarioData.Values)
- {
- scenarioData.Recet();
- }
- List<int> list = new List<int>();
- string a2 = reader.ReadString();
- if (a2 == "CM3D2_SCENARIO_ID_START")
- {
- string text = reader.ReadString();
- while (text != "CM3D2_SCENARIO_ID_END")
- {
- list.Add(int.Parse(text));
- text = reader.ReadString();
- }
- List<int> list2 = new List<int>();
- string a3 = reader.ReadString();
- if (a3 == "CM3D2_SELECTABLE_START")
- {
- string text2 = reader.ReadString();
- while (text2 != "CM3D2_SELECTABLE_END")
- {
- list2.Add(int.Parse(text2));
- text2 = reader.ReadString();
- }
- }
- else
- {
- this.DeserializeFiled = true;
- Debug.Log("ScenarioSelectMgr.cs:重要シナリオデータIDを書き込む前のバージョンのデータです(2017/10/24より前)");
- }
- foreach (int key in list)
- {
- if (this.m_AllScenarioData.ContainsKey(key))
- {
- this.m_AllScenarioData[key].Deserialize(reader);
- }
- else
- {
- ScenarioData scenarioData2 = new ScenarioData();
- scenarioData2.Deserialize(reader);
- }
- }
- this.m_ImportantScenarioList.Clear();
- foreach (int key2 in list2)
- {
- if (this.m_AllScenarioData.ContainsKey(key2))
- {
- this.m_ImportantScenarioList.Add(this.m_AllScenarioData[key2]);
- }
- }
- }
- else
- {
- Debug.Log("ScenarioSelectMgr.cs:有効IDを書き込む前のバージョンのデータです(2017/10/23より前)");
- this.DeserializeFiled = true;
- foreach (ScenarioData scenarioData3 in this.m_AllScenarioData.Values)
- {
- scenarioData3.Deserialize(reader);
- }
- this.m_ImportantScenarioList = (from e in this.m_AllScenarioData.Values
- where e.IsPlayable && e.IsImportant
- select e).ToList<ScenarioData>();
- }
- }
- public void AddedDisplay(string label)
- {
- GameObject gameObject = Utility.CreatePrefab(null, "SceneScenarioSelect/Prefab/AdditionalScenario", false);
- gameObject.GetComponent<AdditionalScenario>().Init(label);
- }
- public bool ExistScenario(int id)
- {
- return this.m_AllScenarioData.ContainsKey(id);
- }
- public const int CheckVersion = 206;
- private const float m_SaveVer = 1.3f;
- private Dictionary<int, ScenarioData> m_AllScenarioData = new Dictionary<int, ScenarioData>();
- private List<ScenarioData> m_ImportantScenarioList = new List<ScenarioData>();
- private ScenarioData[] m_AddedScenerio;
- private Dictionary<string, string> m_PersonalConvertData = new Dictionary<string, string>();
- }
|