Skip to content

Commit

Permalink
字段类型:lua => code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhandouxiaojiji committed Feb 27, 2024
1 parent 2f53c44 commit 239e352
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
4 changes: 2 additions & 2 deletions render-process/Editor/NodePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ export default class NodePanel extends React.Component<NodePanelProps> {
return <InputNumber style={{ width: "100%" }} onBlur={this.handleSubmit} />;
} else if (e.type.indexOf("boolean") >= 0) {
return <Switch onChange={this.handleSubmit} />;
} else if (e.type.indexOf("lua") >= 0) {
return <Input onBlur={this.handleSubmit} placeholder={"公式"} />;
} else if (e.type.indexOf("code") >= 0) {
return <Input onBlur={this.handleSubmit} placeholder={"表达式"} />;
} else if (e.type.indexOf("enum") >= 0 ) {
return <Select style={{ width: 120 }} onChange={this.handleSubmit} >
{
Expand Down
2 changes: 1 addition & 1 deletion sample/node-config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"name":"AlwaysFail","type":"Decorator","doc":"+ 只能有一个子节点,多个仅执行第一个\n+ 不管子节点是否成功都返回失败\n","desc":"始终返回失败"},{"name":"AlwaysSuccess","type":"Decorator","doc":"+ 只能有一个子节点,多个仅执行第一个\n+ 不管子节点是否成功都返回成功\n","desc":"始终返回成功"},{"name":"Attack","type":"Action","input":["{目标}"],"desc":"攻击"},{"name":"Cmp","type":"Condition","doc":"+ 若值为空,返回失败\n+ 非整数类型可能会报错\n","input":["值(int)"],"args":[{"name":"value","desc":"值","type":"lua?"},{"name":"gt","desc":">","type":"int?"},{"name":"ge","desc":">=","type":"int?"},{"name":"eq","desc":"==","type":"int?"},{"name":"le","desc":"<=","type":"int?"},{"name":"lt","desc":"<","type":"int?"}],"desc":"比较值大小"},{"name":"FindEnemy","output":["目标单位"],"type":"Condition","doc":"+ 没找到返回失败\n","args":[{"name":"x","desc":"x","type":"int?"},{"name":"y","desc":"y","type":"int?"},{"name":"w","desc":"宽","type":"int?"},{"name":"h","desc":"高","type":"int?"},{"name":"count","desc":"查找上限","type":"string?"}],"desc":"查找敌人"},{"name":"GetHp","output":["生命值"],"type":"Action","desc":"获取生命值"},{"name":"Idle","type":"Action","desc":"待机"},{"name":"Log","type":"Action","args":[{"name":"str","desc":"日志","type":"string"}],"desc":"打印日志"},{"name":"MoveToPos","type":"Action","args":[{"name":"x","desc":"x","type":"int"},{"name":"y","desc":"y","type":"int"}],"desc":"移动到坐标"},{"name":"MoveToTarget","type":"Action","input":["{目标}"],"desc":"移动到目标"},{"name":"Not","type":"Decorator","doc":"+ 将子节点的返回值取反\n","desc":"取反"},{"name":"Parallel","type":"Composite","doc":"执行所有子节点并返回成功\n","desc":"并行执行"},{"name":"Selector","type":"Composite","doc":"+ 一直往下执行,有子节点返回成功则返回成功,若全部节点返回失败则返回失败\n+ 子节点是或的关系\n","desc":"选择执行"},{"name":"Sequence","type":"Composite","doc":"+ 一直往下执行,有子节点返回成功则返回成功,若全部节点返回失败则返回失败\n+ 子节点是或的关系\n","desc":"顺序执行"},{"name":"Wait","type":"Action","args":[{"name":"time","desc":"时间/tick","type":"int"}],"desc":"等待"}]
[{"name":"AlwaysFail","type":"Decorator","doc":"+ 只能有一个子节点,多个仅执行第一个\n+ 不管子节点是否成功都返回失败\n","desc":"始终返回失败"},{"name":"AlwaysSuccess","type":"Decorator","doc":"+ 只能有一个子节点,多个仅执行第一个\n+ 不管子节点是否成功都返回成功\n","desc":"始终返回成功"},{"name":"Attack","type":"Action","input":["{目标}"],"desc":"攻击"},{"name":"Cmp","type":"Condition","doc":"+ 若值为空,返回失败\n+ 非整数类型可能会报错\n","input":["值(int)"],"args":[{"name":"value","desc":"值","type":"code?"},{"name":"gt","desc":">","type":"int?"},{"name":"ge","desc":">=","type":"int?"},{"name":"eq","desc":"==","type":"int?"},{"name":"le","desc":"<=","type":"int?"},{"name":"lt","desc":"<","type":"int?"}],"desc":"比较值大小"},{"name":"FindEnemy","output":["目标单位"],"type":"Condition","doc":"+ 没找到返回失败\n","args":[{"name":"x","desc":"x","type":"int?"},{"name":"y","desc":"y","type":"int?"},{"name":"w","desc":"宽","type":"int?"},{"name":"h","desc":"高","type":"int?"},{"name":"count","desc":"查找上限","type":"string?"}],"desc":"查找敌人"},{"name":"GetHp","output":["生命值"],"type":"Action","desc":"获取生命值"},{"name":"Idle","type":"Action","desc":"待机"},{"name":"Log","type":"Action","args":[{"name":"str","desc":"日志","type":"string"}],"desc":"打印日志"},{"name":"MoveToPos","type":"Action","args":[{"name":"x","desc":"x","type":"int"},{"name":"y","desc":"y","type":"int"}],"desc":"移动到坐标"},{"name":"MoveToTarget","type":"Action","input":["{目标}"],"desc":"移动到目标"},{"name":"Not","type":"Decorator","doc":"+ 将子节点的返回值取反\n","desc":"取反"},{"name":"Parallel","type":"Composite","doc":"执行所有子节点并返回成功\n","desc":"并行执行"},{"name":"Selector","type":"Composite","doc":"+ 一直往下执行,有子节点返回成功则返回成功,若全部节点返回失败则返回失败\n+ 子节点是或的关系\n","desc":"选择执行"},{"name":"Sequence","type":"Composite","doc":"+ 一直往下执行,有子节点返回成功则返回成功,若全部节点返回失败则返回失败\n+ 子节点是或的关系\n","desc":"顺序执行"},{"name":"Wait","type":"Action","args":[{"name":"time","desc":"时间/tick","type":"int"}],"desc":"等待"}]
56 changes: 55 additions & 1 deletion sample/workdir/monster.json
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
{"name":"monster","root":{"id":1,"name":"Sequence","desc":"怪物测试AI","args":{},"children":[{"id":2,"name":"Sequence","desc":"攻击","args":{},"children":[{"id":3,"name":"GetHp","args":{},"output":["hp"]},{"id":4,"name":"Cmp","args":{"gt":50},"input":["hp"]},{"id":5,"name":"Log","desc":"攻击","args":{"str":"Attack!"}}]},{"id":6,"name":"Log","desc":"逃跑","args":{"str":"Run!"}}]},"desc":"怪物测试AI"}
{
"name": "monster",
"root": {
"id": 1,
"name": "Sequence",
"desc": "怪物测试AI",
"args": {},
"children": [
{
"id": 2,
"name": "Sequence",
"desc": "攻击",
"args": {},
"children": [
{
"id": 3,
"name": "GetHp",
"args": {},
"output": [
"hp"
]
},
{
"id": 4,
"name": "Cmp",
"args": {
"gt": 50,
"value": "hp"
},
"input": [
""
]
},
{
"id": 5,
"name": "Log",
"desc": "攻击",
"args": {
"str": "Attack!"
}
}
]
},
{
"id": 6,
"name": "Log",
"desc": "逃跑",
"args": {
"str": "Run!"
}
}
]
},
"desc": "怪物测试AI"
}

0 comments on commit 239e352

Please sign in to comment.