修复已经发现的ai改变阵营会报错的bug

This commit is contained in:
小李xl 2024-04-09 00:56:43 +08:00
parent 3a7fb7d3b3
commit 1ffb286c42
11 changed files with 41 additions and 23 deletions

View File

@ -1 +1 @@
[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[{"Position":{"X":0,"Y":0},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":53,"Y":31},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0003","CurrAmmon":"12","ResidueAmmo":"12"},"Altitude":0,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":84,"Y":8},"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":5.551115E-14}]}]]}] [{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[{"Position":{"X":-81,"Y":25},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":53,"Y":31},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0003","CurrAmmon":"12","ResidueAmmo":"12"},"Altitude":0,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":84,"Y":8},"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":5.551115E-14}]},{"Position":{"X":-54,"Y":20},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":5.551115E-14}]}]]}]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1 +1 @@
{"Position":{"X":-5,"Y":-7},"Size":{"X":15,"Y":16},"DoorAreaInfos":[],"GroupName":"Test1","RoomType":2,"RoomName":"Start2","Weight":100,"Remark":""} {"Position":{"X":-9,"Y":-7},"Size":{"X":19,"Y":16},"DoorAreaInfos":[],"GroupName":"Test1","RoomType":2,"RoomName":"Start2","Weight":100,"Remark":""}

View File

@ -1 +1 @@
{"NavigationVertices":[{"X":122,"Y":122},{"X":-42,"Y":122},{"X":-42,"Y":-58},{"X":122,"Y":-58}],"NavigationPolygon":[[0,1,2,3]],"Floor":[-3,-4,0,3,-3,-3,0,3,-3,-2,0,3,-3,-1,0,3,-3,0,0,3,-3,1,0,3,-3,2,0,3,-3,3,0,3,-3,4,0,3,-3,5,0,3,-3,6,0,3,-2,-4,0,3,-2,-3,0,3,-2,-2,0,3,-2,-1,0,3,-2,0,0,3,-2,1,0,3,-2,2,0,3,-2,3,0,3,-2,4,0,3,-2,5,0,3,-2,6,0,3,-1,-4,0,3,-1,-3,0,3,-1,-2,0,3,-1,-1,0,3,-1,0,0,3,-1,1,0,3,-1,2,0,3,-1,3,0,3,-1,4,0,3,-1,5,0,3,-1,6,0,3,0,-4,0,3,0,-3,0,3,0,-2,0,3,0,-1,0,3,0,0,0,3,0,1,0,3,0,2,0,3,0,3,0,3,0,4,0,3,0,5,0,3,0,6,0,3,1,-4,0,3,1,-3,0,3,1,-2,0,3,1,-1,0,3,1,0,0,3,1,1,0,3,1,2,0,3,1,3,0,3,1,4,0,3,1,5,0,3,1,6,0,3,2,-4,0,3,2,-3,0,3,2,-2,0,3,2,-1,0,3,2,0,0,3,2,1,0,3,2,2,0,3,2,3,0,3,2,4,0,3,2,5,0,3,2,6,0,3,3,-4,0,3,3,-3,0,3,3,-2,0,3,3,-1,0,3,3,0,0,3,3,1,0,3,3,2,0,3,3,3,0,3,3,4,0,3,3,5,0,3,3,6,0,3,4,-4,0,3,4,-3,0,3,4,-2,0,3,4,-1,0,3,4,0,0,3,4,1,0,3,4,2,0,3,4,3,0,3,4,4,0,3,4,5,0,3,4,6,0,3,5,-4,0,3,5,-3,0,3,5,-2,0,3,5,-1,0,3,5,0,0,3,5,1,0,3,5,2,0,3,5,3,0,3,5,4,0,3,5,5,0,3,5,6,0,3,6,-4,0,3,6,-3,0,3,6,-2,0,3,6,-1,0,3,6,0,0,3,6,1,0,3,6,2,0,3,6,3,0,3,6,4,0,3,6,5,0,3,6,6,0,3,7,-4,0,3,7,-3,0,3,7,-2,0,3,7,-1,0,3,7,0,0,3,7,1,0,3,7,2,0,3,7,3,0,3,7,4,0,3,7,5,0,3,7,6,0,3],"CustomFloor1":[],"CustomFloor2":[],"CustomFloor3":[],"CustomMiddle1":[],"CustomMiddle2":[],"CustomTop":[]} {"NavigationVertices":[{"X":6,"Y":86},{"X":122,"Y":122},{"X":-106,"Y":122},{"X":-22,"Y":86},{"X":-106,"Y":-58},{"X":-22,"Y":-22},{"X":122,"Y":-58},{"X":6,"Y":-22}],"NavigationPolygon":[[0,1,2,3],[3,2,4,5],[5,4,6,7],[6,1,0,7]],"Floor":[-3,-4,0,3,-3,-3,0,3,-3,-2,0,3,-3,-1,0,3,-3,0,0,3,-3,1,0,3,-3,2,0,3,-3,3,0,3,-3,4,0,3,-3,5,0,3,-3,6,0,3,-2,-4,0,3,-2,-3,0,3,-2,-2,0,3,-2,0,0,3,-2,1,0,3,-2,2,0,3,-2,3,0,3,-2,4,0,3,-2,5,0,3,-2,6,0,3,-1,-4,0,3,-1,-3,0,3,-1,5,0,3,-1,6,0,3,0,-4,0,3,0,-3,0,3,0,-2,0,3,0,-1,0,3,0,0,0,3,0,1,0,3,0,2,0,3,0,3,0,3,0,4,0,3,0,5,0,3,0,6,0,3,1,-4,0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7,4,0,3,-7,5,0,3,-7,6,0,3,-2,-1,0,3],"CustomFloor1":[],"CustomFloor2":[],"CustomFloor3":[],"CustomMiddle1":[],"CustomMiddle2":[],"CustomTop":[]}

View File

@ -134,7 +134,7 @@ public partial class GameApplication : Node2D, ICoroutine
//固定帧率 //固定帧率
//Engine.MaxFps = TargetFps; //Engine.MaxFps = TargetFps;
//调试绘制开关 //调试绘制开关
ActivityObject.IsDebug = false; ActivityObject.IsDebug = true;
//Engine.TimeScale = 0.2f; //Engine.TimeScale = 0.2f;
//调整窗口分辨率 //调整窗口分辨率
OnWindowSizeChanged(); OnWindowSizeChanged();

View File

@ -7,13 +7,10 @@ namespace AiState;
/// </summary> /// </summary>
public class AiAstonishedState : StateBase<AiRole, AIStateEnum> public class AiAstonishedState : StateBase<AiRole, AIStateEnum>
{ {
/// <summary>
/// 下一个状态
/// </summary>
public AIStateEnum NextState;
private float _timer; private float _timer;
private object[] _args; private object[] _args;
//用于判断是否进入过惊讶状态
private bool _flag = false;
public AiAstonishedState() : base(AIStateEnum.AiAstonished) public AiAstonishedState() : base(AIStateEnum.AiAstonished)
{ {
@ -28,9 +25,15 @@ public class AiAstonishedState : StateBase<AiRole, AIStateEnum>
return; return;
} }
if (_flag)
{
ChangeNextState(args);
return;
}
_flag = true;
_args = args; _args = args;
NextState = (AIStateEnum)args[0];
_timer = 0.6f; _timer = 0.6f;
//播放惊讶表情 //播放惊讶表情
@ -46,14 +49,19 @@ public class AiAstonishedState : StateBase<AiRole, AIStateEnum>
_timer -= delta; _timer -= delta;
if (_timer <= 0) if (_timer <= 0)
{ {
if (_args.Length == 1) ChangeNextState(_args);
{ }
ChangeState(NextState); }
}
else if (_args.Length == 2) private void ChangeNextState(object[] args)
{ {
ChangeState(NextState, _args[1]); if (args.Length == 1)
} {
ChangeState((AIStateEnum)args[0]);
}
else if (args.Length == 2)
{
ChangeState((AIStateEnum)args[0], args[1]);
} }
} }
} }

