123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692 |
- using System;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.IO;
- using UnityEngine;
- using UnityEngine.EventSystems;
- namespace MyRoomCustom
- {
- public class CreativeRoomManager : MonoBehaviour
- {
- public CreativeRoom creativeRoom
- {
- get
- {
- return this.m_PtrCreativeRoom;
- }
- }
- public CreativeRoomUIObjectSettings creativeRoomUIObjSetting
- {
- get
- {
- return this.m_PtrCreativeRoomUIObjectSettings;
- }
- }
- public CreativeRoomUIPlacementMaid creativeRoomUIMaid
- {
- get
- {
- return this.m_PtrCreativeRoomUIPlacementMaid;
- }
- }
- public Camera inputCamera
- {
- get
- {
- return this.m_CamerauGUI;
- }
- }
- private float cameraFOV
- {
- set
- {
- if (value != this.m_CamerauGUI.fieldOfView)
- {
- this.m_CamerauGUI.fieldOfView = value;
- }
- }
- }
- private float cameraOrthographicSize
- {
- set
- {
- if (value != this.m_CamerauGUI.orthographicSize)
- {
- this.m_CamerauGUI.orthographicSize = value;
- }
- }
- }
- private bool cameraOrthographic
- {
- set
- {
- if (value != this.m_CamerauGUI.orthographic)
- {
- this.m_CamerauGUI.orthographic = value;
- }
- }
- }
- private Rect cameraRect
- {
- set
- {
- if (value != this.m_CamerauGUI.rect)
- {
- this.m_CamerauGUI.rect = value;
- }
- }
- }
- private void Awake()
- {
- Camera camera = GameMain.Instance.MainCamera.camera;
- this.m_MainCamera = camera;
- GameObject gameObject = new GameObject("[CreativeRoom]Camera (Input Module)");
- this.m_CamerauGUI = gameObject.AddComponent<Camera>();
- this.m_CamerauGUI.clearFlags = CameraClearFlags.Nothing;
- this.m_CamerauGUI.useOcclusionCulling = false;
- this.m_CamerauGUI.enabled = false;
- this.m_CamerauGUI.allowHDR = false;
- this.m_CamerauGUI.allowMSAA = false;
- this.m_CamerauGUI.gameObject.AddComponent<PhysicsRaycaster>();
- Transform transform = camera.transform;
- gameObject.transform.SetParent(transform, false);
- gameObject.transform.localPosition = Vector3.zero;
- gameObject.transform.localEulerAngles = Vector3.zero;
- gameObject.transform.localScale = Vector3.one;
- this.cameraFOV = camera.fieldOfView;
- this.cameraOrthographic = camera.orthographic;
- this.cameraOrthographicSize = camera.orthographicSize;
- this.cameraRect = camera.pixelRect;
- CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
- for (int i = 0; i < characterMgr.GetMaidCount(); i++)
- {
- if (characterMgr.GetMaid(i) != null)
- {
- characterMgr.GetMaid(i).Visible = false;
- }
- }
- }
- private void Start()
- {
- if (!this.m_PtrCreativeRoom)
- {
- this.m_PtrCreativeRoom = UnityEngine.Object.FindObjectOfType<CreativeRoom>();
- }
- if (!this.m_PtrCreativeRoomUIObjectSettings)
- {
- this.m_PtrCreativeRoomUIObjectSettings = UnityEngine.Object.FindObjectOfType<CreativeRoomUIObjectSettings>();
- }
- if (!this.m_PtrCreativeRoomUIPlacementMaid)
- {
- this.m_PtrCreativeRoomUIPlacementMaid = UnityEngine.Object.FindObjectOfType<CreativeRoomUIPlacementMaid>();
- }
- this.GetTagBackup();
- GameMain.Instance.BgMgr.DeleteBg();
- GameMain.Instance.SoundMgr.PlayBGM(this.m_MusicName + ".ogg", 0.5f, true);
- GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
- GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0f, 1.8f, 0f), true);
- GameMain.Instance.MainCamera.SetDistance(7f, true);
- GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(45f, 20f), true);
- GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color));
- if (!uGUITutorialPanel.IsOpened())
- {
- uGUITutorialPanel.OpenTutorial("SceneCreativeRoom", null, false);
- }
- }
- private void Update()
- {
- GameMain.VRDeviceType vrdeviceTypeID = GameMain.Instance.VRDeviceTypeID;
- if (vrdeviceTypeID != GameMain.VRDeviceType.RIFT_TOUCH && vrdeviceTypeID != GameMain.VRDeviceType.VIVE)
- {
- this.cameraFOV = this.m_MainCamera.fieldOfView;
- this.cameraOrthographic = this.m_MainCamera.orthographic;
- this.cameraOrthographicSize = this.m_MainCamera.orthographicSize;
- this.cameraRect = this.m_MainCamera.pixelRect;
- }
- }
- public CreativeRoomManager.CreativeRoomHeader Save(int number)
- {
- string text = UTY.gameProjectPath + "\\";
- text += "MyRoom\\";
- string text2 = "Room_";
- text2 += number.ToString("000");
- text2 += ".room";
- if (!Directory.Exists(text))
- {
- Directory.CreateDirectory(text);
- }
- MemoryStream memoryStream = new MemoryStream();
- BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
- string text3 = DateTime.Now.ToString("yyyyMMddHHmm");
- CreativeRoomManager.CreativeRoomHeader creativeRoomHeader = this.GetSaveDataHeader(number);
- if (creativeRoomHeader != null)
- {
- binaryWriter.Write("COM3D2_MY_ROOM");
- binaryWriter.Write("2");
- binaryWriter.Write(creativeRoomHeader.comment);
- binaryWriter.Write(text3);
- string value = creativeRoomHeader.guid;
- if (string.IsNullOrEmpty(value))
- {
- value = Guid.NewGuid().ToString();
- }
- binaryWriter.Write(value);
- creativeRoomHeader.lastWriteTime = text3;
- }
- else
- {
- binaryWriter.Write("COM3D2_MY_ROOM");
- binaryWriter.Write("2");
- binaryWriter.Write(string.Empty);
- binaryWriter.Write(text3);
- string text4 = Guid.NewGuid().ToString();
- binaryWriter.Write(text4);
- creativeRoomHeader = new CreativeRoomManager.CreativeRoomHeader();
- creativeRoomHeader.guid = text4;
- creativeRoomHeader.comment = string.Empty;
- creativeRoomHeader.lastWriteTime = text3;
- }
- this.m_PtrCreativeRoom.SavePanelData(binaryWriter);
- this.m_PtrCreativeRoomUIObjectSettings.SaveDeployObjectData(binaryWriter);
- File.WriteAllBytes(text + text2, memoryStream.ToArray());
- memoryStream.Close();
- memoryStream.Dispose();
- return creativeRoomHeader;
- }
- public void Load(int number)
- {
- string text = UTY.gameProjectPath + "\\";
- text += "MyRoom\\";
- if (!Directory.Exists(text))
- {
- Directory.CreateDirectory(text);
- }
- string text2 = text + "Room_" + number.ToString("000");
- if (File.Exists(text2 + ".save"))
- {
- text2 += ".save";
- }
- else
- {
- if (!File.Exists(text2 + ".room"))
- {
- Debug.LogWarning(string.Format("[CreativeRoomManager]{0}\u3000のセーブファイルが見つかりませんでした", text2));
- return;
- }
- text2 += ".room";
- }
- FileStream fileStream = new FileStream(text2, FileMode.Open);
- byte[] buffer = new byte[fileStream.Length];
- fileStream.Read(buffer, 0, (int)fileStream.Length);
- fileStream.Close();
- fileStream.Dispose();
- BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer));
- string a = binaryReader.ReadString();
- int num = 0;
- if (a != "COM3D2_MY_ROOM")
- {
- binaryReader.BaseStream.Seek(0L, SeekOrigin.Begin);
- }
- else if (!int.TryParse(binaryReader.ReadString(), out num))
- {
- string message = "[自室カスタム]セーブデータのヘッダーが不正です\n" + text2;
- Debug.LogError(message);
- NDebug.Assert(message, false);
- }
- binaryReader.ReadString();
- binaryReader.ReadString();
- if (num >= 1)
- {
- binaryReader.ReadString();
- }
- this.m_PtrCreativeRoom.LoadPanelData(binaryReader);
- this.m_PtrCreativeRoomUIObjectSettings.LoadDeployObjectData(binaryReader);
- this.m_PtrCreativeRoomUIObjectSettings.SetDeploymentObjectGizmoEnable(false);
- binaryReader.Close();
- }
- public CreativeRoomManager.CreativeRoomHeader GetSaveDataHeader(int number)
- {
- return this.GetSaveDataHeader(number.ToString("000"));
- }
- public CreativeRoomManager.CreativeRoomHeader GetSaveDataHeader(string number)
- {
- string str = UTY.gameProjectPath + "\\";
- str += "MyRoom\\";
- string text = "Room_" + number;
- if (File.Exists(str + text + ".save"))
- {
- text += ".save";
- }
- else
- {
- text += ".room";
- }
- if (!File.Exists(str + text))
- {
- return null;
- }
- FileStream fileStream = new FileStream(str + text, FileMode.Open);
- byte[] buffer = new byte[fileStream.Length];
- fileStream.Read(buffer, 0, (int)fileStream.Length);
- fileStream.Close();
- fileStream.Dispose();
- BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer));
- CreativeRoomManager.CreativeRoomHeader creativeRoomHeader = new CreativeRoomManager.CreativeRoomHeader();
- string a = binaryReader.ReadString();
- int num = 0;
- if (a != "COM3D2_MY_ROOM")
- {
- binaryReader.BaseStream.Seek(0L, SeekOrigin.Begin);
- }
- else if (!int.TryParse(binaryReader.ReadString(), out num))
- {
- string message = "[自室カスタム]セーブデータのヘッダーが不正です\n" + text;
- Debug.LogError(message);
- NDebug.Assert(message, false);
- }
- creativeRoomHeader.comment = binaryReader.ReadString();
- creativeRoomHeader.lastWriteTime = binaryReader.ReadString();
- if (num >= 1)
- {
- creativeRoomHeader.guid = binaryReader.ReadString();
- }
- creativeRoomHeader.headerSize = binaryReader.BaseStream.Position;
- binaryReader.Close();
- return creativeRoomHeader;
- }
- public void SaveComment(int number, string comment)
- {
- this.SaveComment(number.ToString("000"), comment);
- }
- public void SaveComment(string number, string comment)
- {
- CreativeRoomManager.CreativeRoomHeader saveDataHeader = this.GetSaveDataHeader(number);
- if (saveDataHeader == null)
- {
- return;
- }
- string str = UTY.gameProjectPath + "\\";
- str += "MyRoom\\";
- string path = str + "Room_" + number + ".room";
- FileStream fileStream = new FileStream(path, FileMode.Open);
- byte[] array = new byte[fileStream.Length];
- fileStream.Read(array, 0, (int)fileStream.Length);
- fileStream.Close();
- fileStream.Dispose();
- MemoryStream memoryStream = new MemoryStream();
- BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
- int num = (int)saveDataHeader.headerSize;
- binaryWriter.Write("COM3D2_MY_ROOM");
- binaryWriter.Write("2");
- binaryWriter.Write(comment);
- binaryWriter.Write(saveDataHeader.lastWriteTime);
- if (string.IsNullOrEmpty(saveDataHeader.guid))
- {
- saveDataHeader.guid = Guid.NewGuid().ToString();
- }
- binaryWriter.Write(saveDataHeader.guid);
- binaryWriter.Write(array, num, array.Length - num);
- File.WriteAllBytes(path, memoryStream.ToArray());
- memoryStream.Close();
- memoryStream.Dispose();
- Debug.Log("セーブデータ" + number + "番:ヘッダーを保存");
- }
- public string DateTimeParse(string strDate)
- {
- return DateTime.ParseExact(strDate, "yyyyMMddHHmm", null).ToString("yyyy.MM.dd HH:mm");
- }
- private void GetTagBackup()
- {
- Dictionary<string, string> tag_backup = GameMain.Instance.ScriptMgr.adv_kag.tag_backup;
- string a;
- if (tag_backup != null && tag_backup.TryGetValue("name", out a) && a == "SceneCreativeRoom")
- {
- if (!tag_backup.TryGetValue("label", out this.m_strScriptReturnLabel))
- {
- Debug.LogFormat("スクリプトからの引数「{0}」がありませんでした", new object[]
- {
- "label"
- });
- }
- }
- }
- public void Exit()
- {
- if (!GameMain.Instance.SysDlg.IsDecided)
- {
- return;
- }
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/セーブしていないデータは失われます。終了しますか?", null, SystemDialog.TYPE.YES_NO, delegate
- {
- if (string.IsNullOrEmpty(this.m_strScriptReturnLabel))
- {
- Debug.Log("シーン終了時に飛ぶラベルがありませんでした");
- return;
- }
- GameMain.Instance.MainCamera.FadeOut(0.5f, false, delegate
- {
- GameMain.Instance.SoundMgr.StopBGM(1f);
- PlacementData.Clear();
- TextureData.Clear();
- uGUIUtility.SetActiveEventSystem(true);
- ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
- scriptMgr.adv_kag.JumpLabel(this.m_strScriptReturnLabel);
- scriptMgr.adv_kag.Exec();
- }, true, default(Color));
- GameMain.Instance.SysDlg.Close();
- }, delegate
- {
- GameMain.Instance.SysDlg.Close();
- uGUIUtility.SetActiveEventSystem(true);
- });
- uGUIUtility.SetActiveEventSystem(false);
- }
- private void OnDestroy()
- {
- if (this.m_CamerauGUI)
- {
- UnityEngine.Object.Destroy(this.m_CamerauGUI.gameObject);
- }
- }
- private static StringDictionary cachedSaveDataDic
- {
- get
- {
- if (CreativeRoomManager.m_CachedSaveDataDic == null)
- {
- CreativeRoomManager.m_CachedSaveDataDic = new StringDictionary();
- string text = UTY.gameProjectPath + "\\";
- text += "MyRoom\\";
- if (Directory.Exists(text))
- {
- string[] files = Directory.GetFiles(text, "*.room");
- for (int i = 0; i < files.Length; i++)
- {
- CreativeRoomManager.CreativeRoomHeader creativeRoomHeader;
- CreativeRoomManager.DeserializeHeader(files[i], out creativeRoomHeader);
- CreativeRoomManager.m_CachedSaveDataDic[creativeRoomHeader.guid] = files[i];
- }
- }
- }
- return CreativeRoomManager.m_CachedSaveDataDic;
- }
- }
- public static Dictionary<string, string> GetSaveDataDic()
- {
- CreativeRoomManager.UpdateSaveDataGUID();
- if (CreativeRoomManager.m_CachedSaveDataDic != null)
- {
- CreativeRoomManager.m_CachedSaveDataDic.Clear();
- }
- CreativeRoomManager.m_CachedSaveDataDic = new StringDictionary();
- string text = UTY.gameProjectPath + "\\";
- text += "MyRoom\\";
- Dictionary<string, string> dictionary = null;
- if (Directory.Exists(text))
- {
- dictionary = new Dictionary<string, string>();
- string[] files = Directory.GetFiles(text, "*.room");
- for (int i = 0; i < files.Length; i++)
- {
- CreativeRoomManager.CreativeRoomHeader creativeRoomHeader;
- CreativeRoomManager.DeserializeHeader(files[i], out creativeRoomHeader);
- string text2 = string.Empty;
- if (string.IsNullOrEmpty(creativeRoomHeader.comment))
- {
- text2 = "自室カスタム" + i.ToString("000");
- }
- else
- {
- int num = 10;
- text2 = creativeRoomHeader.comment;
- if (text2.Length > num)
- {
- text2 = text2.Substring(0, num - 1) + "…";
- }
- }
- dictionary.Add(creativeRoomHeader.guid, text2);
- CreativeRoomManager.m_CachedSaveDataDic[creativeRoomHeader.guid] = files[i];
- }
- }
- return dictionary;
- }
- private static void UpdateSaveDataGUID()
- {
- string text = UTY.gameProjectPath + "\\";
- text += "MyRoom\\";
- if (Directory.Exists(text))
- {
- SortedDictionary<string, KeyValuePair<FileInfo, CreativeRoomManager.CreativeRoomHeader>> sortedDictionary = new SortedDictionary<string, KeyValuePair<FileInfo, CreativeRoomManager.CreativeRoomHeader>>();
- string[] files = Directory.GetFiles(text, "*.room");
- for (int i = 0; i < files.Length; i++)
- {
- CreativeRoomManager.CreativeRoomHeader creativeRoomHeader;
- CreativeRoomManager.DeserializeHeader(files[i], out creativeRoomHeader);
- FileInfo fileInfo = new FileInfo(files[i]);
- if (sortedDictionary.ContainsKey(creativeRoomHeader.guid))
- {
- string message = "ファイル「" + fileInfo.Name + "」の内部IDが重複しています。新しい内部IDを作成します。";
- Debug.LogWarning(message);
- KeyValuePair<FileInfo, CreativeRoomManager.CreativeRoomHeader> keyValuePair = sortedDictionary[creativeRoomHeader.guid];
- FileInfo key = keyValuePair.Key;
- CreativeRoomManager.CreativeRoomHeader value = keyValuePair.Value;
- CreativeRoomManager.CreativeRoomHeader creativeRoomHeader2 = (!(fileInfo.CreationTimeUtc <= key.CreationTimeUtc)) ? creativeRoomHeader : value;
- FileInfo info = (!(fileInfo.CreationTimeUtc <= key.CreationTimeUtc)) ? fileInfo : key;
- creativeRoomHeader2.guid = Guid.NewGuid().ToString();
- CreativeRoomManager.SerializeAndUpdateHeader(info, creativeRoomHeader2);
- }
- if (!sortedDictionary.ContainsKey(creativeRoomHeader.guid))
- {
- sortedDictionary.Add(creativeRoomHeader.guid, new KeyValuePair<FileInfo, CreativeRoomManager.CreativeRoomHeader>(fileInfo, creativeRoomHeader));
- }
- else
- {
- KeyValuePair<FileInfo, CreativeRoomManager.CreativeRoomHeader> keyValuePair2 = sortedDictionary[creativeRoomHeader.guid];
- sortedDictionary[creativeRoomHeader.guid] = new KeyValuePair<FileInfo, CreativeRoomManager.CreativeRoomHeader>(fileInfo, creativeRoomHeader);
- sortedDictionary.Add(keyValuePair2.Value.guid, new KeyValuePair<FileInfo, CreativeRoomManager.CreativeRoomHeader>(keyValuePair2.Key, keyValuePair2.Value));
- }
- }
- }
- }
- public static GameObject InstantiateRoom(string guid_room)
- {
- if (!CreativeRoomManager.cachedSaveDataDic.ContainsKey(guid_room))
- {
- string message = "[CreativeRoom]\u3000存在しないGUIDを読み込もうとしました";
- NDebug.Assert(message, false);
- Debug.LogError(message);
- }
- GameObject gameObject = null;
- string path = CreativeRoomManager.cachedSaveDataDic[guid_room];
- if (!File.Exists(path))
- {
- string message2 = "[CreativeRoom]\u3000存在しないファイルを読み込もうとしました";
- NDebug.Warning(message2);
- Debug.LogWarning(message2);
- }
- else
- {
- using (FileStream fileStream = new FileStream(path, FileMode.Open))
- {
- byte[] buffer = new byte[fileStream.Length];
- fileStream.Read(buffer, 0, (int)fileStream.Length);
- using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer)))
- {
- CreativeRoomManager.CreativeRoomHeader creativeRoomHeader;
- CreativeRoomManager.DeserializeHeader(binaryReader, out creativeRoomHeader);
- long position = binaryReader.BaseStream.Position;
- int num = binaryReader.ReadInt32();
- int num2 = binaryReader.ReadInt32();
- int num3 = binaryReader.ReadInt32();
- float num4 = binaryReader.ReadSingle();
- binaryReader.BaseStream.Seek(position, SeekOrigin.Begin);
- GameObject gameObject2 = CreativeRoom.Load(binaryReader);
- GameObject gameObject3 = CreativeRoomUIObjectSettings.Load(binaryReader);
- gameObject2.name = "Parent Room Mesh";
- gameObject3.name = "Parent Deployment Object";
- gameObject = new GameObject("部屋でーた");
- gameObject2.transform.SetParent(gameObject.transform, true);
- gameObject3.transform.SetParent(gameObject.transform, true);
- Vector3 localPosition = -0.5f * num4 * new Vector3((float)(num - 1), 0f, (float)(num3 - 1));
- gameObject2.transform.localPosition = localPosition;
- gameObject3.transform.localPosition = localPosition;
- }
- }
- }
- return gameObject;
- }
- public static bool IsExistSaveData(string guid_room)
- {
- return CreativeRoomManager.cachedSaveDataDic.ContainsKey(guid_room) && File.Exists(CreativeRoomManager.cachedSaveDataDic[guid_room]);
- }
- private static void FileOpen(string path, Action<BinaryReader> action)
- {
- using (FileStream fileStream = new FileStream(path, FileMode.Open))
- {
- byte[] buffer = new byte[fileStream.Length];
- fileStream.Read(buffer, 0, (int)fileStream.Length);
- using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer)))
- {
- action(binaryReader);
- }
- }
- }
- private static void DeserializeHeader(string path, out CreativeRoomManager.CreativeRoomHeader header)
- {
- using (FileStream fileStream = new FileStream(path, FileMode.Open))
- {
- byte[] buffer = new byte[fileStream.Length];
- fileStream.Read(buffer, 0, (int)fileStream.Length);
- using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer)))
- {
- CreativeRoomManager.DeserializeHeader(binaryReader, out header);
- }
- }
- }
- private static void DeserializeHeader(BinaryReader br, out CreativeRoomManager.CreativeRoomHeader header)
- {
- string a = br.ReadString();
- int num = 0;
- if (a != "COM3D2_MY_ROOM")
- {
- br.BaseStream.Seek(0L, SeekOrigin.Begin);
- }
- else if (!int.TryParse(br.ReadString(), out num))
- {
- string message = "[CreativeRoom]\u3000セーブデータのヘッダーが不正です";
- Debug.LogError(message);
- NDebug.Assert(message, false);
- }
- header = new CreativeRoomManager.CreativeRoomHeader();
- header.comment = br.ReadString();
- header.lastWriteTime = br.ReadString();
- if (num >= 1)
- {
- header.guid = br.ReadString();
- }
- header.headerSize = br.BaseStream.Position;
- }
- private static void SerializeAndUpdateHeader(FileInfo info, CreativeRoomManager.CreativeRoomHeader header)
- {
- CreativeRoomManager.CreativeRoomHeader creativeRoomHeader;
- CreativeRoomManager.DeserializeHeader(info.FullName, out creativeRoomHeader);
- FileStream fileStream = new FileStream(info.FullName, FileMode.Open);
- byte[] array = new byte[fileStream.Length];
- fileStream.Read(array, 0, (int)fileStream.Length);
- fileStream.Close();
- fileStream.Dispose();
- MemoryStream memoryStream = new MemoryStream();
- BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
- int num = (int)creativeRoomHeader.headerSize;
- binaryWriter.Write("COM3D2_MY_ROOM");
- binaryWriter.Write("2");
- binaryWriter.Write(header.comment);
- binaryWriter.Write(header.lastWriteTime);
- binaryWriter.Write(header.guid);
- binaryWriter.Write(array, num, array.Length - num);
- File.WriteAllBytes(info.FullName, memoryStream.ToArray());
- memoryStream.Close();
- memoryStream.Dispose();
- Debug.Log("セーブデータ" + info.Name + ":ヘッダーを保存");
- }
- [SerializeField]
- private CreativeRoom m_PtrCreativeRoom;
- [SerializeField]
- private CreativeRoomUIObjectSettings m_PtrCreativeRoomUIObjectSettings;
- [SerializeField]
- private CreativeRoomUIPlacementMaid m_PtrCreativeRoomUIPlacementMaid;
- [SerializeField]
- private RectTransform m_PtrCreativeRoomUIModeChangeButtons;
- private Camera m_MainCamera;
- private Camera m_CamerauGUI;
- private const string STR_SAVE_DATA_PATH = "MyRoom";
- private const string STR_SAVE_FILE_NAME = "Room_";
- private const string STR_SAVE_EXT = ".room";
- private const string STR_SERIALIZE_VER = "2";
- private const string STR_HEADER = "COM3D2_MY_ROOM";
- public string m_MusicName = "BGM020";
- private string m_strScriptReturnLabel = string.Empty;
- private static StringDictionary m_CachedSaveDataDic;
- private const string STR_ROOM_NAME_DEFAULT_HEADER = "自室カスタム";
- private const int ROOM_NAME_MAX_COUNT = 10;
- private const string STR_ROOM_NAME_ELLIPSE = "…";
- public class CreativeRoomHeader
- {
- public string guid;
- public string comment;
- public string lastWriteTime;
- public long headerSize;
- }
- }
- }
|