123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using wf;
- namespace Kasizuki
- {
- public static class RoomData
- {
- public static int Count
- {
- get
- {
- RoomData.CreateData();
- return RoomData.commonIdManager.idMap.Count;
- }
- }
- public static bool Contains(string name)
- {
- return RoomData.commonIdManager.nameMap.ContainsKey(name);
- }
- public static bool Contains(int id)
- {
- return RoomData.commonIdManager.idMap.ContainsKey(id);
- }
- public static int uniqueNameToId(string uniqueName)
- {
- RoomData.CreateData();
- NDebug.Assert(RoomData.commonIdManager.nameMap.ContainsKey(uniqueName), "傅き.部屋データ\nユニーク名[" + uniqueName + "]をIDに変換できませんでした");
- return RoomData.commonIdManager.nameMap[uniqueName];
- }
- public static string IdToUniqueName(int id)
- {
- RoomData.CreateData();
- NDebug.Assert(RoomData.commonIdManager.idMap.ContainsKey(id), "傅き.部屋データ\nID[" + id + "]をユニーク名に変換できませんでした");
- return RoomData.commonIdManager.idMap[id].Key;
- }
- public static RoomData.Data GetData(int id)
- {
- RoomData.CreateData();
- NDebug.Assert(RoomData.basicDatas.ContainsKey(id), "傅き.部屋データ\nID[" + id + "]のデータは存在しません");
- return RoomData.basicDatas[id];
- }
- public static RoomData.Data GetData(string uniqueName)
- {
- return RoomData.GetData(RoomData.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(string uniqueName)
- {
- RoomData.CreateData();
- return RoomData.commonIdManager.enabledIdList.Contains(RoomData.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(int id)
- {
- RoomData.CreateData();
- return RoomData.commonIdManager.enabledIdList.Contains(id);
- }
- public static List<RoomData.Data> GetAllDatas(bool onlyEnabled)
- {
- RoomData.CreateData();
- List<RoomData.Data> list = new List<RoomData.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in RoomData.commonIdManager.idMap)
- {
- if (!onlyEnabled || RoomData.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
- {
- list.Add(RoomData.basicDatas[keyValuePair.Key]);
- }
- }
- return list;
- }
- public static List<RoomData.Data> GetDatas(Func<RoomData.Data, bool> customCheckFunction)
- {
- RoomData.CreateData();
- List<RoomData.Data> list = new List<RoomData.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in RoomData.commonIdManager.idMap)
- {
- RoomData.Data data = RoomData.basicDatas[keyValuePair.Key];
- if (customCheckFunction(data))
- {
- list.Add(data);
- }
- }
- return list;
- }
- public static void CreateData()
- {
- if (RoomData.commonIdManager != null)
- {
- return;
- }
- RoomData.commonIdManager = new CsvCommonIdManager("kasizuki_room", "傅き.部屋データ", CsvCommonIdManager.Type.IdAndUniqueName, null);
- RoomData.basicDatas = new Dictionary<int, RoomData.Data>();
- string[] array = new string[]
- {
- "list"
- };
- KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
- for (int i = 0; i < array2.Length; i++)
- {
- string text = "kasizuki_room_" + array[i] + ".nei";
- AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
- CsvParser csvParser = new CsvParser();
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, text + "\nopen failed.");
- array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
- }
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in RoomData.commonIdManager.idMap)
- {
- int key = keyValuePair.Key;
- RoomData.Data value = new RoomData.Data(key, array2[0].Value);
- RoomData.basicDatas.Add(key, value);
- }
- foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
- {
- keyValuePair2.Value.Dispose();
- keyValuePair2.Key.Dispose();
- }
- }
- private const string csvTopCommonName = "kasizuki_room";
- private const string typeNameForErrorLog = "傅き.部屋データ";
- private static CsvCommonIdManager commonIdManager;
- private static Dictionary<int, RoomData.Data> basicDatas;
- public class Data
- {
- public Data(int uniqueID, CsvParser csv)
- {
- for (int i = 0; i < csv.max_cell_y; i++)
- {
- if (csv.IsCellToExistData(0, i) && csv.GetCellAsInteger(0, i) == uniqueID)
- {
- int num = 1;
- this.ID = uniqueID;
- this.uniqueName = csv.GetCellAsString(num++, i);
- this.isExistUpwardRoom = csv.IsCellToExistData(num, i);
- if (this.isExistUpwardRoom)
- {
- this.upwardRoomID = csv.GetCellAsInteger(num, i);
- }
- num++;
- this.facilityTypeID = csv.GetCellAsInteger(num++, i);
- this.facilityDefaultName = csv.GetCellAsString(num++, i);
- this.drawName = csv.GetCellAsString(num++, i);
- this.thumbnailName = csv.GetCellAsString(num++, i);
- this.explanatoryText = csv.GetCellAsString(num++, i);
- bool flag = FacilityDataTable.GetFacilityStatus(this.facilityTypeID, true) != null;
- bool flag2 = FacilityDataTable.GetFacilityTypeID(this.facilityDefaultName) != -1;
- if (!flag && !flag2)
- {
- Debug.LogWarning("表データ内の施設ID、施設名がどちらも正しくない");
- }
- else if (flag && !flag2)
- {
- Debug.LogWarning("表データ内の施設名が正しくない");
- this.facilityDefaultName = FacilityDataTable.GetFacilityStatus(this.facilityTypeID, true).name;
- }
- else if (!flag && flag2)
- {
- Debug.LogWarning("表データ内の施設IDが正しくない");
- this.facilityTypeID = FacilityDataTable.GetFacilityTypeID(this.facilityDefaultName);
- }
- string cellAsString = csv.GetCellAsString(num++, i);
- if (!string.IsNullOrEmpty(cellAsString))
- {
- try
- {
- string[] array = cellAsString.Split(new char[]
- {
- ','
- });
- for (int j = 0; j < array.Length; j++)
- {
- array[j] = array[j].Trim();
- }
- this.strConditionsArraySystemFlag = array;
- }
- catch (Exception ex)
- {
- NDebug.Assert(ex.ToString(), false);
- Debug.LogError(ex);
- }
- }
- Dictionary<ManDataType, bool> dictionary = new Dictionary<ManDataType, bool>();
- int count = ManData.Count;
- for (int k = 0; k < count; k++)
- {
- string cellAsString2 = csv.GetCellAsString(num, 0);
- ManDataType manType = ManData.GetData(cellAsString2).manType;
- dictionary.Add(manType, csv.GetCellAsString(num++, i) == "○");
- }
- this.enableManTypeDic = new ReadOnlyDictionary<ManDataType, bool>(dictionary);
- FacilityDataTable.FacilityDefaultData facilityDefaultData = FacilityDataTable.GetFacilityDefaultData(this.facilityTypeID, true);
- this.isEnableNTR = facilityDefaultData.isEnableNTR;
- this.isOnlyNTR = facilityDefaultData.isOnlyNTR;
- }
- }
- }
- public string drawNameTerm
- {
- get
- {
- return "SceneKasizukiMainMenu/部屋名/" + this.drawName;
- }
- }
- public string explanatoryTextTerm
- {
- get
- {
- return "SceneKasizukiMainMenu/部屋説明/" + this.drawName;
- }
- }
- public RoomData.Data GetUpwardRoomData()
- {
- if (this.isExistUpwardRoom)
- {
- if (RoomData.IsEnabled(this.upwardRoomID))
- {
- return RoomData.GetData(this.upwardRoomID);
- }
- string message = string.Concat(new object[]
- {
- "傅き.部屋データ\n部屋[",
- this.uniqueName,
- "]の上位ID[",
- this.upwardRoomID,
- "]のデータは存在しません"
- });
- NDebug.Assert(message, false);
- }
- return null;
- }
- public RoomData.Data GetSubordinateRoomData()
- {
- List<RoomData.Data> datas = RoomData.GetDatas((RoomData.Data data) => data.upwardRoomID == this.ID);
- RoomData.Data result = null;
- if (datas != null && datas.Count == 1)
- {
- result = datas[0];
- }
- return result;
- }
- public List<PlayData.Data> GetPlayDatas()
- {
- List<PlayData.Data> datas = PlayData.GetDatas((PlayData.Data playData) => playData.roomID == this.ID);
- RoomData.Data subordinateRoomData = this.GetSubordinateRoomData();
- if (subordinateRoomData != null)
- {
- foreach (PlayData.Data item in subordinateRoomData.GetPlayDatas())
- {
- if (!datas.Contains(item))
- {
- datas.Add(item);
- }
- }
- }
- return datas;
- }
- public bool IsExistFacility()
- {
- if (!FacilityDataTable.IsExistFacilityData(this.facilityTypeID, true))
- {
- string message = string.Concat(new object[]
- {
- "傅き.部屋データ\n部屋データ[",
- this.uniqueName,
- "]に対応する施設のID[",
- this.facilityTypeID,
- "は存在しない施設データです"
- });
- Debug.LogWarning(message);
- return false;
- }
- FacilityManager facilityMgr = GameMain.Instance.FacilityMgr;
- if (facilityMgr == null)
- {
- string message2 = "施設マネージャクラスが見つかりませんでした";
- Debug.LogWarning(message2);
- return false;
- }
- return facilityMgr.IsExistTypeFacility(this.facilityTypeID);
- }
- public readonly int ID;
- public readonly string uniqueName;
- public readonly int upwardRoomID;
- public readonly int facilityTypeID;
- public readonly string facilityDefaultName;
- public readonly string drawName;
- public readonly string thumbnailName;
- public readonly string explanatoryText;
- public readonly string[] strConditionsArraySystemFlag;
- public readonly ReadOnlyDictionary<ManDataType, bool> enableManTypeDic;
- public readonly bool isExistUpwardRoom;
- public readonly bool isEnableNTR;
- public readonly bool isOnlyNTR;
- }
- }
- }
|