查看: 4520|回复: 12

[原创发布] 【2016.09.23】扫雷 1.0

[复制链接]
梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2016-9-23 23:25:11 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 汪汪 于 2016-9-23 23:31 编辑

扫雷

  1. //=============================================================================
  2. // SaoLei.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc 扫雷
  6. * @author wangwang
  7. *
  8. * @param ver
  9. * @desc 版本
  10. * @default 1.0
  11. *
  12. * @help
  13. *
  14. * ===================================================
  15. * 初始化
  16. *
  17. * $gameVariables._data[1] = new SaoLei(2,5,5,6)
  18. * 基础事件 2号事件(之后不要有事件)
  19. * 宽 5
  20. * 高 5
  21. * 雷数 6
  22. *
  23. * ===================================================
  24. * 更新
  25. *
  26. * 当结束时返回 true
  27. *
  28. * $gameVariables._data[1].update()
  29. *
  30. * 键盘输入时
  31. *   
  32. * 按 ok 键 翻开雷区
  33. * 按 shift + ok 插拔旗
  34. *
  35. * 触摸输入时
  36. *
  37. * 单击 插拔旗
  38. * 长按 翻开雷区
  39. *
  40. * 插旗只能插指定地雷数的旗
  41. * 当 翻开地雷 或者 除插旗外都翻开时 结束
  42. *
  43. * ===================================================
  44. * 结果
  45. *
  46. * var z = $gameVariables._data[1].gameEval()
  47. * "未标的地雷数" , z[0]
  48. * "标错的旗子数" , z[1]
  49. * "正确的旗子数" , z[2]
  50. *
  51. * ===================================================
  52. * 刷新
  53. *
  54. * 雷区重置
  55. * $gameVariables._data[1].refresh()
  56. *
  57. * ===================================================
  58. *
  59. *  
  60. */


  61. function SaoLei() {
  62.     this.initialize.apply(this, arguments);

  63. }

  64. //设置创造者
  65. SaoLei.prototype.constructor = SaoLei;

  66. SaoLei.prototype.initialize = function (id, x, y, z) {
  67.     this._x = x
  68.     this._y = y
  69.     this._z = z
  70.     this.make()
  71.     this.setup(id)
  72.     console.log(this.makeSprite2())
  73. };

  74. SaoLei.prototype.gameEval = function () {
  75.     var r = [0, 0, 0]
  76.     for (var i = 0; i < this._leiqu.length; i++) {
  77.         var z0 = (this._leiqu[i] == 9)
  78.         var z1 = (this._xianshi[i] == 2)
  79.         if (z0) {
  80.             if (!z1) {
  81.                 //未插旗的地雷
  82.                 r[0]++
  83.             } else {
  84.                 //正确的旗子
  85.                 r[2]++
  86.             }
  87.         } else {
  88.             if (z1) {
  89.                 //错误的旗子
  90.                 r[1]++
  91.             }
  92.         }
  93.     }
  94.     return r
  95. }


  96. SaoLei.prototype.update = function () {
  97.     if( this.isend() ){
  98.         return  true
  99.     }
  100.     var shift = Input.isPressed('shift')
  101.     var ok = Input.isTriggered('ok')
  102.     if (ok) {
  103.     } else {
  104.         ok = this.updateTouchInput()
  105.         if (ok) {
  106.             shift = true
  107.             if (TouchInput.isLongPressed()) {
  108.                 this.updateInput(true, true)
  109.                 shift = false
  110.             }
  111.         }
  112.     }
  113.     this.updateInput(ok, shift)
  114.     return  false
  115. }


  116. SaoLei.prototype.updateTouchInput = function () {
  117.     if (TouchInput.isRepeated()) {
  118.         var x = $gameMap.canvasToMapX(TouchInput.x);
  119.         var y = $gameMap.canvasToMapY(TouchInput.y);
  120.         var x0 = x - this._eventx
  121.         var y0 = y - this._eventy
  122.         if (x0 >= 0 && x0 < this._x && y0 >= 0 && y0 <= this._y) {
  123.             $gamePlayer.locate(x, y)
  124.             return true
  125.         }
  126.     }
  127.     return false
  128. }


  129. SaoLei.prototype.updateInput = function (ok, shift) {
  130.     if (ok) {
  131.         var x = $gamePlayer._x
  132.         var y = $gamePlayer._y
  133.         var x0 = x - this._eventx
  134.         var y0 = y - this._eventy
  135.         if (x0 >= 0 && x0 < this._x && y0 >= 0 && y0 <= this._y) {
  136.             var id = y0 * this._x + x0
  137.             if (shift) {
  138.                 this.dianji2(id)
  139.             } else {
  140.                 this.dianji(id)
  141.             }
  142.         }
  143.     }
  144. }

  145. SaoLei.prototype.refresh = function () {
  146.     this.make()
  147.     var all = this._x * this._y
  148.     for (var i = 0; i < all; i++) {
  149.         this.showleiqu(i, 11)
  150.     }
  151. }

  152. SaoLei.prototype.setup = function (id) {
  153.     this.getevent(id)
  154.     this.makeEvent()
  155. }

  156. SaoLei.prototype.setLeiQu = function (id, num) {
  157.     this._leiqu[id] = num
  158. }
  159. SaoLei.prototype.getLeiQu = function (id) {
  160.     return this._leiqu[id]
  161. }


  162. SaoLei.prototype.setQi = function (id, num) {
  163.     if (num == 0) {
  164.         if (this._xianshi[id]) {
  165.             this._xsshu--
  166.         }
  167.     } else {
  168.         if (!this._xianshi[id]) {
  169.             this._xsshu++
  170.         }
  171.     }
  172.     if (num == 2) {
  173.         if (!this._xianshi[id]) {
  174.             this._qishu++
  175.         }
  176.     } else {
  177.         if (this._xianshi[id] == 2) {
  178.             this._qishu--
  179.         }
  180.     }
  181.     this._xianshi[id] = num
  182. }
  183. SaoLei.prototype.getQu = function (id) {
  184.     return this._xianshi[id]
  185. }


  186. //制作扫雷区
  187. SaoLei.prototype.make = function (x, y, z) {
  188.     var all = this._x * this._y
  189.     var lei = []

  190.     this._qishu = 0
  191.     this._xsshu = 0
  192.     this._leiqu = []
  193.     this._xianshi = []

  194.     for (var i = 0; i < all; i++) {
  195.         this.setLeiQu(i, 0)
  196.         this._xianshi[i] = 0
  197.         lei[i] = i
  198.     }
  199.     for (var i = 0; i < this._z; i++) {
  200.         var lid = Math.floor(lei.length * Math.random())
  201.         var id = lei[lid]
  202.         this._leiqu[id] = 9
  203.         lei.splice(lid, 1)
  204.     }
  205.     for (var i = 0; i < all; i++) {
  206.         this.makenum(i)
  207.     }
  208. };


  209. //安装
  210. SaoLei.prototype.showleiqu = function (id, z) {
  211.     var e = $gameMap.event(id + this._eventId)
  212.     if (e) {
  213.         if (z == 0) {
  214.             var d = 4
  215.             var p = 0

  216.         } else if (z == 1) {
  217.             var d = 4
  218.             var p = 1

  219.         } else if (z == 2) {
  220.             var d = 4
  221.             var p = 2

  222.         } else if (z == 3) {
  223.             var d = 6
  224.             var p = 0

  225.         } else if (z == 4) {
  226.             var d = 6
  227.             var p = 1

  228.         } else if (z == 5) {
  229.             var d = 6
  230.             var p = 2

  231.         } else if (z == 6) {
  232.             var d = 8
  233.             var p = 0

  234.         } else if (z == 7) {
  235.             var d = 8
  236.             var p = 1

  237.         } else if (z == 8) {
  238.             var d = 8
  239.             var p = 2
  240.         } else if (z == 9) {
  241.             var d = 2
  242.             var p = 2
  243.         } else if (z == 10) {
  244.             var d = 2
  245.             var p = 1
  246.         } else if (z == 11) {
  247.             var d = 2
  248.             var p = 0
  249.         }
  250.         e._direction = d
  251.         e._originalPattern = p
  252.     }
  253. };



  254. SaoLei.prototype.getevent = function (id) {
  255.     this._eventId = id
  256.     this._eventx = $gameMap.event(this._eventId)._x
  257.     this._eventy = $gameMap.event(this._eventId)._y
  258. };
  259. //棋子id x
  260. SaoLei.prototype._idx = function (id) {
  261.     return id % this._x
  262. }
  263. //棋子id y
  264. SaoLei.prototype._idy = function (id) {
  265.     return (id - id % this._x) / this._y
  266. }

  267. SaoLei.prototype.makeEvent = function () {
  268.     for (var i = 1; i < this._leiqu.length; i++) {
  269.         var x = this._idx(i)
  270.         var y = this._idy(i)
  271.         SaoLei.copyEvent(this._eventId, i, this._eventx + x, this._eventy + y)
  272.     }
  273. };


  274. SaoLei.prototype.makeSprite = function () {
  275.     var t = ""
  276.     for (var yi = 0; yi < this._y; yi++) {
  277.         t += "\n"
  278.         for (var xi = 0; xi < this._x; xi++) {
  279.             var id = xi + yi * this._x
  280.             t += this._leiqu[id]
  281.         }
  282.     }
  283.     return t
  284. };

  285. SaoLei.prototype.makeSprite2 = function () {
  286.     var t = ""
  287.     for (var yi = 0; yi < this._y; yi++) {
  288.         t += "\n"
  289.         for (var xi = 0; xi < this._x; xi++) {
  290.             var id = xi + yi * this._x
  291.             if (this._xianshi[id] == 1 ) {
  292.                 t += this._leiqu[id]
  293.             } else if(this._xianshi[id] == 2 ){
  294.                 t += "F"
  295.             }else{
  296.                 t += "H"
  297.             }
  298.         }
  299.     }
  300.     return t
  301. };


  302. SaoLei.prototype.makenum = function (id) {
  303.     if (this.getLeiQu(id) === 9) {
  304.         return
  305.     }
  306.     var num = 0
  307.     for (var d = 1; d < 10; d++) {
  308.         var id2 = this.idd(id, d)
  309.         if (this.getLeiQu(id2) === 9) {
  310.             num++
  311.         }
  312.     }
  313.     this.setLeiQu(id, num)
  314. };


  315. SaoLei.prototype.isend = function () {
  316.     return this._xianshi.length == this._xsshu
  317. };

  318. SaoLei.prototype.idd = function (id, d) {
  319.     var x = id % this._x
  320.     var y = (id - x) / this._x
  321.     var dn = [0, [-1, 1], [0, 1], [1, 1], [-1, 0], 0, [1, 0], [-1, -1], [0, -1], [1, -1]]
  322.     var xyd = dn[d] || [0, 0]
  323.     var x2 = x + xyd[0]
  324.     var y2 = y + xyd[1]
  325.     if (x2 < 0 || y2 < 0 || x2 >= this._x || y2 >= this._y) {
  326.         return -1
  327.     }
  328.     return y2 * this._x + x2
  329. };

  330. SaoLei.prototype.dianji2 = function (id) {
  331.     if (!this._xianshi[id]) {
  332.         if (this._qishu < this._z) {
  333.             this.setQi(id, 2)
  334.             this.showleiqu(id, 10)
  335.             console.log(this.makeSprite2())            
  336.         }
  337.     } else if (this._xianshi[id] == 2) {
  338.         this.setQi(id, 0)
  339.         this.showleiqu(id, 11)
  340.         console.log(this.makeSprite2())
  341.     }
  342. };

  343. SaoLei.prototype.dianji = function (id) {
  344.     if (!this._xianshi[id]) {
  345.         if (this.getLeiQu(id) == 9) {
  346.             this.showall(id)
  347.             this.dead(id)
  348.         } else {
  349.             this.show(id)
  350.         }
  351.         console.log(this.makeSprite2())
  352.     }
  353. };

  354. SaoLei.prototype.dead = function (id) {
  355.     var e = $gameMap.event(id + this._eventId)
  356.     e.requestAnimation(1)
  357. };

  358. SaoLei.prototype.showall = function (id) {
  359.     var all = this._x * this._y
  360.     for (var i = 0; i < all; i++) {
  361.         var z = this._xianshi[i]
  362.         this.setQi(i, z || 1)
  363.         var num = this.getLeiQu(i)
  364.         if(num == 9 && z == 2){
  365.             num = 10
  366.         }
  367.         this.showleiqu(i, num)
  368.     }
  369. }

  370. SaoLei.prototype.show = function (id) {
  371.     this.setQi(id, 1)
  372.     var num = this.getLeiQu(id)
  373.     this.showleiqu(id, num)
  374.     if (num == 0) {
  375.         for (var d = 1; d < 10; d++) {
  376.             var id2 = this.idd(id, d)
  377.             if (id2 >= 0 && d != 5 && !this._xianshi[id2]) {
  378.                 this.show(id2)
  379.                 console.log(id2)
  380.             }
  381.         }
  382.     }
  383. };

  384. //复制fid事件到tid x ,y
  385. SaoLei.copyEvent = function (fid, id, x, y) {
  386.     if (fid > 0 && id > 0) {
  387.         var fid = fid
  388.         var tid = fid + id
  389.         if (DataManager.isMapLoaded()) {
  390.             var event = SaoLei.loadDataEvent(tid)
  391.             if (event) {
  392.                 var event = SaoLei.loadGameEvent(tid)
  393.             } else {
  394.                 var event = SaoLei._changeNowMapEvent(fid, tid)
  395.             }
  396.             event.locate(x, y)
  397.         }
  398.     }
  399. }

  400. //改变当前地图id事件为 event (csh 是否重设位置)
  401. SaoLei._changeNowMapEvent = function (fid, tid) {
  402.     return SaoLei._addNowMapEvent(fid, tid)
  403. }

  404. //添加当前地图事件
  405. SaoLei._addNowMapEvent = function (fid, tid) {
  406.     $gameMap._events[tid] = new Game_Event($gameMap.mapId(), fid)
  407.     if (SceneManager && SceneManager._scene && SceneManager._scene.constructor == Scene_Map) {
  408.         if (SceneManager._scene._spriteset && SceneManager._scene._spriteset._characterSprites) {
  409.             var spriteset = SceneManager._scene._spriteset
  410.             var characterSprites = SceneManager._scene._spriteset._characterSprites
  411.             var c = new Sprite_Character($gameMap._events[tid])
  412.             characterSprites.push(c)
  413.             spriteset._tilemap.addChild(c);
  414.         }
  415.     }
  416.     return $gameMap._events[tid]
  417. }

  418. //读取当前地图id事件
  419. SaoLei.loadDataEvent = function (id) {
  420.     var event;
  421.     var mapdata = $dataMap
  422.     if (mapdata) {
  423.         var events = mapdata.events
  424.         if (events) {
  425.             var event = events[id]
  426.         }
  427.     }
  428.     return event;
  429. }
  430. SaoLei.loadGameEvent = function (id) {
  431.     var event;
  432.     var mapdata = $gameMap
  433.     if (mapdata) {
  434.         var events = mapdata._events
  435.         if (events) {
  436.             var event = events[id]
  437.         }
  438.     }
  439.     return event;
  440. }
