diff --git a/client/Assets/Game/Scripts/AI/AIBase.cs b/client/Assets/Game/Scripts/AI/AIObjectBase.cs similarity index 78% rename from client/Assets/Game/Scripts/AI/AIBase.cs rename to client/Assets/Game/Scripts/AI/AIObjectBase.cs index f87da2f..7da44d7 100644 --- a/client/Assets/Game/Scripts/AI/AIBase.cs +++ b/client/Assets/Game/Scripts/AI/AIObjectBase.cs @@ -12,15 +12,13 @@ namespace Game { BehaviorTree Tree(); void Create(); - void Reset(GameEntity entity); void Tick(); } public partial class AIObjectBase : IAIObject where T : new() { - private GameEntity _entity; - private BehaviorTreeBuilder _builder; - private BehaviorTree _tree; + protected BehaviorTreeBuilder _builder; + protected BehaviorTree _tree; public static EventCallbackCreate GetCreator() { @@ -34,11 +32,6 @@ namespace Game _tree = _builder.Build(); } - public void Reset(GameEntity entity) - { - _entity = entity; - } - protected virtual void OnCreate() { } diff --git a/client/Assets/Game/Scripts/AI/AIBase.cs.meta b/client/Assets/Game/Scripts/AI/AIObjectBase.cs.meta similarity index 100% rename from client/Assets/Game/Scripts/AI/AIBase.cs.meta rename to client/Assets/Game/Scripts/AI/AIObjectBase.cs.meta diff --git a/client/Assets/Game/Scripts/AI/_Common/CommonWrapper.cs b/client/Assets/Game/Scripts/AI/AIObjectBaseWrapper.cs similarity index 92% rename from client/Assets/Game/Scripts/AI/_Common/CommonWrapper.cs rename to client/Assets/Game/Scripts/AI/AIObjectBaseWrapper.cs index be8cbd1..26fa141 100644 --- a/client/Assets/Game/Scripts/AI/_Common/CommonWrapper.cs +++ b/client/Assets/Game/Scripts/AI/AIObjectBaseWrapper.cs @@ -14,7 +14,7 @@ namespace Game protected void Selector(Action action) { - Selector("selector",action); + Selector("selector", action); } protected void Selector(string name, Action action) @@ -23,9 +23,10 @@ namespace Game action(); _builder.End(); } + protected void Sequence(Action action) { - Sequence("sequence",action); + Sequence("sequence", action); } protected void Sequence(string name, Action action) diff --git a/client/Assets/Game/Scripts/AI/_Common/CommonWrapper.cs.meta b/client/Assets/Game/Scripts/AI/AIObjectBaseWrapper.cs.meta similarity index 100% rename from client/Assets/Game/Scripts/AI/_Common/CommonWrapper.cs.meta rename to client/Assets/Game/Scripts/AI/AIObjectBaseWrapper.cs.meta diff --git a/client/Assets/Game/Scripts/AI/BehaviorTreePoolManager.cs b/client/Assets/Game/Scripts/AI/BehaviorTreePoolManager.cs index de5c4a1..7614616 100644 --- a/client/Assets/Game/Scripts/AI/BehaviorTreePoolManager.cs +++ b/client/Assets/Game/Scripts/AI/BehaviorTreePoolManager.cs @@ -19,15 +19,15 @@ namespace Game if (!interfaceType.IsAssignableFrom(type)) continue; if (type.IsGenericType) continue; if (type.IsInterface) continue; - if (type.BaseType == null) continue; - var method = type.BaseType.GetMethod("GetCreator", BindingFlags.Static | BindingFlags.Public); + if (type.BaseType?.BaseType == null) continue; + var method = type.BaseType.BaseType.GetMethod("GetCreator", BindingFlags.Static | BindingFlags.Public); if (method == null) continue; var creator = (EventCallbackCreate)method.Invoke(null, new object[] { }); _dict.Add(type.Name, creator); } } - public BehaviorTreePoolItem Create(GameEntity entity, string name) + public BehaviorTreePoolItem CreateAIEntity(GameEntity entity, string name) { if (!_dict.ContainsKey(name)) { @@ -40,7 +40,7 @@ namespace Game item.AIObject = _dict[name](); item.AIObject.Create(); }); - ret.AIObject.Reset(entity); + ((IAIEntity)ret.AIObject).Reset(entity); return ret; } } diff --git a/client/Assets/Game/Scripts/AI/Director.meta b/client/Assets/Game/Scripts/AI/Director.meta new file mode 100644 index 0000000..b746179 --- /dev/null +++ b/client/Assets/Game/Scripts/AI/Director.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 74d9b9671dc9421b9034b1cc8da51c53 +timeCreated: 1685467902 \ No newline at end of file diff --git a/client/Assets/Game/Scripts/AI/Entity.meta b/client/Assets/Game/Scripts/AI/Entity.meta new file mode 100644 index 0000000..f0132df --- /dev/null +++ b/client/Assets/Game/Scripts/AI/Entity.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 837ddc9b1e71476586fae46b0718215c +timeCreated: 1685467862 \ No newline at end of file diff --git a/client/Assets/Game/Scripts/AI/Entity/AIEntityBase.cs b/client/Assets/Game/Scripts/AI/Entity/AIEntityBase.cs new file mode 100644 index 0000000..5decf06 --- /dev/null +++ b/client/Assets/Game/Scripts/AI/Entity/AIEntityBase.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using CleverCrow.Fluid.BTs.Trees; +using UnityEngine; +using UnityEngine.Timeline; + +namespace Game +{ + public interface IAIEntity + { + void Reset(GameEntity entity); + } + + public partial class AIEntityBase : AIObjectBase, IAIEntity where T : new() + { + private GameEntity _entity; + + public void Reset(GameEntity entity) + { + _entity = entity; + } + } +} \ No newline at end of file diff --git a/client/Assets/Game/Scripts/AI/Entity/AIEntityBase.cs.meta b/client/Assets/Game/Scripts/AI/Entity/AIEntityBase.cs.meta new file mode 100644 index 0000000..dec7b3c --- /dev/null +++ b/client/Assets/Game/Scripts/AI/Entity/AIEntityBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 552291c8ded048dc9addebeba764a4df +timeCreated: 1685468018 \ No newline at end of file diff --git a/client/Assets/Game/Scripts/AI/Boss.meta b/client/Assets/Game/Scripts/AI/Entity/Boss.meta similarity index 100% rename from client/Assets/Game/Scripts/AI/Boss.meta rename to client/Assets/Game/Scripts/AI/Entity/Boss.meta diff --git a/client/Assets/Game/Scripts/AI/Monster.meta b/client/Assets/Game/Scripts/AI/Entity/Monster.meta similarity index 100% rename from client/Assets/Game/Scripts/AI/Monster.meta rename to client/Assets/Game/Scripts/AI/Entity/Monster.meta diff --git a/client/Assets/Game/Scripts/AI/Monster/AIMonster01.cs b/client/Assets/Game/Scripts/AI/Entity/Monster/AIMonster01.cs similarity index 96% rename from client/Assets/Game/Scripts/AI/Monster/AIMonster01.cs rename to client/Assets/Game/Scripts/AI/Entity/Monster/AIMonster01.cs index 7c1211d..635691d 100644 --- a/client/Assets/Game/Scripts/AI/Monster/AIMonster01.cs +++ b/client/Assets/Game/Scripts/AI/Entity/Monster/AIMonster01.cs @@ -1,11 +1,12 @@ namespace Game { - public class AIMonster01 : AIObjectBase + public class AIMonster01 : AIEntityBase { protected override void OnCreate() { Sequence(() => { + CheckStagger(); FindTarget(); Selector(() => { diff --git a/client/Assets/Game/Scripts/AI/Monster/AIMonster01.cs.meta b/client/Assets/Game/Scripts/AI/Entity/Monster/AIMonster01.cs.meta similarity index 100% rename from client/Assets/Game/Scripts/AI/Monster/AIMonster01.cs.meta rename to client/Assets/Game/Scripts/AI/Entity/Monster/AIMonster01.cs.meta diff --git a/client/Assets/Game/Scripts/AI/_Common.meta b/client/Assets/Game/Scripts/AI/Entity/_Common.meta similarity index 100% rename from client/Assets/Game/Scripts/AI/_Common.meta rename to client/Assets/Game/Scripts/AI/Entity/_Common.meta diff --git a/client/Assets/Game/Scripts/AI/_Common/Common.cs b/client/Assets/Game/Scripts/AI/Entity/_Common/Common.cs similarity index 90% rename from client/Assets/Game/Scripts/AI/_Common/Common.cs rename to client/Assets/Game/Scripts/AI/Entity/_Common/Common.cs index 2dd364d..e68a340 100644 --- a/client/Assets/Game/Scripts/AI/_Common/Common.cs +++ b/client/Assets/Game/Scripts/AI/Entity/_Common/Common.cs @@ -1,6 +1,6 @@ namespace Game { - public partial class AIObjectBase where T : new() + public partial class AIEntityBase : AIObjectBase where T : new() { protected void FindTarget() { @@ -16,6 +16,11 @@ }); } + protected void CheckStagger() + { + Condition($"检查硬直状态", () => !Util.EntityIsStagger(_entity)); + } + protected void CheckModuleType(EAIModuleType moduleType) { Condition($"检查模块类型-{moduleType}", () => _entity.aI.ModuleType.Value == moduleType); diff --git a/client/Assets/Game/Scripts/AI/_Common/Common.cs.meta b/client/Assets/Game/Scripts/AI/Entity/_Common/Common.cs.meta similarity index 100% rename from client/Assets/Game/Scripts/AI/_Common/Common.cs.meta rename to client/Assets/Game/Scripts/AI/Entity/_Common/Common.cs.meta diff --git a/client/Assets/Game/Scripts/AI/_Common/CommonMove.cs b/client/Assets/Game/Scripts/AI/Entity/_Common/CommonMove.cs similarity index 93% rename from client/Assets/Game/Scripts/AI/_Common/CommonMove.cs rename to client/Assets/Game/Scripts/AI/Entity/_Common/CommonMove.cs index 34a9748..cfbe0bf 100644 --- a/client/Assets/Game/Scripts/AI/_Common/CommonMove.cs +++ b/client/Assets/Game/Scripts/AI/Entity/_Common/CommonMove.cs @@ -1,6 +1,6 @@ namespace Game { - public partial class AIObjectBase where T : new() + public partial class AIEntityBase : AIObjectBase where T : new() { protected void MoveTo() { diff --git a/client/Assets/Game/Scripts/AI/_Common/CommonMove.cs.meta b/client/Assets/Game/Scripts/AI/Entity/_Common/CommonMove.cs.meta similarity index 100% rename from client/Assets/Game/Scripts/AI/_Common/CommonMove.cs.meta rename to client/Assets/Game/Scripts/AI/Entity/_Common/CommonMove.cs.meta diff --git a/client/Assets/Game/Scripts/Blueprint/BlueprintPoolManager.cs b/client/Assets/Game/Scripts/Blueprint/BlueprintPoolManager.cs index 4937e3c..3debf39 100644 --- a/client/Assets/Game/Scripts/Blueprint/BlueprintPoolManager.cs +++ b/client/Assets/Game/Scripts/Blueprint/BlueprintPoolManager.cs @@ -82,10 +82,6 @@ namespace Game public abstract partial class Util { - public static void RunBp(string name, string trigger, BlueprintBasicData data) - { - BlueprintPoolManager.Instance.Run(name, trigger, data); - } public static void RunBp(string name, string trigger) { BlueprintPoolManager.Instance.Run(name, trigger, null); diff --git a/client/Assets/Game/Scripts/ECS/System/AISystem.cs b/client/Assets/Game/Scripts/ECS/System/AISystem.cs index c0a7db7..0e08c8b 100644 --- a/client/Assets/Game/Scripts/ECS/System/AISystem.cs +++ b/client/Assets/Game/Scripts/ECS/System/AISystem.cs @@ -1,13 +1,16 @@ using Entitas; using UnityEngine; using Game; + public class AISystem : IExecuteSystem, IInitializeSystem { private IGroup _entities; + public void Initialize() { _entities = Util.GetGroup(GameMatcher.AI); } + public void Execute() { foreach (var entity in _entities) @@ -25,14 +28,17 @@ public class AISystem : IExecuteSystem, IInitializeSystem { return; } + if (ai.IsHungryFull.Value) { return; } + if (ai.AttackPermit.Value) { return; } + var newHungry = ai.Hungry.Value + ai.HungryIncrease * ai.HungryIncreaseRate * Time.deltaTime; ai.Hungry.Value = Mathf.Min(ai.HungryMax.Value, newHungry); if (ai.Hungry.Value >= ai.HungryMax.Value) @@ -53,25 +59,23 @@ public class AISystem : IExecuteSystem, IInitializeSystem { return; } + if (!ai.IsInit) { ai.IsInit = true; } + ai.ThinkCdNow -= Time.deltaTime; if (ai.ThinkCdNow > 0) { return; } + ai.ThinkCdNow = ai.ThinkCdMax; - if (Util.EntityIsStagger(entity)) - { - return; - } if (skill.IsRunning) { return; } ai.BehaviorTree.Tick(); } - } \ No newline at end of file diff --git a/client/Assets/Game/Scripts/ECS/Util/UtilEntity.cs b/client/Assets/Game/Scripts/ECS/Util/UtilEntity.cs index 3264d98..7c16101 100644 --- a/client/Assets/Game/Scripts/ECS/Util/UtilEntity.cs +++ b/client/Assets/Game/Scripts/ECS/Util/UtilEntity.cs @@ -336,7 +336,7 @@ namespace Game { var ai = entity.aI; var view = entity.view; - ai.BehaviorTree = BehaviorTreePoolManager.Instance.Create(entity, cfg.AIRes); + ai.BehaviorTree = BehaviorTreePoolManager.Instance.CreateAIEntity(entity, cfg.AIRes); var go = view.GameObject; var goMonsterInfo = go.GetComponent(); if (goMonsterInfo == null) diff --git a/client/Assets/Game/Scripts/Level/LevelPoolItem.cs b/client/Assets/Game/Scripts/Level/LevelPoolItem.cs index 5ffe70e..6f7be89 100644 --- a/client/Assets/Game/Scripts/Level/LevelPoolItem.cs +++ b/client/Assets/Game/Scripts/Level/LevelPoolItem.cs @@ -172,6 +172,8 @@ public class LevelPoolItem : ObjectPoolItemBase } }); } + + NextWave(); } @@ -200,21 +202,16 @@ public class LevelPoolItem : ObjectPoolItemBase { foreach (var item in _levelData) { - if (item is LevelNodeMonsterWave) + if (!(item is LevelNodeMonsterWave itemLevelNodeMonsterWave)) continue; + if (itemLevelNodeMonsterWave.GetWaveIndex() != _waveNow) continue; + foreach (var monster in itemLevelNodeMonsterWave.GetMonsters()) { - var itemLevelNodeMonsterWave = item as LevelNodeMonsterWave; - if (itemLevelNodeMonsterWave.GetWaveIndex() == _waveNow) - { - foreach (var monster in itemLevelNodeMonsterWave.GetMonsters()) - { - Util.CreateEntity(monster.GetCfgId(), (entity) => { entity.SetPos(monster.GetPos()); }); - } - - isOk = true; - CurWave = itemLevelNodeMonsterWave; - break; - } + Util.CreateEntity(monster.GetCfgId(), (entity) => { entity.SetPos(monster.GetPos()); }); } + + isOk = true; + CurWave = itemLevelNodeMonsterWave; + break; } if (isOk) diff --git a/config/Partitions/'Entities'-TypedPartition(65471dbc-8598-4c8f-b7d5-a524fe2e9dd6).adpd b/config/Partitions/'Entities'-TypedPartition(65471dbc-8598-4c8f-b7d5-a524fe2e9dd6).adpd index 791709a..b95026e 100644 Binary files a/config/Partitions/'Entities'-TypedPartition(65471dbc-8598-4c8f-b7d5-a524fe2e9dd6).adpd and b/config/Partitions/'Entities'-TypedPartition(65471dbc-8598-4c8f-b7d5-a524fe2e9dd6).adpd differ diff --git a/config/Partitions/'Template_Design'-TypedPartition(a9484374-acae-4f33-9aec-67cd28df7e81).adpd b/config/Partitions/'Template_Design'-TypedPartition(a9484374-acae-4f33-9aec-67cd28df7e81).adpd index 15b4bd6..487be43 100644 Binary files a/config/Partitions/'Template_Design'-TypedPartition(a9484374-acae-4f33-9aec-67cd28df7e81).adpd and b/config/Partitions/'Template_Design'-TypedPartition(a9484374-acae-4f33-9aec-67cd28df7e81).adpd differ diff --git a/config/Sessions/SessionData_LocalUser.adpd b/config/Sessions/SessionData_LocalUser.adpd index 37ff2fc..de41e17 100644 Binary files a/config/Sessions/SessionData_LocalUser.adpd and b/config/Sessions/SessionData_LocalUser.adpd differ