临时提交尝试将状态机xml改成Json

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-11-13 19:47:48 +08:00
parent de8b204ebd
commit ae81ee6c84
316 changed files with 13752 additions and 35589 deletions

View File

@@ -0,0 +1,72 @@
using System;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Dialog Example
/// Multiple event calls to modify the contents of a dialog box are not recommended,
/// Usually, I will choose to conduct actual dialogue development in combination with some kind of configuration table system,
/// But doing so here can make users learn BehaviorTreeSystem more simply and clearly
/// <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĶԻ<C4B6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ֵ<EFBFBD><D6B5><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><C2A3>һ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>ʵ<EFBFBD>ʶԻ<CAB6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ѧϰ<D1A7><CFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򵥺<EFBFBD><F2B5A5BA><EFBFBD><EFBFBD><EFBFBD>
///
/// The behavior tree can quickly build a dialogue system and speed up the development of the plot system
/// <20><>Ϊ<EFBFBD><CEAA><EFBFBD>ܿ<EFBFBD><DCBF>ٵĹ<D9B5><C4B9><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ի<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>Ŀ<EFBFBD><C4BF><EFBFBD>
/// </summary>
public class Example2 : MonoBehaviour
{
[SerializeField]
Transform m_grid;
[SerializeField]
BehaviorTreeSlayer.BehaviorTree behaviorTree;
[SerializeField]
Texture2D[] icons;
[SerializeField]
Text label;
[SerializeField]
RawImage portrait;
private void Start()
{
behaviorTree.Regist("SetIcon", SetIcon);
behaviorTree.Regist("SetText", SetText);
behaviorTree.Regist("SetBtns", SetBtns);
}
private void SetBtns(object obj)
{
int count = (int)obj;
for (int i = 0; i < count; i++)
{
m_grid.GetChild(i).gameObject.SetActive(true);
}
for (int i = count; i < m_grid.childCount; i++)
{
m_grid.GetChild(i).gameObject.SetActive(false);
}
}
private void OnDestroy()
{
behaviorTree.UnRegist("SetIcon");
behaviorTree.UnRegist("SetText");
behaviorTree.UnRegist("SetBtns");
}
private void SetText(object obj)
{
//Please notice that sometimes, \n maybe auto translate to \\n
label.text = obj.ToString().Replace("\\n", "\n");
}
private void SetIcon(object obj)
{
int idx = (int)obj;
portrait.texture = icons[idx % icons.Length];
}
public void OnClick(int x)
{
behaviorTree["index"] = x;
behaviorTree.Dispatch("EvtIndex", behaviorTree);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6039b831965f5c649b7be5a9be67cd79
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,65 @@
using JNGame.Math;
namespace BehaviorTreeSlayer
{
public class IndexSelector : CompositeNode
{
bool isDone = false;
public override void Enter(object args)
{
(args as BehaviorTree).Regist("EvtIndex", OnEvent);
Index = 0;
}
private void OnEvent(object args)
{
isDone = true;
BehaviorTree tree = args as BehaviorTree;
Index = (int)tree["index"] % childs.Count;//must set Index value before this
}
private TreeNode last;
public override void Add(TreeNode component)
{
base.Add(component);
Index = 0;
state = TaskResult.None;
last = null;
}
public override void Exit(object args)
{
(args as BehaviorTree).UnRegist("EvtIndex");
isDone = false;
Index = 0;
}
public override TaskResult Tick(LFloat dt, object args = null)
{
if (!isDone)
{
return TaskResult.Running;
}
childs.Sort((a, b) => a.x < b.x ? -1 : 1);
TreeNode curNode = childs[Index];
if (last != curNode)
{
curNode.Enter(args);
}
TaskResult rst = curNode.Tick(dt, args);
curNode.state = rst;
last = curNode;
if (rst == TaskResult.Running)
{
return TaskResult.Running;
}
else
{
//isDone = false;
state = TaskResult.None;
curNode.Exit(args);
return TaskResult.OK;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1e2825dce8ea20341b04a88a41ae5ac1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using JNGame.Math;
namespace BehaviorTreeSlayer
{
public class SetContent : ActionNode
{
[OutField]
public int IconIdx;
[OutField]
public string Content;
[OutField]
public int BtnCount;
public override TaskResult Tick(LFloat dt, object args = null)
{
BehaviorTree behaviorTree = args as BehaviorTree;
behaviorTree.Dispatch("SetText", Content);
behaviorTree.Dispatch("SetIcon", IconIdx);
behaviorTree.Dispatch("SetBtns", BtnCount);
return TaskResult.OK;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c5bf7346637c99d4b8d7fcff9f4f804f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: eaec2f927b3386f41aad528fc322bf7a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: d2678e983684146a39528107190a74a7
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: 2
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 0d7cbde5ee1c841ceb33d915c12b3a2e
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: 2
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 0ba2b2a9fb8244834aab80b28cfec808
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: 2
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 1867c4c47d95444eca16c7becda769ba
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: 2
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,80 @@
<?xml version="1.0"?>
<Entry xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<x>3980</x>
<y>2100</y>
<childs>
<TreeNode xsi:type="Repeat">
<x>3920</x>
<y>2300</y>
<childs>
<TreeNode xsi:type="Sequence">
<x>3760</x>
<y>2460</y>
<childs>
<TreeNode xsi:type="SetContent">
<x>3660</x>
<y>2640</y>
<IconIdx>0</IconIdx>
<Content>Lily \n Greeting my lord~</Content>
<BtnCount>2</BtnCount>
</TreeNode>
<TreeNode xsi:type="IndexSelector">
<x>3820</x>
<y>2640</y>
<childs>
<TreeNode xsi:type="Sequence">
<x>3680</x>
<y>2860</y>
<childs>
<TreeNode xsi:type="SetContent">
<x>3620</x>
<y>3040</y>
<IconIdx>1</IconIdx>
<Content>Joe\n Hi</Content>
<BtnCount>1</BtnCount>
</TreeNode>
<TreeNode xsi:type="IndexSelector">
<x>3740</x>
<y>3040</y>
<childs>
<TreeNode xsi:type="Log">
<x>3740</x>
<y>3180</y>
<Text>taopc</Text>
</TreeNode>
</childs>
</TreeNode>
</childs>
</TreeNode>
<TreeNode xsi:type="Sequence">
<x>3900</x>
<y>2840</y>
<childs>
<TreeNode xsi:type="SetContent">
<x>3900</x>
<y>3040</y>
<IconIdx>2</IconIdx>
<Content>Jim\n Welcome</Content>
<BtnCount>1</BtnCount>
</TreeNode>
<TreeNode xsi:type="IndexSelector">
<x>4020</x>
<y>3040</y>
<childs>
<TreeNode xsi:type="Log">
<x>4020</x>
<y>3200</y>
<Text>taopc</Text>
</TreeNode>
</childs>
</TreeNode>
</childs>
</TreeNode>
</childs>
</TreeNode>
</childs>
</TreeNode>
</childs>
</TreeNode>
</childs>
</Entry>

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 11669c657e7b2574e85e490c71ae4152
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: