diff --git a/logic/Client/MainWindow.xaml.cs b/logic/Client/MainWindow.xaml.cs index 603597a..b42743c 100644 --- a/logic/Client/MainWindow.xaml.cs +++ b/logic/Client/MainWindow.xaml.cs @@ -851,7 +851,7 @@ namespace Client { case Protobuf.BulletType.BombBomb: { - double bombRange = 1.0*data.BombRange / Preparation.Utility.GameData.numOfPosGridPerCell; + double bombRange = 1.0 * data.BombRange / Preparation.Utility.GameData.numOfPosGridPerCell; Ellipse icon = new() { Width = 2 * bombRange * unitWidth, diff --git a/logic/GameClass/GameObj/Map/Map.cs b/logic/GameClass/GameObj/Map/Map.cs index adbfc49..75645fc 100644 --- a/logic/GameClass/GameObj/Map/Map.cs +++ b/logic/GameClass/GameObj/Map/Map.cs @@ -221,6 +221,20 @@ namespace GameClass.GameObj } return flag; } + public bool RemoveJustFromMap(GameObj gameObj) + { + GameObjLockDict[gameObj.Type].EnterWriteLock(); + bool flag; + try + { + flag = GameObjDict[gameObj.Type].Remove(gameObj); + } + finally + { + GameObjLockDict[gameObj.Type].ExitWriteLock(); + } + return flag; + } public void Add(GameObj gameObj) { GameObjLockDict[gameObj.Type].EnterWriteLock(); diff --git a/logic/GameRules.md b/logic/GameRules.md index f7903d1..377f1ab 100644 --- a/logic/GameRules.md +++ b/logic/GameRules.md @@ -1,5 +1,5 @@ # 规则 -V4.0 +V4.1 - [规则](#规则) - [简则](#简则) - [地图](#地图) diff --git a/logic/Gaming/AttackManager.cs b/logic/Gaming/AttackManager.cs index 312f336..44dbea5 100644 --- a/logic/Gaming/AttackManager.cs +++ b/logic/Gaming/AttackManager.cs @@ -6,6 +6,7 @@ using Preparation.Utility; using GameEngine; using Preparation.Interface; using Timothy.FrameRateTask; +using System.Numerics; namespace Gaming { @@ -73,22 +74,34 @@ namespace Gaming #endif bullet.CanMove = false; - if (gameMap.Remove(bullet) && bullet.BulletBombRange > 0) - gameMap.Add(new BombedBullet(bullet)); - if (bullet.BulletBombRange == 0) { + gameMap.Remove(bullet); if (objBeingShot == null) { - characterManager.BackSwing((Character?)bullet.Parent, bullet.Backswing); + characterManager.BackSwing((Character)bullet.Parent, bullet.Backswing); return; } BombObj(bullet, objBeingShot); - characterManager.BackSwing((Character?)bullet.Parent, bullet.RecoveryFromHit); + characterManager.BackSwing((Character)bullet.Parent, bullet.RecoveryFromHit); return; } + if (gameMap.Remove(bullet)) + { + BombedBullet bombedBullet = new(bullet); + gameMap.Add(bombedBullet); + new Thread + (() => + { + Thread.Sleep(GameData.frameDuration); + gameMap.RemoveJustFromMap(bombedBullet); + } + ) + { IsBackground = true }.Start(); + } + /*if (objBeingShot != null) { else if (objBeingShot is Bullet) //子弹不能相互引爆,若要更改这一设定,取消注释即可。 @@ -138,10 +151,10 @@ namespace Gaming if (objBeingShot == null) { - characterManager.BackSwing((Character?)bullet.Parent, bullet.Backswing); + characterManager.BackSwing((Character)bullet.Parent, bullet.Backswing); } else - characterManager.BackSwing((Character?)bullet.Parent, bullet.RecoveryFromHit); + characterManager.BackSwing((Character)bullet.Parent, bullet.RecoveryFromHit); } public bool Attack(Character player, double angle) @@ -169,35 +182,20 @@ namespace Gaming if (bullet.CastTime > 0) { characterManager.SetPlayerState(player, PlayerStateType.TryingToAttack); - - new Thread + if (bullet.IsRemoteAttack) + { + new Thread (() => { - new FrameRateTaskExecutor( - loopCondition: () => player.PlayerState == PlayerStateType.TryingToAttack && gameMap.Timer.IsGaming, - loopToDo: () => + Thread.Sleep(bullet.CastTime); + if (player.PlayerState == PlayerStateType.TryingToAttack) { - }, - timeInterval: GameData.frameDuration, - finallyReturn: () => 0, - maxTotalDuration: bullet.CastTime - ) - - .Start(); - - if (gameMap.Timer.IsGaming) - { - if (player.PlayerState == PlayerStateType.TryingToAttack) - { - characterManager.SetPlayerState(player); - } - else - bullet.IsMoving = false; - gameMap.Remove(bullet); + characterManager.SetPlayerState(player); } } ) - { IsBackground = true }.Start(); + { IsBackground = true }.Start(); + } } } if (bullet != null) diff --git a/logic/Gaming/CharacterManager .cs b/logic/Gaming/CharacterManager .cs index 3b7a11e..e5242a0 100644 --- a/logic/Gaming/CharacterManager .cs +++ b/logic/Gaming/CharacterManager .cs @@ -354,9 +354,9 @@ namespace Gaming else TryBeAwed(student, bullet); } - public bool BackSwing(Character? player, int time) + public bool BackSwing(Character player, int time) { - if (player == null || time <= 0) return false; + if (time <= 0) return false; if (player.PlayerState == PlayerStateType.Swinging || (!player.Commandable() && player.PlayerState != PlayerStateType.TryingToAttack)) return false; SetPlayerState(player, PlayerStateType.Swinging); diff --git a/logic/Server/CopyInfo.cs b/logic/Server/CopyInfo.cs index ba57920..d255068 100644 --- a/logic/Server/CopyInfo.cs +++ b/logic/Server/CopyInfo.cs @@ -148,6 +148,7 @@ namespace Server { BulletMessage = new() { + Type = Transformation.ToBulletType(bullet.TypeOfBullet), X = bullet.Position.x, Y = bullet.Position.y, FacingDirection = bullet.FacingDirection.Angle(), @@ -184,6 +185,7 @@ namespace Server { BombedBulletMessage = new() { + Type = Transformation.ToBulletType(bombedBullet.bulletHasBombed.TypeOfBullet), X = bombedBullet.bulletHasBombed.Position.x, Y = bombedBullet.bulletHasBombed.Position.y, FacingDirection = bombedBullet.FacingDirection.Angle(), @@ -191,6 +193,7 @@ namespace Server BombRange = bombedBullet.bulletHasBombed.BulletBombRange } }; + // Debugger.Output(bombedBullet, bombedBullet.Place.ToString()+" "+bombedBullet.Position.ToString()); return msg; }