Browse Source

Merge pull request #221 from shangfengh/new

fix: 🐛 fix the bug of Climbing Window ,which is about IgnoreCollideExecutor
tags/0.1.0
Changli Tang GitHub 2 years ago
parent
commit
dad58c4e0c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 34 additions and 48 deletions
  1. +1
    -1
      logic/GameClass/GameObj/Bullet/Bullet.cs
  2. +2
    -2
      logic/GameClass/GameObj/Character/Character.cs
  3. +1
    -5
      logic/GameClass/GameObj/GameObj.cs
  4. +1
    -1
      logic/GameClass/GameObj/Map/Doorway.cs
  5. +1
    -1
      logic/GameClass/GameObj/Map/EmergencyExit.cs
  6. +0
    -12
      logic/GameClass/GameObj/Map/Map.cs
  7. +4
    -2
      logic/GameClass/GameObj/Map/Window.cs
  8. +1
    -1
      logic/GameClass/GameObj/Prop.cs
  9. +1
    -0
      logic/GameEngine/CollisionChecker.cs
  10. +15
    -10
      logic/Gaming/ActionManager.cs
  11. +0
    -9
      logic/Gaming/Game.cs
  12. +1
    -1
      logic/Preparation/Interface/IGameObj.cs
  13. +3
    -1
      logic/Preparation/Interface/IMoveable.cs
  14. +3
    -2
      logic/规则Logic.md

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

@@ -34,7 +34,7 @@ namespace GameClass.GameObj
public abstract bool CanAttack(GameObj target);
public abstract bool CanBeBombed(GameObjType gameObjType);

