From b4fdc3b3264cf283af72848628bf94b190a9e4f1 Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 15 Mar 2018 14:13:16 +0800 Subject: [PATCH] Init Item --- libs/core.js | 2 ++ libs/events.js | 4 ++++ libs/items.js | 21 --------------------- project/functions.comment.js | 1 + project/functions.js | 30 +++++++++++++++++++++++++++++- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/libs/core.js b/libs/core.js index 3c822481..131e5ee4 100644 --- a/libs/core.js +++ b/libs/core.js @@ -281,6 +281,8 @@ core.prototype.init = function (coreData, callback) { core.setRequestAnimationFrame(); core.showStartAnimate(); + + if (core.isset(functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins)) core.plugin = new functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins.plugin(); diff --git a/libs/events.js b/libs/events.js index 1a4e2e46..b78d5519 100644 --- a/libs/events.js +++ b/libs/events.js @@ -71,6 +71,10 @@ events.prototype.getEvents = function (eventName) { return this.events[eventName]; } +events.prototype.initGame = function () { + return this.eventdata.initGame(); +} + ////// 游戏开始事件 ////// events.prototype.startGame = function (hard) { diff --git a/libs/items.js b/libs/items.js index 6fe44427..55462352 100644 --- a/libs/items.js +++ b/libs/items.js @@ -14,27 +14,6 @@ items.prototype.init = function () { ////// 获得所有道具 ////// items.prototype.getItems = function () { - // 大黄门钥匙?钥匙盒? - if (core.flags.bigKeyIsBox) - this.items['bigKey'] = {'cls': 'items', 'name': '钥匙盒'}; - // 面前的墙?四周的墙? - if (core.flags.pickaxeFourDirections) - this.items.pickaxe.text = "可以破坏勇士四周的墙"; - if (core.flags.bombFourDirections) - this.items.bomb.text = "可以炸掉勇士四周的怪物"; - if (core.flags.equipment) { - this.items.sword1 = {'cls': 'constants', 'name': '铁剑', 'text': '一把很普通的铁剑'}; - this.items.sword2 = {'cls': 'constants', 'name': '银剑', 'text': '一把很普通的银剑'}; - this.items.sword3 = {'cls': 'constants', 'name': '骑士剑', 'text': '一把很普通的骑士剑'}; - this.items.sword4 = {'cls': 'constants', 'name': '圣剑', 'text': '一把很普通的圣剑'}; - this.items.sword5 = {'cls': 'constants', 'name': '神圣剑', 'text': '一把很普通的神圣剑'}; - this.items.shield1 = {'cls': 'constants', 'name': '铁盾', 'text': '一个很普通的铁盾'}; - this.items.shield2 = {'cls': 'constants', 'name': '银盾', 'text': '一个很普通的银盾'}; - this.items.shield3 = {'cls': 'constants', 'name': '骑士盾', 'text': '一个很普通的骑士盾'}; - this.items.shield4 = {'cls': 'constants', 'name': '圣盾', 'text': '一个很普通的圣盾'}; - this.items.shield5 = {'cls': 'constants', 'name': '神圣盾', 'text': '一个很普通的神圣盾'}; - } - return this.items; } diff --git a/project/functions.comment.js b/project/functions.comment.js index 1c704822..7a07aa1e 100644 --- a/project/functions.comment.js +++ b/project/functions.comment.js @@ -1,6 +1,7 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "events" : { + "initGame": "游戏开始前的一些初始化操作", "setInitData" : "不同难度分别设置初始属性", "win" : "游戏获胜事件", "lose" : "游戏失败事件", diff --git a/project/functions.js b/project/functions.js index 47d04eaf..ea90575f 100644 --- a/project/functions.js +++ b/project/functions.js @@ -1,6 +1,33 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { "events":{ +////// 游戏开始前的一些初始化操作 ////// +"initGame": function() { + // 游戏开始前的一些初始化操作 + + // 根据flag来对道具进行修改 + if (core.flags.bigKeyIsBox) + core.material.items.bigKey = {'cls': 'items', 'name': '钥匙盒'}; + // 面前的墙?四周的墙? + if (core.flags.pickaxeFourDirections) + core.material.items.pickaxe.text = "可以破坏勇士四周的墙"; + if (core.flags.bombFourDirections) + core.material.items.bomb.text = "可以炸掉勇士四周的怪物"; + if (core.flags.equipment) { + core.material.items.sword1 = {'cls': 'constants', 'name': '铁剑', 'text': '一把很普通的铁剑'}; + core.material.items.sword2 = {'cls': 'constants', 'name': '银剑', 'text': '一把很普通的银剑'}; + core.material.items.sword3 = {'cls': 'constants', 'name': '骑士剑', 'text': '一把很普通的骑士剑'}; + core.material.items.sword4 = {'cls': 'constants', 'name': '圣剑', 'text': '一把很普通的圣剑'}; + core.material.items.sword5 = {'cls': 'constants', 'name': '神圣剑', 'text': '一把很普通的神圣剑'}; + core.material.items.shield1 = {'cls': 'constants', 'name': '铁盾', 'text': '一个很普通的铁盾'}; + core.material.items.shield2 = {'cls': 'constants', 'name': '银盾', 'text': '一个很普通的银盾'}; + core.material.items.shield3 = {'cls': 'constants', 'name': '骑士盾', 'text': '一个很普通的骑士盾'}; + core.material.items.shield4 = {'cls': 'constants', 'name': '圣盾', 'text': '一个很普通的圣盾'}; + core.material.items.shield5 = {'cls': 'constants', 'name': '神圣盾', 'text': '一个很普通的神圣盾'}; + } + + +}, ////// 不同难度分别设置初始属性 ////// "setInitData":function (hard) { // 不同难度分别设置初始属性 @@ -305,13 +332,14 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = console.log("插件编写测试"); // 可以写一些其他的被直接执行的代码 + // 在这里写所有需要自定义的函数 // 写法必须是 this.xxx = function (args) { ... // 如果不写this的话,函数将无法被外部所访问 this.test = function () { console.log("插件函数执行测试"); } - + this.useEquipment = function (itemId) { // 使用装备 if (itemId.indexOf("sword")==0) { var now=core.getFlag('sword', 'sword0'); // 当前装备剑的ID