diff --git a/DungeonShooting_Godot/prefab/role/Enemy0002.tscn b/DungeonShooting_Godot/prefab/role/Enemy0002.tscn index 241a249..77eae57 100644 --- a/DungeonShooting_Godot/prefab/role/Enemy0002.tscn +++ b/DungeonShooting_Godot/prefab/role/Enemy0002.tscn @@ -86,6 +86,7 @@ [node name="Enemy0002" node_paths=PackedStringArray("ViewRay", "NavigationAgent2D", "NavigationPoint", "FirePoint", "HurtArea", "HurtCollision", "InteractiveArea", "InteractiveCollision", "TipRoot", "TipSprite", "AnimationPlayer", "MountPoint", "BackMountPoint", "MeleeAttackArea", "MeleeAttackCollision", "ShadowSprite", "AnimatedSprite", "Collision") instance=ExtResource("1_fanet")] script = ExtResource("2_3an4s") +CanPickUpWeapon = false ViewRay = NodePath("ViewRay") NavigationAgent2D = NodePath("NavigationPoint/NavigationAgent2D") NavigationPoint = NodePath("NavigationPoint") diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/Preinstall.json index 24320a8..1579f73 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/Preinstall.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/Preinstall.json @@ -1 +1 @@ -[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":0,"Y":0},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":-14,"Y":-16},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":100,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":22,"Y":-24},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"7","ResidueAmmo":"70"},"Altitude":8,"VerticalSpeed":0}]}],[{"Position":{"X":-66,"Y":45},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":-66,"Y":45},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0.8,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]}]]}] \ No newline at end of file +[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":-84,"Y":-46},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":-85,"Y":-71},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":100,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-56,"Y":-72},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"7","ResidueAmmo":"70"},"Altitude":8,"VerticalSpeed":0}]}],[{"Position":{"X":30,"Y":75},"Size":{"X":29,"Y":28},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]},{"Position":{"X":-88,"Y":70},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0.8,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":65,"Y":-66},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0002","CurrAmmon":"7","ResidueAmmo":"7"},"Altitude":0,"VerticalSpeed":0}]}]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/Preview.png b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/Preview.png index ef0a8a1..2215059 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/Preview.png +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/Preview.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/RoomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/RoomInfo.json index b98bd6e..a5d10e3 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/RoomInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/RoomInfo.json @@ -1 +1 @@ -{"Position":{"X":-8,"Y":-7},"Size":{"X":15,"Y":14},"DoorAreaInfos":[],"GroupName":"TestGroup1","RoomType":1,"RoomName":"Start3","Weight":100,"Remark":""} \ No newline at end of file +{"Position":{"X":-8,"Y":-7},"Size":{"X":15,"Y":14},"DoorAreaInfos":[{"Direction":1,"Start":0,"End":96},{"Direction":2,"Start":0,"End":208},{"Direction":0,"Start":0,"End":192},{"Direction":3,"Start":0,"End":208}],"GroupName":"TestGroup1","RoomType":1,"RoomName":"Start3","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/TileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/TileInfo.json index ea81c00..53a6fcc 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/TileInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start3/TileInfo.json @@ -1 +1 @@ -{"NavigationList":[{"Type":0,"Points":[-104,-88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,1,0,2,7,1,-7,0,2,7,1,1,0,2,7,2,-7,0,2,7,2,1,0,2,7,3,-7,0,2,7,3,1,0,3,7,4,-7,0,2,7,5,-7,0,2,7],"Top":[-8,-7,0,3,4,-8,-6,0,3,3,-8,-5,0,3,3,-8,-4,0,3,3,-8,-3,0,3,3,-8,-2,0,3,3,-8,-1,0,3,3,-8,0,0,11,2,-8,1,0,3,4,-8,2,0,3,3,-8,3,0,3,3,-8,4,0,3,3,-8,5,0,3,3,-8,6,0,11,2,-7,0,0,2,2,-7,6,0,2,2,-6,0,0,2,2,-6,6,0,2,2,-5,0,0,2,2,-5,6,0,2,2,-4,0,0,2,2,-4,6,0,2,2,-3,0,0,2,2,-3,6,0,2,2,-2,0,0,2,2,-2,6,0,2,2,-1,0,0,2,2,-1,6,0,2,2,0,0,0,2,2,0,6,0,2,2,1,0,0,2,2,1,6,0,2,2,2,0,0,2,2,2,6,0,2,2,3,0,0,3,2,3,6,0,2,2,4,6,0,2,2,5,6,0,2,2,6,-7,0,1,4,6,-6,0,1,3,6,-5,0,1,3,6,-4,0,1,3,6,-3,0,1,3,6,-2,0,1,3,6,-1,0,1,3,6,0,0,1,3,6,1,0,1,3,6,2,0,1,3,6,3,0,1,3,6,4,0,1,3,6,5,0,1,3,6,6,0,13,2]} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiFindAmmoState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiFindAmmoState.cs index 682aae1..108652c 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiFindAmmoState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiFindAmmoState.cs @@ -15,9 +15,12 @@ //导航目标点刷新计时器 private float _navigationUpdateTimer = 0; private float _navigationInterval = 1f; - - private bool _isInTailAfterRange = false; + private float _tailAfterTimer = 0; + private ActivityObject _attackTarget; + + private float _idleTimer = 0; + private bool _playAnimFlag = false; public AiFindAmmoState() : base(AIStateEnum.AiFindAmmo) { @@ -25,33 +28,65 @@ public override void Enter(AIStateEnum prev, params object[] args) { - if (Master.LookTarget == null) - { - throw new Exception("进入 AIAdvancedStateEnum.AiFindAmmo 状态时角色没有攻击目标!"); - } - if (args.Length == 0) { throw new Exception("进入 AiStateEnum.AiFindAmmo 状态必须要把目标武器当成参数传过来"); } + if (args.Length >= 2) + { + _attackTarget = (ActivityObject)args[1]; + } + else + { + _attackTarget = null; + } + SetTargetWeapon((Weapon)args[0]); - _navigationUpdateTimer = 0; - _isInTailAfterRange = false; + _navigationUpdateTimer = _navigationInterval; _tailAfterTimer = 0; //标记武器 _target.SetSign(SignNames.AiFindWeaponSign, Master); + + _playAnimFlag = prev == AIStateEnum.AiLeaveFor; + if (_playAnimFlag) + { + Master.AnimationPlayer.Play(AnimatorNames.Query); + } } public override void Process(float delta) { + if (_playAnimFlag && _idleTimer > 0) + { + _idleTimer -= delta; + return; + } + if (!Master.IsAllWeaponTotalAmmoEmpty()) //已经有弹药了 { - ChangeState(GetNextState()); + RunNextState(); return; } + if (Master.LookTarget == null) //没有目标 + { + //临时处理 + var player = Player.Current; + var playerPos = player.GetCenterPosition(); + if (Master.IsInViewRange(playerPos) && !Master.TestViewRayCast(playerPos)) //发现玩家 + { + //关闭射线检测 + Master.TestViewRayCastOver(); + //发现玩家 + Master.LookTarget = player; + //进入惊讶状态, 然后再进入通知状态 + ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiFindAmmo, _target); + return; + } + } + //更新目标位置 if (_navigationUpdateTimer <= 0) { @@ -72,12 +107,12 @@ if (_target == null) //也没有其他可用的武器了 { - ChangeState(GetNextState()); + RunNextState(); } } else if (_target.Master == Master) //已经被自己拾起 { - ChangeState(GetNextState()); + RunNextState(); } else if (_target.Master != null) //武器已经被其他角色拾起! { @@ -86,20 +121,23 @@ if (_target == null) //也没有其他可用的武器了 { - ChangeState(GetNextState()); + RunNextState(); } } else { - //检测目标没有超出跟随视野距离 - _isInTailAfterRange = Master.IsInTailAfterViewRange(Master.LookTarget.GetCenterPosition()); - if (_isInTailAfterRange) + if (Master.LookTarget != null) { - _tailAfterTimer = 0; - } - else - { - _tailAfterTimer += delta; + //检测目标没有超出跟随视野距离 + var isInTailAfterRange = Master.IsInTailAfterViewRange(Master.LookTarget.GetCenterPosition()); + if (isInTailAfterRange) + { + _tailAfterTimer = 0; + } + else + { + _tailAfterTimer += delta; + } } //向武器移动 @@ -116,17 +154,28 @@ } } - private AIStateEnum GetNextState() + private void RunNextState() { - return _tailAfterTimer > 10 ? AIStateEnum.AiNormal : AIStateEnum.AiTailAfter; + if (_attackTarget != null) + { + ChangeState(AIStateEnum.AiLeaveFor, _attackTarget); + } + else if (Master.LookTarget != null) + { + ChangeState(_tailAfterTimer > 10 ? AIStateEnum.AiNormal : AIStateEnum.AiTailAfter); + } + else + { + ChangeState(AIStateEnum.AiNormal); + } } private void SetTargetWeapon(Weapon weapon) { _target = weapon; - //设置目标点 - if (_target != null) + if (weapon != null) { + //设置目标点 Master.NavigationAgent2D.TargetPosition = _target.GlobalPosition; } } @@ -137,15 +186,17 @@ { Master.DrawLine(Vector2.Zero, Master.ToLocal(_target.GlobalPosition), Colors.Purple); - if (_tailAfterTimer <= 0) + if (Master.LookTarget != null) { - Master.DrawLine(Vector2.Zero, Master.ToLocal(Master.LookTarget.GetCenterPosition()), Colors.Orange); + if (_tailAfterTimer <= 0) + { + Master.DrawLine(Vector2.Zero, Master.ToLocal(Master.LookTarget.GetCenterPosition()), Colors.Orange); + } + else if (_tailAfterTimer <= 10) + { + Master.DrawLine(Vector2.Zero, Master.ToLocal(Master.LookTarget.GetCenterPosition()), Colors.Blue); + } } - else if (_tailAfterTimer <= 10) - { - Master.DrawLine(Vector2.Zero, Master.ToLocal(Master.LookTarget.GetCenterPosition()), Colors.Blue); - } - } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiLeaveForState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiLeaveForState.cs index 39d62aa..d5bc087 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiLeaveForState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiLeaveForState.cs @@ -12,14 +12,15 @@ //导航目标点刷新计时器 private float _navigationUpdateTimer = 0; private float _navigationInterval = 0.3f; - - private float _idleTimer = 0; //目标 private ActivityObject _target; //目标点 private Vector2 _targetPosition; + private float _idleTimer = 0; + private bool _playAnimFlag = false; + public AiLeaveForState() : base(AIStateEnum.AiLeaveFor) { } @@ -30,7 +31,7 @@ { throw new Exception("进入 AINormalStateEnum.AiLeaveFor 状态必须带上目标对象"); } - + _target = (ActivityObject)args[0]; //先检查弹药是否打光 @@ -40,8 +41,7 @@ var targetWeapon = Master.FindTargetWeapon(); if (targetWeapon != null) { - Master.LookTarget = _target; - ChangeState(AIStateEnum.AiFindAmmo, targetWeapon); + ChangeState(AIStateEnum.AiFindAmmo, targetWeapon, _target); return; } } @@ -49,7 +49,12 @@ _idleTimer = 1; _targetPosition = _target.GetCenterPosition(); Master.LookTargetPosition(_targetPosition); - Master.AnimationPlayer.Play(AnimatorNames.Query); + + _playAnimFlag = prev != AIStateEnum.AiFindAmmo; + if (_playAnimFlag) + { + Master.AnimationPlayer.Play(AnimatorNames.Query); + } } public override void Exit(AIStateEnum next) @@ -59,7 +64,7 @@ public override void Process(float delta) { - if (_idleTimer > 0) + if (_playAnimFlag && _idleTimer > 0) { _idleTimer -= delta; return; @@ -104,7 +109,7 @@ Master.TestViewRayCastOver(); //切换成发现目标状态 Master.LookTarget = Player.Current; - ChangeState(AIStateEnum.AiFollowUp); + ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiFollowUp); return; } else diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNormalState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNormalState.cs index f91594a..be8f86e 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNormalState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiNormalState.cs @@ -52,6 +52,8 @@ if (Master.IsInViewRange(playerPos) && !Master.TestViewRayCast(playerPos)) //发现玩家 { + //关闭射线检测 + Master.TestViewRayCastOver(); //发现玩家 Master.LookTarget = player; //进入惊讶状态, 然后再进入通知状态