Commit 3d4630ab authored by rockyl's avatar rockyl

目录调整,修复一些bug

parent 092956b1
Pipeline #177390 failed with stages
in 0 seconds
var leftValue = typeof props.left === 'string' ? '"' + props.left + '"' : props.left;
var rightValue = typeof props.right === 'string' ? '"' + props.right + '"' : props.right;
var operator = (args ? args.operator : props.operator) || '==';
if (operator === '==' || operator === '!=') {
operator += '=';
}
var func = new Function('return ' + leftValue + operator + rightValue);
var result = func();
next(result ? 'true' : 'false');
...@@ -12,21 +12,18 @@ ...@@ -12,21 +12,18 @@
"type": "data", "type": "data",
"default": "" "default": ""
}, },
"strict": {
"alias": "严格模式",
"type": "boolean",
"default": false
},
"operator": { "operator": {
"alias": "操作符", "alias": "操作符",
"type": "enum", "type": "enum",
"enum": [ "enum": [
"==", "==",
"!=",
"===",
"!==",
">", ">",
">=", ">=",
"<", "<",
"<=", "<="
"!="
], ],
"default": "==" "default": "=="
} }
...@@ -36,7 +33,7 @@ ...@@ -36,7 +33,7 @@
"false" "false"
], ],
"id": "compare", "id": "compare",
"script": "var operator = (args ? args.operator : props.operator) || '==';\nif (operator === '==' || operator === '!=') {\n operator += '=';\n}\nvar func = new Function('return ' + props.left + operator + props.right);\nvar result = func();\nnext(result ? 'true' : 'false');\n", "script": "var leftValue = typeof props.left === 'string' ? '\"' + props.left + '\"' : props.left;\nvar rightValue = typeof props.right === 'string' ? '\"' + props.right + '\"' : props.right;\nvar operator = (args ? args.operator : props.operator) || '==';\nif (operator === '==' || operator === '!=') {\n operator += '=';\n}\nvar func = new Function('return ' + leftValue + operator + rightValue);\nvar result = func();\nnext(result ? 'true' : 'false');\n",
"group": "base", "group": "base",
"type": "builtin" "type": "builtin"
} }
var data;
if (props.path) {
data = engine.gameStage.dataCenter.getDataByPath(props.path);
}
else {
data = engine.gameStage.dataCenter.getGroup(props.name);
}
next('success', data);
if (args && args.url) {
location.href = args.url;
}
else if (props.url) {
location.href = props.url;
}
next('complete');
{
"name": "跳转页面",
"desc": "跳转页面",
"props": {
"url": {
"alias": "地址",
"type": "data"
}
},
"output": [
"complete"
],
"id": "jump",
"script": "if (args && args.url) {\n location.href = args.url;\n}\nelse if (props.url) {\n location.href = props.url;\n}\nnext('complete');\n",
"group": "base",
"type": "builtin"
}
console.log(props ? props.content : (args ? args.content : ''));
next('success');
engine.gameStage.dataCenter.mutate(props.name, args, props.path);
next('success', args);
setTimeout(function () {
next('complete');
}, args ? args.duration : props.duration);
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"complete" "complete"
], ],
"id": "wait", "id": "wait",
"script": "setTimeout(function () {\n next('complete');\n}, args ? args.duration : (props.duration || 0));\n", "script": "setTimeout(function () {\n next('complete');\n}, args ? args.duration : props.duration);\n",
"group": "base", "group": "base",
"type": "builtin" "type": "builtin"
} }
var key = 'state-' + vm.id;
global[key] = true;
engine.Tween.get(props.target)
.set({ rotation: 0 })
.to({ rotation: 360 }, props.duration, engine.Ease.quintIn)
.call(function () {
next('success');
playLoop();
});
function playLoop() {
var goon = global[key];
if (goon) {
engine.Tween.get(props.target)
.set({ rotation: 0 })
.to({ rotation: 360 }, props.duration / 4)
.call(function () {
engine.globalEvent.dispatchEvent('loop-end');
playLoop();
});
}
}
{
"name": "入口",
"desc": "入口节点,每个行为的入口",
"props": {},
"output": [
"success"
],
"id": "turntable-start",
"script": "var key = 'state-' + vm.id;\nglobal[key] = true;\nengine.Tween.get(props.target)\n .set({ rotation: 0 })\n .to({ rotation: 360 }, props.duration, engine.Ease.quintIn)\n .call(function () {\n next('success');\n playLoop();\n});\nfunction playLoop() {\n var goon = global[key];\n if (goon) {\n engine.Tween.get(props.target)\n .set({ rotation: 0 })\n .to({ rotation: 360 }, props.duration / 4)\n .call(function () {\n engine.globalEvent.dispatchEvent('loop-end');\n playLoop();\n });\n }\n}\n",
"group": "custom",
"type": "builtin"
}
if (args && args.hasOwnProperty('index')) {
var key = 'state-' + vm.id;
var index = args.index;
var per = 360 / props.divid;
var ratio = per * props.ratio;
var rotation_1 = 360 * 3 - index * per + Math.random() * ratio + (per - ratio) / 2;
delete global[key];
engine.globalEvent.once('loop-end', function () {
engine.Tween.get(props.target || target)
.to({ rotation: rotation_1 }, props.duration, engine.Ease.quintOut)
.call(function () {
next('success');
});
});
}
else {
engine.Tween.removeTweens(props.target || target);
next('success');
}
{
"name": "入口",
"desc": "入口节点,每个行为的入口",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"divide": {
"type": "number",
"default": 6,
"alias": "转盘格数"
},
"duration": {
"type": "number",
"default": 1000,
"alias": "时间"
},
"ratio": {
"alias": "占比",
"type": "number",
"default": "0.9"
}
},
"output": [
"success"
],
"id": "turntable-stop",
"script": "if (args && args.hasOwnProperty('index')) {\n var key = 'state-' + vm.id;\n var index = args.index;\n var per = 360 / props.divid;\n var ratio = per * props.ratio;\n var rotation_1 = 360 * 3 - index * per + Math.random() * ratio + (per - ratio) / 2;\n delete global[key];\n engine.globalEvent.once('loop-end', function () {\n engine.Tween.get(props.target || target)\n .to({ rotation: rotation_1 }, props.duration, engine.Ease.quintOut)\n .call(function () {\n next('success');\n });\n });\n}\nelse {\n engine.Tween.removeTweens(props.target || target);\n next('success');\n}\n",
"group": "custom",
"type": "builtin"
}
location.href = '/record';
next('success');
var count = props.count, field = props.field, successValues = props.successValues;
var key = 'counting-' + vm.id;
var counting = global[key] || 0;
counting++;
var successArr = successValues.split(',');
if (successArr.indexOf(args[field] + '') >= 0) {
delete global[key];
next('success', args);
}
else if (counting < count) {
global[key] = counting;
next('continue');
}
else {
delete global[key];
next('timeout');
}
{ {
"script": "var count = props.count, field = props.field, successValues = props.successValues;\nvar key = 'counting-' + vm.id;\nvar counting = global[key] || 0;\ncounting++;\nvar successArr = successValues.split(',');\nif (successArr.indexOf(args[field]) >= 0) {\n delete global[key];\n next('success');\n}\nelse if (counting < count) {\n global[key] = counting;\n next('continue');\n}\nelse {\n delete global[key];\n next('timeout');\n}\n", "script": "var count = props.count, field = props.field, successValues = props.successValues;\nvar key = 'counting-' + vm.id;\nvar counting = global[key] || 0;\ncounting++;\nvar successArr = successValues.split(',');\nif (successArr.indexOf(args[field] + '') >= 0) {\n delete global[key];\n next('success', args);\n}\nelse if (counting < count) {\n global[key] = counting;\n next('continue');\n}\nelse {\n delete global[key];\n next('timeout');\n}\n",
"props": { "props": {
"count": { "count": {
"type": "number", "type": "number",
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"alias": "字段名", "alias": "字段名",
"default": "status" "default": "status"
}, },
"successArr": { "successValues": {
"type": "string", "type": "string",
"alias": "成功值" "alias": "成功值"
} }
......
{
"name": "Http轮询",
"props": {
"url": {
"type": "string",
"enum": [],
"alias": "链接"
},
"method": {
"type": "enum",
"enum": [
"get",
"post"
],
"alias": "方法",
"default": "get"
},
"count": {
"type": "number",
"enum": [],
"alias": "次数",
"default": 10
},
"delay": {
"type": "number",
"enum": [],
"default": 500,
"alias": "单次延时"
},
"name": {
"type": "string",
"enum": [],
"alias": "数据名"
},
"field": {
"type": "string",
"enum": [],
"alias": "字段名"
},
"successValues": {
"type": "string",
"enum": [],
"alias": "成功值"
}
},
"output": [
"success",
"failed",
"timeout"
],
"sub": {
"442452af-e4d2-47be-b931-86fef866056f": {
"uuid": "442452af-e4d2-47be-b931-86fef866056f",
"meta": "entry",
"design": {
"x": 26,
"y": 15,
"input": {},
"output": {
"success": [
{
"x": 124.5,
"y": 31
}
]
}
},
"props": {},
"output": {
"success": [
"2b895831-d362-491a-a57b-cd6e2d7223a8"
]
}
},
"9def8371-1326-4daa-8220-78cf888297e3": {
"uuid": "9def8371-1326-4daa-8220-78cf888297e3",
"meta": "wait",
"design": {
"x": 343,
"y": 277,
"input": {
"default": [
{
"x": 5.5,
"y": 39
}
]
},
"output": {
"complete": [
{
"x": 124.5,
"y": 39
}
]
}
},
"props": {
"duration": {
"type": "link",
"alias": "delay"
}
},
"output": {
"complete": [
"2b895831-d362-491a-a57b-cd6e2d7223a8"
]
}
},
"b88c8995-28eb-470f-a8a2-7484c9f98e05": {
"uuid": "b88c8995-28eb-470f-a8a2-7484c9f98e05",
"meta": "http-polling-judge",
"design": {
"x": 441,
"y": 57,
"input": {
"default": [
{
"x": 5.5,
"y": 56
}
]
},
"output": {
"continue": [
{
"x": 124.5,
"y": 42
}
],
"timeout": [
{
"x": 124.5,
"y": 56
}
],
"success": [
{
"x": 124.5,
"y": 70
}
]
}
},
"props": {
"count": {
"type": "link"
},
"field": {
"type": "link"
},
"successValues": {
"type": "link"
}
},
"output": {
"continue": [
"9def8371-1326-4daa-8220-78cf888297e3"
]
}
},
"2b895831-d362-491a-a57b-cd6e2d7223a8": {
"uuid": "2b895831-d362-491a-a57b-cd6e2d7223a8",
"meta": "duiba-api",
"design": {
"x": 238,
"y": 10,
"input": {
"default": [
{
"x": 5.5,
"y": 56
}
]
},
"output": {
"success": [
{
"x": 124.5,
"y": 49
}
],
"failed": [
{
"x": 124.5,
"y": 63
}
]
}
},
"props": {
"url": {
"type": "link"
},
"method": {
"type": "link"
},
"name": {
"type": "link"
}
},
"output": {
"success": [
"b88c8995-28eb-470f-a8a2-7484c9f98e05"
]
}
}
},
"subEntry": "442452af-e4d2-47be-b931-86fef866056f",
"metas": [
{
"script": "var count = props.count, field = props.field, successValues = props.successValues;\nvar key = 'counting-' + vm.id;\nvar counting = global[key] || 0;\ncounting++;\nvar successArr = successValues.split(',');\nif (successArr.indexOf(args[field] + '') >= 0) {\n delete global[key];\n next('success', args);\n}\nelse if (counting < count) {\n global[key] = counting;\n next('continue');\n}\nelse {\n delete global[key];\n next('timeout');\n}\n",
"props": {
"count": {
"type": "number",
"default": 5,
"alias": "次数"
},
"field": {
"type": "string",
"alias": "字段名",
"default": "status"
},
"successValues": {
"type": "string",
"alias": "成功值"
}
},
"name": "轮询判断",
"output": [
"success",
"continue",
"timeout"
],
"id": "http-polling-judge",
"group": "net",
"type": "builtin"
}
],
"id": "http-polling",
"script": "",
"group": "net",
"type": "builtin"
}
if (!props.url) {
console.log('url is empty');
next('exception', '\'url is empty\'');
}
else {
engine.globalLoader.httpRequest(function (s, payload) {
if (s) {
next('success', payload);
}
else {
next('failed', payload);
}
}, props.url, props.method, 'json');
}
{ {
"name": "HttpRequest", "name": "Http请求",
"desc": "http请求", "desc": "Http请求",
"props": { "props": {
"url": { "url": {
"type": "string", "type": "string",
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
"exception" "exception"
], ],
"id": "http-request", "id": "http-request",
"script": "if (!props.url) {\n console.log('url is empty');\n next('exception', '\\'url is empty\\'');\n}\nelse {\n engine.globalLoader.httpRequest(function (s, payload) {\n if (s) {\n next('success', payload);\n }\n else {\n next('failed', payload);\n }\n }, props.url, props.method || 'get', 'json');\n}\n", "script": "if (!props.url) {\n console.log('url is empty');\n next('exception', '\\'url is empty\\'');\n}\nelse {\n engine.globalLoader.httpRequest(function (s, payload) {\n if (s) {\n next('success', payload);\n }\n else {\n next('failed', payload);\n }\n }, props.url, props.method, 'json');\n}\n",
"group": "net", "group": "net",
"type": "builtin" "type": "builtin"
} }
This diff is collapsed.
if (props.closeAll) {
engine.gameStage.popupContainer.popAll();
}
else {
engine.gameStage.popupContainer.pop();
}
next('complete');
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"complete" "complete"
], ],
"id": "pop-dialog", "id": "pop-dialog",
"script": "if (props.closeAll) {\n engine.gameStage.popupContainer.popAll();\n}\nelse {\n engine.gameStage.popupContainer.pop();\n}\n", "script": "if (props.closeAll) {\n engine.gameStage.popupContainer.popAll();\n}\nelse {\n engine.gameStage.popupContainer.pop();\n}\nnext('complete');\n",
"group": "base", "group": "view",
"type": "builtin" "type": "builtin"
} }
if (props.closeAll) {
if (!props.viewName) {
console.log('没有设置视图名');
next('exception', '没有设置视图名');
}
else {
var gameStage = engine.gameStage;
var viewConfig = gameStage.getViewConfigByName(props.viewName);
if (viewConfig) {
var view = engine.instantiate(viewConfig);
gameStage.sceneContainer.push(view);
}
else {
console.error('view config not exists');
}
next('complete');
}
}
else {
engine.gameStage.popupContainer.pop();
next('complete');
}
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"complete" "complete"
], ],
"id": "pop-scene", "id": "pop-scene",
"script": "if (props.closeAll) {\n if (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n }\n else {\n var gameStage = engine.gameStage;\n var viewConfig = gameStage.getViewConfigByName(props.viewName);\n if (viewConfig) {\n var view = engine.instantiate(viewConfig);\n gameStage.sceneContainer.push(view);\n }\n else {\n console.error('view config not exists');\n }\n }\n}\nelse {\n engine.gameStage.popupContainer.pop();\n}\n", "script": "if (props.closeAll) {\n if (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n }\n else {\n var gameStage = engine.gameStage;\n var viewConfig = gameStage.getViewConfigByName(props.viewName);\n if (viewConfig) {\n var view = engine.instantiate(viewConfig);\n gameStage.sceneContainer.push(view);\n }\n else {\n console.error('view config not exists');\n }\n next('complete');\n }\n}\nelse {\n engine.gameStage.popupContainer.pop();\n next('complete');\n}\n",
"group": "base", "group": "view",
"type": "builtin" "type": "builtin"
} }
if (!props.viewName) {
console.log('没有设置视图名');
next('exception', '没有设置视图名');
}
else {
var gameStage = engine.gameStage;
var viewConfig = gameStage.getViewConfigByName(props.viewName);
if (viewConfig) {
var view = engine.instantiate(viewConfig);
gameStage.popupContainer.push(view, { center: props.center });
}
else {
console.error('view config not exists');
}
next('complete');
}
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"complete" "complete"
], ],
"id": "push-dialog", "id": "push-dialog",
"script": "if (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage = engine.gameStage;\n var viewConfig = gameStage.getViewConfigByName(props.viewName);\n if (viewConfig) {\n var view = engine.instantiate(viewConfig);\n gameStage.popupContainer.push(view, { center: props.center || true });\n }\n else {\n console.error('view config not exists');\n }\n}\n", "script": "if (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage = engine.gameStage;\n var viewConfig = gameStage.getViewConfigByName(props.viewName);\n if (viewConfig) {\n var view = engine.instantiate(viewConfig);\n gameStage.popupContainer.push(view, { center: props.center });\n }\n else {\n console.error('view config not exists');\n }\n next('complete');\n}\n",
"group": "base", "group": "view",
"type": "builtin" "type": "builtin"
} }
if (!props.viewName) {
console.log('没有设置视图名');
next('exception', '没有设置视图名');
}
else {
var gameStage = engine.gameStage;
var viewConfig = gameStage.getViewConfigByName(props.viewName);
if (viewConfig) {
var view = engine.instantiate(viewConfig);
gameStage.sceneContainer.push(view);
}
else {
console.error('view config not exists');
}
next('complete');
}
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"complete" "complete"
], ],
"id": "push-scene", "id": "push-scene",
"script": "if (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage = engine.gameStage;\n var viewConfig = gameStage.getViewConfigByName(props.viewName);\n if (viewConfig) {\n var view = engine.instantiate(viewConfig);\n gameStage.sceneContainer.push(view);\n }\n else {\n console.error('view config not exists');\n }\n}\n", "script": "if (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage = engine.gameStage;\n var viewConfig = gameStage.getViewConfigByName(props.viewName);\n if (viewConfig) {\n var view = engine.instantiate(viewConfig);\n gameStage.sceneContainer.push(view);\n }\n else {\n console.error('view config not exists');\n }\n next('complete');\n}\n",
"group": "base", "group": "view",
"type": "builtin" "type": "builtin"
} }
var targetNode = target || props.target;
if (targetNode) {
targetNode.mouseEnabled = props.enabled;
}
next('success');
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"success" "success"
], ],
"id": "set-mouse-enabled", "id": "set-mouse-enabled",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n targetNode.mouseEnabled = props.enabled;\n next('success');\n}\n", "script": "var targetNode = target || props.target;\nif (targetNode) {\n targetNode.mouseEnabled = props.enabled;\n}\nnext('success');\n",
"group": "base", "group": "view",
"type": "builtin" "type": "builtin"
} }
var targetNode = target || props.target;
if (targetNode) {
var field = props.field, valueType = props.valueType, value = props.value;
if (field && value) {
var tValue = void 0;
switch (valueType) {
case 'number':
tValue = parseFloat(value);
break;
case 'string':
tValue = value;
break;
case 'boolean':
tValue = value === 'true' ? true : (value === 'false' ? false : value);
break;
}
if (tValue !== undefined) {
targetNode[field] = tValue;
}
}
}
next('success');
{
"name": "设置节点属性",
"desc": "设置节点属性",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"field": {
"type": "string",
"alias": "属性名"
},
"valueType": {
"type": "enum",
"enum": [
"number",
"string",
"boolean"
],
"alias": "数值类型",
"default": "number"
},
"value": {
"type": "string",
"alias": "数值"
}
},
"output": [
"success"
],
"id": "set-node-property",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n var field = props.field, valueType = props.valueType, value = props.value;\n if (field && value) {\n var tValue = void 0;\n switch (valueType) {\n case 'number':\n tValue = parseFloat(value);\n break;\n case 'string':\n tValue = value;\n break;\n case 'boolean':\n tValue = value === 'true' ? true : (value === 'false' ? false : value);\n break;\n }\n if (tValue !== undefined) {\n targetNode[field] = tValue;\n }\n }\n}\nnext('success');\n",
"group": "view",
"type": "builtin"
}
var targetNode = target || props.target;
if (targetNode) {
targetNode.visible = props.visible;
}
next('success');
{
"name": "设置节点可见性",
"desc": "设置节点可见性",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"visible": {
"type": "boolean",
"alias": "可否可见",
"default": false
}
},
"output": [
"success"
],
"id": "set-node-visibility",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n targetNode.visible = props.visible;\n}\nnext('success');\n",
"group": "view",
"type": "builtin"
}
var targetNode = target || props.target;
if (targetNode) {
var scriptsProxy = targetNode.scriptsProxy;
var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;
var script = void 0;
if (scriptIndex !== undefined) {
script = scriptsProxy.all[scriptIndex];
}
else if (scriptName !== undefined) {
script = scriptsProxy.get(scriptName);
}
if (script) {
script.disabled = !enabled;
}
}
next('success');
{
"name": "设置脚本有效性",
"desc": "设置脚本有效性,优先查找索引",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"scriptIndex": {
"type": "number",
"alias": "脚本索引"
},
"name": {
"type": "string",
"alias": "脚本名"
},
"enabled": {
"type": "boolean",
"alias": "可否有效",
"default": false
}
},
"output": [
"success"
],
"id": "set-script-enabled",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n var scriptsProxy = targetNode.scriptsProxy;\n var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;\n var script = void 0;\n if (scriptIndex !== undefined) {\n script = scriptsProxy.all[scriptIndex];\n }\n else if (scriptName !== undefined) {\n script = scriptsProxy.get(scriptName);\n }\n if (script) {\n script.disabled = !enabled;\n }\n}\nnext('success');\n",
"group": "view",
"type": "builtin"
}
var targetNode = target || props.target;
if (targetNode) {
var scriptsProxy = targetNode.scriptsProxy;
var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;
var script = void 0;
if (scriptIndex !== undefined) {
script = scriptsProxy.all[scriptIndex];
}
else if (scriptName !== undefined) {
script = scriptsProxy.get(scriptName);
}
if (script) {
var field = props.field, valueType = props.valueType, value = props.value;
if (field && value) {
var tValue = void 0;
switch (valueType) {
case 'number':
tValue = parseFloat(value);
break;
case 'string':
tValue = value;
break;
case 'boolean':
tValue = value === 'true' ? true : (value === 'false' ? false : value);
break;
}
if (tValue !== undefined) {
script[field] = tValue;
}
}
}
}
next('success');
{
"name": "设置脚本属性",
"desc": "设置脚本属性,优先查找索引",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"scriptIndex": {
"type": "number",
"alias": "脚本索引"
},
"name": {
"type": "string",
"alias": "脚本名"
},
"field": {
"type": "string",
"alias": "属性名"
},
"valueType": {
"type": "enum",
"enum": [
"number",
"string",
"boolean"
],
"alias": "数值类型",
"default": "number"
},
"value": {
"type": "string",
"alias": "数值"
}
},
"output": [
"success"
],
"id": "set-script-property",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n var scriptsProxy = targetNode.scriptsProxy;\n var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;\n var script = void 0;\n if (scriptIndex !== undefined) {\n script = scriptsProxy.all[scriptIndex];\n }\n else if (scriptName !== undefined) {\n script = scriptsProxy.get(scriptName);\n }\n if (script) {\n var field = props.field, valueType = props.valueType, value = props.value;\n if (field && value) {\n var tValue = void 0;\n switch (valueType) {\n case 'number':\n tValue = parseFloat(value);\n break;\n case 'string':\n tValue = value;\n break;\n case 'boolean':\n tValue = value === 'true' ? true : (value === 'false' ? false : value);\n break;\n }\n if (tValue !== undefined) {\n script[field] = tValue;\n }\n }\n }\n}\nnext('success');\n",
"group": "view",
"type": "builtin"
}
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
* Created by rockyl on 2019-11-16. * Created by rockyl on 2019-11-16.
*/ */
let leftValue = typeof props.left === 'string' ? '"' + props.left + '"' : props.left;
let rightValue = typeof props.right === 'string' ? '"' + props.right + '"' : props.right;
let operator = (args ? args.operator : props.operator) || '=='; let operator = (args ? args.operator : props.operator) || '==';
if(operator === '==' || operator === '!='){ if(operator === '==' || operator === '!='){
operator += '='; operator += '=';
} }
let func = new Function('return ' + props.left + operator + props.right); let func = new Function('return ' + leftValue + operator + rightValue);
let result = func(); let result = func();
next(result ? 'true' : 'false'); next(result ? 'true' : 'false');
...@@ -4,9 +4,8 @@ ...@@ -4,9 +4,8 @@
"props": { "props": {
"left": {"alias": "左值","type": "data", "default": ""}, "left": {"alias": "左值","type": "data", "default": ""},
"right": {"alias": "右值","type": "data", "default": ""}, "right": {"alias": "右值","type": "data", "default": ""},
"strict": {"alias": "严格模式","type": "boolean", "default": false},
"operator": {"alias": "操作符","type": "enum", "operator": {"alias": "操作符","type": "enum",
"enum": ["==",">",">=","<","<=","!="], "enum": ["==","!=","===","!==",">",">=","<","<="],
"default": "=="} "default": "=="}
}, },
"output": [ "output": [
......
/**
* Created by rockyl on 2019-11-16.
*/
if (args && args.url) {
location.href = args.url;
} else if (props.url) {
location.href = props.url;
}
next('complete');
{
"name": "跳转页面",
"desc": "跳转页面",
"props": {
"url": {
"alias": "地址",
"type": "data"
}
},
"output": [
"complete"
]
}
\ No newline at end of file
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
setTimeout(function(){ setTimeout(function(){
next('complete') next('complete')
}, args ? args.duration : (props.duration || 0)); }, args ? args.duration : props.duration);
/**
* Created by rockyl on 2019-11-16.
*/
const key = 'state-' + vm.id;
global[key] = true;
engine.Tween.get(props.target)
.set({rotation: 0})
.to({rotation: 360}, props.duration, engine.Ease.quintIn)
.call(function () {
next('success');
playLoop();
});
function playLoop() {
let goon = global[key];
if (goon) {
engine.Tween.get(props.target)
.set({rotation: 0})
.to({rotation: 360}, props.duration / 4)
.call(function () {
engine.globalEvent.dispatchEvent('loop-end');
playLoop();
})
}
}
{
"name": "入口",
"desc": "入口节点,每个行为的入口",
"props": {},
"output": [
"success"
]
}
/**
* Created by rockyl on 2019-11-16.
*/
if (args && args.hasOwnProperty('index')) {
const key = 'state-' + vm.id;
let index = args.index;
let per = 360 / props.divid;
let ratio = per * props.ratio;
let rotation = 360 * 3 - index * per + Math.random() * ratio + (per - ratio) / 2;
delete global[key];
engine.globalEvent.once('loop-end', function () {
engine.Tween.get(props.target || target)
.to({rotation}, props.duration, engine.Ease.quintOut)
.call(function () {
next('success');
})
});
} else {
engine.Tween.removeTweens(props.target || target);
next('success');
}
{
"name": "入口",
"desc": "入口节点,每个行为的入口",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"divide": {
"type": "number",
"default": 6,
"alias": "转盘格数"
},
"duration": {
"type": "number",
"default": 1000,
"alias": "时间"
},
"ratio": {
"alias": "占比",
"type": "number",
"default": "0.9"
}
},
"output": [
"success"
]
}
...@@ -8,9 +8,9 @@ let counting = global[key] || 0; ...@@ -8,9 +8,9 @@ let counting = global[key] || 0;
counting++; counting++;
let successArr = successValues.split(','); let successArr = successValues.split(',');
if (successArr.indexOf(args[field]) >= 0) { if (successArr.indexOf(args[field] + '') >= 0) {
delete global[key]; delete global[key];
next('success'); next('success', args);
} else if (counting < count) { } else if (counting < count) {
global[key] = counting; global[key] = counting;
next('continue'); next('continue');
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"alias": "字段名", "alias": "字段名",
"default": "status" "default": "status"
}, },
"successArr": { "successValues": {
"type": "string", "type": "string",
"alias": "成功值" "alias": "成功值"
} }
......
...@@ -2,19 +2,3 @@ ...@@ -2,19 +2,3 @@
* Created by rockyl on 2019-11-16. * Created by rockyl on 2019-11-16.
*/ */
const {count, field, successValues} = props;
const key = 'counting-' + vm.id;
let counting = global[key] || 0;
counting++;
let successArr = successValues.split(',');
if (successArr.indexOf(args[field]) >= 0) {
delete global[key];
next('success');
} else if (counting < count) {
global[key] = counting;
next('continue');
} else {
delete global[key];
next('timeout');
}
{ {
"id": "polling", "name": "Http轮询",
"name": "轮询",
"script": "",
"props": { "props": {
"url": { "url": {
"type": "string", "type": "string",
...@@ -211,7 +209,7 @@ ...@@ -211,7 +209,7 @@
"subEntry": "442452af-e4d2-47be-b931-86fef866056f", "subEntry": "442452af-e4d2-47be-b931-86fef866056f",
"metas": [ "metas": [
{ {
"script": "var count = props.count, field = props.field, successValues = props.successValues;\nvar key = 'counting-' + vm.id;\nvar counting = global[key] || 0;\ncounting++;\nvar successArr = successValues.split(',');\nif (successArr.indexOf(args[field]) >= 0) {\n delete global[key];\n next('success');\n}\nelse if (counting < count) {\n global[key] = counting;\n next('continue');\n}\nelse {\n delete global[key];\n next('timeout');\n}\n", "script": "var count = props.count, field = props.field, successValues = props.successValues;\nvar key = 'counting-' + vm.id;\nvar counting = global[key] || 0;\ncounting++;\nvar successArr = successValues.split(',');\nif (successArr.indexOf(args[field] + '') >= 0) {\n delete global[key];\n next('success', args);\n}\nelse if (counting < count) {\n global[key] = counting;\n next('continue');\n}\nelse {\n delete global[key];\n next('timeout');\n}\n",
"props": { "props": {
"count": { "count": {
"type": "number", "type": "number",
...@@ -223,7 +221,7 @@ ...@@ -223,7 +221,7 @@
"alias": "字段名", "alias": "字段名",
"default": "status" "default": "status"
}, },
"successArr": { "successValues": {
"type": "string", "type": "string",
"alias": "成功值" "alias": "成功值"
} }
......
...@@ -13,5 +13,5 @@ if(!props.url){ ...@@ -13,5 +13,5 @@ if(!props.url){
}else{ }else{
next('failed', payload); next('failed', payload);
} }
}, props.url, props.method || 'get', 'json'); }, props.url, props.method, 'json');
} }
{ {
"name": "HttpRequest", "name": "Http请求",
"desc": "http请求", "desc": "Http请求",
"props": { "props": {
"url": {"type": "string", "alias": "地址"}, "url": {"type": "string", "alias": "地址"},
"method": {"type": "enum", "enum": ["get", "post"], "alias": "方法", "default": "get"} "method": {"type": "enum", "enum": ["get", "post"], "alias": "方法", "default": "get"}
......
/**
* Created by rockyl on 2019-11-20.
*/
This diff is collapsed.
...@@ -7,3 +7,4 @@ if(props.closeAll){ ...@@ -7,3 +7,4 @@ if(props.closeAll){
}else{ }else{
engine.gameStage.popupContainer.pop(); engine.gameStage.popupContainer.pop();
} }
next('complete');
...@@ -15,7 +15,13 @@ if(props.closeAll){ ...@@ -15,7 +15,13 @@ if(props.closeAll){
} else { } else {
console.error('view config not exists'); console.error('view config not exists');
} }
next('complete');
} }
}else{ }else{
engine.gameStage.popupContainer.pop(); engine.gameStage.popupContainer.pop();
}
next('complete');
}
\ No newline at end of file
...@@ -10,8 +10,11 @@ if (!props.viewName) { ...@@ -10,8 +10,11 @@ if (!props.viewName) {
let viewConfig = gameStage.getViewConfigByName(props.viewName); let viewConfig = gameStage.getViewConfigByName(props.viewName);
if (viewConfig) { if (viewConfig) {
let view = engine.instantiate(viewConfig); let view = engine.instantiate(viewConfig);
gameStage.popupContainer.push(view, {center: props.center || true}); gameStage.popupContainer.push(view, {center: props.center});
} else { } else {
console.error('view config not exists'); console.error('view config not exists');
} }
next('complete');
} }
...@@ -14,4 +14,7 @@ if (!props.viewName) { ...@@ -14,4 +14,7 @@ if (!props.viewName) {
} else { } else {
console.error('view config not exists'); console.error('view config not exists');
} }
next('complete');
} }
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
let targetNode = target || props.target; let targetNode = target || props.target;
if(targetNode){ if(targetNode){
targetNode.mouseEnabled = props.enabled; targetNode.mouseEnabled = props.enabled;
next('success') }
}
\ No newline at end of file next('success');
/**
* Created by rockyl on 2019-11-16.
*/
let targetNode = target || props.target;
if (targetNode) {
const {field, valueType, value} = props;
if (field && value) {
let tValue;
switch (valueType) {
case 'number':
tValue = parseFloat(value);
break;
case 'string':
tValue = value;
break;
case 'boolean':
tValue = value === 'true' ? true : (value === 'false' ? false : value);
break;
}
if (tValue !== undefined) {
targetNode[field] = tValue;
}
}
}
next('success');
{
"name": "设置节点属性",
"desc": "设置节点属性",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"field": {
"type": "string",
"alias": "属性名"
},
"valueType": {
"type": "enum",
"enum": ["number", "string", "boolean"],
"alias": "数值类型",
"default": "number"
},
"value": {
"type": "string",
"alias": "数值"
}
},
"output": [
"success"
]
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-16.
*/
let targetNode = target || props.target;
if(targetNode){
targetNode.visible = props.visible;
}
next('success');
{
"name": "设置节点可见性",
"desc": "设置节点可见性",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"visible": {
"type": "boolean",
"alias": "可否可见",
"default": false
}
},
"output": [
"success"
]
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-16.
*/
let targetNode = target || props.target;
if (targetNode) {
const {scriptsProxy} = targetNode;
const {scriptIndex, scriptName, enabled} = props;
let script;
if (scriptIndex !== undefined) {
script = scriptsProxy.all[scriptIndex];
} else if (scriptName !== undefined) {
script = scriptsProxy.get(scriptName);
}
if (script) {
script.disabled = !enabled;
}
}
next('success');
{
"name": "设置脚本有效性",
"desc": "设置脚本有效性,优先查找索引",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"scriptIndex": {
"type": "number",
"alias": "脚本索引"
},
"name": {
"type": "string",
"alias": "脚本名"
},
"enabled": {
"type": "boolean",
"alias": "可否有效",
"default": false
}
},
"output": [
"success"
]
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-16.
*/
let targetNode = target || props.target;
if (targetNode) {
const {scriptsProxy} = targetNode;
const {scriptIndex, scriptName, enabled} = props;
let script;
if (scriptIndex !== undefined) {
script = scriptsProxy.all[scriptIndex];
} else if (scriptName !== undefined) {
script = scriptsProxy.get(scriptName);
}
if (script) {
const {field, valueType, value} = props;
if (field && value) {
let tValue;
switch (valueType) {
case 'number':
tValue = parseFloat(value);
break;
case 'string':
tValue = value;
break;
case 'boolean':
tValue = value === 'true' ? true : (value === 'false' ? false : value);
break;
}
if (tValue !== undefined) {
script[field] = tValue;
}
}
}
}
next('success');
{
"name": "设置脚本属性",
"desc": "设置脚本属性,优先查找索引",
"props": {
"target": {
"type": "node",
"alias": "目标节点"
},
"scriptIndex": {
"type": "number",
"alias": "脚本索引"
},
"name": {
"type": "string",
"alias": "脚本名"
},
"field": {
"type": "string",
"alias": "属性名"
},
"valueType": {
"type": "enum",
"enum": ["number", "string", "boolean"],
"alias": "数值类型",
"default": "number"
},
"value": {
"type": "string",
"alias": "数值"
}
},
"output": [
"success"
]
}
\ No newline at end of file
...@@ -24,9 +24,10 @@ function compileProcess(sourcePath, output, isBuiltin) { ...@@ -24,9 +24,10 @@ function compileProcess(sourcePath, output, isBuiltin) {
meta.type = 'builtin' meta.type = 'builtin'
} }
const outputPath = path.join(output, sourcePath + '.json'); const outputPath = path.join(output, sourcePath);
fs.ensureDirSync(path.dirname(outputPath)); fs.ensureDirSync(path.dirname(outputPath));
fs.writeJsonSync(outputPath, meta, {spaces: ' '}); fs.writeJsonSync(outputPath + '.json', meta, {spaces: ' '});
fs.writeFileSync(outputPath + '.js', code);
console.log(`compile process [${sourcePath}] successfully!`); console.log(`compile process [${sourcePath}] successfully!`);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment