/*: * @plugindesc フトコロ版スキルツリー拡張プラグイン * @target MZ * * @param increment * @text ゲージ増加量 * @type number * @decimals 1 * @default 2.0 * @min 0.1 * @desc 1フレームあたりのゲージ増加量(0.1~) */ !function() { 'use strict'; let $p = function parse(param) { try { param = JSON.parse(param); } catch (e) {} if (Array.isArray(param)) { param = param.map(value => parse(value)); } else if (typeof param == 'object') { for (let key in param) { param[key] = parse(param[key]); } } return param; }({ ...PluginManager.parameters('FTKR_SkillTreeSystem_Ext') }); //============================================================================== // Scene_Boot //============================================================================== (__loadSystemImages => { Scene_Boot.prototype.loadSystemImages = function() { __loadSystemImages.apply(this, arguments); ImageManager.loadSystem('CircleGauge'); }; })(Scene_Boot.prototype.loadSystemImages); //============================================================================== // Scene_STS //============================================================================== (__create => { Scene_STS.prototype.create = function() { __create.apply(this, arguments); this.circleSprite = new Sprite_CircleGauge(ImageManager.loadSystem('CircleGauge')); this.addChild(this.circleSprite); }; })(Scene_STS.prototype.create); //============================================================================== // Window_SkillTree //============================================================================== (__initialize => { Window_SkillTree.prototype.initialize = function() { __initialize.apply(this, arguments); this.__pressOk = [0, 0]; this.__isReady = false; this.__noBuzzer = false; }; })(Window_SkillTree.prototype.initialize); (__actSelect => { Window_SkillTree.prototype.actSelect = function(index) { __actSelect.apply(this, arguments); this.__isReady = false; }; })(Window_SkillTree.prototype.actSelect); (__isCursorMovable => { Window_SkillTree.prototype.isCursorMovable = function() { return __isCursorMovable.apply(this, arguments) && this.__pressOk.every(v => v == 0); }; })(Window_SkillTree.prototype.isCursorMovable); (__callHandler => { Window_SkillTree.prototype.callHandler = function(symbol) { if (symbol == 'ok') { this.activate(); return; } __callHandler.apply(this, arguments); }; })(Window_SkillTree.prototype.callHandler); (__playOkSound => { Window_SkillTree.prototype.playOkSound = function() { ; }; })(Window_SkillTree.prototype.playOkSound); (__playBuzzerSound => { Window_SkillTree.prototype.playBuzzerSound = function() { if (this.__noBuzzer) return; __playBuzzerSound.apply(this, arguments); }; })(Window_SkillTree.prototype.playBuzzerSound); //-------------------------------------------------------------------------- // キャンセル入力時のゲージ停止処理を追加 //-------------------------------------------------------------------------- (__update => { Window_SkillTree.prototype.update = function() { __update.apply(this, arguments); // キャンセルキーが押されている場合、ゲージを停止してハンドラを解除する if (Input.isPressed('cancel')) { let sprite = this.parent.parent.circleSprite; if (sprite && sprite.visible) { sprite._handler = null; // OK用ハンドラを解除 sprite.stop(); this.__noBuzzer = false; } // OK押下のカウンタをリセットして以降の処理を中断 this.__pressOk = [0, 0]; return; } if (Input.isPressed('ok')) { this.__pressOk[0]++; } else { this.__pressOk[0] = 0; } if (TouchInput.isPressed()) { this.__pressOk[1]++; } else { this.__pressOk[1] = 0; } if (this.__isReady && this.__pressOk.some(v => v == 1)) { this.__noBuzzer = false; if (this.__pressOk[0] == 1 || this.hitIndex() == this.index()) { if (this.isLearnOk(this.item())) { let ssi = FTKR.STS.sFrame.icon; let rect = this.itemRect(this.index()); let x = this.x + this.standardPadding() + ssi.offsetX + rect.x + rect.width / 2; let y = this.y + this.standardPadding() + ssi.offsetY + rect.y + rect.height / 2; let sprite = this.parent.parent.circleSprite; sprite.start(x, y, this._handlers['ok']); this.__noBuzzer = true; } } } else if (this.__pressOk.every(v => v == 0)) { let sprite = this.parent.parent.circleSprite; if (sprite && sprite.visible) { sprite.stop(); this.__noBuzzer = false; } this.__isReady = true; } }; })(Window_SkillTree.prototype.update); //============================================================================== // Sprite_CircleGauge //============================================================================== class Sprite_CircleGauge extends Sprite { constructor(bitmap) { super(); this.init(); bitmap.addLoadListener(this.setup.bind(this, bitmap)); } init() { this.anchor.x = 0.5; this.anchor.y = 0.5; // ゲージスプライト this._circleSprite = [new Sprite(), new Sprite()]; this._circleSprite[0].anchor.x = 1.0; this._circleSprite[0].anchor.y = 0.5; this._circleSprite[1].anchor.y = 0.5; this.addChild(this._circleSprite[0]); this.addChild(this._circleSprite[1]); // マスクスプライト this._maskSprite = [new Sprite(), new Sprite()]; this._maskSprite[0].anchor.y = 0.5; this._maskSprite[1].anchor.x = 1.0; this._maskSprite[1].anchor.y = 0.5; this.addChild(this._maskSprite[0]); this.addChild(this._maskSprite[1]); // プロパティ this._rate = 0; this._state = 0; this._handler = null; this.visible = false; } setup(bitmap) { let width = bitmap.width; let height = bitmap.height; this.bitmap = bitmap; this.setFrame(0, 0, width, height / 2); this.setupCircleSprite(); this.setupMaskSprite(); this.setupSound(); } setupCircleSprite() { let bitmap = this.bitmap; let width = bitmap.width; let height = bitmap.height; // ゲージ画像(左) this._circleSprite[0].bitmap = bitmap; this._circleSprite[0].setFrame(0, height / 2, width / 2, height / 2); // ゲージ画像(右) this._circleSprite[1].bitmap = bitmap; this._circleSprite[1].setFrame(width / 2, height / 2, width / 2, height / 2); } setupMaskSprite() { let height = this.bitmap.height / 2 + 16; // マスク用Bitmap let maskBitmap = new Bitmap(height, height); maskBitmap.fillAll('#ffffff'); // マスクスプライト(左用) this._maskSprite[0].bitmap = maskBitmap; this._circleSprite[0].mask = this._maskSprite[0]; // マスクスプライト(右用) this._maskSprite[1].bitmap = maskBitmap; this._circleSprite[1].mask = this._maskSprite[1]; } setupSound() { this._se = new WebAudio(`audio/se/CircleGauge${AudioManager.audioFileExt()}`); } start(x, y, handler) { this.x = x; this.y = y; this._state = 1; this._rate = 0; this._handler = handler; AudioManager.updateSeParameters(this._se, {volume: 100, pitch: 100, pan: 0 }); this._se.play(false, 0); } stop() { this._rate = 0; this._state = 0; this._handler = null; this._se.stop(); } update() { super.update(); if (this._state == 1) { this._rate = Math.min(this._rate + $p['increment'], 100); this.visible = true; } else { this._rate = 0; this.visible = false; } if (this._rate <= 50) { let deg = this._rate / 50 * 180; this._maskSprite[1].rotation = deg / 180 * Math.PI; this._maskSprite[0].rotation = 0; } else { let deg = (this._rate - 50) / 50 * 180; this._maskSprite[0].rotation = deg / 180 * Math.PI; this._maskSprite[1].rotation = Math.PI; } if (this._rate >= 100) { if (this._handler) { this._handler(); } this.stop(); this.visible = false; } } } window.Sprite_CircleGauge = Sprite_CircleGauge; }();