diff --git a/CAPI/cpp/API/src/AI.cpp b/CAPI/cpp/API/src/AI.cpp index 2709e2e..c37b914 100644 --- a/CAPI/cpp/API/src/AI.cpp +++ b/CAPI/cpp/API/src/AI.cpp @@ -3,7 +3,7 @@ #include #include "AI.h" #include "constants.h" -//注意不要使用conio.h,Windows.h等非标准库 +// 注意不要使用conio.h,Windows.h等非标准库 // 为假则play()期间确保游戏状态不更新,为真则只保证游戏状态在调用相关方法时不更新 extern const bool asynchronous = false; diff --git a/docs/GameRules.md b/docs/GameRules.md index 3b194c0..ffc4fd4 100644 --- a/docs/GameRules.md +++ b/docs/GameRules.md @@ -194,9 +194,9 @@ $$ | 隐蔽度 | 1.5 | 1 | 0.8 | 0.75| | 警戒范围 | 22,100 | 17000 | 15300 | 17000 | 视野范围 | 15600 | 13000 | 13000 | 14300| -| 开锁门速度 | 4000 | 4000 | 4000 |4000 | -| 翻窗速度 | 2540 | 2540 | 2794 | 2540| -| 翻箱速度 | 1000 | 1100 | 1000 |1000| +| 开锁门速度/ms | 4000 | 4000 | 4000 |4000 | +| 翻窗速度/s | 2540 | 2540 | 2794 | 2540| +| 翻箱速度/ms | 1000 | 1100 | 1000 |1000| #### Assassin - 普通攻击为 CommonAttackOfGhost @@ -244,17 +244,17 @@ $$ | 学生职业 | 教师Teacher | 健身狂Athlete | 学霸StraightAStudent | 开心果Sunshine | | :------------ | :--------------------- | :--------------------- | :--------------------- | :--------------------- | -| 移动速度 | 2700 | 3150 | 2880 | 3000 | +| 移动速度/s | 2700 | 3150 | 2880 | 3000 | | 最大毅力值 | 30000000 | 3000000 | 3300000 | 3200000 | | 最大沉迷度 | 600000 | 54,000 | 78,000 | 66,000 | | 学习一科速度 | 0 | 73 | 135 | 123 | -| 勉励速度 | 80 | 90 | 100 | 120 | +| 勉励速度/ms | 80 | 90 | 100 | 120 | | 隐蔽度 | 0.5 | 0.9 | 0.9 | 0.8 | | 警戒范围 | 7500 | 15000 | 13,500 | 15000 | | 视野范围 | 9,000 | 11000 | 9,000 | 10000 | -| 开锁门速度 | 4000 | 4000 | 4000 | 2800 | -| 翻窗速度 | 1270 | 3048 | 2116 | 2540 | -| 翻箱速度 | 1000 | 1000 | 1000 | 900 | +| 开锁门速度/ms | 4000 | 4000 | 4000 | 2800 | +| 翻窗速度/ms | 1270 | 3048 | 2116 | 2540 | +| 翻箱速度/ms | 1000 | 1000 | 1000 | 900 | #### 运动员 - 主动技能 @@ -312,7 +312,7 @@ $$ - 眩晕状态中的玩家不能再次被眩晕 ### 初始状态 - - 玩家出生点固定且一定为空地 + - 初赛玩家出生点固定且一定为空地 ### 道具 - 使用钥匙相当于销毁 diff --git a/logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs b/logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs index 32d0129..672e40f 100644 --- a/logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs +++ b/logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs @@ -130,7 +130,7 @@ namespace GameClass.GameObj public override bool CanAttack(GameObj target) { - return XY.Distance(this.Position, target.Position) <= BulletBombRange; + return XY.DistanceFloor3(this.Position, target.Position) <= BulletBombRange; } public override bool CanBeBombed(GameObjType gameObjType) { @@ -176,7 +176,7 @@ namespace GameClass.GameObj public override bool CanAttack(GameObj target) { - return XY.Distance(this.Position, target.Position) <= BulletBombRange; + return XY.DistanceFloor3(this.Position, target.Position) <= BulletBombRange; } public override bool CanBeBombed(GameObjType gameObjType) { diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs index b6d040a..b0c3d3b 100644 --- a/logic/GameClass/GameObj/Character/Character.cs +++ b/logic/GameClass/GameObj/Character/Character.cs @@ -594,7 +594,7 @@ namespace GameClass.GameObj { return true; } - if (targetObj.Type == GameObjType.Character && XY.Distance(targetObj.Position, this.Position) < this.Radius + targetObj.Radius) + if (targetObj.Type == GameObjType.Character && XY.DistanceFloor3(targetObj.Position, this.Position) < this.Radius + targetObj.Radius) return true; return false; } diff --git a/logic/GameEngine/CollisionChecker.cs b/logic/GameEngine/CollisionChecker.cs index 0d1d3ea..046d5bc 100644 --- a/logic/GameEngine/CollisionChecker.cs +++ b/logic/GameEngine/CollisionChecker.cs @@ -75,7 +75,7 @@ namespace GameEngine // if (obj.WillCollideWith(square, obj.Position)) // tmpMax = 0; // else tmpMax = - // Math.Abs(XYPosition.Distance(obj.Position, square.Position) - obj.Radius - + // Math.Abs(XYPosition.DistanceFloor3(obj.Position, square.Position) - obj.Radius - // (square.Radius / Math.Min(Math.Abs(Math.Cos(angle)), Math.Abs(Math.Sin(angle))))); // return tmpMax; // } @@ -144,7 +144,7 @@ namespace GameEngine case ShapeType.Circle: { // 计算两者之间的距离 - double mod = XY.Distance(listObj.Position, obj.Position); + double mod = XY.DistanceFloor3(listObj.Position, obj.Position); int orgDeltaX = listObj.Position.x - obj.Position.x; int orgDeltaY = listObj.Position.y - obj.Position.y; @@ -181,7 +181,7 @@ namespace GameEngine while (left < right - 1) { int mid = (right - left) / 2 + left; - if (obj.WillCollideWith(listObj, obj.Position + new XY((int)(mid * Math.Cos(moveVec.Angle())), (int)(mid * Math.Sin(moveVec.Angle()))))) + if (obj.WillCollideWith(listObj, obj.Position + new XY(moveVec, mid))) { right = mid; } diff --git a/logic/GameEngine/MoveEngine.cs b/logic/GameEngine/MoveEngine.cs index 795460e..ac6bdbe 100644 --- a/logic/GameEngine/MoveEngine.cs +++ b/logic/GameEngine/MoveEngine.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using System.Threading; using Preparation.Interface; using Preparation.Utility; diff --git a/logic/Gaming/ActionManager.cs b/logic/Gaming/ActionManager.cs index 6d2d1ea..7ad0e10 100644 --- a/logic/Gaming/ActionManager.cs +++ b/logic/Gaming/ActionManager.cs @@ -1,6 +1,4 @@ using System; -using System.Diagnostics; -using System.Net.NetworkInformation; using System.Threading; using GameClass.GameObj; using GameEngine; diff --git a/logic/Gaming/CharacterManager .cs b/logic/Gaming/CharacterManager .cs index 071ac60..f3cbd19 100644 --- a/logic/Gaming/CharacterManager .cs +++ b/logic/Gaming/CharacterManager .cs @@ -135,10 +135,10 @@ namespace Gaming double bgmVolume = 0; foreach (Character person in gameMap.GameObjDict[GameObjType.Character]) { - if (!person.IsGhost() && XY.Distance(newPlayer.Position, person.Position) <= (newPlayer.AlertnessRadius / person.Concealment)) + if (!person.IsGhost() && XY.DistanceFloor3(newPlayer.Position, person.Position) <= (newPlayer.AlertnessRadius / person.Concealment)) { - if ((double)newPlayer.AlertnessRadius / XY.Distance(newPlayer.Position, person.Position) > bgmVolume) - bgmVolume = newPlayer.AlertnessRadius / XY.Distance(newPlayer.Position, person.Position); + if ((double)newPlayer.AlertnessRadius / XY.DistanceFloor3(newPlayer.Position, person.Position) > bgmVolume) + bgmVolume = newPlayer.AlertnessRadius / XY.DistanceFloor3(newPlayer.Position, person.Position); } } newPlayer.AddBgm(BgmType.StudentIsApproaching, bgmVolume); @@ -151,11 +151,11 @@ namespace Gaming { if (!noise) { - if (XY.Distance(newPlayer.Position, person.Position) <= (newPlayer.AlertnessRadius / person.Concealment)) - newPlayer.AddBgm(BgmType.GhostIsComing, (double)newPlayer.AlertnessRadius / XY.Distance(newPlayer.Position, person.Position)); + if (XY.DistanceFloor3(newPlayer.Position, person.Position) <= (newPlayer.AlertnessRadius / person.Concealment)) + newPlayer.AddBgm(BgmType.GhostIsComing, (double)newPlayer.AlertnessRadius / XY.DistanceFloor3(newPlayer.Position, person.Position)); else newPlayer.AddBgm(BgmType.GhostIsComing, 0); } - if (newPlayer.CharacterType != CharacterType.Teacher && newPlayer.CharacterType != CharacterType.Robot && !newPlayer.NoHp() && newPlayer.PlayerState != PlayerStateType.Stunned && XY.Distance(newPlayer.Position, person.Position) <= GameData.PinningDownRange) + if (newPlayer.CharacterType != CharacterType.Teacher && newPlayer.CharacterType != CharacterType.Robot && !newPlayer.NoHp() && newPlayer.PlayerState != PlayerStateType.Stunned && XY.DistanceFloor3(newPlayer.Position, person.Position) <= GameData.PinningDownRange) { TimePinningDown += GameData.checkInterval; newPlayer.AddScore(GameData.StudentScorePinDown(TimePinningDown) - ScoreAdded); @@ -180,10 +180,10 @@ namespace Gaming double bgmVolume = 0; foreach (Generator generator in gameMap.GameObjDict[GameObjType.Generator]) { - if (XY.Distance(newPlayer.Position, generator.Position) <= newPlayer.AlertnessRadius) + if (XY.DistanceFloor3(newPlayer.Position, generator.Position) <= newPlayer.AlertnessRadius) { - if (generator.NumOfFixing > 0 && (double)newPlayer.AlertnessRadius * generator.DegreeOfRepair / GameData.degreeOfFixedGenerator / XY.Distance(newPlayer.Position, generator.Position) > bgmVolume) - bgmVolume = (double)newPlayer.AlertnessRadius * generator.DegreeOfRepair / GameData.degreeOfFixedGenerator / XY.Distance(newPlayer.Position, generator.Position); + if (generator.NumOfFixing > 0 && (double)newPlayer.AlertnessRadius * generator.DegreeOfRepair / GameData.degreeOfFixedGenerator / XY.DistanceFloor3(newPlayer.Position, generator.Position) > bgmVolume) + bgmVolume = (double)newPlayer.AlertnessRadius * generator.DegreeOfRepair / GameData.degreeOfFixedGenerator / XY.DistanceFloor3(newPlayer.Position, generator.Position); } } newPlayer.AddBgm(BgmType.GeneratorIsBeingFixed, bgmVolume); diff --git a/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs b/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs index 061dc79..2587cfe 100644 --- a/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs +++ b/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs @@ -51,7 +51,7 @@ namespace Gaming { if (!person.IsGhost() && player.CharacterType != CharacterType.Robot && !person.NoHp()) { - double dis = XY.Distance(person.Position, player.Position); + double dis = XY.DistanceFloor3(person.Position, player.Position); if (dis >= player.AlertnessRadius) { person.AddMoveSpeed(GameData.checkIntervalWhenShowTime, dis / player.AlertnessRadius); @@ -185,7 +185,7 @@ namespace Gaming { foreach (Character character in gameMap.GameObjDict[GameObjType.Character]) { - if (!character.IsGhost() && !character.NoHp() && XY.Distance(character.Position, player.Position) <= player.ViewRange) + if (!character.IsGhost() && !character.NoHp() && XY.DistanceFloor3(character.Position, player.Position) <= player.ViewRange) { if (characterManager.BeStunned(character, GameData.timeOfStudentStunnedWhenHowl)) player.AddScore(GameData.TrickerScoreStudentBeStunned(GameData.timeOfStudentStunnedWhenHowl)); diff --git a/logic/Preparation/Interface/IMoveable.cs b/logic/Preparation/Interface/IMoveable.cs index e6f2d03..a9ee5cb 100644 --- a/logic/Preparation/Interface/IMoveable.cs +++ b/logic/Preparation/Interface/IMoveable.cs @@ -24,7 +24,7 @@ namespace Preparation.Interface if (targetObj.Shape == ShapeType.Circle) { - return XY.Distance(nextPos, targetObj.Position) < targetObj.Radius + Radius; + return XY.DistanceCeil3(nextPos, targetObj.Position) < targetObj.Radius + Radius; } else // Square { diff --git a/logic/Preparation/Utility/XY.cs b/logic/Preparation/Utility/XY.cs index 3798bb5..3fbc34e 100644 --- a/logic/Preparation/Utility/XY.cs +++ b/logic/Preparation/Utility/XY.cs @@ -62,14 +62,24 @@ namespace Preparation.Utility { return v1.x != v2.x || v1.y != v2.y; } - public static double Distance(XY p1, XY p2) + + public static double DistanceFloor3(XY p1, XY p2) { long c = (((long)(p1.x - p2.x) * (p1.x - p2.x)) + ((long)(p1.y - p2.y) * (p1.y - p2.y))) * 1000000; long t = c / 2 + 1; - while (t * t > c || (t + 1) * (t + 1) < c) + while (t * t > c || (t + 1) * (t + 1) <= c) t = (c / t + t) / 2; return (double)t / 1000.0; } + public static double DistanceCeil3(XY p1, XY p2) + { + long c = (((long)(p1.x - p2.x) * (p1.x - p2.x)) + ((long)(p1.y - p2.y) * (p1.y - p2.y))) * 1000000; + long t = c / 2 + 1; + while (t * t > c || (t + 1) * (t + 1) <= c) + t = (c / t + t) / 2; + if (t * t == c) return (double)t / 1000.0; + else return (double)(t + 1) / 1000.0; + } public double Length() { return Math.Sqrt(((long)x * x) + ((long)y * y));