123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using wf;
- public static class YotogiStage
- {
- public static int Count
- {
- get
- {
- YotogiStage.CreateData();
- return YotogiStage.commonIdManager.idMap.Count;
- }
- }
- public static bool Contains(string name)
- {
- YotogiStage.CreateData();
- return YotogiStage.commonIdManager.nameMap.ContainsKey(name);
- }
- public static bool Contains(int id)
- {
- YotogiStage.CreateData();
- return YotogiStage.commonIdManager.idMap.ContainsKey(id);
- }
- public static int uniqueNameToId(string name)
- {
- YotogiStage.CreateData();
- NDebug.Assert(YotogiStage.commonIdManager.nameMap.ContainsKey(name), "夜伽ステージ\nユニーク名[" + name + "]をIDに変換できませんでした");
- return YotogiStage.commonIdManager.nameMap[name];
- }
- public static string IdToUniqueName(int id)
- {
- YotogiStage.CreateData();
- NDebug.Assert(YotogiStage.commonIdManager.idMap.ContainsKey(id), "夜伽ステージ\nID[" + id + "]をユニーク名に変換できませんでした");
- return YotogiStage.commonIdManager.idMap[id].Key;
- }
- public static YotogiStage.Data GetData(int id)
- {
- YotogiStage.CreateData();
- NDebug.Assert(YotogiStage.basicDatas.ContainsKey(id), "夜伽ステージ\nID[" + id + "]のデータは存在しません");
- return YotogiStage.basicDatas[id];
- }
- public static YotogiStage.Data GetData(string uniqueName)
- {
- return YotogiStage.GetData(YotogiStage.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(string uniqueName)
- {
- YotogiStage.CreateData();
- return YotogiStage.commonIdManager.enabledIdList.Contains(YotogiStage.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(int id)
- {
- YotogiStage.CreateData();
- return YotogiStage.commonIdManager.enabledIdList.Contains(id);
- }
- public static List<YotogiStage.Data> GetAllDatas(bool onlyEnabled)
- {
- YotogiStage.CreateData();
- List<YotogiStage.Data> list = new List<YotogiStage.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in YotogiStage.commonIdManager.idMap)
- {
- if (!onlyEnabled || YotogiStage.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
- {
- list.Add(YotogiStage.basicDatas[keyValuePair.Key]);
- }
- }
- return list;
- }
- public static void CreateData()
- {
- if (YotogiStage.commonIdManager != null)
- {
- return;
- }
- YotogiStage.commonIdManager = new CsvCommonIdManager("yotogi_stage", "夜伽ステージ", CsvCommonIdManager.Type.IdAndUniqueName, null);
- YotogiStage.basicDatas = new Dictionary<int, YotogiStage.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 = "yotogi_stage_" + 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);
- }
- HashSet<int> hashSet = new HashSet<int>(YotogiStage.commonIdManager.enabledIdList);
- using (AFileBase afileBase2 = GameUty.FileSystem.FileOpen("yotogi_stage_compatibility_list.nei"))
- {
- if (afileBase2 != null && afileBase2.IsValid())
- {
- using (CsvParser csvParser2 = new CsvParser())
- {
- if (csvParser2.Open(afileBase2))
- {
- for (int j = 1; j < csvParser2.max_cell_y; j++)
- {
- if (csvParser2.IsCellToExistData(0, j))
- {
- int cellAsInteger = csvParser2.GetCellAsInteger(0, j);
- string cellAsString = csvParser2.GetCellAsString(2, j);
- bool flag = !string.IsNullOrEmpty(cellAsString) && PluginData.IsEnabled(cellAsString);
- if (flag && !hashSet.Contains(cellAsInteger))
- {
- hashSet.Add(cellAsInteger);
- }
- }
- }
- }
- }
- }
- }
- Dictionary<int, KeyValuePair<string, string>> idMap = new Dictionary<int, KeyValuePair<string, string>>(YotogiStage.commonIdManager.idMap);
- Dictionary<string, int> nameMap = new Dictionary<string, int>(YotogiStage.commonIdManager.nameMap);
- YotogiStage.commonIdManager = new CsvCommonIdManager(idMap, nameMap, hashSet, CsvCommonIdManager.Type.IdAndUniqueName);
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in YotogiStage.commonIdManager.idMap)
- {
- YotogiStage.basicDatas.Add(keyValuePair.Key, new YotogiStage.Data(keyValuePair.Key, array2[0].Value));
- }
- foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
- {
- keyValuePair2.Value.Dispose();
- keyValuePair2.Key.Dispose();
- }
- }
- private const string csvTopCommonName = "yotogi_stage";
- private const string typeNameForErrorLog = "夜伽ステージ";
- public const string termRootText = "SceneYotogi/背景タイプ/";
- private static CsvCommonIdManager commonIdManager;
- private static Dictionary<int, YotogiStage.Data> basicDatas;
- public class Data : IComparable, IComparable<YotogiStage.Data>
- {
- public Data(int id, CsvParser basicCsv)
- {
- List<int> list = new List<int>();
- for (int i = 1; i < basicCsv.max_cell_y; i++)
- {
- if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
- {
- this.id = id;
- int num = 1;
- string text = string.Empty;
- this.uniqueName = basicCsv.GetCellAsString(num++, i);
- this.drawName = basicCsv.GetCellAsString(num++, i);
- this.sortId = basicCsv.GetCellAsInteger(num++, i);
- this.drawClubGrade = basicCsv.GetCellAsInteger(num++, i);
- this.requestClubGrade = basicCsv.GetCellAsInteger(num++, i);
- this.requestFacilityIds = new int[0];
- text = basicCsv.GetCellAsString(num++, i);
- if (!string.IsNullOrEmpty(text))
- {
- string[] array = text.Split(new char[]
- {
- ','
- });
- this.requestFacilityIds = new int[array.Length];
- for (int j = 0; j < array.Length; j++)
- {
- this.requestFacilityIds[j] = int.Parse(array[j].Trim());
- }
- }
- this.prefabName = new string[2];
- this.thumbnailName = new string[2];
- for (int k = 0; k < this.prefabName.Length; k++)
- {
- this.prefabName[k] = basicCsv.GetCellAsString(num++, i);
- this.thumbnailName[k] = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".tex");
- }
- this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg");
- string cellAsString = basicCsv.GetCellAsString(num++, i);
- string[] array2 = cellAsString.Split(new char[]
- {
- ','
- });
- NDebug.Assert(array2.Length == 6, "ステージカメラ設定が不正です\nLine : " + i.ToString());
- Vector3 center = new Vector3(float.Parse(array2[0]), float.Parse(array2[1]), float.Parse(array2[2]));
- float radius = float.Parse(array2[3]);
- Vector2 v = new Vector2(float.Parse(array2[4]), float.Parse(array2[5]));
- this.stageSelectCameraData = new YotogiStage.Data.Camera(center, v, radius);
- cellAsString = basicCsv.GetCellAsString(num++, i);
- array2 = cellAsString.Split(new char[]
- {
- ','
- });
- NDebug.Assert(array2.Length == 6, "カス子位置情報が不正です\nLine : " + i.ToString());
- Vector3 position = new Vector3(float.Parse(array2[0]), float.Parse(array2[1]), float.Parse(array2[2]));
- Vector3 rotation = new Vector3(float.Parse(array2[3]), float.Parse(array2[4]), float.Parse(array2[5]));
- cellAsString = basicCsv.GetCellAsString(num++, i);
- array2 = cellAsString.Split(new char[]
- {
- ','
- });
- NDebug.Assert(array2.Length == 2, "スキル選択時カメラデータが不正です\nLine : " + i.ToString());
- Vector2 cameraAngle = new Vector2(float.Parse(array2[0]), float.Parse(array2[1]));
- this.skillSelectcharacterData = new YotogiStage.Data.Character(position, rotation, cameraAngle);
- string cellAsString2 = basicCsv.GetCellAsString(num++, i);
- string[] array3 = cellAsString2.Split(new char[]
- {
- ','
- });
- NDebug.Assert(array3.Length == 4, "スキル選択時ライトデータが不正です\nLine : " + i.ToString());
- Vector3 position2 = new Vector3(float.Parse(array3[0]), float.Parse(array3[1]), float.Parse(array3[2]));
- float intensity = float.Parse(array3[3]);
- this.skillSelectLightData = new YotogiStage.Data.Light(position2, intensity);
- break;
- }
- }
- }
- public int CompareTo(YotogiStage.Data other)
- {
- return this.sortId.CompareTo(other.sortId);
- }
- public int CompareTo(object other)
- {
- return this.sortId.CompareTo(((YotogiStage.Data)other).sortId);
- }
- public bool isYotogiPlayable(int clubGrade, bool checkFacility)
- {
- if (clubGrade < this.requestClubGrade)
- {
- return false;
- }
- bool flag = this.requestFacilityIds.Length == 0;
- FacilityManager facilityMgr = GameMain.Instance.FacilityMgr;
- foreach (int facilityTypeID in this.requestFacilityIds)
- {
- if (checkFacility)
- {
- flag |= facilityMgr.IsExistTypeFacility(facilityTypeID);
- }
- else
- {
- flag |= facilityMgr.IsFacilityBuildFlag(facilityTypeID);
- }
- }
- return flag;
- }
- public string termName
- {
- get
- {
- return "SceneYotogi/背景タイプ/" + this.uniqueName;
- }
- }
- public readonly int id;
- public readonly string uniqueName;
- public readonly string drawName;
- public readonly int drawClubGrade;
- public readonly int sortId;
- public readonly int requestClubGrade;
- public readonly int[] requestFacilityIds;
- public readonly string[] prefabName;
- public readonly string[] thumbnailName;
- public readonly string bgmFileName;
- public readonly YotogiStage.Data.Camera stageSelectCameraData;
- public readonly YotogiStage.Data.Light skillSelectLightData;
- public readonly YotogiStage.Data.Character skillSelectcharacterData;
- public class Camera
- {
- public Camera(Vector3 center, Vector3 angle, float radius)
- {
- this.center = center;
- this.angle = angle;
- this.radius = radius;
- }
- public void Apply(CameraMain camera)
- {
- camera.SetFromScriptOnTarget(this.center, this.radius, this.angle);
- }
- public void Apply()
- {
- this.Apply(GameMain.Instance.MainCamera);
- }
- public readonly Vector3 center;
- public readonly Vector2 angle;
- public readonly float radius;
- }
- public class Light
- {
- public Light(Vector3 position, float intensity)
- {
- this.position = position;
- this.intensity = intensity;
- }
- public void Apply(LightMain light)
- {
- light.SetRotation(this.position);
- light.SetIntensity(this.intensity);
- }
- public void Apply()
- {
- this.Apply(GameMain.Instance.MainLight);
- }
- public readonly Vector3 position;
- public readonly float intensity;
- }
- public class Character
- {
- public Character(Vector3 position, Vector3 rotation, Vector2 cameraAngle)
- {
- this.position = position;
- this.rotation = rotation;
- this.cameraAngle = cameraAngle;
- }
- public void Apply(CharacterMgr charaMgr)
- {
- charaMgr.SetCharaAllPos(this.position);
- charaMgr.SetCharaAllRot(this.rotation);
- }
- public void Apply()
- {
- this.Apply(GameMain.Instance.CharacterMgr);
- }
- public readonly Vector3 position;
- public readonly Vector3 rotation;
- public readonly Vector2 cameraAngle;
- }
- }
- }
|