diff --git a/logic/GameClass/GameObj/Bullet/BombedBullet.cs b/logic/GameClass/GameObj/Bullet/BombedBullet.cs
index b4afd1f..492ecb8 100644
--- a/logic/GameClass/GameObj/Bullet/BombedBullet.cs
+++ b/logic/GameClass/GameObj/Bullet/BombedBullet.cs
@@ -3,7 +3,7 @@
namespace GameClass.GameObj
{
// 为方便界面组做子弹爆炸特效,现引入“爆炸中的子弹”,在每帧发送给界面组
- public sealed class BombedBullet : GameObj
+ public sealed class BombedBullet : Immovable
{
public override ShapeType Shape => ShapeType.Circle;
public override bool IsRigid => false;
@@ -15,7 +15,7 @@ namespace GameClass.GameObj
{
this.bulletHasBombed = bullet;
this.MappingID = bullet.ID;
- this.FacingDirection = bullet.FacingDirection;
+ this.facingDirection = bullet.FacingDirection;
}
}
}
diff --git a/logic/GameClass/GameObj/Bullet/Bullet.cs b/logic/GameClass/GameObj/Bullet/Bullet.cs
index acada59..ff512bc 100644
--- a/logic/GameClass/GameObj/Bullet/Bullet.cs
+++ b/logic/GameClass/GameObj/Bullet/Bullet.cs
@@ -44,7 +44,7 @@ namespace GameClass.GameObj
public Bullet(Character player, int radius, XY Position) :
base(Position, radius, GameObjType.Bullet)
{
- this.CanMove = true;
+ this.canMove = true;
this.moveSpeed = this.Speed;
this.hasSpear = player.TryUseSpear();
this.Parent = player;
diff --git a/logic/GameClass/GameObj/Character/Character.Skill.cs b/logic/GameClass/GameObj/Character/Character.Skill.cs
index c835a6d..0ae23db 100644
--- a/logic/GameClass/GameObj/Character/Character.Skill.cs
+++ b/logic/GameClass/GameObj/Character/Character.Skill.cs
@@ -57,7 +57,7 @@ namespace GameClass.GameObj
protected Character(XY initPos, int initRadius, CharacterType characterType) :
base(initPos, initRadius, GameObjType.Character)
{
- this.CanMove = true;
+ this.canMove = true;
this.score = 0;
this.buffManager = new BuffManager();
this.occupation = OccupationFactory.FindIOccupation(characterType);
diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs
index aa799eb..ba00643 100644
--- a/logic/GameClass/GameObj/Character/Character.cs
+++ b/logic/GameClass/GameObj/Character/Character.cs
@@ -2,9 +2,6 @@
using Preparation.Utility;
using System;
using System.Collections.Generic;
-using System.Numerics;
-using System.Runtime.InteropServices;
-using System.Threading;
namespace GameClass.GameObj
{
@@ -58,10 +55,20 @@ namespace GameClass.GameObj
/// 进行一次攻击
///
/// 攻击操作发出的子弹
- public Bullet? Attack(XY pos)
+ public Bullet? Attack(double angle)
{
if (TrySubBulletNum())
- return BulletFactory.GetBullet(this, pos);
+ {
+ XY res = Position + new XY // 子弹紧贴人物生成。
+ (
+ (int)(Math.Abs((Radius + BulletFactory.BulletRadius(BulletOfPlayer)) * Math.Cos(angle))) * ((Math.Cos(angle) > 0) ? 1 : -1),
+ (int)(Math.Abs((Radius + BulletFactory.BulletRadius(BulletOfPlayer)) * Math.Sin(angle))) * ((Math.Sin(angle) > 0) ? 1 : -1)
+ );
+ Bullet? bullet = BulletFactory.GetBullet(this, res);
+ if (bullet == null) return null;
+ facingDirection = new(angle, bullet.BulletAttackRange);
+ return bullet;
+ }
else
return null;
}
@@ -362,9 +369,9 @@ namespace GameClass.GameObj
lock (gameObjLock)
{
playerState = playerStateType;
- CanMove = false;
+ canMove = false;
IsResetting = true;
- Position = GameData.PosWhoDie;
+ position = GameData.PosWhoDie;
}
}
#endregion
diff --git a/logic/GameClass/GameObj/GameObj.cs b/logic/GameClass/GameObj/GameObj.cs
index 0c9c301..0b7727c 100644
--- a/logic/GameClass/GameObj/GameObj.cs
+++ b/logic/GameClass/GameObj/GameObj.cs
@@ -24,18 +24,18 @@ namespace GameClass.GameObj
public long ID { get; }
protected XY position;
- public virtual XY Position { get; set; }
+ public abstract XY Position { get; }
protected XY facingDirection = new(1, 0);
- public virtual XY FacingDirection { get; set; }
+ public abstract XY FacingDirection { get; }
+
+ protected bool canMove;
+ public abstract bool CanMove { get; }
public abstract bool IsRigid { get; }
public abstract ShapeType Shape { get; }
- protected bool canMove;
- public virtual bool CanMove { get; set; }
-
public int Radius { get; }
public virtual bool IgnoreCollideExecutor(IGameObj targetObj) => false;
diff --git a/logic/GameClass/GameObj/Immovable.cs b/logic/GameClass/GameObj/Immovable.cs
new file mode 100644
index 0000000..6662d98
--- /dev/null
+++ b/logic/GameClass/GameObj/Immovable.cs
@@ -0,0 +1,19 @@
+using Preparation.Interface;
+using Preparation.Utility;
+
+namespace GameClass.GameObj
+{
+ public abstract class Immovable : GameObj
+ {
+
+ public override XY Position => position;
+
+ public override XY FacingDirection => facingDirection;
+
+ public override bool CanMove => false;
+
+ public Immovable(XY initPos, int initRadius, GameObjType initType) : base(initPos, initRadius, initType)
+ {
+ }
+ }
+}
diff --git a/logic/GameClass/GameObj/Map/Chest.cs b/logic/GameClass/GameObj/Map/Chest.cs
index 1cc8707..69a1ed9 100644
--- a/logic/GameClass/GameObj/Map/Chest.cs
+++ b/logic/GameClass/GameObj/Map/Chest.cs
@@ -5,12 +5,11 @@ namespace GameClass.GameObj
///
/// 箱子
///
- public class Chest : Tile
+ public class Chest : Immovable
{
public Chest(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Chest)
{
- this.CanMove = false;
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
diff --git a/logic/GameClass/GameObj/Map/Door.cs b/logic/GameClass/GameObj/Map/Door.cs
index c6e392a..2410421 100644
--- a/logic/GameClass/GameObj/Map/Door.cs
+++ b/logic/GameClass/GameObj/Map/Door.cs
@@ -6,7 +6,7 @@ namespace GameClass.GameObj
///
/// 门
///
- public class Door : Tile
+ public class Door : Immovable
{
public Door(XY initPos, PlaceType placeType) :
base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Door)
@@ -24,7 +24,6 @@ namespace GameClass.GameObj
doorNum = 6;
break;
}
- this.CanMove = false;
}
private readonly int doorNum;
diff --git a/logic/GameClass/GameObj/Map/Doorway.cs b/logic/GameClass/GameObj/Map/Doorway.cs
index 7be71ac..71b2017 100644
--- a/logic/GameClass/GameObj/Map/Doorway.cs
+++ b/logic/GameClass/GameObj/Map/Doorway.cs
@@ -6,12 +6,11 @@ namespace GameClass.GameObj
///
/// 出口
///
- public class Doorway : Tile
+ public class Doorway : Immovable
{
public Doorway(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Doorway)
{
- this.CanMove = false;
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
diff --git a/logic/GameClass/GameObj/Map/EmergencyExit.cs b/logic/GameClass/GameObj/Map/EmergencyExit.cs
index 25144b8..5e51daf 100644
--- a/logic/GameClass/GameObj/Map/EmergencyExit.cs
+++ b/logic/GameClass/GameObj/Map/EmergencyExit.cs
@@ -6,12 +6,11 @@ namespace GameClass.GameObj
///
/// 紧急出口
///
- public class EmergencyExit : Tile
+ public class EmergencyExit : Immovable
{
public EmergencyExit(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.EmergencyExit)
{
- this.CanMove = false;
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
diff --git a/logic/GameClass/GameObj/Map/Generator.cs b/logic/GameClass/GameObj/Map/Generator.cs
index 1252b74..204c0f3 100644
--- a/logic/GameClass/GameObj/Map/Generator.cs
+++ b/logic/GameClass/GameObj/Map/Generator.cs
@@ -5,12 +5,11 @@ namespace GameClass.GameObj
///
/// 发电机
///
- public class Generator : Tile
+ public class Generator : Immovable
{
public Generator(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Generator)
{
- this.CanMove = false;
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
diff --git a/logic/GameClass/GameObj/Map/Wall.cs b/logic/GameClass/GameObj/Map/Wall.cs
index 7d06537..8001b8d 100644
--- a/logic/GameClass/GameObj/Map/Wall.cs
+++ b/logic/GameClass/GameObj/Map/Wall.cs
@@ -5,12 +5,11 @@ namespace GameClass.GameObj
///
/// 墙体
///
- public class Wall : Tile
+ public class Wall : Immovable
{
public Wall(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Wall)
{
- this.CanMove = false;
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
diff --git a/logic/GameClass/GameObj/Map/Window.cs b/logic/GameClass/GameObj/Map/Window.cs
index 00585a1..864e58f 100644
--- a/logic/GameClass/GameObj/Map/Window.cs
+++ b/logic/GameClass/GameObj/Map/Window.cs
@@ -6,12 +6,11 @@ namespace GameClass.GameObj
///
/// 窗
///
- public class Window : Tile
+ public class Window : Immovable
{
public Window(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Window)
{
- this.CanMove = false;
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
diff --git a/logic/GameClass/GameObj/Moveable.cs b/logic/GameClass/GameObj/Moveable.cs
index 3a48ef3..b134e67 100644
--- a/logic/GameClass/GameObj/Moveable.cs
+++ b/logic/GameClass/GameObj/Moveable.cs
@@ -73,12 +73,13 @@ namespace GameClass.GameObj
lock (moveReaderWriterLock)
return canMove;
}
- set
+ }
+
+ public void ReSetCanMove(bool value)
+ {
+ lock (moveReaderWriterLock)
{
- lock (moveReaderWriterLock)
- {
- canMove = value;
- }
+ canMove = value;
}
}
diff --git a/logic/GameClass/GameObj/OutOfBoundBlock.cs b/logic/GameClass/GameObj/OutOfBoundBlock.cs
index 3cd88eb..8f0c45d 100644
--- a/logic/GameClass/GameObj/OutOfBoundBlock.cs
+++ b/logic/GameClass/GameObj/OutOfBoundBlock.cs
@@ -6,12 +6,11 @@ namespace GameClass.GameObj
///
/// 逻辑墙
///
- public class OutOfBoundBlock : GameObj, IOutOfBound
+ public class OutOfBoundBlock : Immovable, IOutOfBound
{
public OutOfBoundBlock(XY initPos) :
base(initPos, int.MaxValue, GameObjType.OutOfBoundBlock)
{
- this.CanMove = false;
}
public override bool IsRigid => true;
diff --git a/logic/GameClass/GameObj/PickedProp.cs b/logic/GameClass/GameObj/PickedProp.cs
index fc070db..c924c82 100644
--- a/logic/GameClass/GameObj/PickedProp.cs
+++ b/logic/GameClass/GameObj/PickedProp.cs
@@ -3,7 +3,7 @@ using System;
namespace GameClass.GameObj
{
// 为方便界面组做道具拾起特效,现引入“被捡起的道具”,在每帧发送给界面组
- public class PickedProp : GameObj
+ public class PickedProp : Immovable
{
public override ShapeType Shape => ShapeType.Circle;
public override bool IsRigid => false;
diff --git a/logic/GameClass/GameObj/Prop.cs b/logic/GameClass/GameObj/Prop.cs
index c3626de..93848e8 100644
--- a/logic/GameClass/GameObj/Prop.cs
+++ b/logic/GameClass/GameObj/Prop.cs
@@ -22,7 +22,7 @@ namespace GameClass.GameObj
public Prop(XY initPos, int radius = GameData.PropRadius) :
base(initPos, radius, GameObjType.Prop)
{
- this.CanMove = false;
+ this.canMove = false;
this.moveSpeed = GameData.PropMoveSpeed;
}
}
diff --git a/logic/GameClass/GameObj/Tile.cs b/logic/GameClass/GameObj/Tile.cs
deleted file mode 100644
index ce71673..0000000
--- a/logic/GameClass/GameObj/Tile.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Preparation.Interface;
-using Preparation.Utility;
-
-namespace GameClass.GameObj
-{
- ///
- /// 一切游戏元素的总基类,与THUAI4不同,继承IMoveable接口(出于一切物体其实都是可运动的指导思想)——LHR
- ///
- public abstract class Tile : GameObj
- {
-
- public override XY Position => position;
-
- public override XY FacingDirection => facingDirection;
-
- public override bool CanMove => false;
-
- public Tile(XY initPos, int initRadius, GameObjType initType) : base(initPos, initRadius, initType)
- {
- }
- }
-}
diff --git a/logic/Gaming/ActionManager.cs b/logic/Gaming/ActionManager.cs
index 2e142e1..5fe275c 100644
--- a/logic/Gaming/ActionManager.cs
+++ b/logic/Gaming/ActionManager.cs
@@ -267,7 +267,7 @@ namespace Gaming
{
Prop prop = chestToOpen.PropInChest[i];
chestToOpen.PropInChest[i] = new NullProp();
- prop.Position = player.Position;
+ prop.ReSetPos(player.Position);
gameMap.Add(prop);
}
}
@@ -323,7 +323,7 @@ namespace Gaming
return;
}
- player.Position = windowToPlayer + windowForClimb.Position;
+ player.ReSetPos(windowToPlayer + windowForClimb.Position);
player.MoveSpeed = player.SpeedOfClimbingThroughWindows;
moveEngine.MoveObj(player, (int)(windowToPlayer.Length() * 3.0 * 1000 / player.MoveSpeed), (-1 * windowToPlayer).Angle());
@@ -339,7 +339,7 @@ namespace Gaming
)
.Start();
XY PosJumpOff = windowForClimb.Position - 2 * windowToPlayer;
- player.Position = PosJumpOff;
+ player.ReSetPos(PosJumpOff);
player.MoveSpeed = player.ReCalculateBuff(BuffType.AddSpeed, player.OrgMoveSpeed, GameData.MaxSpeed, GameData.MinSpeed);
windowForClimb.WhoIsClimbing = null;
// gameMap.Remove(addWall);
diff --git a/logic/Gaming/AttackManager.cs b/logic/Gaming/AttackManager.cs
index 69203b1..f35960a 100644
--- a/logic/Gaming/AttackManager.cs
+++ b/logic/Gaming/AttackManager.cs
@@ -33,7 +33,7 @@ namespace Gaming
Debugger.Output(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount64);
if (obj.CanMove && ((Bullet)obj).TypeOfBullet != BulletType.JumpyDumpty)
BulletBomb((Bullet)obj, null);
- obj.CanMove = false;
+ obj.ReSetCanMove(false);
}
);
this.characterManager = characterManager;
@@ -66,7 +66,7 @@ namespace Gaming
public bool TryRemoveBullet(Bullet bullet)
{
- bullet.CanMove = false;
+ bullet.ReSetCanMove(false);
if (gameMap.Remove(bullet))
{
if (bullet.BulletBombRange > 0)
@@ -172,20 +172,14 @@ namespace Gaming
Debugger.Output(player, player.CharacterType.ToString() + "Attack in " + player.BulletOfPlayer.ToString());
Debugger.Output(player, player.Position.ToString() + " " + player.Radius.ToString() + " " + BulletFactory.BulletRadius(player.BulletOfPlayer).ToString());
- XY res = player.Position + new XY // 子弹紧贴人物生成。
- (
- (int)(Math.Abs((player.Radius + BulletFactory.BulletRadius(player.BulletOfPlayer)) * Math.Cos(angle))) * ((Math.Cos(angle) > 0) ? 1 : -1),
- (int)(Math.Abs((player.Radius + BulletFactory.BulletRadius(player.BulletOfPlayer)) * Math.Sin(angle))) * ((Math.Sin(angle) > 0) ? 1 : -1)
- );
- Bullet? bullet = player.Attack(res);
+ Bullet? bullet = player.Attack(angle);
if (bullet != null)
{
- player.FacingDirection = new(angle, bullet.BulletAttackRange);
Debugger.Output(bullet, "Attack in " + bullet.Position.ToString());
bullet.AP += player.TryAddAp() ? GameData.ApPropAdd : 0;
- bullet.CanMove = true;
+ bullet.ReSetCanMove(true);
gameMap.Add(bullet);
moveEngine.MoveObj(bullet, (int)((bullet.BulletAttackRange - player.Radius - BulletFactory.BulletRadius(player.BulletOfPlayer)) * 1000 / bullet.MoveSpeed), angle); // 这里时间参数除出来的单位要是ms
if (bullet.CastTime > 0)
diff --git a/logic/Gaming/CharacterManager .cs b/logic/Gaming/CharacterManager .cs
index 92593a4..31a5b18 100644
--- a/logic/Gaming/CharacterManager .cs
+++ b/logic/Gaming/CharacterManager .cs
@@ -407,7 +407,7 @@ namespace Gaming
Prop? prop = player.UseProp(i);
if (prop != null)
{
- prop.Position = player.Position;
+ prop.ReSetPos(player.Position);
gameMap.Add(prop);
}
}
diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs
index 8378eba..8a0dd98 100644
--- a/logic/Gaming/Game.cs
+++ b/logic/Gaming/Game.cs
@@ -316,7 +316,7 @@ namespace Gaming
{
foreach (Character player in gameMap.GameObjDict[GameObjType.Character])
{
- player.CanMove = false;
+ player.ReSetCanMove(false);
}
}
gameMap.GameObjDict[keyValuePair.Key].Clear();
diff --git a/logic/Gaming/PropManager.cs b/logic/Gaming/PropManager.cs
index 57b18c9..9bf9714 100644
--- a/logic/Gaming/PropManager.cs
+++ b/logic/Gaming/PropManager.cs
@@ -124,7 +124,7 @@ namespace Gaming
if (prop.GetPropType() == PropType.Null)
return;
- prop.Position = player.Position;
+ prop.ReSetPos(player.Position);
gameMap.Add(prop);
}
diff --git a/logic/Preparation/Interface/IGameObj.cs b/logic/Preparation/Interface/IGameObj.cs
index 949e5e3..017226f 100644
--- a/logic/Preparation/Interface/IGameObj.cs
+++ b/logic/Preparation/Interface/IGameObj.cs
@@ -10,7 +10,7 @@ namespace Preparation.Interface
public XY FacingDirection { get; }
public bool IsRigid { get; }
public ShapeType Shape { get; }
- public bool CanMove { get; set; }
+ public bool CanMove { get; }
public int Radius { get; } // if Square, Radius equals half length of one side
public bool IgnoreCollideExecutor(IGameObj targetObj); // 忽略碰撞,在具体类中实现
}
diff --git a/logic/Preparation/Interface/IMoveable.cs b/logic/Preparation/Interface/IMoveable.cs
index bc8e8f9..7abe556 100644
--- a/logic/Preparation/Interface/IMoveable.cs
+++ b/logic/Preparation/Interface/IMoveable.cs
@@ -11,6 +11,7 @@ namespace Preparation.Interface
public bool IsResetting { get; set; } // reviving
public bool IsAvailable { get; }
public long MovingSetPos(XY moveVec);
+ public void ReSetCanMove(bool value);
public bool WillCollideWith(IGameObj? targetObj, XY nextPos) // 检查下一位置是否会和目标物碰撞
{
if (targetObj == null)
diff --git a/logic/Server/CopyInfo.cs b/logic/Server/CopyInfo.cs
index ff88b8b..9b4ff84 100644
--- a/logic/Server/CopyInfo.cs
+++ b/logic/Server/CopyInfo.cs
@@ -268,7 +268,6 @@ namespace Server
Y = chest.Position.y
}
};
- Debugger.Output(chest, chest.OpenStartTime.ToString());
int progress = (chest.WhoOpen != null) ? ((time - chest.OpenStartTime) * chest.WhoOpen.SpeedOfOpenChest) : 0;
msg.ChestMessage.Progress = (progress > GameData.degreeOfOpenedChest) ? GameData.degreeOfOpenedChest : progress;
return msg;