Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
5a625678
E
et
项目概览
老鱼er
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
et
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5a625678
编写于
6月 19, 2017
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
整理了行为树代码,暂时没发现bug
上级
8ebb054d
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
297 addition
and
706 deletion
+297
-706
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorManager.cs
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorManager.cs
+7
-16
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorNodeConfigExtension.cs
.../Editor/BehaviorTreeEditor/BehaviorNodeConfigExtension.cs
+2
-2
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeOperateUtility.cs
...s/Editor/BehaviorTreeEditor/BehaviorTreeOperateUtility.cs
+3
-9
Unity/Assets/Editor/BehaviorTreeEditor/ExportNodeTypeConfig.cs
.../Assets/Editor/BehaviorTreeEditor/ExportNodeTypeConfig.cs
+1
-1
Unity/Assets/Editor/BehaviorTreeEditor/NodeExtension.cs
Unity/Assets/Editor/BehaviorTreeEditor/NodeExtension.cs
+2
-2
Unity/Assets/Editor/BehaviorTreeEditor/PropertyDesigner.cs
Unity/Assets/Editor/BehaviorTreeEditor/PropertyDesigner.cs
+0
-4
Unity/Assets/Res/BT/BT_大厅UI创建时执行行为树.prefab
Unity/Assets/Res/BT/BT_大厅UI创建时执行行为树.prefab
+202
-103
Unity/Assets/Scripts/BehaviorTree/BehaviorNodeConfig.cs
Unity/Assets/Scripts/BehaviorTree/BehaviorNodeConfig.cs
+3
-3
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeArgsDict.cs
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeArgsDict.cs
+45
-399
Unity/Assets/Scripts/BehaviorTree/NodeProto.cs
Unity/Assets/Scripts/BehaviorTree/NodeProto.cs
+11
-1
Unity/Assets/Scripts/BehaviorTree/ValueBase.cs
Unity/Assets/Scripts/BehaviorTree/ValueBase.cs
+19
-164
Unity/Assets/Scripts/Component/BehaviorTreeComponent.cs
Unity/Assets/Scripts/Component/BehaviorTreeComponent.cs
+2
-2
未找到文件。
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorManager.cs
浏览文件 @
5a625678
...
...
@@ -202,7 +202,7 @@ namespace MyEditor
{
ClientNodeTypeProto
proto
=
ExportNodeTypeConfig
.
GetNodeTypeProtoFromDll
(
nodeProto
.
name
);
List
<
string
>
unUsedList
=
new
List
<
string
>();
foreach
(
KeyValuePair
<
string
,
ValueBase
>
item
in
nodeProto
.
args_dict
)
foreach
(
KeyValuePair
<
string
,
ValueBase
>
item
in
nodeProto
.
args_dict
.
Dict
()
)
{
if
(!
proto
.
new_args_desc
.
Exists
(
a
=>
(
a
.
name
==
item
.
Key
)))
{
...
...
@@ -263,9 +263,9 @@ namespace MyEditor
{
config
.
RootNodeConfig
=
NodeDataToNodeConfig
(
tree
.
Root
);
}
catch
catch
(
Exception
e
)
{
Debug
.
LogError
(
$"tree name :
{
tree
.
BehaviorNodeData
.
nam
e
}
"
);
Log
.
Error
(
$"tree name :
{
tree
.
BehaviorNodeData
.
name
}
{
e
}
"
);
}
config
.
RootNodeConfig
.
gameObject
.
transform
.
parent
=
config
.
gameObject
.
transform
;
...
...
@@ -302,7 +302,7 @@ namespace MyEditor
go
.
name
=
nodeData
.
name
;
nodeConfig
.
describe
=
nodeData
.
describe
;
List
<
string
>
unUseList
=
new
List
<
string
>();
foreach
(
KeyValuePair
<
string
,
ValueBase
>
args
in
nodeData
.
args_dict
)
foreach
(
KeyValuePair
<
string
,
ValueBase
>
args
in
nodeData
.
args_dict
.
Dict
()
)
{
if
(!
ExportNodeTypeConfig
.
NodeHasField
(
nodeData
.
name
,
args
.
Key
))
{
...
...
@@ -313,7 +313,7 @@ namespace MyEditor
try
{
string
fieldName
=
args
.
Key
;
object
fieldValue
=
args
.
Value
.
GetValue
ByType
(
originType
);
object
fieldValue
=
args
.
Value
.
GetValue
(
);
Type
type
=
BTTypeManager
.
GetBTType
(
originType
);
Component
comp
=
go
.
AddComponent
(
type
);
FieldInfo
fieldNameInfo
=
type
.
GetField
(
"fieldName"
);
...
...
@@ -406,9 +406,9 @@ namespace MyEditor
copyNode
.
describe
=
node
.
describe
;
copyNode
.
Pos
=
node
.
Pos
;
copyNode
.
args_dict
=
new
BehaviorTreeArgsDict
();
foreach
(
KeyValuePair
<
string
,
ValueBase
>
item
in
node
.
args_dict
)
foreach
(
KeyValuePair
<
string
,
ValueBase
>
item
in
node
.
args_dict
.
Dict
()
)
{
ValueBase
valueBase
=
ValueBase
.
Clone
(
item
.
Value
);
ValueBase
valueBase
=
item
.
Value
.
Clone
(
);
copyNode
.
args_dict
.
Add
(
item
.
Key
,
valueBase
);
}
List
<
BehaviorNodeData
>
list
=
new
List
<
BehaviorNodeData
>();
...
...
@@ -523,15 +523,6 @@ namespace MyEditor
foreach
(
NodeFieldDesc
desc
in
list
)
{
if
(!
nodeProto
.
args_dict
.
ContainsKey
(
desc
.
name
))
{
ValueBase
valueBase
=
new
ValueBase
();
nodeProto
.
args_dict
.
Add
(
desc
.
name
,
valueBase
);
}
if
(
string
.
IsNullOrEmpty
(
nodeProto
.
args_dict
[
desc
.
name
].
enumValue
))
{
nodeProto
.
args_dict
[
desc
.
name
].
enumValue
=
BTEnvKey
.
None
;
}
string
value
=
nodeProto
.
args_dict
.
GetTreeDictValue
(
desc
.
type
,
desc
.
name
)?.
ToString
();
resultList
.
Add
(
value
);
}
...
...
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorNodeConfigExtension.cs
浏览文件 @
5a625678
...
...
@@ -16,13 +16,13 @@ namespace Model
nodeConfig
.
name
=
nodeData
.
name
;
go
.
name
=
nodeData
.
name
;
nodeConfig
.
describe
=
nodeData
.
describe
;
foreach
(
KeyValuePair
<
string
,
ValueBase
>
args
in
nodeData
.
args_dict
)
foreach
(
KeyValuePair
<
string
,
ValueBase
>
args
in
nodeData
.
args_dict
.
Dict
()
)
{
Type
originType
=
ExportNodeTypeConfig
.
GetFieldType
(
nodeData
.
name
,
args
.
Key
);
try
{
string
fieldName
=
args
.
Key
;
object
fieldValue
=
args
.
Value
.
GetValue
ByType
(
originType
);
object
fieldValue
=
args
.
Value
.
GetValue
(
);
Type
type
=
BTTypeManager
.
GetBTType
(
originType
);
UnityEngine
.
Component
comp
=
go
.
AddComponent
(
type
);
FieldInfo
fieldNameInfo
=
type
.
GetField
(
"fieldName"
);
...
...
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeOperateUtility.cs
浏览文件 @
5a625678
...
...
@@ -42,10 +42,10 @@ namespace MyEditor
public
void
UpdateData
()
{
foreach
(
KeyValuePair
<
string
,
ValueBase
>
argsItem
in
Proto
.
args_dict
)
foreach
(
KeyValuePair
<
string
,
ValueBase
>
argsItem
in
Proto
.
args_dict
.
Dict
()
)
{
FieldInfo
fieldInfo
=
typeof
(
T
).
GetField
(
argsItem
.
Key
,
BindingFlags
.
Instance
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Public
);
fieldInfo
.
SetValue
(
Node
,
argsItem
.
Value
.
GetValue
ByType
(
fieldInfo
.
FieldType
));
fieldInfo
.
SetValue
(
Node
,
argsItem
.
Value
.
GetValue
(
));
}
}
}
...
...
@@ -59,13 +59,7 @@ namespace MyEditor
/// <returns></returns>
public
static
NodeProto
NodeProtoParamClone
(
NodeProto
p
)
{
NodeProto
newP
=
new
NodeProto
();
foreach
(
KeyValuePair
<
string
,
ValueBase
>
dict
in
p
.
args_dict
)
{
string
key
=
dict
.
Key
;
ValueBase
value
=
ValueBase
.
Clone
(
dict
.
Value
);
newP
.
args_dict
.
Add
(
key
,
value
);
}
NodeProto
newP
=
new
NodeProto
(
p
.
args_dict
.
Clone
());
return
newP
;
}
...
...
Unity/Assets/Editor/BehaviorTreeEditor/ExportNodeTypeConfig.cs
浏览文件 @
5a625678
...
...
@@ -245,7 +245,7 @@ namespace MyEditor
FieldInfo
fieldInfo
=
nodeType
.
GetField
(
fieldName
,
BindingFlags
.
Instance
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Public
);
if
(
fieldInfo
==
null
)
{
Log
.
Error
(
string
.
Format
(
"{0}节点不存在此属性:{1}"
,
nodeName
,
fieldName
)
);
Log
.
Error
(
$"
{
nodeName
}
节点不存在此属性:
{
fieldName
}
"
);
}
return
fieldInfo
.
FieldType
;
}
...
...
Unity/Assets/Editor/BehaviorTreeEditor/NodeExtension.cs
浏览文件 @
5a625678
...
...
@@ -26,10 +26,10 @@ namespace Model
NodeProto
p
=
protoStack
.
Dequeue
();
Node
node
=
nodeStack
.
Dequeue
();
foreach
(
KeyValuePair
<
string
,
ValueBase
>
argsItem
in
p
.
args_dict
)
foreach
(
KeyValuePair
<
string
,
ValueBase
>
argsItem
in
p
.
args_dict
.
Dict
()
)
{
FieldInfo
fieldInfo
=
node
.
GetType
().
GetField
(
argsItem
.
Key
,
BindingFlags
.
Instance
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Public
);
fieldInfo
.
SetValue
(
node
,
argsItem
.
Value
.
GetValue
ByType
(
fieldInfo
.
FieldType
));
fieldInfo
.
SetValue
(
node
,
argsItem
.
Value
.
GetValue
(
));
}
foreach
(
NodeProto
child
in
p
.
Children
)
{
...
...
Unity/Assets/Editor/BehaviorTreeEditor/PropertyDesigner.cs
浏览文件 @
5a625678
...
...
@@ -395,10 +395,6 @@ namespace MyEditor
Type
fieldType
=
ExportNodeTypeConfig
.
GetFieldType
(
nodeName
,
desc
.
name
);
ClientNodeTypeProto
clientNode
=
ExportNodeTypeConfig
.
GetNodeTypeProtoFromDll
(
nodeName
);
object
newValue
=
null
;
if
(!
mCurBehaviorNode
.
args_dict
.
ContainsKey
(
desc
.
name
))
{
mCurBehaviorNode
.
args_dict
.
Add
(
desc
.
name
,
new
ValueBase
());
}
if
(
BehaviorTreeArgsDict
.
IsStringType
(
fieldType
))
{
if
(
nodeParamType
==
NodeParamType
.
Input
)
...
...
Unity/Assets/Res/BT/BT_大厅UI创建时执行行为树.prefab
浏览文件 @
5a625678
...
...
@@ -11,219 +11,253 @@ Prefab:
m_ParentPrefab
:
{
fileID
:
0
}
m_RootGameObject
:
{
fileID
:
1000012987241756
}
m_IsPrefabParent
:
1
---
!u!1
&100001
0648217578
---
!u!1
&100001
2663018806
GameObject
:
m_ObjectHideFlags
:
1
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4000012502268996
}
-
component
:
{
fileID
:
114000012927878958
}
-
component
:
{
fileID
:
114000012831209000
}
-
component
:
{
fileID
:
114000012254895660
}
-
component
:
{
fileID
:
4000012504621142
}
-
component
:
{
fileID
:
114000012710832806
}
-
component
:
{
fileID
:
114000010724577698
}
m_Layer
:
0
m_Name
:
UIScale
m_Name
:
UICreateRoot
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&1000012987241756
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4000013585351022
}
-
component
:
{
fileID
:
114000011653782440
}
m_Layer
:
0
m_Name
:
"
BT_
\u5927\u5385
UI
\u521B\u5EFA\u65F6\u6267\u884C\u884C\u4E3A\u6811
"
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&10
00011153220328
---
!u!1
&10
34247352937670
GameObject
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4
000010573939176
}
-
component
:
{
fileID
:
114
00001210149739
0
}
-
component
:
{
fileID
:
114
000012687440004
}
-
component
:
{
fileID
:
1140
00013925923264
}
-
component
:
{
fileID
:
4
457920297853128
}
-
component
:
{
fileID
:
114
87284447502703
0
}
-
component
:
{
fileID
:
114
110232272482830
}
-
component
:
{
fileID
:
1140
44811302282582
}
m_Layer
:
0
m_Name
:
CreateUIEffect
m_Name
:
UIScale
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&10
00012663018806
---
!u!1
&10
66642639074170
GameObject
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4000012504621142
}
-
component
:
{
fileID
:
114000012710832806
}
-
component
:
{
fileID
:
114000010724577698
}
-
component
:
{
fileID
:
4745976513105564
}
-
component
:
{
fileID
:
114317227427338956
}
m_Layer
:
0
m_Name
:
UICreateRoot
m_Name
:
Sequence
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&1
000012987241756
---
!u!1
&1
110138203716930
GameObject
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4000013585351022
}
-
component
:
{
fileID
:
114000011653782440
}
-
component
:
{
fileID
:
4560144792414304
}
-
component
:
{
fileID
:
114142340205944714
}
-
component
:
{
fileID
:
114725129530404376
}
-
component
:
{
fileID
:
114191766196617972
}
m_Layer
:
0
m_Name
:
"
BT_
\u5927\u5385
UI
\u521B\u5EFA\u65F6\u6267\u884C\u884C\u4E3A\u6811
"
m_Name
:
UIScale
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&1
163409429689796
---
!u!1
&1
267004197537310
GameObject
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4
777383378286486
}
-
component
:
{
fileID
:
114
089724657400710
}
-
component
:
{
fileID
:
4
435494203767800
}
-
component
:
{
fileID
:
114
890143310458668
}
m_Layer
:
0
m_Name
:
Se
lector
m_Name
:
Se
quence
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&1
859411246719846
---
!u!1
&1
358106256802118
GameObject
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4489196859550532
}
-
component
:
{
fileID
:
114749116948314830
}
-
component
:
{
fileID
:
4462160128095018
}
-
component
:
{
fileID
:
114014332988097306
}
-
component
:
{
fileID
:
114509115340170806
}
-
component
:
{
fileID
:
114530184371611064
}
m_Layer
:
0
m_Name
:
Selector
m_Name
:
CreateUIEffect
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&189
81998889563
78
---
!u!1
&189
50408747247
78
GameObject
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4203174777903220
}
-
component
:
{
fileID
:
114016773258390882
}
-
component
:
{
fileID
:
4490211137182780
}
-
component
:
{
fileID
:
114377559183498788
}
-
component
:
{
fileID
:
114803133420492300
}
-
component
:
{
fileID
:
114015794394339256
}
m_Layer
:
0
m_Name
:
Selector
m_Name
:
CreateUIEffect
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!4
&400001
0573939176
---
!u!4
&400001
2504621142
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
100001
1153220328
}
m_GameObject
:
{
fileID
:
100001
2663018806
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
4000012504621142
}
m_RootOrder
:
1
m_Children
:
-
{
fileID
:
4435494203767800
}
-
{
fileID
:
4745976513105564
}
m_Father
:
{
fileID
:
4000013585351022
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&400001
2502268996
---
!u!4
&400001
3585351022
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
100001
0648217578
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-
0
,
w
:
1
}
m_GameObject
:
{
fileID
:
100001
2987241756
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
4000012504621142
}
m_Children
:
-
{
fileID
:
4000012504621142
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&4
000012504621142
---
!u!4
&4
435494203767800
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1
000012663018806
}
m_GameObject
:
{
fileID
:
1
267004197537310
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
-
{
fileID
:
4000012502268996
}
-
{
fileID
:
4000010573939176
}
-
{
fileID
:
4777383378286486
}
m_Father
:
{
fileID
:
4000013585351022
}
-
{
fileID
:
4490211137182780
}
-
{
fileID
:
4560144792414304
}
m_Father
:
{
fileID
:
4000012504621142
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&4
000013585351022
---
!u!4
&4
457920297853128
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
10
00012987241756
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_GameObject
:
{
fileID
:
10
34247352937670
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
-
{
fileID
:
4000012504621142
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
m_Children
:
[]
m_Father
:
{
fileID
:
4745976513105564
}
m_RootOrder
:
1
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&4
203174777903220
---
!u!4
&4
462160128095018
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1
89819988895637
8
}
m_GameObject
:
{
fileID
:
1
35810625680211
8
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
47
77383378286486
}
m_RootOrder
:
1
m_Father
:
{
fileID
:
47
45976513105564
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&44
89196859550532
---
!u!4
&44
90211137182780
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
18
59411246719846
}
m_GameObject
:
{
fileID
:
18
95040874724778
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
4
777383378286486
}
m_Father
:
{
fileID
:
4
435494203767800
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&4777383378286486
---
!u!4
&4560144792414304
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1110138203716930
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
4435494203767800
}
m_RootOrder
:
1
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&4745976513105564
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1
163409429689796
}
m_GameObject
:
{
fileID
:
1
066642639074170
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
-
{
fileID
:
44
89196859550532
}
-
{
fileID
:
4
203174777903220
}
-
{
fileID
:
44
62160128095018
}
-
{
fileID
:
4
457920297853128
}
m_Father
:
{
fileID
:
4000012504621142
}
m_RootOrder
:
2
m_RootOrder
:
1
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!114
&114000010724577698
MonoBehaviour
:
...
...
@@ -250,25 +284,51 @@ MonoBehaviour:
m_Name
:
m_EditorClassIdentifier
:
RootNodeConfig
:
{
fileID
:
114000012710832806
}
---
!u!114
&114000012
101497390
---
!u!114
&114000012
710832806
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
100001
1153220328
}
m_GameObject
:
{
fileID
:
100001
2663018806
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d74453161f00b24287b1f1fb56b0778
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
id
:
100003
id
:
100001
describe
:
"
\u5927\u5385
UI
\u521B\u5EFA\u65F6\u6267\u884C\u884C\u4E3A\u6811
"
---
!u!114
&114014332988097306
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1358106256802118
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d74453161f00b24287b1f1fb56b0778
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
id
:
100006
describe
:
---
!u!114
&114000012254895660
---
!u!114
&114015794394339256
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1895040874724778
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
7be3fccf10005084b99360e730465802
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
fieldName
:
effect
fieldValue
:
{
fileID
:
1000013439777610
,
guid
:
ec75b784e8d7596478790f42fd4d9937
,
type
:
2
}
---
!u!114
&114044811302282582
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
10
00010648217578
}
m_GameObject
:
{
fileID
:
10
34247352937670
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
543f3ab39de095e4e80a0c5bbff4242e
,
type
:
3
}
...
...
@@ -276,12 +336,12 @@ MonoBehaviour:
m_EditorClassIdentifier
:
fieldName
:
scale
fieldValue
:
1
---
!u!114
&114
000012687440004
---
!u!114
&114
110232272482830
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
10
00011153220328
}
m_GameObject
:
{
fileID
:
10
34247352937670
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
872ab75cd8949824c994b1fb31d221f1
,
type
:
3
}
...
...
@@ -289,51 +349,77 @@ MonoBehaviour:
m_EditorClassIdentifier
:
fieldName
:
uiKey
fieldValue
:
UI
---
!u!114
&114
000012710832806
---
!u!114
&114
142340205944714
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1
000012663018806
}
m_GameObject
:
{
fileID
:
1
110138203716930
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d74453161f00b24287b1f1fb56b0778
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
id
:
10000
1
describe
:
"
\u5927\u5385
UI
\u521B\u5EFA\u65F6\u6267\u884C\u884C\u4E3A\u6811
"
---
!u!114
&114
000012831209000
id
:
10000
4
describe
:
---
!u!114
&114
191766196617972
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1
000010648217578
}
m_GameObject
:
{
fileID
:
1
110138203716930
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
872ab75cd8949824c994b1fb31d221f1
,
type
:
3
}
m_Script
:
{
fileID
:
11500000
,
guid
:
543f3ab39de095e4e80a0c5bbff4242e
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
fieldName
:
uiKey
fieldValue
:
UI
---
!u!114
&114
000012927878958
fieldName
:
scale
fieldValue
:
1
---
!u!114
&114
317227427338956
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
10
00010648217578
}
m_GameObject
:
{
fileID
:
10
66642639074170
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d74453161f00b24287b1f1fb56b0778
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
id
:
10000
2
id
:
10000
5
describe
:
---
!u!114
&114
000013925923264
---
!u!114
&114
377559183498788
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1000011153220328
}
m_GameObject
:
{
fileID
:
1895040874724778
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d74453161f00b24287b1f1fb56b0778
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
id
:
100003
describe
:
---
!u!114
&114509115340170806
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1358106256802118
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
872ab75cd8949824c994b1fb31d221f1
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
fieldName
:
uiKey
fieldValue
:
UI
---
!u!114
&114530184371611064
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1358106256802118
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
7be3fccf10005084b99360e730465802
,
type
:
3
}
...
...
@@ -341,42 +427,55 @@ MonoBehaviour:
m_EditorClassIdentifier
:
fieldName
:
effect
fieldValue
:
{
fileID
:
1000013439777610
,
guid
:
ec75b784e8d7596478790f42fd4d9937
,
type
:
2
}
---
!u!114
&114
016773258390882
---
!u!114
&114
725129530404376
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1
898199888956378
}
m_GameObject
:
{
fileID
:
1
110138203716930
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d74453161f00b24287b1f1fb56b0778
,
type
:
3
}
m_Script
:
{
fileID
:
11500000
,
guid
:
872ab75cd8949824c994b1fb31d221f1
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
id
:
100006
describe
:
---
!u!114
&114
08972465740071
0
fieldName
:
uiKey
fieldValue
:
UI
---
!u!114
&114
80313342049230
0
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1163409429689796
}
m_GameObject
:
{
fileID
:
1895040874724778
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
872ab75cd8949824c994b1fb31d221f1
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
fieldName
:
uiKey
fieldValue
:
UI
---
!u!114
&114872844475027030
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1034247352937670
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d74453161f00b24287b1f1fb56b0778
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
id
:
10000
4
id
:
10000
7
describe
:
---
!u!114
&114
749116948314830
---
!u!114
&114
890143310458668
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1
859411246719846
}
m_GameObject
:
{
fileID
:
1
267004197537310
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d74453161f00b24287b1f1fb56b0778
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
id
:
10000
5
id
:
10000
2
describe
:
Unity/Assets/Scripts/BehaviorTree/BehaviorNodeConfig.cs
浏览文件 @
5a625678
...
...
@@ -24,14 +24,14 @@ namespace Model
foreach
(
BTTypeBaseComponent
item
in
gameObject
.
GetComponents
<
BTTypeBaseComponent
>())
{
FieldInfo
info
=
item
.
GetType
().
GetField
(
"fieldValue"
);
ValueBase
valueBase
=
new
ValueBase
()
;
ValueBase
valueBase
;
if
(
item
.
GetType
()
==
typeof
(
BTEnumComponent
))
{
valueBase
.
SetValueByType
(
typeof
(
Enum
),
info
.
GetValue
(
item
));
valueBase
=
new
ValueBase
(
info
.
GetValue
(
item
));
}
else
{
valueBase
.
SetValueByType
(
info
.
FieldType
,
info
.
GetValue
(
item
));
valueBase
=
new
ValueBase
(
info
.
GetValue
(
item
));
}
dict
.
Add
(
item
.
fieldName
,
valueBase
);
...
...
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeArgsDict.cs
浏览文件 @
5a625678
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
Base
;
using
UnityEngine
;
...
...
@@ -6,105 +7,69 @@ using UnityEngine;
namespace
Model
{
[
Serializable
]
public
class
BehaviorTreeArgsDict
:
Dictionary
<
string
,
ValueBase
>
public
class
BehaviorTreeArgsDict
{
public
void
SetKeyValueComp
(
Type
type
,
string
fieldName
,
object
value
)
private
readonly
Dictionary
<
string
,
ValueBase
>
dict
=
new
Dictionary
<
string
,
ValueBase
>();
public
void
Add
(
string
key
,
ValueBase
value
)
{
if
(
IsStringType
(
type
))
{
SetStrValue
(
fieldName
,
(
string
)
value
);
}
else
if
(
IsObjectType
(
type
))
{
SetObjectValue
(
fieldName
,
type
,
(
UnityEngine
.
Object
)
value
);
}
else
if
(
IsIntType
(
type
))
{
int
intValue
=
0
;
int
.
TryParse
(
value
.
ToString
(),
out
intValue
);
SetIntValue
(
fieldName
,
intValue
);
}
else
if
(
IsLongType
(
type
))
{
long
longValue
=
0
;
long
.
TryParse
(
value
.
ToString
(),
out
longValue
);
SetLongValue
(
fieldName
,
longValue
);
}
else
if
(
IsFloatType
(
type
))
{
float
floatValue
=
0
;
float
.
TryParse
(
value
.
ToString
(),
out
floatValue
);
SetFloatValue
(
fieldName
,
floatValue
);
}
else
if
(
IsDoubleType
(
type
))
{
double
doubleValue
=
0
;
double
.
TryParse
(
value
.
ToString
(),
out
doubleValue
);
SetDoubleValue
(
fieldName
,
doubleValue
);
}
else
if
(
IsBoolType
(
type
))
{
bool
boolValue
=
false
;
bool
.
TryParse
(
value
.
ToString
(),
out
boolValue
);
SetBoolValue
(
fieldName
,
boolValue
);
}
else
if
(
IsStringArrType
(
type
))
{
SetStrArrValue
(
fieldName
,
(
string
[])
value
);
}
else
if
(
IsIntArrType
(
type
))
{
SetIntArrValue
(
fieldName
,
(
int
[])
value
);
}
else
if
(
IsLongArrType
(
type
))
{
SetLongArrValue
(
fieldName
,
(
long
[])
value
);
}
else
if
(
IsFloatArrType
(
type
))
{
SetFloatArrValue
(
fieldName
,
(
float
[])
value
);
}
else
if
(
IsDoubleArrType
(
type
))
{
SetDoubleArrValue
(
fieldName
,
(
double
[])
value
);
}
else
if
(
IsEnumType
(
type
))
{
SetEnumValue
(
fieldName
,
value
.
ToString
());
}
else
if
(
IsObjectArrayType
(
type
))
{
SetObjectArrayValue
(
fieldName
,
type
,
(
UnityEngine
.
Object
[])
value
);
}
else
this
.
dict
.
Add
(
key
,
value
);
}
public
void
Remove
(
string
key
)
{
this
.
dict
.
Remove
(
key
);
}
public
bool
ContainsKey
(
string
key
)
{
return
this
.
dict
.
ContainsKey
(
key
);
}
public
Dictionary
<
string
,
ValueBase
>
Dict
()
{
return
this
.
dict
;
}
public
BehaviorTreeArgsDict
Clone
()
{
BehaviorTreeArgsDict
behaviorTreeArgsDict
=
new
BehaviorTreeArgsDict
();
foreach
(
KeyValuePair
<
string
,
ValueBase
>
keyValuePair
in
this
.
dict
)
{
Log
.
Error
(
$"行为树节点暂时未支持此类型:
{
type
}
!"
);
behaviorTreeArgsDict
.
Add
(
keyValuePair
.
Key
,
keyValuePair
.
Value
.
Clone
()
);
}
return
behaviorTreeArgsDict
;
}
private
void
SetConvertebleValue
(
string
fieldName
,
float
value
)
public
void
SetKeyValueComp
(
Type
type
,
string
fieldName
,
object
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
try
{
this
[
fieldName
].
Convertivle
=
value
;
ValueBase
valueBase
;
if
(!
this
.
dict
.
TryGetValue
(
fieldName
,
out
valueBase
))
{
valueBase
=
new
ValueBase
();
this
.
dict
.
Add
(
fieldName
,
valueBase
);
}
valueBase
.
SetValue
(
value
);
}
else
catch
(
Exception
e
)
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
Convertivle
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
Log
.
Error
(
$"SetKeyValueComp error:
{
fieldName
}
{
e
}
"
);
}
}
public
object
GetTreeDictValue
(
Type
fieldType
,
string
fieldName
)
{
if
(!
this
.
ContainsKey
(
fieldName
))
if
(!
this
.
dict
.
ContainsKey
(
fieldName
))
{
Log
.
Error
(
$"fieldName:
{
fieldName
}
不存在!!!!"
);
return
null
;
}
ValueBase
obj
=
this
[
fieldName
];
return
obj
.
GetValue
ByType
(
fieldType
);
ValueBase
obj
=
this
.
dict
[
fieldName
];
return
obj
.
GetValue
(
);
}
/// <summary>
...
...
@@ -283,325 +248,6 @@ namespace Model
return
false
;
}
/// <summary>
/// Set Value
/// </summary>
/// <param nodeName="fieldName"></param>
/// <param nodeName="value"></param>
public
void
SetStrValue
(
string
fieldName
,
string
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
StringValue
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
StringValue
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetIntValue
(
string
fieldName
,
int
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
Int32Value
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
Int32Value
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetLongValue
(
string
fieldName
,
long
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
Int64Value
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
Int64Value
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetFloatValue
(
string
fieldName
,
float
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
SingleValue
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
SingleValue
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetDoubleValue
(
string
fieldName
,
double
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
DoubleValue
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
DoubleValue
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetBoolValue
(
string
fieldName
,
bool
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
BooleanValue
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
BooleanValue
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetStrArrValue
(
string
fieldName
,
string
[]
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
StringArray
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
StringArray
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetIntArrValue
(
string
fieldName
,
int
[]
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
Int32Array
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
Int32Array
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetLongArrValue
(
string
fieldName
,
long
[]
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
Int64Array
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
Int64Array
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetFloatArrValue
(
string
fieldName
,
float
[]
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
SingleArray
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
SingleArray
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetDoubleArrValue
(
string
fieldName
,
double
[]
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
DoubleArray
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
DoubleArray
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetObjectValue
(
string
fieldName
,
Type
type
,
UnityEngine
.
Object
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
]?.
SetValueByType
(
type
,
value
);
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
if
(
value
!=
null
)
{
valueBase
.
SetValueByType
(
type
,
value
);
}
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetEnumValue
(
string
fieldName
,
string
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
].
enumValue
=
value
;
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
valueBase
.
enumValue
=
value
;
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
void
SetObjectArrayValue
(
string
fieldName
,
Type
type
,
UnityEngine
.
Object
[]
value
)
{
if
(
this
.
ContainsKey
(
fieldName
))
{
this
[
fieldName
]?.
SetValueByType
(
type
,
value
);
}
else
{
ValueBase
valueBase
=
new
ValueBase
();
if
(
value
!=
null
)
{
valueBase
.
SetValueByType
(
type
,
value
);
}
this
.
Add
(
fieldName
,
valueBase
);
}
}
public
static
GameObject
[]
ConvertToGameObjectArray
(
UnityEngine
.
Object
[]
objectArray
)
{
if
(
objectArray
==
null
)
{
return
null
;
}
GameObject
[]
newObjectArray
=
new
GameObject
[
objectArray
.
Length
];
for
(
int
i
=
0
;
i
<
objectArray
.
Length
;
i
++)
{
newObjectArray
[
i
]
=
(
GameObject
)
objectArray
[
i
];
}
return
newObjectArray
;
}
public
static
Material
[]
ConvertToMaterialArray
(
UnityEngine
.
Object
[]
objectArray
)
{
if
(
objectArray
==
null
)
{
return
null
;
}
Material
[]
newObjectArray
=
new
Material
[
objectArray
.
Length
];
for
(
int
i
=
0
;
i
<
objectArray
.
Length
;
i
++)
{
newObjectArray
[
i
]
=
(
Material
)
objectArray
[
i
];
}
return
newObjectArray
;
}
public
static
Texture
[]
ConvertToTextureArray
(
UnityEngine
.
Object
[]
objectArray
)
{
if
(
objectArray
==
null
)
{
return
null
;
}
Texture
[]
newObjectArray
=
new
Texture
[
objectArray
.
Length
];
for
(
int
i
=
0
;
i
<
objectArray
.
Length
;
i
++)
{
newObjectArray
[
i
]
=
(
Texture
)
objectArray
[
i
];
}
return
newObjectArray
;
}
public
static
Texture2D
[]
ConvertToTexture2DArray
(
UnityEngine
.
Object
[]
objectArray
)
{
if
(
objectArray
==
null
)
{
return
null
;
}
Texture2D
[]
newObjectArray
=
new
Texture2D
[
objectArray
.
Length
];
for
(
int
i
=
0
;
i
<
objectArray
.
Length
;
i
++)
{
newObjectArray
[
i
]
=
(
Texture2D
)
objectArray
[
i
];
}
return
newObjectArray
;
}
public
static
Texture3D
[]
ConvertToTexture3DArray
(
UnityEngine
.
Object
[]
objectArray
)
{
if
(
objectArray
==
null
)
{
return
null
;
}
Texture3D
[]
newObjectArray
=
new
Texture3D
[
objectArray
.
Length
];
for
(
int
i
=
0
;
i
<
objectArray
.
Length
;
i
++)
{
newObjectArray
[
i
]
=
(
Texture3D
)
objectArray
[
i
];
}
return
newObjectArray
;
}
public
static
Shader
[]
ConvertToShaderArray
(
UnityEngine
.
Object
[]
objectArray
)
{
if
(
objectArray
==
null
)
{
return
null
;
}
Shader
[]
newObjectArray
=
new
Shader
[
objectArray
.
Length
];
for
(
int
i
=
0
;
i
<
objectArray
.
Length
;
i
++)
{
newObjectArray
[
i
]
=
(
Shader
)
objectArray
[
i
];
}
return
newObjectArray
;
}
public
static
AudioClip
[]
ConvertToAudioClipArray
(
UnityEngine
.
Object
[]
objectArray
)
{
if
(
objectArray
==
null
)
{
return
null
;
}
AudioClip
[]
newObjectArray
=
new
AudioClip
[
objectArray
.
Length
];
for
(
int
i
=
0
;
i
<
objectArray
.
Length
;
i
++)
{
newObjectArray
[
i
]
=
(
AudioClip
)
objectArray
[
i
];
}
return
newObjectArray
;
}
public
static
Sprite
[]
ConvertToSpriteArray
(
UnityEngine
.
Object
[]
objectArray
)
{
if
(
objectArray
==
null
)
{
return
null
;
}
Sprite
[]
newObjectArray
=
new
Sprite
[
objectArray
.
Length
];
for
(
int
i
=
0
;
i
<
objectArray
.
Length
;
i
++)
{
newObjectArray
[
i
]
=
(
Sprite
)
objectArray
[
i
];
}
return
newObjectArray
;
}
public
static
bool
SatisfyCondition
(
GameObject
go
,
Type
[]
constraintTypes
)
{
if
(
go
==
null
||
constraintTypes
==
null
||
constraintTypes
.
Length
<=
0
)
...
...
Unity/Assets/Scripts/BehaviorTree/NodeProto.cs
浏览文件 @
5a625678
...
...
@@ -10,7 +10,7 @@ namespace Model
public
string
describe
=
""
;
public
BehaviorTreeArgsDict
args_dict
=
new
BehaviorTreeArgsDict
()
;
public
BehaviorTreeArgsDict
args_dict
;
public
List
<
NodeProto
>
children
=
new
List
<
NodeProto
>();
...
...
@@ -25,5 +25,15 @@ namespace Model
this
.
children
=
value
;
}
}
public
NodeProto
()
{
this
.
args_dict
=
new
BehaviorTreeArgsDict
();
}
public
NodeProto
(
BehaviorTreeArgsDict
dict
)
{
this
.
args_dict
=
dict
;
}
}
}
\ No newline at end of file
Unity/Assets/Scripts/BehaviorTree/ValueBase.cs
浏览文件 @
5a625678
using
System
;
using
System.Reflection
;
using
UnityEngine
;
namespace
Model
{
[
Serializable
]
public
class
ValueBase
{
public
IConvertible
Convertivle
;
public
string
enumValue
;
public
string
StringValue
;
public
bool
BooleanValue
;
public
int
Int32Value
;
public
long
Int64Value
;
public
float
SingleValue
;
public
double
DoubleValue
;
public
int
[]
Int32Array
;
public
long
[]
Int64Array
;
public
string
[]
StringArray
;
public
float
[]
SingleArray
;
public
double
[]
DoubleArray
;
private
object
value
;
public
GameObject
GameObjectValue
;
public
AudioClip
AudioClipValue
;
public
Material
MaterialValue
;
public
Shader
ShaderValue
;
public
Texture
TextureValue
;
public
Texture2D
Texture2DValue
;
public
Texture3D
Texture3DValue
;
public
Sprite
SpriteValue
;
public
GameObject
[]
GameObjectArray
;
public
AudioClip
[]
AudioClipArray
;
public
Material
[]
MaterialArray
;
public
Shader
[]
ShaderArray
;
public
Texture
[]
TextureArray
;
public
Texture2D
[]
Texture2DArray
;
public
Texture3D
[]
Texture3DArray
;
public
Sprite
[]
SpriteArray
;
public
static
ValueBase
Clone
(
ValueBase
source
)
public
ValueBase
(
object
v
)
{
ValueBase
v
=
new
ValueBase
();
FieldInfo
[]
infos
=
source
.
GetType
().
GetFields
();
foreach
(
FieldInfo
info
in
infos
)
{
object
value
;
if
(
info
.
FieldType
.
IsSubclassOf
(
typeof
(
Array
)))
{
Array
sourceArray
=
(
Array
)
info
.
GetValue
(
source
);
if
(
sourceArray
==
null
)
{
continue
;
}
Array
dest
=
Array
.
CreateInstance
(
info
.
FieldType
.
GetElementType
(),
sourceArray
.
Length
);
Array
.
Copy
(
sourceArray
,
dest
,
dest
.
Length
);
value
=
dest
;
}
else
{
value
=
info
.
GetValue
(
source
);
}
info
.
SetValue
(
v
,
value
);
}
return
v
;
this
.
value
=
v
;
}
public
object
GetValueByType
(
Type
type
)
public
ValueBase
(
)
{
try
{
FieldInfo
fieldInfo
=
GetFieldInfo
(
type
);
if
(
BehaviorTreeArgsDict
.
IsEnumType
(
type
))
{
Enum
value
;
if
(
string
.
IsNullOrEmpty
(
enumValue
))
{
value
=
GetDefaultEnumValue
(
type
);
}
else
{
value
=
(
Enum
)
Enum
.
Parse
(
type
,
enumValue
);
}
return
value
;
}
if
(
BehaviorTreeArgsDict
.
IsStringType
(
type
))
{
if
(
string
.
IsNullOrEmpty
(
this
.
StringValue
))
{
this
.
StringValue
=
this
.
enumValue
;
return
this
.
StringValue
;
}
}
return
fieldInfo
.
GetValue
(
this
);
}
catch
(
Exception
err
)
{
throw
new
GameException
(
$"行为树报错:
{
err
}
"
);
}
}
p
rivate
Enum
GetDefaultEnumValue
(
Type
type
)
p
ublic
ValueBase
Clone
(
)
{
Array
array
=
Enum
.
GetValues
(
type
);
Enum
value
=
(
Enum
)
array
.
GetValue
(
0
);
return
value
;
}
public
void
SetValueByType
(
Type
type
,
object
value
)
{
if
(
type
==
null
)
{
return
;
}
FieldInfo
field
=
GetFieldInfo
(
type
);
if
(
BehaviorTreeArgsDict
.
IsMaterialArrayType
(
field
.
FieldType
))
{
field
.
SetValue
(
this
,
BehaviorTreeArgsDict
.
ConvertToMaterialArray
((
UnityEngine
.
Object
[])
value
));
}
else
if
(
BehaviorTreeArgsDict
.
IsGameObjectArrayType
(
field
.
FieldType
))
ValueBase
v
;
Type
vType
=
this
.
value
.
GetType
();
if
(
vType
.
IsSubclassOf
(
typeof
(
Array
)))
{
field
.
SetValue
(
this
,
BehaviorTreeArgsDict
.
ConvertToGameObjectArray
((
UnityEngine
.
Object
[])
value
));
}
else
if
(
BehaviorTreeArgsDict
.
IsTextureArrayType
(
field
.
FieldType
))
{
field
.
SetValue
(
this
,
BehaviorTreeArgsDict
.
ConvertToTextureArray
((
UnityEngine
.
Object
[])
value
));
}
else
if
(
BehaviorTreeArgsDict
.
IsTexture2DArrayType
(
field
.
FieldType
))
{
field
.
SetValue
(
this
,
BehaviorTreeArgsDict
.
ConvertToTexture2DArray
((
UnityEngine
.
Object
[])
value
));
}
else
if
(
BehaviorTreeArgsDict
.
IsTexture3DArrayType
(
field
.
FieldType
))
{
field
.
SetValue
(
this
,
BehaviorTreeArgsDict
.
ConvertToTexture3DArray
((
UnityEngine
.
Object
[])
value
));
}
else
if
(
BehaviorTreeArgsDict
.
IsShaderArrayType
(
field
.
FieldType
))
{
field
.
SetValue
(
this
,
BehaviorTreeArgsDict
.
ConvertToShaderArray
((
UnityEngine
.
Object
[])
value
));
}
else
if
(
BehaviorTreeArgsDict
.
IsAudioClipArrayType
(
field
.
FieldType
))
{
field
.
SetValue
(
this
,
BehaviorTreeArgsDict
.
ConvertToAudioClipArray
((
UnityEngine
.
Object
[])
value
));
}
else
if
(
BehaviorTreeArgsDict
.
IsSpriteArrayType
(
field
.
FieldType
))
{
field
.
SetValue
(
this
,
BehaviorTreeArgsDict
.
ConvertToSpriteArray
((
UnityEngine
.
Object
[])
value
));
Array
sourceArray
=
(
Array
)
this
.
value
;
Array
dest
=
Array
.
CreateInstance
(
vType
.
GetElementType
(),
sourceArray
.
Length
);
Array
.
Copy
(
sourceArray
,
dest
,
dest
.
Length
);
v
=
new
ValueBase
(
dest
);
}
else
{
field
.
SetValue
(
this
,
value
);
v
=
new
ValueBase
(
value
);
}
return
v
;
}
p
rivate
FieldInfo
GetFieldInfo
(
Type
type
)
p
ublic
object
GetValue
(
)
{
string
fieldName
;
if
(
BehaviorTreeArgsDict
.
IsEnumType
(
type
))
{
fieldName
=
"enumValue"
;
}
else
if
(
type
.
IsArray
)
{
fieldName
=
type
.
GetElementType
()
+
"Array"
;
}
else
{
fieldName
=
type
.
Name
+
"Value"
;
}
fieldName
=
RemovePrefix
(
fieldName
);
FieldInfo
fieldInfo
=
GetType
().
GetField
(
fieldName
);
return
fieldInfo
;
return
this
.
value
;
}
p
rivate
string
RemovePrefix
(
string
fieldName
)
p
ublic
void
SetValue
(
object
v
)
{
string
enginePrefix
=
"UnityEngine."
;
int
engineIndex
=
fieldName
.
IndexOf
(
enginePrefix
);
if
(
engineIndex
!=
-
1
)
{
fieldName
=
fieldName
.
Remove
(
engineIndex
,
enginePrefix
.
Length
);
}
string
systemPrefix
=
"System."
;
int
systemIndex
=
fieldName
.
IndexOf
(
systemPrefix
);
if
(
systemIndex
!=
-
1
)
{
fieldName
=
fieldName
.
Remove
(
systemIndex
,
systemPrefix
.
Length
);
}
return
fieldName
;
this
.
value
=
v
;
}
}
}
\ No newline at end of file
Unity/Assets/Scripts/Component/BehaviorTreeComponent.cs
浏览文件 @
5a625678
...
...
@@ -57,7 +57,7 @@ namespace Model
{
Type
type
=
Game
.
EntityEventManager
.
GetAssembly
(
"Model"
).
GetType
(
"Model."
+
nodeProto
.
name
);
foreach
(
var
args_item
in
nodeProto
.
args_dict
)
foreach
(
var
args_item
in
nodeProto
.
args_dict
.
Dict
()
)
{
FieldInfo
fieldInfo
=
type
.
GetField
(
args_item
.
Key
,
BindingFlags
.
Instance
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Public
);
if
(
fieldInfo
==
null
)
...
...
@@ -70,7 +70,7 @@ namespace Model
private
static
void
NewSetValue
(
ref
Node
node
,
FieldInfo
field
,
ValueBase
valueBase
,
string
nodeName
)
{
field
.
SetValue
(
node
,
valueBase
.
GetValue
ByType
(
field
.
FieldType
));
field
.
SetValue
(
node
,
valueBase
.
GetValue
(
));
}
private
Node
CreateOneNode
(
NodeProto
proto
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录