From 7cbb4185a0201d91c2ba4261464d8156eb1bc77e Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Mon, 27 Mar 2023 10:28:17 +0800 Subject: [PATCH] fix: :bug: fix the fuction of Skill "CanBeginToCharge" --- logic/GameClass/GameObj/Character/Skill.cs | 2 +- logic/GameClass/GameObj/Moveable.cs | 13 ++-- .../SkillManager/SkillManager.ActiveSkill.cs | 73 ++++++++++--------- logic/Preparation/Utility/GameData.cs | 15 +++- logic/Preparation/Utility/XY.cs | 12 ++- 5 files changed, 66 insertions(+), 49 deletions(-) diff --git a/logic/GameClass/GameObj/Character/Skill.cs b/logic/GameClass/GameObj/Character/Skill.cs index e99fdd7..e021722 100644 --- a/logic/GameClass/GameObj/Character/Skill.cs +++ b/logic/GameClass/GameObj/Character/Skill.cs @@ -80,7 +80,7 @@ namespace GameClass.GameObj return new BecomeInvisible(); case ActiveSkillType.UseKnife: return new UseKnife(); - case ActiveSkillType.CanBeginToCharge: + case ActiveSkillType.CanBeginToCharge: return new CanBeginToCharge(); case ActiveSkillType.Punish: return new Punish(); diff --git a/logic/GameClass/GameObj/Moveable.cs b/logic/GameClass/GameObj/Moveable.cs index 70c0c3c..128240f 100644 --- a/logic/GameClass/GameObj/Moveable.cs +++ b/logic/GameClass/GameObj/Moveable.cs @@ -50,12 +50,13 @@ namespace GameClass.GameObj // 移动,改变坐标 public long MovingSetPos(XY moveVec, PlaceType place) { - lock (gameObjLock) - { - FacingDirection = moveVec; - this.Position += moveVec; - this.place = place; - } + if (moveVec.x != 0 || moveVec.y != 0) + lock (gameObjLock) + { + FacingDirection = moveVec; + this.Position += moveVec; + this.place = place; + } return moveVec * moveVec; } diff --git a/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs b/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs index 773968a..e903f9a 100644 --- a/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs +++ b/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs @@ -31,47 +31,48 @@ namespace Gaming if ((!player.Commandable())) return false; IActiveSkill skill = player.UseIActiveSkill(ActiveSkillType.CanBeginToCharge); Debugger.Output(player, "can begin to charge!"); - new Thread - ( - () => - { - new FrameRateTaskExecutor( - loopCondition: () => player.Commandable() && gameMap.Timer.IsGaming, - loopToDo: () => - { - gameMap.GameObjLockDict[GameObjType.Character].EnterReadLock(); - try - { - foreach (Character character in gameMap.GameObjDict[GameObjType.Character]) - { - if (character.IsGhost() != player.IsGhost() && XY.Distance(player.Position + new XY(player.FacingDirection, player.Radius), character.Position) <= character.Radius) - { - AttackManager.BeStunned(character, GameData.TimeOfGhostFaintingWhenCharge); - player.AddScore(GameData.StudentScoreTrickerBeStunned(GameData.TimeOfGhostFaintingWhenCharge)); - AttackManager.BeStunned(player, GameData.TimeOfStudentFaintingWhenCharge); - break; - } - } - } - finally - { - gameMap.GameObjLockDict[GameObjType.Character].ExitReadLock(); - } - }, - timeInterval: GameData.frameDuration, - finallyReturn: () => 0, - maxTotalDuration: skill.DurationTime - ) - .Start(); - } - - ) - { IsBackground = true }.Start(); return ActiveSkillEffect(skill, player, () => { player.AddMoveSpeed(skill.DurationTime, 3.0); + new Thread + ( + () => + { + new FrameRateTaskExecutor( + loopCondition: () => player.Commandable() && gameMap.Timer.IsGaming, + loopToDo: () => + { + gameMap.GameObjLockDict[GameObjType.Character].EnterReadLock(); + try + { + foreach (Character character in gameMap.GameObjDict[GameObjType.Character]) + { + if (character.IsGhost() != player.IsGhost() && Math.Max(XY.Distance(player.Position, character.Position), XY.Distance(player.Position + new XY(player.FacingDirection, player.Radius), character.Position)) <= character.Radius + player.Radius + GameData.tolerancesLength) + { + AttackManager.BeStunned(character, GameData.TimeOfGhostFaintingWhenCharge); + player.AddScore(GameData.StudentScoreTrickerBeStunned(GameData.TimeOfGhostFaintingWhenCharge)); + AttackManager.BeStunned(player, GameData.TimeOfStudentFaintingWhenCharge); + break; + } + } + } + finally + { + gameMap.GameObjLockDict[GameObjType.Character].ExitReadLock(); + } + }, + timeInterval: GameData.frameDuration, + finallyReturn: () => 0, + maxTotalDuration: skill.DurationTime + ) + + .Start(); + } + + ) + { IsBackground = true }.Start(); }, () => { diff --git a/logic/Preparation/Utility/GameData.cs b/logic/Preparation/Utility/GameData.cs index 2e2159a..87992b7 100644 --- a/logic/Preparation/Utility/GameData.cs +++ b/logic/Preparation/Utility/GameData.cs @@ -7,9 +7,11 @@ namespace Preparation.Utility { #region 基本常数 public const int numOfStepPerSecond = 20; // 每秒行走的步数 + + public const int tolerancesLength = 10; + public const int frameDuration = 50; // 每帧时长 public const int checkInterval = 50; // 检查位置标志、补充子弹的帧时长 - public const long gameDuration = 600000; // 游戏时长600000ms = 10min public const int MinSpeed = 1; // 最小速度 @@ -63,7 +65,7 @@ namespace Preparation.Utility #endregion #region 角色相关 public const int numOfStudent = 4; - public const int characterRadius = numOfPosGridPerCell / 2 / 5 * 4; // 人物半径 + public const int characterRadius = numOfPosGridPerCell * 4 / 10; // 人物半径 public const int basicTreatSpeed = 100; public const int basicFixSpeed = 100; @@ -79,7 +81,12 @@ namespace Preparation.Utility public const int basicTreatmentDegree = 1500000; public const int basicTimeOfRescue = 1000; - public const int basicMoveSpeed = 9000;//DEBUG //1270;TRUE // 基本移动速度,单位:s-1 +#if DEBUG + public const int basicMoveSpeed = 9000;// 基本移动速度,单位:s-1 +#else + public const int basicMoveSpeed = 1270; +#endif + public const int characterMaxSpeed = 12000; // 最大速度 public const double basicConcealment = 1.0; @@ -177,7 +184,7 @@ namespace Preparation.Utility public const int PropRadius = numOfPosGridPerCell / 2; public const int PropMoveSpeed = 3000; public const int PropMaxMoveDistance = 15 * numOfPosGridPerCell; - public const long PropProduceTime = 10000; + public const long PropProduceTime = 20000; public const int PropDuration = 10000; public const int ApPropAdd = basicApOfGhost * 12 / 10; diff --git a/logic/Preparation/Utility/XY.cs b/logic/Preparation/Utility/XY.cs index 2f04b33..b75602c 100644 --- a/logic/Preparation/Utility/XY.cs +++ b/logic/Preparation/Utility/XY.cs @@ -19,8 +19,16 @@ namespace Preparation.Utility } public XY(XY Direction, double length) { - this.x = (int)(length * Math.Cos(Direction.Angle())); - this.y = (int)(length * Math.Sin(Direction.Angle())); + if (Direction.x == 0 && Direction.y == 0) + { + this.x = 0; + this.y = 0; + } + else + { + this.x = (int)(length * Math.Cos(Direction.Angle())); + this.y = (int)(length * Math.Sin(Direction.Angle())); + } } public override string ToString() {