复制代码










Project7.zip (30.25 KB, 下载次数: 157)

不要吐槽人物去哪了....我用的空白
BaiduShurufa_2016-9-23_22-59-39.png

评分

参与人数 1星屑 +58 收起 理由
邪月长啸 + 58 塞糖

查看全部评分

梦石
0
星屑
79
在线时间
112 小时
注册时间
2010-6-16
回帖
70
发表于 2016-9-24 00:21:02 | 显示全部楼层
{:2_258:}{:2_258:}
回复

使用道具 举报

梦石
0
星屑
225
在线时间
162 小时
注册时间
2015-11-23
回帖
90
发表于 2016-9-24 10:49:44 | 显示全部楼层
汪神实力新作,当顶
自天地未辟混沌未开时就已经开始装逼的神奇人物
MV的魔塔模板::托管在github上的游戏,可以直接运行
基于RPGMakerMV的JavaScript基础
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2016-9-24 11:03:27 | 显示全部楼层
本帖最后由 tseyik 于 2016-9-24 13:55 编辑

tomoaky
也有這個
TMPlugin - マインスウィーパ
http://hikimoki.sakura.ne.jp/plugin/plugin_neta.html
2016/08/12
Ver1.0.0 公開
・効果音が未使用ファイル削除ツールに対応していなかった不具合の修正
 これにともない、プラグインパラメータが変更されています。
