Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CM3D2.YotogiParamCtrl.Plugin.0.0.0.1 : 夜伽時のパラメータ(興奮/精神/理性)を固定するUnityInjector用プラグイン
- // 機能.
- // 夜伽画面中にテンキー0で機能有効/無効の切り替え
- // テンキー1、2、3を押して興奮・精神・理性に対象を切り替えて、テンキーの+/-で5ずつ増減させる。
- // 作成の経緯.
- // AddModsSliderの夜伽時のパラメータ固定機能がOculusVRでは動作しないために作成.
- // 0.0.0.1 初版(Add Mods Sliderを参考に新規作成)
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Reflection;
- using System.Text;
- using UnityEngine;
- using UnityInjector.Attributes;
- namespace CM3D2.YotogiParamCtrl.Plugin
- {
- [PluginFilter("CM3D2x64"),
- PluginFilter("CM3D2x86"),
- PluginFilter("CM3D2VRx64"),
- PluginName("CM3D2 YotogiParamCtrl"),
- PluginVersion("0.0.0.1")]
- public class YotogiParamCtrl : UnityInjector.PluginBase
- {
- public const string Version = "0.0.0.1";
- private const int SCENELEVEL_YOTOGI = 14; // 夜伽シーンを表す定数
- private const int MAID_EXCITE = 0; // 興奮度
- private const int MAID_MIND = 1; // 精神
- private const int MAID_REASON = 2; // 理性
- private const float PARAM_STEP = 5f; // パラメータ増減値
- private YotogiParamBasicBar yotogiParamBasicBar; // 画面上部の夜伽バー(多分)
- private int sceneLevel;
- private bool is_enable = false;
- private int param_idx = MAID_EXCITE; // 初期操作対象は興奮度としておく
- private float[] fYotogiValue = new float[] { 0f, 0f, 0f };
- private float[] fYotogiMinValue = new float[] { -100f, 0f, 0f };
- private float[] fYotogiMaxValue = new float[] { 0f, 0f, 0f };
- // スクリプト起動時に呼ばれるハンドラ
- public void Awake()
- {
- // シーン変更時に破棄されないようにする
- GameObject.DontDestroyOnLoad(this);
- return;
- }
- // シーンレベルロード完了時に呼ばれるハンドラ
- public void OnLevelWasLoaded(int level)
- {
- // シーンレベルの保存
- sceneLevel = level;
- return;
- }
- // 毎フレーム呼ばれるハンドラ
- public void Update()
- {
- // 夜伽時、本プラグインのメイン処理
- if (sceneLevel == SCENELEVEL_YOTOGI) {
- // 夜伽対象のメイドへの参照を取得
- Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
- // 未取得の場合、夜伽用のUIバーへの参照を取得.
- if (!this.yotogiParamBasicBar)
- {
- this.yotogiParamBasicBar = BaseMgr<YotogiParamBasicBar>.Instance;
- }
- // テンキー0で有効/無効の切り替えを制御
- if (Input.GetKeyDown(KeyCode.Keypad0)) {
- if (is_enable) {
- is_enable = false;
- //Debug.Log("YotogiParamCtrl is Disable");
- }
- else {
- is_enable = true;
- //Debug.Log("YotogiParamCtrl is Enable");
- }
- }
- // 機能有効、かつ夜伽バーの取得に成功、メイドへの参照に成功している場合、処理実行する
- if ((is_enable == true) && (this.yotogiParamBasicBar != null) && (maid != null)) {
- // 操作対象切り替え(興奮度)
- if ( Input.GetKeyDown(KeyCode.Keypad1) ) {
- param_idx = MAID_EXCITE;
- //Debug.Log("YotogiParamCtrl Target:Excite");
- }
- // 操作対象切り替え(精神)
- else if ( Input.GetKeyDown(KeyCode.Keypad2) ) {
- param_idx = MAID_MIND;
- //Debug.Log("YotogiParamCtrl Target:Mind");
- }
- // 操作対象切り替え(理性)
- else if ( Input.GetKeyDown(KeyCode.Keypad3) ) {
- param_idx = MAID_REASON;
- //Debug.Log("YotogiParamCtrl Target:Reason");
- }
- // 現在値を取得
- fYotogiValue[MAID_EXCITE] = maid.Param.status.cur_excite; // 興奮度
- fYotogiValue[MAID_MIND] = maid.Param.status.cur_mind; // 精神
- fYotogiValue[MAID_REASON] = maid.Param.status.cur_reason; // 理性
- // 最大値を取得
- fYotogiMaxValue[MAID_EXCITE] = 300; // 興奮度
- fYotogiMaxValue[MAID_MIND] = maid.Param.status.mind + maid.Param.status.maid_class_bonus_status.mind; // 精神
- fYotogiMaxValue[MAID_REASON] = maid.Param.status.reason; // 理性
- // 最小値を取得(コードとしてはは不要だが、修正しやすいように)
- fYotogiMinValue[MAID_EXCITE] = -100; // 興奮度
- fYotogiMinValue[MAID_MIND] = 0; // 精神
- fYotogiMinValue[MAID_REASON] = 0; // 理性
- // テンキー「+」で増加
- if ( Input.GetKeyDown(KeyCode.KeypadPlus) ) {
- fYotogiValue[param_idx] += PARAM_STEP;
- //Debug.Log("YotogiParamCtrl Paramater Plus");
- }
- // テンキー「-」で減少
- else if ( Input.GetKeyDown(KeyCode.KeypadMinus) ) {
- fYotogiValue[param_idx] -= PARAM_STEP;
- //Debug.Log("YotogiParamCtrl Paramater Minus");
- }
- // 最大値、最小値へのクリッピング
- if (fYotogiValue[param_idx] > fYotogiMaxValue[param_idx]) {
- fYotogiValue[param_idx] = fYotogiMaxValue[param_idx];
- //Debug.Log("YotogiParamCtrl Max Value");
- }
- else if (fYotogiValue[param_idx] < fYotogiMinValue[param_idx]) {
- fYotogiValue[param_idx] = fYotogiMinValue[param_idx];
- //Debug.Log("YotogiParamCtrl Min Value");
- }
- // メイドのパラメータ更新
- maid.Param.SetCurExcite((int)fYotogiValue[MAID_EXCITE]);
- maid.Param.SetCurMind((int)fYotogiValue[MAID_MIND]);
- maid.Param.SetCurReason((int)fYotogiValue[MAID_REASON]);
- // 夜伽バーの更新
- this.yotogiParamBasicBar.SetCurrentExcite((int)this.fYotogiValue[MAID_EXCITE], true);
- this.yotogiParamBasicBar.SetCurrentMind((int)this.fYotogiValue[MAID_MIND], true);
- this.yotogiParamBasicBar.SetCurrentReason((int)this.fYotogiValue[MAID_REASON], true);
- }
- }
- else
- {
- // 夜伽シーン以外では、誤動作防止のため無効化
- is_enable = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement