Browse Source

fix: 🐛 Try to fix the problem of clipping

tags/0.1.0
shangfengh 2 years ago
parent
commit
916cf02f06
11 changed files with 40 additions and 33 deletions
  1. +1
    -1
      CAPI/cpp/API/src/AI.cpp
  2. +9
    -9
      docs/GameRules.md
  3. +2
    -2
      logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs
  4. +1
    -1
      logic/GameClass/GameObj/Character/Character.cs
  5. +3
    -3
      logic/GameEngine/CollisionChecker.cs
  6. +0
    -1
      logic/GameEngine/MoveEngine.cs
  7. +0
    -2
      logic/Gaming/ActionManager.cs
  8. +9
    -9
      logic/Gaming/CharacterManager .cs
  9. +2
    -2
      logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs
  10. +1
    -1
      logic/Preparation/Interface/IMoveable.cs
  11. +12
    -2
      logic/Preparation/Utility/XY.cs

+ 1
- 1
CAPI/cpp/API/src/AI.cpp View File

@@ -3,7 +3,7 @@
#include <array> #include <array>
#include "AI.h" #include "AI.h"
#include "constants.h" #include "constants.h"
//注意不要使用conio.h,Windows.h等非标准库
// 注意不要使用conio.h,Windows.h等非标准库


// 为假则play()期间确保游戏状态不更新,为真则只保证游戏状态在调用相关方法时不更新 // 为假则play()期间确保游戏状态不更新,为真则只保证游戏状态在调用相关方法时不更新
extern const bool asynchronous = false; extern const bool asynchronous = false;


+ 9
- 9
docs/GameRules.md View File

@@ -194,9 +194,9 @@ $$
| 隐蔽度 | 1.5 | 1 | 0.8 | 0.75| | 隐蔽度 | 1.5 | 1 | 0.8 | 0.75|
| 警戒范围 | 22,100 | 17000 | 15300 | 17000 | 警戒范围 | 22,100 | 17000 | 15300 | 17000
| 视野范围 | 15600 | 13000 | 13000 | 14300| | 视野范围 | 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 #### Assassin
- 普通攻击为 CommonAttackOfGhost - 普通攻击为 CommonAttackOfGhost
@@ -244,17 +244,17 @@ $$


| 学生职业 | 教师Teacher | 健身狂Athlete | 学霸StraightAStudent | 开心果Sunshine | | 学生职业 | 教师Teacher | 健身狂Athlete | 学霸StraightAStudent | 开心果Sunshine |
| :------------ | :--------------------- | :--------------------- | :--------------------- | :--------------------- | | :------------ | :--------------------- | :--------------------- | :--------------------- | :--------------------- |
| 移动速度 | 2700 | 3150 | 2880 | 3000 |
| 移动速度/s | 2700 | 3150 | 2880 | 3000 |
| 最大毅力值 | 30000000 | 3000000 | 3300000 | 3200000 | | 最大毅力值 | 30000000 | 3000000 | 3300000 | 3200000 |
| 最大沉迷度 | 600000 | 54,000 | 78,000 | 66,000 | | 最大沉迷度 | 600000 | 54,000 | 78,000 | 66,000 |
| 学习一科速度 | 0 | 73 | 135 | 123 | | 学习一科速度 | 0 | 73 | 135 | 123 |
| 勉励速度 | 80 | 90 | 100 | 120 |
| 勉励速度/ms | 80 | 90 | 100 | 120 |
| 隐蔽度 | 0.5 | 0.9 | 0.9 | 0.8 | | 隐蔽度 | 0.5 | 0.9 | 0.9 | 0.8 |
| 警戒范围 | 7500 | 15000 | 13,500 | 15000 | | 警戒范围 | 7500 | 15000 | 13,500 | 15000 |
| 视野范围 | 9,000 | 11000 | 9,000 | 10000 | | 视野范围 | 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 @@ $$
- 眩晕状态中的玩家不能再次被眩晕 - 眩晕状态中的玩家不能再次被眩晕


### 初始状态 ### 初始状态
- 玩家出生点固定且一定为空地
- 初赛玩家出生点固定且一定为空地


### 道具 ### 道具
- 使用钥匙相当于销毁 - 使用钥匙相当于销毁


+ 2
- 2
logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs View File

@@ -130,7 +130,7 @@ namespace GameClass.GameObj


public override bool CanAttack(GameObj target) 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) public override bool CanBeBombed(GameObjType gameObjType)
{ {
@@ -176,7 +176,7 @@ namespace GameClass.GameObj


public override bool CanAttack(GameObj target) 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) public override bool CanBeBombed(GameObjType gameObjType)
{ {


+ 1
- 1
logic/GameClass/GameObj/Character/Character.cs View File

@@ -594,7 +594,7 @@ namespace GameClass.GameObj
{ {
return true; 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 true;
return false; return false;
} }


+ 3
- 3
logic/GameEngine/CollisionChecker.cs View File

@@ -75,7 +75,7 @@ namespace GameEngine
// if (obj.WillCollideWith(square, obj.Position)) // if (obj.WillCollideWith(square, obj.Position))
// tmpMax = 0; // tmpMax = 0;
// else tmpMax = // 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))))); // (square.Radius / Math.Min(Math.Abs(Math.Cos(angle)), Math.Abs(Math.Sin(angle)))));
// return tmpMax; // return tmpMax;
// } // }
@@ -144,7 +144,7 @@ namespace GameEngine
case ShapeType.Circle: 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 orgDeltaX = listObj.Position.x - obj.Position.x;
int orgDeltaY = listObj.Position.y - obj.Position.y; int orgDeltaY = listObj.Position.y - obj.Position.y;


@@ -181,7 +181,7 @@ namespace GameEngine
while (left < right - 1) while (left < right - 1)
{ {
int mid = (right - left) / 2 + left; 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; right = mid;
} }


+ 0
- 1
logic/GameEngine/MoveEngine.cs View File

@@ -1,5 +1,4 @@
using System; using System;
using System.Numerics;
using System.Threading; using System.Threading;
using Preparation.Interface; using Preparation.Interface;
using Preparation.Utility; using Preparation.Utility;


+ 0
- 2
logic/Gaming/ActionManager.cs View File

@@ -1,6 +1,4 @@
using System; using System;
using System.Diagnostics;
using System.Net.NetworkInformation;
using System.Threading; using System.Threading;
using GameClass.GameObj; using GameClass.GameObj;
using GameEngine; using GameEngine;


+ 9
- 9
logic/Gaming/CharacterManager .cs View File

@@ -135,10 +135,10 @@ namespace Gaming
double bgmVolume = 0; double bgmVolume = 0;
foreach (Character person in gameMap.GameObjDict[GameObjType.Character]) 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); newPlayer.AddBgm(BgmType.StudentIsApproaching, bgmVolume);
@@ -151,11 +151,11 @@ namespace Gaming
{ {
if (!noise) 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); 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; TimePinningDown += GameData.checkInterval;
newPlayer.AddScore(GameData.StudentScorePinDown(TimePinningDown) - ScoreAdded); newPlayer.AddScore(GameData.StudentScorePinDown(TimePinningDown) - ScoreAdded);
@@ -180,10 +180,10 @@ namespace Gaming
double bgmVolume = 0; double bgmVolume = 0;
foreach (Generator generator in gameMap.GameObjDict[GameObjType.Generator]) 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); newPlayer.AddBgm(BgmType.GeneratorIsBeingFixed, bgmVolume);


+ 2
- 2
logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs View File

@@ -51,7 +51,7 @@ namespace Gaming
{ {
if (!person.IsGhost() && player.CharacterType != CharacterType.Robot && !person.NoHp()) 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) if (dis >= player.AlertnessRadius)
{ {
person.AddMoveSpeed(GameData.checkIntervalWhenShowTime, dis / player.AlertnessRadius); person.AddMoveSpeed(GameData.checkIntervalWhenShowTime, dis / player.AlertnessRadius);
@@ -185,7 +185,7 @@ namespace Gaming
{ {
foreach (Character character in gameMap.GameObjDict[GameObjType.Character]) 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)) if (characterManager.BeStunned(character, GameData.timeOfStudentStunnedWhenHowl))
player.AddScore(GameData.TrickerScoreStudentBeStunned(GameData.timeOfStudentStunnedWhenHowl)); player.AddScore(GameData.TrickerScoreStudentBeStunned(GameData.timeOfStudentStunnedWhenHowl));


+ 1
- 1
logic/Preparation/Interface/IMoveable.cs View File

@@ -24,7 +24,7 @@ namespace Preparation.Interface


if (targetObj.Shape == ShapeType.Circle) 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 else // Square
{ {


+ 12
- 2
logic/Preparation/Utility/XY.cs View File

@@ -62,14 +62,24 @@ namespace Preparation.Utility
{ {
return v1.x != v2.x || v1.y != v2.y; 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 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; 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; t = (c / t + t) / 2;
return (double)t / 1000.0; 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() public double Length()
{ {
return Math.Sqrt(((long)x * x) + ((long)y * y)); return Math.Sqrt(((long)x * x) + ((long)y * y));


Loading…
Cancel
Save