GameModeManager.cs 3.9 KB

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