| @@ -8,7 +8,8 @@ namespace GameClass.GameObj | |||||
| public override ShapeType Shape => ShapeType.Circle; | public override ShapeType Shape => ShapeType.Circle; | ||||
| public override bool IsRigid => false; | public override bool IsRigid => false; | ||||
| public long MappingID { get; } | public long MappingID { get; } | ||||
| public Bullet bulletHasBombed; | |||||
| public readonly Bullet bulletHasBombed; | |||||
| public readonly XY facingDirection; | |||||
| public BombedBullet(Bullet bullet) : | public BombedBullet(Bullet bullet) : | ||||
| base(bullet.Position, bullet.Radius, GameObjType.BombedBullet) | base(bullet.Position, bullet.Radius, GameObjType.BombedBullet) | ||||
| @@ -88,17 +88,6 @@ namespace GameClass.GameObj | |||||
| } | } | ||||
| } | } | ||||
| private int selfHealingTimes = 1;//剩余的自愈次数 | |||||
| public int SelfHealingTimes | |||||
| { | |||||
| get => selfHealingTimes; | |||||
| set | |||||
| { | |||||
| lock (gameObjLock) | |||||
| selfHealingTimes = (value > 0) ? value : 0; | |||||
| } | |||||
| } | |||||
| private int degreeOfTreatment = 0; | private int degreeOfTreatment = 0; | ||||
| public int DegreeOfTreatment | public int DegreeOfTreatment | ||||
| { | { | ||||
| @@ -17,6 +17,7 @@ namespace GameClass.GameObj | |||||
| public object InventoryLock => inventoryLock; | public object InventoryLock => inventoryLock; | ||||
| #region 装弹、攻击相关的基本属性及方法 | #region 装弹、攻击相关的基本属性及方法 | ||||
| private readonly object attackLock = new(); | |||||
| /// <summary> | /// <summary> | ||||
| /// 装弹冷却 | /// 装弹冷却 | ||||
| /// </summary> | /// </summary> | ||||
| @@ -25,7 +26,7 @@ namespace GameClass.GameObj | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| lock (actionLock) | |||||
| lock (attackLock) | |||||
| { | { | ||||
| return cd; | return cd; | ||||
| } | } | ||||
| @@ -36,7 +37,7 @@ namespace GameClass.GameObj | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| lock (actionLock) | |||||
| lock (attackLock) | |||||
| return orgCD; | return orgCD; | ||||
| } | } | ||||
| } | } | ||||
| @@ -47,14 +48,14 @@ namespace GameClass.GameObj | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| lock (actionLock) | |||||
| lock (attackLock) | |||||
| { | { | ||||
| return bulletOfPlayer; | return bulletOfPlayer; | ||||
| } | } | ||||
| } | } | ||||
| set | set | ||||
| { | { | ||||
| lock (actionLock) | |||||
| lock (attackLock) | |||||
| { | { | ||||
| bulletOfPlayer = value; | bulletOfPlayer = value; | ||||
| cd = orgCD = (BulletFactory.BulletCD(value)); | cd = orgCD = (BulletFactory.BulletCD(value)); | ||||
| @@ -69,7 +70,7 @@ namespace GameClass.GameObj | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| lock (actionLock) | |||||
| lock (attackLock) | |||||
| { | { | ||||
| return maxBulletNum; | return maxBulletNum; | ||||
| } | } | ||||
| @@ -80,7 +81,7 @@ namespace GameClass.GameObj | |||||
| public int UpdateBulletNum(int time) | public int UpdateBulletNum(int time) | ||||
| { | { | ||||
| lock (actionLock) | |||||
| lock (attackLock) | |||||
| { | { | ||||
| if (bulletNum < maxBulletNum) | if (bulletNum < maxBulletNum) | ||||
| { | { | ||||
| @@ -98,7 +99,7 @@ namespace GameClass.GameObj | |||||
| /// <returns>攻击操作发出的子弹</returns> | /// <returns>攻击操作发出的子弹</returns> | ||||
| public Bullet? Attack(double angle, int time) | public Bullet? Attack(double angle, int time) | ||||
| { | { | ||||
| lock (actionLock) | |||||
| lock (attackLock) | |||||
| { | { | ||||
| if (bulletOfPlayer == BulletType.Null) | if (bulletOfPlayer == BulletType.Null) | ||||
| return null; | return null; | ||||
| @@ -115,7 +116,7 @@ namespace GameClass.GameObj | |||||
| Bullet? bullet = BulletFactory.GetBullet(this, res, this.bulletOfPlayer); | Bullet? bullet = BulletFactory.GetBullet(this, res, this.bulletOfPlayer); | ||||
| if (bullet == null) return null; | if (bullet == null) return null; | ||||
| if (TryAddAp()) bullet.AddAP(GameData.ApPropAdd); | if (TryAddAp()) bullet.AddAP(GameData.ApPropAdd); | ||||
| facingDirection = new(angle, bullet.AttackDistance); | |||||
| FacingDirection = new(angle, bullet.AttackDistance); | |||||
| return bullet; | return bullet; | ||||
| } | } | ||||
| else | else | ||||
| @@ -26,9 +26,6 @@ namespace GameClass.GameObj | |||||
| protected XY position; | protected XY position; | ||||
| public abstract XY Position { get; } | public abstract XY Position { get; } | ||||
| protected XY facingDirection = new(1, 0); | |||||
| public abstract XY FacingDirection { get; } | |||||
| public abstract bool CanMove { get; } | public abstract bool CanMove { get; } | ||||
| public abstract bool IsRigid { get; } | public abstract bool IsRigid { get; } | ||||
| @@ -7,8 +7,6 @@ namespace GameClass.GameObj | |||||
| public override XY Position => position; | public override XY Position => position; | ||||
| public override XY FacingDirection => facingDirection; | |||||
| public override bool CanMove => false; | public override bool CanMove => false; | ||||
| public Immovable(XY initPos, int initRadius, GameObjType initType) : base(initPos, initRadius, initType) | public Immovable(XY initPos, int initRadius, GameObjType initType) : base(initPos, initRadius, initType) | ||||
| @@ -52,13 +52,19 @@ namespace GameClass.GameObj | |||||
| } | } | ||||
| } | } | ||||
| public override XY FacingDirection | |||||
| protected XY facingDirection = new(1, 0); | |||||
| public XY FacingDirection | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| lock (actionLock) | lock (actionLock) | ||||
| return facingDirection; | return facingDirection; | ||||
| } | } | ||||
| set | |||||
| { | |||||
| lock (actionLock) | |||||
| facingDirection = value; | |||||
| } | |||||
| } | } | ||||
| private int isMoving = 0; | private int isMoving = 0; | ||||
| @@ -7,7 +7,6 @@ namespace Preparation.Interface | |||||
| public GameObjType Type { get; } | public GameObjType Type { get; } | ||||
| public long ID { get; } | public long ID { get; } | ||||
| public XY Position { get; } // if Square, Pos equals the center | public XY Position { get; } // if Square, Pos equals the center | ||||
| public XY FacingDirection { get; } | |||||
| public bool IsRigid { get; } | public bool IsRigid { get; } | ||||
| public ShapeType Shape { get; } | public ShapeType Shape { get; } | ||||
| public bool CanMove { get; } | public bool CanMove { get; } | ||||
| @@ -6,6 +6,7 @@ namespace Preparation.Interface | |||||
| { | { | ||||
| public interface IMoveable : IGameObj | public interface IMoveable : IGameObj | ||||
| { | { | ||||
| public XY FacingDirection { get; set; } | |||||
| object ActionLock { get; } | object ActionLock { get; } | ||||
| public int MoveSpeed { get; } | public int MoveSpeed { get; } | ||||
| public bool IsMoving { get; set; } | public bool IsMoving { get; set; } | ||||