protected override bool IgnoreCollideExecutor(IGameObj targetObj)
public override bool IgnoreCollideExecutor(IGameObj targetObj)
{
if (targetObj.Type == GameObjType.Prop || targetObj.Type == GameObjType.Bullet)
return true;


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

@@ -607,11 +607,11 @@ namespace GameClass.GameObj

public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Circle;
protected override bool IgnoreCollideExecutor(IGameObj targetObj)
public override bool IgnoreCollideExecutor(IGameObj targetObj)
{
if (IsResetting)
return true;
if (targetObj.Type == GameObjType.Prop) // 自己队的地雷忽略碰撞
if (targetObj.Type == GameObjType.Prop)
{
return true;
}


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

@@ -82,11 +82,7 @@ namespace GameClass.GameObj

public int Radius { get; }

/// </summary>
/// <returns> 依具体类及该方法参数而定,默认为false </returns>
protected virtual bool IgnoreCollideExecutor(IGameObj targetObj) => false;

bool IGameObj.IgnoreCollide(IGameObj targetObj) => IgnoreCollideExecutor(targetObj);
public virtual bool IgnoreCollideExecutor(IGameObj targetObj) => false;
public GameObj(XY initPos, int initRadius, GameObjType initType)
{
this.Position = this.birthPos = initPos;


+ 1
- 1
logic/GameClass/GameObj/Map/Doorway.cs View File

@@ -16,7 +16,7 @@ namespace GameClass.GameObj
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
protected override bool IgnoreCollideExecutor(IGameObj targetObj)
public override bool IgnoreCollideExecutor(IGameObj targetObj)
{
if (!IsOpen()) return false;
if (targetObj.Type != GameObjType.Character)


+ 1
- 1
logic/GameClass/GameObj/Map/EmergencyExit.cs View File

@@ -17,7 +17,7 @@ namespace GameClass.GameObj
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;

protected override bool IgnoreCollideExecutor(IGameObj targetObj)
public override bool IgnoreCollideExecutor(IGameObj targetObj)
{
if (!canOpen) return true;
if (!IsOpen) return false;


+ 0
- 12
logic/GameClass/GameObj/Map/Map.cs View File

@@ -173,18 +173,6 @@ namespace GameClass.GameObj
}
return flag;
}
public bool RemoveJustFromMap(GameObj gameObj)
{
GameObjLockDict[gameObj.Type].EnterWriteLock();
try
{
return GameObjDict[gameObj.Type].Remove(gameObj);
}
finally
{
GameObjLockDict[gameObj.Type].ExitWriteLock();
}
}
public void Add(GameObj gameObj)
{
GameObjLockDict[gameObj.Type].EnterWriteLock();


+ 4
- 2
logic/GameClass/GameObj/Map/Window.cs View File

@@ -16,12 +16,14 @@ namespace GameClass.GameObj
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
protected override bool IgnoreCollideExecutor(IGameObj targetObj)
public override bool IgnoreCollideExecutor(IGameObj targetObj)
{
if (targetObj.Type != GameObjType.Character)
return true; // 非玩家不碰撞
if (targetObj == whoIsClimbing)
if (whoIsClimbing != null && targetObj.ID == whoIsClimbing.ID)
{
return true;
}
return false;
}



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

@@ -7,7 +7,7 @@ namespace GameClass.GameObj
{
public override bool IsRigid => true;

protected override bool IgnoreCollideExecutor(IGameObj targetObj)
public override bool IgnoreCollideExecutor(IGameObj targetObj)
{
if (targetObj.Type == GameObjType.Prop || targetObj.Type == GameObjType.Bullet
|| targetObj.Type == GameObjType.Character || targetObj.Type == GameObjType.Chest)


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

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Threading;
using Preparation.Interface;
using Preparation.Utility;


+ 15
- 10
logic/Gaming/ActionManager.cs View File

@@ -371,13 +371,13 @@ namespace Gaming
() =>
{
new FrameRateTaskExecutor<int>(
loopCondition: () => player.PlayerState == PlayerStateType.ClimbingThroughWindows && gameMap.Timer.IsGaming,
loopToDo: () => { },
timeInterval: GameData.frameDuration,
finallyReturn: () => 0,
maxTotalDuration: (int)((windowToPlayer + windowForClimb.Position - player.Position).Length() * 1000 / player.MoveSpeed)
)
.Start();
loopCondition: () => player.PlayerState == PlayerStateType.ClimbingThroughWindows && gameMap.Timer.IsGaming,
loopToDo: () => { },
timeInterval: GameData.frameDuration,
finallyReturn: () => 0,
maxTotalDuration: (int)((windowToPlayer + windowForClimb.Position - player.Position).Length() * 1000 / player.MoveSpeed)
)
.Start();
if (player.PlayerState != PlayerStateType.ClimbingThroughWindows)
{
windowForClimb.WhoIsClimbing = null;
@@ -386,10 +386,14 @@ namespace Gaming

player.ReSetPos(windowToPlayer + windowForClimb.Position, PlaceType.Window);
player.MoveSpeed = player.SpeedOfClimbingThroughWindows;
MovePlayer(player, (int)(windowToPlayer.Length() * 3.0 * 1000 / player.MoveSpeed), (-1 * windowToPlayer).Angle());

moveEngine.MoveObj(player, (int)(windowToPlayer.Length() * 3.0 * 1000 / player.MoveSpeed), (-1 * windowToPlayer).Angle());

new FrameRateTaskExecutor<int>(
loopCondition: () => player.PlayerState == PlayerStateType.ClimbingThroughWindows && player.IsMoving && gameMap.Timer.IsGaming,
loopToDo: () => { },
loopCondition: () => player.PlayerState == PlayerStateType.ClimbingThroughWindows && gameMap.Timer.IsGaming,
loopToDo: () =>
{
},
timeInterval: GameData.frameDuration,
finallyReturn: () => 0,
maxTotalDuration: (int)(windowToPlayer.Length() * 3.0 * 1000 / player.MoveSpeed)
@@ -506,6 +510,7 @@ namespace Gaming
OnCollision: (obj, collisionObj, moveVec) =>
{
SkillWhenColliding((Character)obj, collisionObj);
Preparation.Utility.Debugger.Output(obj, " end move with " + collisionObj.ToString());
//if (collisionObj is Mine)
//{
// ActivateMine((Character)obj, (Mine)collisionObj);


+ 0
- 9
logic/Gaming/Game.cs View File

@@ -273,11 +273,6 @@ namespace Gaming
{
if (!gameMap.Timer.IsGaming)
return;
/* new Thread
(
() =>
{
Thread.Sleep(10);*/
gameMap.GameObjLockDict[GameObjType.Character].EnterWriteLock();
try
{
@@ -293,10 +288,6 @@ namespace Gaming
{
gameMap.GameObjLockDict[GameObjType.Character].ExitWriteLock();
}
/* }
)
{ IsBackground = true }.Start();
*/
}

public void AllPlayerUsePassiveSkill()


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

@@ -14,6 +14,6 @@ namespace Preparation.Interface
public bool CanMove { get; set; }
public bool IsResetting { get; set; } // reviving
public int Radius { get; } // if Square, Radius equals half length of one side
protected bool IgnoreCollide(IGameObj targetObj); // 忽略碰撞,在具体类中实现
public bool IgnoreCollideExecutor(IGameObj targetObj); // 忽略碰撞,在具体类中实现
}
}

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

@@ -18,8 +18,10 @@ namespace Preparation.Interface
// 会移动的只有子弹和人物,都是Circle
if (!targetObj.IsRigid || targetObj.ID == ID)
return false;
if (IgnoreCollide(targetObj))

if (IgnoreCollideExecutor(targetObj) || targetObj.IgnoreCollideExecutor(this))
return false;

if (targetObj.Shape == ShapeType.Circle)
{
return XY.Distance(nextPos, targetObj.Position) < targetObj.Radius + Radius;


+ 3
- 2
logic/规则Logic.md View File

@@ -208,10 +208,11 @@
- 实际上救援或治疗不同的人是有效的

### 破译与逃脱
- 每张地图都有10台电机,求生者需要破译其中的7台,并开启任意一个大门后从任意一个开启的大门- 逃脱,亦或者在只剩1名求生者的情况下从紧急出口逃脱;
- 每张地图都有10台电机,求生者需要破译其中的7台,并开启任意一个大门后从任意一个开启的大门逃脱,亦或者在只剩1名求生者的情况下从紧急出口逃脱;
- 求生者和监管者在靠近电机时,可以看到电机的破译进度条。
- 紧急出口会在电机破译完成3台的情况下在地图的3-5个固定紧急出口刷新点之一随机刷新。
- 当求生者只剩1名时,紧急出口盖将会自动打开,该求生者可从紧急出口逃脱。
- 紧急出口与大门对于人有碰撞体积
- 当求生者只剩1名时,紧急出口将会自动打开,该求生者可从紧急出口逃脱。
- 开启大门所需时间为18秒。
- 大门开启的进度不清空
- 一个大门同时最多可以由一人开启


Loading…
Cancel
Save