2016/03/04
Ver0.11b 公開
・ツクールMV1.1.0の未使用ファイル削除ツールに対応
2016/02/05
Ver0.1b 公開

MineSweeper.png
MineSweeper.png
点击展开/收起
  1. //=============================================================================
  2. // TMPlugin - マインスウィーパ
  3. // バージョン: 1.0.0
  4. // 最終更新日: 2016/08/12
  5. // 配布元    : [url]http://hikimoki.sakura.ne.jp/[/url]
  6. //-----------------------------------------------------------------------------
  7. // Copyright (c) 2016 tomoaky
  8. // Released under the MIT license.
  9. // [url]http://opensource.org/licenses/mit-license.php[/url]
  10. //=============================================================================

  11. /*:
  12. * @plugindesc 有名な地雷撤去ゲームっぽいものを追加します。
  13. *
  14. * @author tomoaky ([url]http://hikimoki.sakura.ne.jp/[/url])
  15. *
  16. * @param command
  17. * @desc 『選択肢の表示』コマンドで使用するマインスウィーパ起動文字列。
  18. * 初期値: [マインスウィーパ]
  19. * @default [マインスウィーパ]
  20. *
  21. * @param iconImage
  22. * @desc 地雷アイコンとして利用する画像ファイル名。
  23. * 初期値: MineSweeper
  24. * @default MineSweeper
  25. * @require 1
  26. * @dir img/system/
  27. * @type file
  28. *
  29. * @param bombSe
  30. * @desc 地雷爆発時に鳴らす効果音のファイル名。
  31. * 初期値: Explosion2
  32. * @default Explosion2
  33. * @require 1
  34. * @dir audio/se/
  35. * @type file

  36. * @param bombSeParameters
  37. * @desc 地雷爆発時に鳴らす効果音の音量、ピッチ、パン。
  38. * 初期値: 90 100 0
  39. * @default 90 100 0
  40. *
  41. * @param clearSe
  42. * @desc 地雷撤去完了時に鳴らす効果音のファイル名。
  43. * 初期値: Applause1
  44. * @default Applause1
  45. * @require 1
  46. * @dir audio/se/
  47. * @type file

  48. * @param clearSeParameters
  49. * @desc 地雷撤去完了時に鳴らす効果音の音量、ピッチ、パン。
  50. * 初期値: 90 100 0
  51. * @default 90 100 0
  52. *
  53. * @help
  54. * 準備:
  55. *
  56. *   プラグインと一緒に配布しているマインスウィーパのアイコン画像を
  57. *   img/system フォルダに保存してください。
  58. *   ファイル名は MineSweeper.png となっています。
  59. *   ファイル名を変更しなければならない場合はプラグインパラメータの
  60. *   iconImage も一緒に変更してください。
  61. *
  62. *
  63. * 使い方:
  64. *
  65. *   イベントコマンド『選択肢の表示』の選択肢 1 番に [マインスウィーパ] と
  66. *   入力することでマインスウィーパが起動します。(括弧は半角です)
  67. *   選択肢 2 番には以下の 5 つの数値を半角スペースで区切って入力します。
  68. *   ・横に並ぶマスの数
  69. *   ・縦に並ぶマスの数
  70. *   ・マス 1 つの幅(ドット数)
  71. *   ・マス 1 つの高さ(ドット数)
  72. *   ・地雷の数
  73. *   例)14 8 32 32 20
  74. *   この例では 1 つが32*32ドットのマスを横に 14、縦に 8、計 112 個並べ、
  75. *   そのうち 20 個のマスに地雷が隠されている状態でスタートします。
  76. *
  77. *   地雷の埋まっていないマスをすべて調査すれば選択肢 1 番の処理が実行され、
  78. *   途中で地雷のあるマスを調査してしまった場合は 2 番が実行されます。
  79. *
  80. *   選択肢 3 番に半角数字で制限時間を設定することができます。
  81. *   入力した秒数が経過するとマインスウィーパが強制終了し、
  82. *   選択肢 3 番の処理が実行されます。
  83. *
  84. *   このプラグインは RPGツクールMV Version 1.3.0 で動作確認をしています。
  85. *
  86. *
  87. * プラグインコマンド:
  88. *
  89. *   mineTime 1
  90. *     直前のマインスウィーパの所要時間をゲーム変数 1 番に代入します。
  91. *
  92. *     mineTime コマンドで得られる値の単位はミリ秒になっていますので、
  93. *     秒に変換したい場合はイベントコマンド『変数の操作』を使い、この値を
  94. *     1000 で割ってください。
  95. *
  96. *     mineTime で得られる結果は直前に実行されたマインスウィーパのものです。
  97. *     また、マインスウィーパとプラグインコマンド実行までの間に
  98. *     セーブ&ロードをはさむと結果が取得できなくなります。
  99. *
  100. *
  101. * 注意事項:
  102. *
  103. *   『文章の表示』コマンドの直後にマインスウィーパを起動した場合、
  104. *   メッセージウィンドウが閉じずにそのままマインスウィーパが起動します。
  105. *   メッセージウィンドウを閉じてからマインスウィーパを起動したい場合は
  106. *   『文章の表示』と『選択肢の表示』の間に『ウェイト』を 1 フレーム以上
  107. *   入れてください。
  108. *
  109. *   また、マインスウィーパウィンドウの上下位置はメッセージウィンドウの
  110. *   上下位置に影響を受けるので、背景が透明で内容が空のメッセージウィンドウを
  111. *   使えばマインスウィーパウィンドウの上下位置を変更することができます。
  112. */

  113. var Imported = Imported || {};
  114. Imported.TMMineSweeper = true;

  115. var TMPlugin = TMPlugin || {};
  116. TMPlugin.MineSweeper = {};
  117. TMPlugin.MineSweeper.Parameters = PluginManager.parameters('TMMineSweeper');
  118. TMPlugin.MineSweeper.Command = TMPlugin.MineSweeper.Parameters['command'] || '[マインスウィーパ]';
  119. TMPlugin.MineSweeper.IconImage = TMPlugin.MineSweeper.Parameters['iconImage'];
  120. var arr = TMPlugin.MineSweeper.Parameters['bombSeParameters'].split(' ');
  121. TMPlugin.MineSweeper.BombSe = { name: TMPlugin.MineSweeper.Parameters['bombSe'],
  122.                                 volume: arr[0], pitch: arr[1], pan: arr[2] };
  123. var arr = TMPlugin.MineSweeper.Parameters['clearSeParameters'].split(' ');
  124. TMPlugin.MineSweeper.ClearSe = { name: TMPlugin.MineSweeper.Parameters['clearSe'],
  125.                                 volume: arr[0], pitch: arr[1], pan: arr[2] };

  126. (function() {

  127.   //-----------------------------------------------------------------------------
  128.   // Game_Temp
  129.   //

  130.   var _Game_Temp_initialize = Game_Temp.prototype.initialize;
  131.   Game_Temp.prototype.initialize = function() {
  132.     _Game_Temp_initialize.call(this);
  133.     this._mineTime = 0;
  134.   };

  135.   Game_Temp.prototype.setMineScore = function(time) {
  136.     this._mineTime = time;
  137.   };
  138.   
  139.   Game_Temp.prototype.mineTime = function() {
  140.     return this._mineTime;
  141.   };
  142.   
  143.   //-----------------------------------------------------------------------------
  144.   // Game_Message
  145.   //

  146.   var _Game_Message_clear = Game_Message.prototype.clear;
  147.   Game_Message.prototype.clear = function() {
  148.     _Game_Message_clear.call(this);
  149.     this._mineWidth      = 0;
  150.     this._mineHeight     = 0;
  151.     this._mineCellWidth  = 0;
  152.     this._mineCellHeight = 0;
  153.     this._mineTimeLimit  = 0;
  154.     this._mineNumber     = 0;
  155.   };

  156.   Game_Message.prototype.mineWidth = function() {
  157.     return this._mineWidth;
  158.   };

  159.   Game_Message.prototype.mineHeight = function() {
  160.     return this._mineHeight;
  161.   };

  162.   Game_Message.prototype.mineCellWidth = function() {
  163.     return this._mineCellWidth;
  164.   };

  165.   Game_Message.prototype.mineCellHeight = function() {
  166.     return this._mineCellHeight;
  167.   };

  168.   Game_Message.prototype.mineNumber = function() {
  169.     return this._mineNumber;
  170.   };

  171.   Game_Message.prototype.setMine = function(choices, cancelType) {
  172.     var arr = choices[1].split(' ');
  173.     this._mineWidth      = +arr[0];
  174.     this._mineHeight     = +arr[1];
  175.     this._mineCellWidth  = +arr[2];
  176.     this._mineCellHeight = +arr[3];
  177.     this._mineNumber     = +arr[4];
  178.     this._mineTimeLimit  = choices[2] ? +choices[2] * 1000 : 0;
  179.     this._choiceCancelType = cancelType;
  180.   };

  181.   Game_Message.prototype.isMineSweeper = function() {
  182.     return this._mineWidth > 0;
  183.   };

  184.   var _Game_Message_isBusy = Game_Message.prototype.isBusy;
  185.   Game_Message.prototype.isBusy = function() {
  186.     return _Game_Message_isBusy.call(this) || this.isMineSweeper();
  187.   };

  188.   //-----------------------------------------------------------------------------
  189.   // Game_Interpreter
  190.   //

  191.   var _Game_Interpreter_setupChoices = Game_Interpreter.prototype.setupChoices;
  192.   Game_Interpreter.prototype.setupChoices = function(params) {
  193.     var choices = params[0].clone();
  194.     if (choices[0] === TMPlugin.MineSweeper.Command) {
  195.       var cancelType = params[1];
  196.       var defaultType = params.length > 2 ? params[2] : 0;
  197.       var positionType = params.length > 3 ? params[3] : 2;
  198.       var background = params.length > 4 ? params[4] : 0;
  199.       if (cancelType >= choices.length) cancelType = -2;
  200.       $gameMessage.setMine(choices, cancelType);
  201.       $gameMessage.setChoiceBackground(background);
  202.       $gameMessage.setChoicePositionType(positionType);
  203.       $gameMessage.setChoiceCallback(function(n) {
  204.         this._branch[this._indent] = n;
  205.       }.bind(this));
  206.     } else {
  207.       _Game_Interpreter_setupChoices.call(this, params);
  208.     }
  209.   };

  210.   var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  211.   Game_Interpreter.prototype.pluginCommand = function(command, args) {
  212.     _Game_Interpreter_pluginCommand.call(this, command, args);
  213.     if (command === 'mineTime') {
  214.       $gameVariables.setValue(+args[0], $gameTemp.mineTime());
  215.     }
  216.   };
  217.   
  218.   //-----------------------------------------------------------------------------
  219.   // Window_MineSweeper
  220.   //

  221.   function Window_MineSweeper() {
  222.       this.initialize.apply(this, arguments);
  223.   }

  224.   Window_MineSweeper.prototype = Object.create(Window_Selectable.prototype);
  225.   Window_MineSweeper.prototype.constructor = Window_MineSweeper;

  226.   Window_MineSweeper.prototype.initialize = function(messageWindow) {
  227.     this._messageWindow = messageWindow;
  228.     Window_Selectable.prototype.initialize.call(this, 0, 0, 0, 0);
  229.     this.openness = 0;
  230.     this.deactivate();
  231.   };
  232.   
  233.   Window_MineSweeper.prototype.maxCols = function() {
  234.     return this._mineWidth || 1;
  235.   };

  236.   Window_MineSweeper.prototype.maxItems = function() {
  237.     return this._mineCellNumber || 0;
  238.   };

  239.   Window_MineSweeper.prototype.spacing = function() {
  240.     return 0;
  241.   };

  242.   Window_MineSweeper.prototype.isCursorMovable = function() {
  243.     return Window_Selectable.prototype.isCursorMovable &&
  244.            this._mineState === -1;
  245.   };

  246.   Window_MineSweeper.prototype.start = function() {
  247.     this._mineWidth      = $gameMessage.mineWidth();
  248.     this._mineHeight     = $gameMessage.mineHeight();
  249.     this._mineCellWidth  = $gameMessage.mineCellWidth();
  250.     this._mineCellHeight = $gameMessage.mineCellHeight();
  251.     this._mineNumber     = $gameMessage.mineNumber();
  252.     this._mineCellNumber = this._mineWidth * this._mineHeight;
  253.     this.clearMine();
  254.     this._mineState = -1;
  255.     this._mineStartTime = new Date();
  256.     this._lastRefreshTime = this._mineStartTime;
  257.     this._sweepCount = 0;
  258.     this.updatePlacement();
  259.     this.updateBackground();
  260.     this.select(0);
  261.     this.refresh();
  262.     this.open();
  263.     this.activate();
  264.   };

  265.   Window_MineSweeper.prototype.clearMine = function() {
  266.     this._mineMap = [];
  267.     for (var i = 0; i < this._mineCellNumber; i++) {
  268.       this._mineMap[i] = { value: 0, mine: 0, flag: false, sweeped: false };
  269.     }
  270.   };
  271.   
  272.   Window_MineSweeper.prototype.setupMine = function() {
  273.     var a = [];
  274.     for (var i = 0; i < this._mineCellNumber; i++) {
  275.       a[i] = i;
  276.     }
  277.     for (var i = -1; i < 2; i++) {
  278.       if ((i >= 0 || this.index() % this._mineWidth > 0) &&
  279.           (i < 1 || this.index() % this._mineWidth < this._mineWidth - 1)) {
  280.         for (var j = -1; j < 2; j++) {
  281.           var index = this.index() + i + this._mineWidth * j;
  282.           if (this.isIndexValid(index)) a.splice(a.indexOf(index), 1);
  283.         }
  284.       }
  285.     }
  286.     for (var i = 0; i < this._mineNumber; i++) {
  287.       var index = a.splice(Math.randomInt(a.length), 1)[0];
  288.       this._mineMap[index].mine = 1;
  289.       for (var j = -1; j < 2; j++) {
  290.         this.increaseMineCount(index + this._mineWidth * j);
  291.         if (index % this._mineWidth > 0) {
  292.           this.increaseMineCount(index - 1 + this._mineWidth * j);
  293.         }
  294.         if (index % this._mineWidth < this._mineWidth - 1) {
  295.           this.increaseMineCount(index + 1 + this._mineWidth * j);
  296.         }
  297.       }
  298.     }
  299.   };
  300.   
  301.   Window_MineSweeper.prototype.increaseMineCount = function(index) {
  302.     if (this.isIndexValid(index)) this._mineMap[index].value++;
  303.   };
  304.   
  305.   Window_MineSweeper.prototype.isIndexValid = function(index) {
  306.     return index >= 0 && index < this._mineCellNumber;
  307.   };
  308.   
  309.   Window_MineSweeper.prototype.updatePlacement = function() {
  310.     var positionType = $gameMessage.choicePositionType();
  311.     var messageY = this._messageWindow.y;
  312.     this.width = this.windowWidth();
  313.     this.height = this.windowHeight();
  314.     if (positionType === 0) {
  315.       this.x = 0;
  316.     } else if (positionType === 1) {
  317.       this.x = (Graphics.boxWidth - this.width) / 2;
  318.     } else {
  319.       this.x = Graphics.boxWidth - this.width;
  320.     }
  321.     if (messageY >= Graphics.boxHeight / 2) {
  322.       this.y = messageY - this.height;
  323.     } else {
  324.       this.y = messageY + this._messageWindow.height;
  325.     }
  326.   };

  327.   Window_MineSweeper.prototype.updateBackground = function() {
  328.     this._background = $gameMessage.choiceBackground();
  329.     this.setBackgroundType(this._background);
  330.   };

  331.   Window_MineSweeper.prototype.windowWidth = function() {
  332.     var width = $gameMessage.mineWidth() * $gameMessage.mineCellWidth() +
  333.                 this.padding * 2;
  334.     return Math.min(width, Graphics.boxWidth);
  335.   };

  336.   Window_MineSweeper.prototype.windowHeight = function() {
  337.     return this.fittingHeight($gameMessage.mineHeight()) + 36;
  338.   };

  339.   Window_MineSweeper.prototype.update = function() {
  340.     var lastIndex = this.index();
  341.     Window_Selectable.prototype.update.call(this);
  342.     if (this.active) {
  343.       if (this._mineState === -1) {
  344.         this.updateTime();
  345.       } else if (Input.isTriggered('ok') || (TouchInput.isTriggered())) {
  346.         $gameMessage.onChoice(this._mineState);
  347.         this.endMineSweeper();
  348.         SoundManager.playOk();
  349.       } else if (Input.isTriggered('escape') || (TouchInput.isCancelled())) {
  350.         $gameMessage.onChoice(this._mineState);
  351.         this.endMineSweeper();
  352.         SoundManager.playCancel();
  353.       }
  354.       if (lastIndex !== this.index()) {
  355.         this.redrawItem(lastIndex);
  356.         this.redrawItem(this.index());
  357.       }
  358.     }
  359.   };
  360.   
  361.   Window_MineSweeper.prototype.updateTime = function() {
  362.     var currentTime = new Date();
  363.     if (currentTime - this._lastRefreshTime > 1000) {
  364.       this.refreshTime();
  365.       this._lastRefreshTime = currentTime;
  366.     }
  367.   };
  368.   
  369.   Window_MineSweeper.prototype.gameOver = function(state) {
  370.     this._mineState = state;
  371.     var time = new Date();
  372.     $gameTemp.setMineScore(time - this._mineStartTime);
  373.     if (this._mineState >= 1) {
  374.       for (var i = 0; i < this._mineCellNumber; i++) {
  375.         var data = this._mineMap[i];
  376.         if (data.mine && !data.sweeped) {
  377.           this._mineMap[i].sweeped = true;
  378.           this.redrawItem(i);
  379.         }
  380.       }
  381.       AudioManager.playSe(TMPlugin.MineSweeper.BombSe);
  382.     } else {
  383.       AudioManager.playSe(TMPlugin.MineSweeper.ClearSe);
  384.     }
  385.   };
  386.   
  387.   Window_MineSweeper.prototype.endMineSweeper = function() {
  388.     this._messageWindow.terminateMessage();
  389.     this.deactivate();
  390.     this.close();
  391.   };
  392.   
  393.   Window_MineSweeper.prototype.drawItem = function(index) {
  394.     var rect = this.itemRect(index);
  395.     var bitmap = ImageManager.loadSystem('MineSweeper');
  396.     var data = this._mineMap[index];
  397.     var sx = 12;
  398.     if (data.sweeped) {
  399.       sx = data.mine ? 8 + data.mine : data.value;
  400.     }
  401.     this.contents.blt(bitmap, sx * 32, 0, 32, 32, rect.x, rect.y,
  402.                       rect.width, rect.height);
  403.     if (data.flag) {
  404.       this.contents.blt(bitmap, 416, 0, 32, 32, rect.x, rect.y,
  405.                         rect.width, rect.height);
  406.     }
  407.     if (index === this.index()) {
  408.       this.contents.blt(bitmap, 448, 0, 32, 32, rect.x, rect.y,
  409.                         rect.width, rect.height);
  410.     }
  411.   };

  412.   Window_MineSweeper.prototype.refresh = function() {
  413.     this.createContents();
  414.     this.drawAllItems();
  415.     this.refreshTime();
  416.   };

  417.   Window_MineSweeper.prototype.refreshTime = function() {
  418.     var time = new Date();
  419.     time -= this._mineStartTime;
  420.     if ($gameMessage._mineTimeLimit) {
  421.       time = $gameMessage._mineTimeLimit - time;
  422.       if (time < 0) {
  423.         time = 0;
  424.         this.gameOver(2);
  425.       }
  426.     }
  427.     var width = this.contents.width - this.textPadding();
  428.     var height = 36;
  429.     var y = this.contents.height - height;
  430.     this.contents.clearRect(0, y, width, height);
  431.     this.drawText(Math.floor(time / 1000) + ' 秒', 0, y, width, 'right');
  432.   };
  433.   
  434.   Window_MineSweeper.prototype.isCurrentItemEnabled = function() {
  435.     return this.index() >= 0 && !this._mineMap[this.index()].sweeped;
  436.   };

  437.   Window_MineSweeper.prototype.isOkEnabled = function() {
  438.     return true;
  439.   };

  440.   Window_MineSweeper.prototype.isCancelEnabled = function() {
  441.     return true;
  442.   };

  443.   Window_MineSweeper.prototype.processOk = function() {
  444.     if (this._mineState === -1) {
  445.       Window_Selectable.prototype.processOk.call(this);
  446.     }
  447.   };

  448.   Window_MineSweeper.prototype.callOkHandler = function() {
  449.     if (this._sweepCount === 0) this.setupMine();
  450.     this._mineSweepTargets = [this.index()];
  451.     while (this._mineSweepTargets.length > 0) {
  452.       this.sweep(this._mineSweepTargets.pop());
  453.     }
  454.     if (this._mineState === -1) this.checkGameComplete();
  455.     this.activate();
  456.   };

  457.   Window_MineSweeper.prototype.sweep = function(index) {
  458.     var data = this._mineMap[index];
  459.     if (data.mine) {
  460.       this.gameOver(1);
  461.       this._mineMap[index].mine = 2;
  462.     }
  463.     this._mineMap[index].sweeped = true;
  464.     this._mineMap[index].flag = false;
  465.     this._sweepCount++;
  466.     this.redrawItem(index);
  467.     if (data.value > 0) return;
  468.     this.addSweepTarget(index - this._mineWidth);
  469.     this.addSweepTarget(index + this._mineWidth);
  470.     for (var i = -1; i < 2; i++) {
  471.       if (index % this._mineWidth > 0) {
  472.         this.addSweepTarget(index - 1 + this._mineWidth * i);
  473.       }
  474.       if (index % this._mineWidth < this._mineWidth - 1) {
  475.         this.addSweepTarget(index + 1 + this._mineWidth * i);
  476.       }
  477.     }
  478.   };
  479.   
  480.   Window_MineSweeper.prototype.addSweepTarget = function(index) {
  481.     if (index >= 0 && index < this._mineCellNumber &&
  482.         this._mineSweepTargets.indexOf(index) === -1 &&
  483.         !this._mineMap[index].sweeped) {
  484.       this._mineSweepTargets.push(index);
  485.     }
  486.   };
  487.   
  488.   Window_MineSweeper.prototype.checkGameComplete = function(index) {
  489.     if (this._sweepCount === this._mineCellNumber - this._mineNumber) {
  490.       this.gameOver(0);
  491.     }
  492.   };
  493.   
  494.   Window_MineSweeper.prototype.processCancel = function() {
  495.     if (this._mineState === -1) {
  496.       Window_Selectable.prototype.processCancel.call(this);
  497.     }
  498.   };

  499.   Window_MineSweeper.prototype.callCancelHandler = function() {
  500.     if (this.index() >= 0 && !this._mineMap[this.index()].sweeped) {
  501.       this._mineMap[this.index()].flag = !this._mineMap[this.index()].flag;
  502.       this.redrawItem(this.index());
  503.     } else {
  504.       SoundManager.playBuzzer();
  505.     }
  506.     this.activate();
  507.   };
  508.   //-----------------------------------------------------------------------------
  509.   // Window_Message
  510.   //

  511.   var _Window_Message_subWindows = Window_Message.prototype.subWindows;
  512.   Window_Message.prototype.subWindows = function() {
  513.     return _Window_Message_subWindows.call(this).concat(this._mineSweeperWindow);
  514.   };

  515.   var _Window_Message_createSubWindows = Window_Message.prototype.createSubWindows;
  516.   Window_Message.prototype.createSubWindows = function() {
  517.     _Window_Message_createSubWindows.call(this);
  518.     this._mineSweeperWindow = new Window_MineSweeper(this);
  519.   };

  520.   var _Window_Message_isAnySubWindowActive = Window_Message.prototype.isAnySubWindowActive;
  521.   Window_Message.prototype.isAnySubWindowActive = function() {
  522.     return (_Window_Message_isAnySubWindowActive.call(this) ||
  523.             this._mineSweeperWindow.active);
  524.   };

  525.   var _Window_Message_startInput = Window_Message.prototype.startInput;
  526.   Window_Message.prototype.startInput = function() {
  527.     if ($gameMessage.isMineSweeper()) {
  528.       this._mineSweeperWindow.start();
  529.       return true;
  530.     }
  531.     return _Window_Message_startInput.call(this);
  532.   };

  533.   //-----------------------------------------------------------------------------
  534.   // Scene_Boot
  535.   //

  536.   var _Scene_Boot_loadSystemImages = Scene_Boot.loadSystemImages;
  537.   Scene_Boot.loadSystemImages = function() {
  538.     _Scene_Boot_loadSystemImages.call(this);
  539.     ImageManager.loadSystem(TMPlugin.MineSweeper.IconImage);
  540.   };

  541. })();
