GameModeManager.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. public static class GameModeManager
  6. {
  7. public static GameModeManager.Data GetData(GameModeManager.Type gameMode)
  8. {
  9. NDebug.Assert(GameModeManager.DataDic.ContainsKey(gameMode), "ゲームの進行モードに不正な値が入りました");
  10. return GameModeManager.DataDic[gameMode];
  11. }
  12. public static GameModeManager.Data GetData()
  13. {
  14. return GameModeManager.GetData(GameModeManager.nowGameMode);
  15. }
  16. public static GameModeManager.Type nowGameMode
  17. {
  18. get
  19. {
  20. return GameModeManager.m_NowGameModeType;
  21. }
  22. set
  23. {
  24. GameModeManager.m_NowGameModeType = value;
  25. }
  26. }
  27. public static bool Serialize(BinaryWriter brWrite)
  28. {
  29. brWrite.Write("CM3D21_GAME_MODE_MGR");
  30. brWrite.Write(1230);
  31. brWrite.Write(1);
  32. brWrite.Write((int)GameModeManager.m_NowGameModeType);
  33. return true;
  34. }
  35. public static bool Deserialize(BinaryReader brRead)
  36. {
  37. GameModeManager.Reset();
  38. if (brRead.BaseStream.Length <= brRead.BaseStream.Position + 1L)
  39. {
  40. Debug.Log("GameModeManager\nこれ以上は読めない");
  41. return false;
  42. }
  43. long position = brRead.BaseStream.Position;
  44. string text = brRead.ReadString();
  45. if (text != "CM3D21_GAME_MODE_MGR")
  46. {
  47. Debug.Log("GameModeManager\nヘッダー取得に失敗しました。\n" + text);
  48. brRead.BaseStream.Seek(position, SeekOrigin.Begin);
  49. return false;
  50. }
  51. int num = brRead.ReadInt32();
  52. position = brRead.BaseStream.Position;
  53. int num2 = brRead.ReadInt32();
  54. int value = brRead.ReadInt32();
  55. try
  56. {
  57. GameModeManager.nowGameMode = (GameModeManager.Type)Enum.ToObject(typeof(GameModeManager.Type), value);
  58. }
  59. catch (Exception e)
  60. {
  61. NDebug.AssertParseError("GameModeManager.Type", e);
  62. }
  63. return true;
  64. }
  65. private static void Reset()
  66. {
  67. GameModeManager.nowGameMode = GameModeManager.Type.Normal;
  68. }
  69. public static readonly Dictionary<GameModeManager.Type, GameModeManager.Data> DataDic = new Dictionary<GameModeManager.Type, GameModeManager.Data>
  70. {
  71. {
  72. GameModeManager.Type.Normal,
  73. new GameModeManager.Data(GameModeManager.Type.Normal, "main_banner_um", "従来のモード\nメイドのスケジュールを設定することで、仕事、育成、夜伽を行う事のできる従来のモード\u3000")
  74. },
  75. {
  76. GameModeManager.Type.LifeMode,
  77. new GameModeManager.Data(GameModeManager.Type.LifeMode, "main_banner_elm", "ライフモード\nメイド達が普段どのような風に\n生活、仕事をしているのかを見ることが出来るモード\n普段は見ることのできない一面や、メイド同士の珍しいやり取りが見れるかも?")
  78. }
  79. };
  80. private static GameModeManager.Type m_NowGameModeType;
  81. private const string STR_LOG_HEAD = "GameModeManager\n";
  82. private const string STR_GAME_MODE_SERIALIZE_HEADER = "CM3D21_GAME_MODE_MGR";
  83. private const int GAME_MODE_SERIALIZE_VER = 1;
  84. public enum Type
  85. {
  86. Normal,
  87. LifeMode
  88. }
  89. public class Data
  90. {
  91. public Data(GameModeManager.Type mode, string strBannerImageName, string strDescription)
  92. {
  93. this.strBannerImageName = strBannerImageName;
  94. this.strDescription = strDescription;
  95. }
  96. public readonly GameModeManager.Type gameMode;
  97. public readonly string strBannerImageName;
  98. public readonly string strDescription;
  99. }
  100. }