View File

@ -43,7 +43,9 @@ public class AiAttackState : StateBase<AiRole, AIStateEnum>
{ {
if (Master.LookTarget == null) if (Master.LookTarget == null)
{ {
throw new Exception("进入 AIAdvancedStateEnum.AiAttack 状态时角色没有攻击目标!"); ChangeState(AIStateEnum.AiNormal);
return;
//throw new Exception("进入 AIAdvancedStateEnum.AiAttack 状态时角色没有攻击目标!");
} }
var weapon = Master.WeaponPack.ActiveItem; var weapon = Master.WeaponPack.ActiveItem;

View File

@ -21,7 +21,9 @@ public class AiFollowUpState : StateBase<AiRole, AIStateEnum>
{ {
if (Master.LookTarget == null) if (Master.LookTarget == null)
{ {
throw new Exception("进入 AIAdvancedStateEnum.AiFollowUp 状态时角色没有攻击目标!"); ChangeState(AIStateEnum.AiNormal);
return;
//throw new Exception("进入 AIAdvancedStateEnum.AiFollowUp 状态时角色没有攻击目标!");
} }
_navigationUpdateTimer = 0; _navigationUpdateTimer = 0;

View File

@ -17,7 +17,9 @@ public class AiNotifyState : StateBase<AiRole, AIStateEnum>
{ {
if (Master.LookTarget == null) if (Master.LookTarget == null)
{ {
throw new Exception("进入 AIAdvancedStateEnum.AiNotify 没有攻击目标!"); ChangeState(AIStateEnum.AiNormal);
return;
//throw new Exception("进入 AIAdvancedStateEnum.AiNotify 没有攻击目标!");
} }
_timer = 1.2f; _timer = 1.2f;
//通知其它角色 //通知其它角色

View File

@ -32,7 +32,9 @@ public class AiSurroundState : StateBase<AiRole, AIStateEnum>
{ {
if (Master.LookTarget == null) if (Master.LookTarget == null)
{ {
throw new Exception("进入 AIAdvancedStateEnum.AiSurround 状态时角色没有攻击目标!"); ChangeState(AIStateEnum.AiNormal);
return;
//throw new Exception("进入 AIAdvancedStateEnum.AiSurround 状态时角色没有攻击目标!");
} }
Master.TargetInView = true; Master.TargetInView = true;

View File

@ -29,7 +29,9 @@ public class AiTailAfterState : StateBase<AiRole, AIStateEnum>
{ {
if (Master.LookTarget == null) if (Master.LookTarget == null)
{ {
throw new Exception("进入 AIAdvancedStateEnum.AiTailAfter 状态时角色没有攻击目标!"); ChangeState(AIStateEnum.AiNormal);
return;
//throw new Exception("进入 AIAdvancedStateEnum.AiTailAfter 状态时角色没有攻击目标!");
} }
_isInViewRange = true; _isInViewRange = true;