复制代码

点评

链接也点不进去。。  发表于 2016-9-24 13:50
看不懂日文。。。  发表于 2016-9-24 13:47
回复

使用道具 举报

梦石
0
星屑
462
在线时间
871 小时
注册时间
2014-5-5
回帖
914
发表于 2016-9-24 13:14:02 | 显示全部楼层
弱弱的问句,这有啥用?貌似现在没几个会玩扫雷把?

点评

我没有别的意思,只觉得PC都自带的游戏,移植到MV意义不大,纯属个人见解,勿怪  发表于 2016-9-24 21:57
可以作为小游戏 加到游戏里 你可以改下素材 比如扫翔  发表于 2016-9-24 19:39
楼上可以证明别人也有写。  发表于 2016-9-24 13:49
回复

使用道具 举报

梦石
0
星屑
245
在线时间
219 小时
注册时间
2015-9-24
回帖
138
发表于 2016-9-29 21:27:32 | 显示全部楼层
做过纯事件版本····虽然支持任意多行···不过要提前放置好事件

点评

好厉害(づ ●─● )づ  发表于 2016-9-30 07:06
回复

使用道具 举报

梦石
0
星屑
230
在线时间
174 小时
注册时间
2016-2-24
回帖
83
发表于 2016-10-1 03:44:03 | 显示全部楼层
素材不是扫向差评
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部