19180529

CM3D2.KissYourMaid.Plugin.cs

Oct 9th, 2015
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 45.93 KB | None | 0 0
  1.  
  2. using ExIni;
  3. using System;
  4. using System.Linq;
  5. using System.Diagnostics;
  6. using UnityEngine;
  7. using UnityInjector.Attributes;
  8.  
  9. // OH版はChu-BLipにしかないクラスを使っている1行のコメントアウトを外しているだけです(maid.onahole.motion.playedPistonSeType)
  10. // 1つのソースファイルで済ませたかったのですが、やり方が分かりませんでした…
  11.  
  12. // コンパイル用コマンド "C:\Windows\Microsoft.NET\Framework\v3.5\csc" /t:library /lib:..\CM3D2x64_Data(環境に合わせて変更)\Managed /r:UnityEngine.dll /r:UnityInjector.dll /r:Assembly-CSharp.dll /r:Assembly-CSharp-firstpass.dll /r:ExIni.dll CM3D2.KissYourMaid.Plugin.cs
  13.  
  14. namespace CM3D2.KissYourMaid.Plugin
  15. {
  16.  
  17.     [PluginFilter("CM3D2x64"), PluginFilter("CM3D2x86"), PluginFilter("CM3D2VRx64"),
  18.     PluginFilter("CM3D2OHx64"), PluginFilter("CM3D2OHx86"), PluginFilter("CM3D2OHVRx64"),
  19.     PluginName("KissYourMaid"), PluginVersion("0.2.0.0")]
  20.  
  21.  
  22.     public class KissYourMaid : UnityInjector.PluginBase
  23.     {
  24.  
  25.         //
  26.         private bool bPluginEnabled = true;                 // 本プラグインの有効状態(下記キーでON/OFFトグル)
  27.         private KeyCode keyPluginToggle = KeyCode.H;        // 本プラグインの有効無効の切替キー(とりあえず被らなそうなHキーに)
  28.  
  29.         // 状態管理
  30.         private int iState = 0;                             // ステート番号
  31.         private int iStateMajor = 10;                       // 距離によるステート
  32.         private int iStateMajorOld = 10;                    // 距離によるステート(前回値)
  33.         private int iStateMinor = 0;                        // 時間経過によるステート
  34.  
  35.         // 10 … 離れている
  36.         // 20 … 近い(キス前・遷移直後)
  37.         // 21 … 近い(キス前・一定時間経過後)
  38.         // 30 … とても近い(キス)
  39.         // 40 … 近い(キス後・遷移直後)
  40.         // 41 … 近い(キス後・一定時間経過後)
  41.  
  42.         // 距離判定
  43.         private float fDistanceToMaidFace;
  44.         private float fDistanceThreshold1;
  45.         private float fDistanceThreshold2;
  46.         private float fDistanceThresholdBase1 = 0.80f;      // 「近い」の判定距離
  47.         private float fDistanceThresholdBase2 = 0.50f;      // 「とても近い」の距離距離
  48.         private float fDistanceThresholdOffset = 0.20f;     // 帰り方向で判定距離をずらす距離
  49.         private float fDistanceThresholdBase1VR = 0.45f;    // (VR時)「近い」の判定距離
  50.         private float fDistanceThresholdBase2VR = 0.30f;    // (VR時)「とても近い」の距離距離
  51.         private float fDistanceThresholdOffsetVR = 0.10f;   // (VR時)帰り方向で判定距離をずらす距離
  52.  
  53.  
  54.         // 表情管理
  55.         private int iStateHoldTime;
  56.         private int iStateAltTime1;
  57.         private int iStateAltTime2;
  58.         private int iStateAltTime1Base = 2;                 // フェイスアニメの変化時間1(秒)(20→21、40→41)
  59.         private int iStateAltTime2Base = 6;                 // フェイスアニメの変化時間2(秒)(30でのランダム選択)
  60.         private int iStateAltTime1RandomExtend = 2;         // 変化時間1へのランダム加算(秒)
  61.         private int iStateAltTime2RandomExtend = 6;         // 変化時間2へのランダム加算(秒)
  62.         private float fAnimeFadeTime = 3.0f;                // フェイスアニメ等のフェード時間(秒)
  63.         private string sFaceAnimeBackup = "";
  64.         private string sFaceBlendBackup = "";
  65.  
  66.         // 表情テーブル
  67.         string[] sFaceAnime20 = new string[] { "変更しない" };
  68.         string[] sFaceAnime21 = new string[] { "目口閉じ" };
  69.         string[] sFaceAnime40 = new string[] { "困った"};
  70.         string[] sFaceAnime41 = new string[] { "優しさ", "微笑み" };
  71.         string[] sFaceAnime30Excite1 = new string[] { "接吻", "エロ羞恥2", "ダンスキス", "ダンス憂い", "エロ舐め通常", "閉じ舐め通常" };
  72.         string[] sFaceAnime30Excite2 = new string[] { "閉じフェラ通常", "エロ好感3", "エロ羞恥3", "エロ舐め快楽", "閉じフェラ愛情", "閉じ舐め愛情" };
  73.         string[] sFaceAnime30Excite3 = new string[] { "まぶたギュ", "エロ舌責", "エロ痛み3", "エロ舐め愛情", "エロ舐め嫌悪", "閉じ舐め快楽" };
  74.         string[] sFaceAnime30Excite4 = new string[] { "エロ痛み我慢3", "エロ興奮3", "エロ舌責快楽", "閉じフェラ嫌悪", "閉じ舐め嫌悪", "エロ痛み2" };
  75.  
  76.         // 声管理
  77.         private bool bVoiceOverrideEnabled = true;          // キス時の音声オーバライド(上書き)機能を使う
  78.         private bool bIsVoiceOverriding = false;            // 音声オーバライド(上書き)を適用中
  79.         private string sLoopVoiceOverriding = "";           // 音声オーバライド(上書き)を適用している音声ファイル名
  80.         private bool bOverrideInterrupted = false;          // 音声オーバライド(上書き)を適用したが、スキル変更などにより割りこまれた
  81.         private string sLoopVoiceBackup = "";               // 音声オーバライド(上書き)を終了した時に、復元再生する音声ファイル名
  82.  
  83.         // 性格別声テーブル 通常版(興奮度別)
  84.         string[] sLoopVoice30PrideExcite1 = new string[] { "s0_01276.ogg", "s0_01277.ogg", "s0_01278.ogg", "s0_01279.ogg" };
  85.         string[] sLoopVoice30PrideExcite2 = new string[] { "s0_01280.ogg", "s0_01281.ogg", "s0_01282.ogg", "s0_01283.ogg" };
  86.         string[] sLoopVoice30PrideExcite3 = new string[] { "s0_01284.ogg", "s0_01285.ogg", "s0_01286.ogg", "s0_01287.ogg" };
  87.         string[] sLoopVoice30PrideExcite4 = new string[] { "s0_01288.ogg", "s0_01289.ogg", "s0_01290.ogg", "s0_01291.ogg" };
  88.  
  89.         string[] sLoopVoice30CoolExcite1 = new string[] { "s1_02349.ogg", "s1_02350.ogg", "s1_02351.ogg", "s1_02352.ogg" };
  90.         string[] sLoopVoice30CoolExcite2 = new string[] { "s1_02353.ogg", "s1_02354.ogg", "s1_02355.ogg", "s1_02356.ogg" };
  91.         string[] sLoopVoice30CoolExcite3 = new string[] { "s1_02357.ogg", "s1_02358.ogg", "s1_02359.ogg", "s1_02360.ogg" };
  92.         string[] sLoopVoice30CoolExcite4 = new string[] { "s1_02361.ogg", "s1_02362.ogg", "s1_02363.ogg", "s1_02364.ogg" };
  93.  
  94.         string[] sLoopVoice30PureExcite1 = new string[] { "s2_01190.ogg", "s2_01191.ogg", "s2_01192.ogg", "s2_01193.ogg" };
  95.         string[] sLoopVoice30PureExcite2 = new string[] { "s2_01194.ogg", "s2_01195.ogg", "s2_01196.ogg", "s2_01197.ogg" };
  96.         string[] sLoopVoice30PureExcite3 = new string[] { "s2_01198.ogg", "s2_01199.ogg", "s2_01200.ogg", "s2_01201.ogg" };
  97.         string[] sLoopVoice30PureExcite4 = new string[] { "s2_01202.ogg", "s2_01203.ogg", "s2_01204.ogg", "s2_01205.ogg" };
  98.  
  99.         // 性格別声テーブル Chu-BLip版(ピストン速度別) ※ 興奮度が存在しないので、ピストン速度で判定する
  100.         // ※ Chu-BLip版では無いファイルが幾つかあったので、テーブルを別にした(こっちに合わせても良さそうだけど…)
  101.         string[] sLoopVoice30PridePiston1 = new string[] { "s0_01278.ogg", "s0_01278.ogg", "s0_01279.ogg", "s0_01279.ogg" };
  102.         string[] sLoopVoice30PridePiston2 = new string[] { "s0_01278.ogg", "s0_01278.ogg", "s0_01279.ogg", "s0_01279.ogg" };
  103.         string[] sLoopVoice30PridePiston3 = new string[] { "s0_01280.ogg", "s0_01280.ogg", "s0_01281.ogg", "s0_01281.ogg" };
  104.         string[] sLoopVoice30PridePiston4 = new string[] { "s0_01282.ogg", "s0_01282.ogg", "s0_01283.ogg", "s0_01283.ogg" };
  105.  
  106.         string[] sLoopVoice30CoolPiston1 = new string[] { "s1_02351.ogg", "s1_02351.ogg", "s1_02352.ogg", "s1_02352.ogg" };
  107.         string[] sLoopVoice30CoolPiston2 = new string[] { "s1_02351.ogg", "s1_02351.ogg", "s1_02352.ogg", "s1_02352.ogg" };
  108.         string[] sLoopVoice30CoolPiston3 = new string[] { "s1_02353.ogg", "s1_02353.ogg", "s1_02354.ogg", "s1_02354.ogg" };
  109.         string[] sLoopVoice30CoolPiston4 = new string[] { "s1_02355.ogg", "s1_02355.ogg", "s1_02356.ogg", "s1_02356.ogg" };
  110.  
  111.         string[] sLoopVoice30PurePiston1 = new string[] { "s2_01192.ogg", "s2_01192.ogg", "s2_01193.ogg", "s2_01193.ogg" };
  112.         string[] sLoopVoice30PurePiston2 = new string[] { "s2_01192.ogg", "s2_01192.ogg", "s2_01193.ogg", "s2_01193.ogg" };
  113.         string[] sLoopVoice30PurePiston3 = new string[] { "s2_01194.ogg", "s2_01194.ogg", "s2_01195.ogg", "s2_01195.ogg" };
  114.         string[] sLoopVoice30PurePiston4 = new string[] { "s2_01196.ogg", "s2_01196.ogg", "s2_01197.ogg", "s2_01197.ogg" };
  115.  
  116.         // 興奮度管理
  117.         private int iExciteLevel = 1;                       // 0~300の興奮度を、1~4の興奮レベルに変換した値
  118.         private int iExciteLevelThreshold1 = 150;           // 興奮レベル1→2閾値
  119.         private int iExciteLevelThreshold2 = 200;           // 興奮レベル2→3閾値
  120.         private int iExciteLevelThreshold3 = 250;           // 興奮レベル3→4閾値
  121.  
  122.         // Chu-B Lip / VR
  123.         private bool bChuBLip;
  124.         private bool bOculusVR;
  125.         private OVRDisplay ovrDisplay;
  126.         private int iExciteLevelOld;
  127.         private bool bPistonSpeedChanged;
  128.        
  129.         //
  130.         private int iSceneLevel = 0;
  131.         private bool bIsYotogiScene;
  132.         private int iFrameCount = 0;
  133.         private int iFpsMax = 60;
  134.         private int iFpsMaxVR = 75;
  135.  
  136.         //
  137.         private CameraMain mainCamera;
  138.         private Maid maid;
  139.         private Transform maidHead;
  140.  
  141.  
  142.  
  143.  
  144.         void Awake()
  145.         {
  146.             GameObject.DontDestroyOnLoad(this);
  147.  
  148.             string path = Application.dataPath;
  149.  
  150.             // ChuBLip判別
  151.             bChuBLip = path.Contains("CM3D2OHx64") || path.Contains("CM3D2OHx86") || path.Contains("CM3D2OHVRx64");
  152.             if (bChuBLip)
  153.             {
  154.                 sLoopVoice30CoolExcite1 = sLoopVoice30PridePiston1;
  155.                 sLoopVoice30CoolExcite2 = sLoopVoice30PridePiston2;
  156.                 sLoopVoice30CoolExcite3 = sLoopVoice30PridePiston3;
  157.                 sLoopVoice30CoolExcite4 = sLoopVoice30PridePiston4;
  158.             }
  159.  
  160.             // VR判別
  161.             bOculusVR = path.Contains("CM3D2OHVRx64") || path.Contains("CM3D2VRx64");
  162.             if (bOculusVR)
  163.             {
  164.                 fDistanceThresholdBase1 = fDistanceThresholdBase1VR;
  165.                 fDistanceThresholdBase2 = fDistanceThresholdBase2VR;
  166.                 fDistanceThresholdOffset = fDistanceThresholdOffsetVR;
  167.                 iFpsMax = iFpsMaxVR;
  168.                 ovrDisplay = new OVRDisplay();
  169.             }
  170.  
  171.             fDistanceThreshold1 = fDistanceThresholdBase1;
  172.             fDistanceThreshold2 = fDistanceThresholdBase2;
  173.  
  174.         }
  175.  
  176.  
  177.  
  178.         public void Start()
  179.         {
  180.  
  181.  
  182.         }
  183.  
  184.  
  185.  
  186.         void OnLevelWasLoaded(int level)
  187.         {
  188.             // レベルの取得
  189.             iSceneLevel = level;
  190.  
  191.             // メインカメラの取得
  192.             mainCamera = GameMain.Instance.MainCamera;
  193.  
  194.             // メイドさんの取得
  195.             maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  196.             if (maid)
  197.             {
  198.  
  199.                 Transform[] objList = maid.transform.GetComponentsInChildren<Transform>();
  200.                 if (objList.Count() == 0)
  201.                 {
  202.  
  203.                 }
  204.                 else
  205.                 {
  206.                     foreach (var gameobject in objList)
  207.                     {
  208.                         if (gameobject.name == "Bone_Face")
  209.                         {
  210.                             maidHead = gameobject;
  211.                         }
  212.                     }
  213.                 }
  214.             }
  215.  
  216.             // 夜伽シーンに有るかチェック
  217.             checkYotogiScene();
  218.  
  219.             // 設定ファイルの読込・初期化
  220.             loadConfigIni();
  221.  
  222.             // 各バックアップ値の初期化
  223.             sFaceAnimeBackup = "";
  224.             sFaceBlendBackup = "";
  225.             sLoopVoiceBackup = "";
  226.         }
  227.  
  228.  
  229.  
  230.         void OnGUI()
  231.         {
  232. #if DEBUG
  233.             //GUIへのデバッグ表示
  234.             if (maid)
  235.             {
  236.                 GUI.Label(new Rect(0, 0, 900, 30),
  237.                               string.Format("Level={0}, Yotogi={1}, iState={2}, fDistanceToMaidFace={3} ",
  238.                                              iSceneLevel, bIsYotogiScene, iState, fDistanceToMaidFace));
  239.  
  240.                 if (maid.AudioMan != null && maid.AudioMan.FileName != null)
  241.                 {
  242.                     GUI.Label(new Rect(0, 30, 900, 60),
  243.                                   string.Format("AudioClip={0}, IsLoop={1}, AudioTime={2} of {3}, ActiveFace={4}, ExciteLevel={5}",
  244.                                                  maid.AudioMan.FileName, maid.AudioMan.audiosource.loop, maid.AudioMan.audiosource.time, maid.AudioMan.audiosource.clip.length, maid.ActiveFace, iExciteLevel));
  245.  
  246.                     GUI.Label(new Rect(0, 60, 900, 90),
  247.                                   string.Format("bIsVoiceOverriding={0}, sLoopVoiceBackup={1}, iStateAltTime1={2}, iStateAltTime2={3}",
  248.                                                 bIsVoiceOverriding, sLoopVoiceBackup, iStateAltTime1, iStateAltTime2));
  249.                 }
  250.             }
  251. #endif
  252.         }
  253.  
  254.  
  255.  
  256.         void Update()
  257.         {
  258.             // 約1秒毎に呼び出す
  259.             if (iFrameCount == iFpsMax)
  260.             {
  261.                 iFrameCount = 0;
  262.  
  263.                 // 表情等変更処理
  264.                 if (bPluginEnabled && bIsYotogiScene)
  265.                 {
  266.                     checkFaceDistance();
  267.                 }
  268.             }
  269.             else
  270.             {
  271.                 iFrameCount++;
  272.             }
  273.  
  274.  
  275.             // 本プラグインの有効無効の切替
  276.             if (Input.GetKeyDown(keyPluginToggle))
  277.             {
  278.                 bPluginEnabled = !bPluginEnabled;
  279.  
  280.                 //// プラグイン有効化時に設定ファイル読みなおし ※再起動しないとIni読みなおしてくれない??
  281.                 //if (bPluginEnabled)
  282.                 //{
  283.                 //    // 設定ファイルの読込・初期化
  284.                 //    loadConfigIni();
  285.                 //}
  286.  
  287.                 // プラグイン無効化時の処理
  288.                 if (!bPluginEnabled && sFaceAnimeBackup != "")
  289.                 {
  290.                     // 表情の復元
  291.                     restoreFace();
  292.  
  293.                     // 音声の復元もしくは停止
  294.                     if (bIsVoiceOverriding)
  295.                     {
  296.                         // オーバライド状態を解除
  297.                         bIsVoiceOverriding = false;
  298.                         bOverrideInterrupted = false;
  299.  
  300.                         // 復元もしくは停止
  301.                         if (sLoopVoiceBackup != "")
  302.                         {
  303.                             maid.AudioMan.LoadPlay(sLoopVoiceBackup, 0f, true, true);
  304.                             debugPrintConsole("voice restore done. " + sLoopVoiceBackup);
  305.                         }
  306.                         else
  307.                         {
  308.                             maid.AudioMan.Stop();
  309.                             debugPrintConsole("voice stop done. " + sLoopVoiceBackup);
  310.                         }
  311.                     }
  312.  
  313.  
  314.  
  315.                 }
  316.             }
  317.         }
  318.  
  319.  
  320.  
  321.  
  322.         // カメラ(プレイヤーの視点)とメイドさんの頭との距離に応じて、
  323.         // 表情など(フェイスアニメ、フェイスブレンド、顔目追従の状態)を変える
  324.         private void checkFaceDistance()
  325.         {
  326.  
  327.             // 距離取得
  328.             if (bOculusVR)
  329.             {
  330.                 OVRPose ovrPose;
  331.                 ovrPose = ovrDisplay.GetHeadPose(0d); //GetEyePoseの方がいい?要検討        
  332.                 Vector3 displayPos = new Vector3(ovrPose.position.x, ovrPose.position.y, ovrPose.position.z);
  333.                 displayPos = Quaternion.Euler(0f, mainCamera.transform.localEulerAngles.y, 0f) * displayPos;
  334.                 fDistanceToMaidFace = Vector3.Distance(maidHead.transform.position, mainCamera.transform.position + displayPos);
  335.             }
  336.             else
  337.             {
  338.                 fDistanceToMaidFace = Vector3.Distance(maidHead.transform.position, mainCamera.transform.position);
  339.             }
  340.  
  341.  
  342.  
  343.             // 距離ステートの変更
  344.             if (fDistanceToMaidFace < fDistanceThreshold2) // 「とても近い」
  345.             {
  346.                 iStateMajor = 30;
  347.                 fDistanceThreshold1 = fDistanceThresholdBase1 + fDistanceThresholdOffset;
  348.                 fDistanceThreshold2 = fDistanceThresholdBase2 + fDistanceThresholdOffset;
  349.             }
  350.             else if (fDistanceToMaidFace < fDistanceThreshold1) // 「近い」
  351.             {
  352.  
  353.                 // 「離れている」から来た時と、「とても近い」から来た時を区別する
  354.                 if (iStateMajorOld < 20)
  355.                 {
  356.                     iStateMajor = 20;
  357.                 }
  358.                 else if (20 <= iStateMajorOld && iStateMajorOld < 30)
  359.                 {
  360.                     iStateMajor = 20;
  361.                 }
  362.                 else if (30 <= iStateMajorOld && iStateMajorOld < 40)
  363.                 {
  364.                     iStateMajor = 40;
  365.                 }
  366.                 else if (40 <= iStateMajorOld)
  367.                 {
  368.                     iStateMajor = 40;
  369.                 }
  370.                 fDistanceThreshold1 = fDistanceThresholdBase1 + fDistanceThresholdOffset;
  371.                 fDistanceThreshold2 = fDistanceThresholdBase2;
  372.             }
  373.             else // 「離れている」
  374.             {
  375.                 iStateMajor = 10;
  376.                 fDistanceThreshold1 = fDistanceThresholdBase1;
  377.                 fDistanceThreshold2 = fDistanceThresholdBase2;
  378.             }
  379.  
  380.             // 「離れている」から遷移してくる時には、その時点での表情などをバックアップしておく
  381.             if (iStateMajor != 10 && iStateMajorOld == 10) backupFace();
  382.  
  383.             // 距離ステートが変わったら、時間カウンタをリセットする
  384.             if (iStateMajor != iStateMajorOld)
  385.             {
  386.                 // 時間カウンタのリセット
  387.                 iStateHoldTime = 0;
  388.                 // 表情変化時間のランダマイズ
  389.                 iStateAltTime1 = iStateAltTime1Base + UnityEngine.Random.Range(0, iStateAltTime1RandomExtend + 1);
  390.             }
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.             // 時間ステートの変更
  398.             if (iStateMajor == 10) iStateMinor = 0;
  399.  
  400.             if (iStateMajor == 20 || iStateMajor == 40)
  401.             {
  402.                 // 時間経過により、一方通行で表情変化      
  403.                 iStateMinor = 0;
  404.                 if (iStateAltTime1 <= iStateHoldTime) iStateMinor = 1;
  405.             }
  406.  
  407.             if (iStateMajor == 30)
  408.             {
  409.                 iStateMinor = 0;
  410.                 if (iStateAltTime2 <= iStateHoldTime)
  411.                 {
  412.                     // 時間カウンタのリセット
  413.                     iStateHoldTime = 0;
  414.                     // 表情変化時間のランダマイズ
  415.                     iStateAltTime2 = iStateAltTime2Base + UnityEngine.Random.Range(0, iStateAltTime2RandomExtend + 1);
  416.                 }
  417.             }
  418.  
  419.             iState = iStateMajor + iStateMinor;
  420.  
  421.  
  422.  
  423.  
  424.             // 興奮度の判定 (通常版用)
  425.             int iCurrentExcite = maid.Param.status.cur_excite;
  426.  
  427.             if (iCurrentExcite < iExciteLevelThreshold1)
  428.             {
  429.                 iExciteLevel = 1;
  430.             }
  431.             else if (iExciteLevelThreshold1 <= iCurrentExcite && iCurrentExcite < iExciteLevelThreshold2)
  432.             {
  433.                 iExciteLevel = 2;
  434.             }
  435.             else if (iExciteLevelThreshold2 <= iCurrentExcite && iCurrentExcite < iExciteLevelThreshold3)
  436.             {
  437.                 iExciteLevel = 3;
  438.             }
  439.             else if (iExciteLevelThreshold3 <= iCurrentExcite)
  440.             {
  441.                 iExciteLevel = 4;
  442.             }
  443.  
  444.  
  445.             // ピストン速度の判定 (Chu-BLip版用)
  446.             string sPistonSpeed = "";
  447.  
  448.             // 次の行はChu-BLip版でしか使えないので、通常版用にコンパイルするときはコメントアウトする。
  449.             //sPistonSpeed = maid.onahole.motion.playedPistonSeType.ToString();
  450.  
  451.  
  452.             if (bChuBLip)
  453.             {
  454.                 if (sPistonSpeed == "低速")
  455.                 {
  456.                     iExciteLevel = 2;
  457.                 }
  458.                 else if (sPistonSpeed == "中速")
  459.                 {
  460.                     iExciteLevel = 3;
  461.                 }
  462.                 else if (sPistonSpeed == "高速")
  463.                 {
  464.                     iExciteLevel = 4;
  465.                 }
  466.                 else // "停止" or NO_DATA
  467.                 {
  468.                     iExciteLevel = 1;
  469.                 }
  470.  
  471.                 // スピードが変わったら音声を改めて適用する
  472.                 if (iExciteLevel != iExciteLevelOld)
  473.                 {
  474.                     bPistonSpeedChanged = true;
  475.                     debugPrintConsole("piston speed has changed.");
  476.                 }
  477.                 iExciteLevelOld = iExciteLevel;
  478.             }
  479.  
  480.  
  481.  
  482.  
  483.  
  484.             // ループ音声の適用
  485.  
  486.             // ループ音声が流れているときはバックアップする(オーバライドしたものは除く)
  487.             // 夜伽前の会話シーンなど、ループ音声が拾えない時もあるので注意すること
  488.             if (bVoiceOverrideEnabled)
  489.             {
  490.  
  491.                 // ループ音声のバックアップ(通常版)
  492.                 if (!bChuBLip && !bIsVoiceOverriding && maid.AudioMan.audiosource.loop && maid.AudioMan.audiosource.isPlaying)
  493.                 {
  494.                     bOverrideInterrupted = false;
  495.                     sLoopVoiceBackup = maid.AudioMan.FileName;
  496.                     debugPrintConsole("voice backup done. " + sLoopVoiceBackup);
  497.                 }
  498.  
  499.                 // 一回再生音声のバックアップ(ChuBLip版)
  500.                 if (bChuBLip && !bIsVoiceOverriding)
  501.                 {
  502.                     bOverrideInterrupted = false;
  503.                     sLoopVoiceBackup = maid.AudioMan.FileName;
  504.                     debugPrintConsole("voice backup done. " + sLoopVoiceBackup);
  505.                 }
  506.  
  507.  
  508.  
  509.  
  510.                 // 音声オーバライド判定開始ここから              
  511.                 bool bAllowVoiceOverride = false;
  512.  
  513.                 // 「とても近い」
  514.                 if (iStateMajor == 30)
  515.                 {
  516.                     // 割り込みされた後、バックアップが拾えてない状況ではない
  517.                     if (!bOverrideInterrupted)
  518.                     {
  519.                         // 音声オーバライド未だ or 時間カウントリセット時
  520.                         if (!bIsVoiceOverriding || iStateHoldTime == 0)
  521.                         {
  522.                             // ループ音声を再生中、もしくは一回再生音声が再生済みなら介入してよい
  523.                             if (maid.AudioMan.audiosource.loop || (!maid.AudioMan.audiosource.loop && !maid.AudioMan.audiosource.isPlaying))
  524.                             {
  525.                                 bAllowVoiceOverride = true;
  526.                             }
  527.  
  528.                             // ChuBLip版では、ループ音声が夜伽で使われないので、上の条件によらず許可する
  529.                             if (bChuBLip)
  530.                             {
  531.                                 bAllowVoiceOverride = true;
  532.                             }
  533.  
  534.                         }
  535.  
  536.                         // ChuBLip版では、ピストン速度に変化があった時に、強制的に新しい音声を再生しなおす
  537.                         if (bChuBLip & bPistonSpeedChanged)
  538.                         {
  539.                             bPistonSpeedChanged = false;
  540.                             bAllowVoiceOverride = true;
  541.                             iStateHoldTime = 0;
  542.                         }
  543.                     }
  544.                 }
  545.  
  546.  
  547.  
  548.                 // 上記でオーバーライドが許可されたら実際に再生する
  549.                 if (bAllowVoiceOverride)
  550.                 {
  551.                     bIsVoiceOverriding = true;
  552.  
  553.  
  554.                     int iRandomVoice = UnityEngine.Random.Range(0, 4);
  555.                     string sPersonal = maid.Param.status.personal.ToString();
  556.  
  557.                     if (sPersonal == "Pure")
  558.                     {
  559.                         if (iExciteLevel == 1)
  560.                         {
  561.                             maid.AudioMan.LoadPlay(sLoopVoice30PureExcite1[iRandomVoice], 0f, true, true);
  562.                         }
  563.                         else if (iExciteLevel == 2)
  564.                         {
  565.                             maid.AudioMan.LoadPlay(sLoopVoice30PureExcite2[iRandomVoice], 0f, true, true);
  566.                         }
  567.                         else if (iExciteLevel == 3)
  568.                         {
  569.                             maid.AudioMan.LoadPlay(sLoopVoice30PureExcite3[iRandomVoice], 0f, true, true);
  570.                         }
  571.                         else if (iExciteLevel == 4)
  572.                         {
  573.                             maid.AudioMan.LoadPlay(sLoopVoice30PureExcite4[iRandomVoice], 0f, true, true);
  574.                         }
  575.  
  576.                     }
  577.                     else if (sPersonal == "Cool")
  578.                     {
  579.                         if (iExciteLevel == 1)
  580.                         {
  581.                             maid.AudioMan.LoadPlay(sLoopVoice30CoolExcite1[iRandomVoice], 0f, true, true);
  582.                         }
  583.                         else if (iExciteLevel == 2)
  584.                         {
  585.                             maid.AudioMan.LoadPlay(sLoopVoice30CoolExcite2[iRandomVoice], 0f, true, true);
  586.                         }
  587.                         else if (iExciteLevel == 3)
  588.                         {
  589.                             maid.AudioMan.LoadPlay(sLoopVoice30CoolExcite3[iRandomVoice], 0f, true, true);
  590.                         }
  591.                         else if (iExciteLevel == 4)
  592.                         {
  593.                             maid.AudioMan.LoadPlay(sLoopVoice30CoolExcite4[iRandomVoice], 0f, true, true);
  594.                         }
  595.  
  596.                     }
  597.                     else if (sPersonal == "Pride")
  598.                     {
  599.                         if (iExciteLevel == 1)
  600.                         {
  601.                             maid.AudioMan.LoadPlay(sLoopVoice30PrideExcite1[iRandomVoice], 0f, true, true);
  602.                         }
  603.                         else if (iExciteLevel == 2)
  604.                         {
  605.                             maid.AudioMan.LoadPlay(sLoopVoice30PrideExcite2[iRandomVoice], 0f, true, true);
  606.                         }
  607.                         else if (iExciteLevel == 3)
  608.                         {
  609.                             maid.AudioMan.LoadPlay(sLoopVoice30PrideExcite3[iRandomVoice], 0f, true, true);
  610.                         }
  611.                         else if (iExciteLevel == 4)
  612.                         {
  613.                             maid.AudioMan.LoadPlay(sLoopVoice30PrideExcite4[iRandomVoice], 0f, true, true);
  614.                         }
  615.  
  616.                     }
  617.                     // 再生を始めたファイル名を記憶
  618.                     sLoopVoiceOverriding = maid.AudioMan.FileName;
  619.  
  620.                 }
  621.  
  622.  
  623.  
  624.  
  625.  
  626.                 // 音声の割り込み判定
  627.                 // 音声オーバライド状態において、一回再生音声に割り込まれたら、
  628.                 // オーバライド状態を一度解除し、バックアップ音声を拾い直す(キスしながらイッてぐったりしたメイドさんに、イク前の発情ボイスを復元してしまうといった事故を防ぐ)
  629.                 if (bIsVoiceOverriding)
  630.                 {
  631.                     // 音を切り替えるタイミングではない
  632.                     if ((iStateMajor == 30 || iStateHoldTime != 0)
  633.                         || (iStateMajor == 20 || iStateHoldTime == iStateAltTime1)
  634.                         || (iStateMajor == 40 || iStateHoldTime == iStateAltTime1))
  635.                     {
  636.                         // 再生中の音声が、オーバライドした音声と一致しない
  637.                         if (maid.AudioMan.FileName != sLoopVoiceOverriding)
  638.                         {
  639.                             bOverrideInterrupted = true;
  640.                             bIsVoiceOverriding = false;
  641.                             sLoopVoiceBackup = "";
  642.                             debugPrintConsole("override interrupted." + sLoopVoiceBackup);
  643.                         }
  644.                     }
  645.                 }
  646.  
  647.  
  648.                 // 音声オーバライドの停止と復元
  649.                 if (iStateMajor != 30 && bIsVoiceOverriding)
  650.                 {
  651.  
  652.                     // オーバライド状態を解除
  653.                     bIsVoiceOverriding = false;
  654.                     bOverrideInterrupted = false;
  655.  
  656.                     if (!bChuBLip)
  657.                     {
  658.                         // 復元もしくは停止
  659.                         if (sLoopVoiceBackup != "")
  660.                         {
  661.                             maid.AudioMan.LoadPlay(sLoopVoiceBackup, 0f, true, true);
  662.                             debugPrintConsole("voice restore done. " + sLoopVoiceBackup);
  663.                         }
  664.                         else
  665.                         {
  666.                             maid.AudioMan.Stop();
  667.                             debugPrintConsole("voice stop done. " + sLoopVoiceBackup);
  668.                         }
  669.                     }
  670.                     else
  671.                     {
  672.                         // Chu-B Lip版は復元をしない(現状、音声セリフ付きの音を復元してしまい不自然になることがある)
  673.  
  674.                     }
  675.                 }
  676.  
  677.  
  678.             }
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.             // フェイスアニメの適用
  688.             bool bAllowChangeFaceAnime = false;
  689.  
  690.             // 遷移直後かカウンタリセット時のタイミングで適用
  691.             if ((iStateHoldTime == 0)
  692.                 || (iStateMajor == 20 && iStateHoldTime == iStateAltTime1)
  693.                 || (iStateMajor == 40 && iStateHoldTime == iStateAltTime1))
  694.             {
  695.                 bAllowChangeFaceAnime = true;
  696.             }
  697.  
  698.             int iRandomFace = 0;
  699.             if (bAllowChangeFaceAnime)
  700.             {
  701.                 string sFaceAnimeName = "";
  702.  
  703.                 if (iState == 20)
  704.                 {
  705.                     iRandomFace = UnityEngine.Random.Range(0, sFaceAnime20.Length);
  706.                     sFaceAnimeName = sFaceAnime20[iRandomFace];
  707.                 }
  708.  
  709.                 if (iState == 21)
  710.                 {
  711.                     iRandomFace = UnityEngine.Random.Range(0, sFaceAnime21.Length);
  712.                     sFaceAnimeName = sFaceAnime21[iRandomFace];
  713.                 }
  714.  
  715.                 if (iState == 40)
  716.                 {
  717.                     iRandomFace = UnityEngine.Random.Range(0, sFaceAnime40.Length);
  718.                     sFaceAnimeName = sFaceAnime40[iRandomFace];
  719.                 }
  720.  
  721.                 if (iState == 41)
  722.                 {
  723.                     iRandomFace = UnityEngine.Random.Range(0, sFaceAnime41.Length);
  724.                     sFaceAnimeName = sFaceAnime41[iRandomFace];
  725.                 }
  726.  
  727.                 if (iState == 30)
  728.                 {
  729.                     if (iExciteLevel == 1)
  730.                     {
  731.                         iRandomFace = UnityEngine.Random.Range(0, sFaceAnime30Excite1.Length);
  732.                         sFaceAnimeName = sFaceAnime30Excite1[iRandomFace];
  733.                     }
  734.                     else if (iExciteLevel == 2)
  735.                     {
  736.                         iRandomFace = UnityEngine.Random.Range(0, sFaceAnime30Excite2.Length);
  737.                         sFaceAnimeName = sFaceAnime30Excite2[iRandomFace];
  738.                     }
  739.                     else if (iExciteLevel == 3)
  740.                     {
  741.                         iRandomFace = UnityEngine.Random.Range(0, sFaceAnime30Excite3.Length);
  742.                         sFaceAnimeName = sFaceAnime30Excite3[iRandomFace];
  743.                     }
  744.                     else if (iExciteLevel == 4)
  745.                     {
  746.                         iRandomFace = UnityEngine.Random.Range(0, sFaceAnime30Excite4.Length);
  747.                         sFaceAnimeName = sFaceAnime30Excite4[iRandomFace];
  748.                     }
  749.                 }
  750.  
  751.                 // ""か"変更しない"でなければ、フェイスアニメを適用する
  752.                 if (sFaceAnimeName != "" && sFaceAnimeName != "変更しない")
  753.                 {
  754.                     maid.FaceAnime(sFaceAnimeName, fAnimeFadeTime, 0);
  755.                 }
  756.  
  757.             }
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.             // フェイスブレンドの適用
  766.             // ステートに応じたフェイスブレンドに上書きする。
  767.             // ただし、より強いものが適用されるなら、そちらを尊重して上書きしない
  768.  
  769.             string sFaceBlendCurrent = maid.FaceName3;
  770.             if (sFaceBlendCurrent == "") sFaceBlendCurrent = "頬0涙0";  // 背景選択時、スキル選択時は、"" が返ってきてエラーが出るため
  771.  
  772.             string sCurrentCheek = "";
  773.             string sCurrentTears = "";
  774.             int iCurrentCheek = 0;
  775.             int iCurrentTears = 0;
  776.             bool bCurrentDrivel = false;
  777.  
  778.             string sChangeCheek = "";
  779.             string sChangeTears = "";
  780.             int iChangeCheek = 0;
  781.             int iChangeTears = 0;
  782.             string sChangeDrivel = "";
  783.             string sChangeBlend = "";
  784.  
  785.             int iOverrideCheek = 0;
  786.             int iOverrideTears = 0;
  787.             bool bOverrideDrivel = false;
  788.  
  789.             // 暫定的に、どのステート対しても、同じフェイスブレンド・顔目追従を適用する
  790.             iOverrideCheek = 2;                                     //"頬2"
  791.             iOverrideTears = 0;                                     //"涙0"
  792.             bOverrideDrivel = false;                                //よだれなし
  793.             maid.EyeToCamera((Maid.EyeMoveType)5, fAnimeFadeTime);  //顔も目もこっち見る
  794.  
  795.             sCurrentCheek = sFaceBlendCurrent.Substring(0, 2);
  796.             if (sCurrentCheek == "頬0") iCurrentCheek = 0;
  797.             if (sCurrentCheek == "頬1") iCurrentCheek = 1;
  798.             if (sCurrentCheek == "頬2") iCurrentCheek = 2;
  799.             if (sCurrentCheek == "頬3") iCurrentCheek = 3;
  800.             iChangeCheek = iCurrentCheek;
  801.             if (iOverrideCheek > iChangeCheek) iChangeCheek = iOverrideCheek;
  802.             if (iChangeCheek == 0) sChangeCheek = "頬0";
  803.             if (iChangeCheek == 1) sChangeCheek = "頬1";
  804.             if (iChangeCheek == 2) sChangeCheek = "頬2";
  805.             if (iChangeCheek == 3) sChangeCheek = "頬3";
  806.  
  807.             sCurrentTears = sFaceBlendCurrent.Substring(2, 2);
  808.             if (sCurrentTears == "涙0") iCurrentTears = 0;
  809.             if (sCurrentTears == "涙1") iCurrentTears = 1;
  810.             if (sCurrentTears == "涙2") iCurrentTears = 2;
  811.             if (sCurrentTears == "涙3") iCurrentTears = 3;
  812.             iChangeTears = iCurrentTears;
  813.             if (iOverrideTears > iChangeTears) iChangeTears = iOverrideTears;
  814.             if (iChangeTears == 0) sChangeTears = "涙0";
  815.             if (iChangeTears == 1) sChangeTears = "涙1";
  816.             if (iChangeTears == 2) sChangeTears = "涙2";
  817.             if (iChangeTears == 3) sChangeTears = "涙3";
  818.  
  819.             if (sFaceBlendCurrent.Substring(3) == "よだれ") bCurrentDrivel = true;
  820.             if (bCurrentDrivel || bOverrideDrivel) sChangeDrivel = "よだれ";
  821.  
  822.             sChangeBlend = sChangeCheek + sChangeTears + sChangeDrivel;
  823.             maid.FaceBlend(sChangeBlend);
  824.  
  825.             debugPrintConsole("FaceBlendLevel=" + iChangeCheek + " , " + iChangeTears + " , " + sChangeDrivel);
  826.             //if (bDebug) Console.WriteLine("FaceBlendLevel : {0}, {1}, {2}", iChangeCheek, iChangeTears, sChangeDrivel);
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.             // 「離れている」に戻る時に、フェイスアニメ・フェイスブレンドを復元する(現在フェイスアニメのみ復元)
  834.             if (iStateMajor == 10 && iStateMajorOld != 10) restoreFace();
  835.  
  836.             // 距離ステートの過去値を更新
  837.             iStateMajorOld = iStateMajor;
  838.  
  839.             // 距離ステート保持時間を加算する(30でカンスト)
  840.             if (iStateHoldTime++ > 30) iStateHoldTime = 30;
  841.  
  842.  
  843.  
  844.  
  845.             debugPrintConsole("Level=" + iSceneLevel + " bIsYotogi=" + bIsYotogiScene +
  846.                              " iState=" + iState + " fDistanceToMaidFace=" + fDistanceToMaidFace);
  847.         }
  848.  
  849.  
  850.  
  851.         // フェイスアニメ・フェイスブレンドのバックアップ
  852.         private void backupFace()
  853.         {
  854.             sFaceAnimeBackup = maid.ActiveFace;
  855.             sFaceBlendBackup = maid.FaceName3;
  856.             // 頭の向き追従状態も保存したいが何処に保存されているか分からない
  857.  
  858.             debugPrintConsole("face backup done. " + sFaceAnimeBackup + " , " + sFaceBlendBackup);
  859.         }
  860.  
  861.  
  862.  
  863.         // フェイスアニメ・フェイスブレンドの復元
  864.         private void restoreFace()
  865.         {
  866.             if (sFaceAnimeBackup != "")
  867.             {
  868.                 maid.FaceAnime(sFaceAnimeBackup, fAnimeFadeTime * 2, 0);
  869.             }
  870.             // 顔目追従も復元したいが、どの変数に保存されているか分からないので保留…
  871.             //maid.EyeToCamera((Maid.EyeMoveType)0, 0f);
  872.  
  873.             //maid.FaceBlend(sFaceBlendBackup);
  874.             // 近づいた時の状況を復元するので、離れた時にスキルが変わっていると表情が食い違って不自然になることがあるが、現状いい方法がないので保留…
  875.             // フェイスブレンドも復元するつもりだったが、突然素に戻ったようになってしまうことが有ったので、戻さないようにした
  876.  
  877.             sFaceAnimeBackup = "";
  878.             sFaceBlendBackup = "";
  879.  
  880.             debugPrintConsole("face restore done. " + sFaceAnimeBackup + " , " + sFaceBlendBackup);
  881.             //if (bDebug) Console.WriteLine("face restore done. {0}, {1}", sFaceAnimeBackup, sFaceBlendBackup);
  882.         }
  883.  
  884.  
  885.  
  886.         // 夜伽シーンにいるかをチェック
  887.         private void checkYotogiScene()
  888.         {
  889.             // OH版は夜伽シーンでもSceneが14にならない(10のまま)ので、YotogiManagerの有無で判別する
  890.             int iYotogiManagerCount = FindObjectsOfType<YotogiManager>().Length;
  891.             bIsYotogiScene = false;
  892.             if (iYotogiManagerCount > 0) bIsYotogiScene = true;
  893.         }
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.         // 設定ファイルの読み込み
  901.         private void loadConfigIni()
  902.         {
  903.             IniKey INIkeyPluginToggle = Preferences["Settings"]["keyPluginToggle"];
  904.             IniKey INIbVoiceOverrideEnabled = Preferences["Settings"]["bVoiceOverrideEnabled"];
  905.             readIniKey(ref keyPluginToggle, ref INIkeyPluginToggle);
  906.             readIniBool(ref bVoiceOverrideEnabled, ref INIbVoiceOverrideEnabled);
  907.  
  908.             IniKey INIiExciteLevelThreshold1 = Preferences["Settings"]["iExciteLevelThreshold1"];
  909.             IniKey INIiExciteLevelThreshold2 = Preferences["Settings"]["iExciteLevelThreshold2"];
  910.             IniKey INIiExciteLevelThreshold3 = Preferences["Settings"]["iExciteLevelThreshold3"];
  911.             readIniInt(ref iExciteLevelThreshold1, ref INIiExciteLevelThreshold1);
  912.             readIniInt(ref iExciteLevelThreshold2, ref INIiExciteLevelThreshold2);
  913.             readIniInt(ref iExciteLevelThreshold3, ref INIiExciteLevelThreshold3);
  914.  
  915.             IniKey INIfDistanceThresholdBase1 = Preferences["Settings"]["fDistanceThresholdBase1"];
  916.             IniKey INIfDistanceThresholdBase2 = Preferences["Settings"]["fDistanceThresholdBase2"];
  917.             IniKey INIfDistanceThresholdOffset = Preferences["Settings"]["fDistanceThresholdOffset"];
  918.             readIniFloat(ref fDistanceThresholdBase1, ref INIfDistanceThresholdBase1);
  919.             readIniFloat(ref fDistanceThresholdBase2, ref INIfDistanceThresholdBase2);
  920.             readIniFloat(ref fDistanceThresholdOffset, ref INIfDistanceThresholdOffset);
  921.  
  922.             IniKey INIfDistanceThresholdBase1VR = Preferences["Settings"]["fDistanceThresholdBase1VR"];
  923.             IniKey INIfDistanceThresholdBase2VR = Preferences["Settings"]["fDistanceThresholdBase2VR"];
  924.             IniKey INIfDistanceThresholdOffsetVR = Preferences["Settings"]["fDistanceThresholdOffsetVR"];
  925.             readIniFloat(ref fDistanceThresholdBase1VR, ref INIfDistanceThresholdBase1VR);
  926.             readIniFloat(ref fDistanceThresholdBase2VR, ref INIfDistanceThresholdBase2VR);
  927.             readIniFloat(ref fDistanceThresholdOffsetVR, ref INIfDistanceThresholdOffsetVR);
  928.  
  929.             IniKey INIiStateAltTime1Base = Preferences["Settings"]["iStateAltTime1Base"];
  930.             IniKey INIiStateAltTime2Base = Preferences["Settings"]["iStateAltTime2Base"];
  931.             IniKey INIiStateAltTime1RandomExtend = Preferences["Settings"]["iStateAltTime1RandomExtend"];
  932.             IniKey INIiStateAltTime2RandomExtend = Preferences["Settings"]["iStateAltTime2RandomExtend"];
  933.             IniKey INIfAnimeFadeTime = Preferences["Settings"]["fAnimeFadeTime"];
  934.             readIniInt(ref iStateAltTime1Base, ref INIiStateAltTime1Base);
  935.             readIniInt(ref iStateAltTime2Base, ref INIiStateAltTime2Base);
  936.             readIniInt(ref iStateAltTime1RandomExtend, ref INIiStateAltTime1RandomExtend);
  937.             readIniInt(ref iStateAltTime2RandomExtend, ref INIiStateAltTime2RandomExtend);
  938.             readIniFloat(ref fAnimeFadeTime, ref INIfAnimeFadeTime);
  939.  
  940.             IniKey INIsFaceAnime20 = Preferences["FaceAnime"]["sFaceAnime20"];
  941.             IniKey INIsFaceAnime21 = Preferences["FaceAnime"]["sFaceAnime21"];
  942.             IniKey INIsFaceAnime40 = Preferences["FaceAnime"]["sFaceAnime40"];
  943.             IniKey INIsFaceAnime41 = Preferences["FaceAnime"]["sFaceAnime41"];
  944.             IniKey INIsFaceAnime30Excite1 = Preferences["FaceAnime"]["sFaceAnime30Excite1"];
  945.             IniKey INIsFaceAnime30Excite2 = Preferences["FaceAnime"]["sFaceAnime30Excite2"];
  946.             IniKey INIsFaceAnime30Excite3 = Preferences["FaceAnime"]["sFaceAnime30Excite3"];
  947.             IniKey INIsFaceAnime30Excite4 = Preferences["FaceAnime"]["sFaceAnime30Excite4"];
  948.             readIniStringArray(ref sFaceAnime20, ref INIsFaceAnime20);
  949.             readIniStringArray(ref sFaceAnime21, ref INIsFaceAnime21);
  950.             readIniStringArray(ref sFaceAnime40, ref INIsFaceAnime40);
  951.             readIniStringArray(ref sFaceAnime41, ref INIsFaceAnime41);
  952.             readIniStringArray(ref sFaceAnime30Excite1, ref INIsFaceAnime30Excite1);
  953.             readIniStringArray(ref sFaceAnime30Excite2, ref INIsFaceAnime30Excite2);
  954.             readIniStringArray(ref sFaceAnime30Excite3, ref INIsFaceAnime30Excite3);
  955.             readIniStringArray(ref sFaceAnime30Excite4, ref INIsFaceAnime30Excite4);
  956.  
  957.  
  958.         }
  959.  
  960.  
  961.  
  962.         // ExIniでキーを読みだす用の関数
  963.         private void readIniKey(ref KeyCode keyTarget, ref IniKey sIniKey)
  964.         {
  965.             if (sIniKey == null || string.IsNullOrEmpty(sIniKey.Value))
  966.             {
  967.                 sIniKey.Value = keyTarget.ToString();
  968.                 SaveConfig();
  969.             }
  970.             else
  971.             {
  972.                 keyTarget = (KeyCode)Enum.Parse(typeof(KeyCode), sIniKey.Value, true);
  973.             }
  974.         }
  975.  
  976.         private void readIniBool(ref bool bTarget, ref IniKey sIniKey)
  977.         {
  978.             if (sIniKey == null || string.IsNullOrEmpty(sIniKey.Value))
  979.             {
  980.                 sIniKey.Value = bTarget.ToString();
  981.                 SaveConfig();
  982.             }
  983.             else
  984.             {
  985.                 bTarget = bool.Parse(sIniKey.Value);
  986.             }
  987.         }
  988.  
  989.         private void readIniInt(ref int iTarget, ref IniKey sIniKey)
  990.         {
  991.             if (sIniKey == null || string.IsNullOrEmpty(sIniKey.Value))
  992.             {
  993.                 sIniKey.Value = iTarget.ToString();
  994.                 SaveConfig();
  995.             }
  996.             else
  997.             {
  998.                 iTarget = int.Parse(sIniKey.Value);
  999.             }
  1000.         }
  1001.  
  1002.         private void readIniFloat(ref float fTarget, ref IniKey sIniKey)
  1003.         {
  1004.             if (sIniKey == null || string.IsNullOrEmpty(sIniKey.Value))
  1005.             {
  1006.                 sIniKey.Value = fTarget.ToString();
  1007.                 sIniKey.Value.Replace("f", "");
  1008.                 SaveConfig();
  1009.             }
  1010.             else
  1011.             {
  1012.                 fTarget = float.Parse(sIniKey.Value);
  1013.             }
  1014.         }
  1015.  
  1016.         private void readIniStringArray(ref string[] sTarget, ref IniKey sIniKey)
  1017.         {
  1018.             if (sIniKey == null || string.IsNullOrEmpty(sIniKey.Value))
  1019.             {
  1020.                 sIniKey.Value = string.Join(",", sTarget);
  1021.                 SaveConfig();
  1022.             }
  1023.             else
  1024.             {
  1025.                 sTarget = sIniKey.Value.Split(',');
  1026.             }
  1027.         }
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.         // デバッグ用コンソール出力メソッド
  1034.         [Conditional("DEBUG")]
  1035.         private void debugPrintConsole(string s)
  1036.         {
  1037.             Console.WriteLine(s);
  1038.         }
  1039.  
  1040.  
  1041.  
  1042.     }
  1043. }
Advertisement
Add Comment
Please, Sign In to add comment