Browse Source

chore: 🎨 add some notes

dev
shangfengh 2 years ago
parent
commit
02231accf2
3 changed files with 14 additions and 13 deletions
  1. +12
    -11
      logic/GameClass/GameObj/Character/Character.cs
  2. +1
    -1
      logic/GameClass/GameObj/Moveable.cs
  3. +1
    -1
      logic/Server/CopyInfo.cs

+ 12
- 11
logic/GameClass/GameObj/Character/Character.cs View File

@@ -8,14 +8,6 @@ namespace GameClass.GameObj
{ {
public partial class Character : Moveable, ICharacter // 负责人LHR摆烂终了 public partial class Character : Moveable, ICharacter // 负责人LHR摆烂终了
{ {

private readonly ReaderWriterLockSlim hpReaderWriterLock = new();
public ReaderWriterLockSlim HPReadWriterLock => hpReaderWriterLock;
private readonly object vampireLock = new();
public object VampireLock => vampire;
private readonly object inventoryLock = new();
public object InventoryLock => inventoryLock;

#region 装弹、攻击相关的基本属性及方法 #region 装弹、攻击相关的基本属性及方法
private readonly object attackLock = new(); private readonly object attackLock = new();
/// <summary> /// <summary>
@@ -79,17 +71,17 @@ namespace GameClass.GameObj
private int bulletNum; private int bulletNum;
private int updateTimeOfBulletNum = 0; private int updateTimeOfBulletNum = 0;


public int UpdateBulletNum(int time)
public int UpdateBulletNum(int time)//通过该函数获取真正的bulletNum
{ {
lock (attackLock) lock (attackLock)
{ {
if (bulletNum < maxBulletNum)
if (bulletNum < maxBulletNum && time - updateTimeOfBulletNum >= cd)
{ {
int add = Math.Min(maxBulletNum - bulletNum, (time - updateTimeOfBulletNum) / cd); int add = Math.Min(maxBulletNum - bulletNum, (time - updateTimeOfBulletNum) / cd);
updateTimeOfBulletNum += add * cd; updateTimeOfBulletNum += add * cd;
return (bulletNum += add); return (bulletNum += add);
} }
return maxBulletNum;
return bulletNum;
} }
} }


@@ -195,6 +187,9 @@ namespace GameClass.GameObj
} }
#endregion #endregion
#region 血量相关的基本属性及方法 #region 血量相关的基本属性及方法
private readonly ReaderWriterLockSlim hpReaderWriterLock = new();
public ReaderWriterLockSlim HPReadWriterLock => hpReaderWriterLock;

private long maxHp; private long maxHp;
public long MaxHp public long MaxHp
{ {
@@ -285,6 +280,9 @@ namespace GameClass.GameObj
} }
} }


private readonly object vampireLock = new();
public object VampireLock => vampire;

private double vampire = 0; // 回血率:0-1之间 private double vampire = 0; // 回血率:0-1之间
public double Vampire public double Vampire
{ {
@@ -620,6 +618,9 @@ namespace GameClass.GameObj
} }


#region 道具和buff相关属性、方法 #region 道具和buff相关属性、方法
private readonly object inventoryLock = new();
public object InventoryLock => inventoryLock;

private Gadget[] propInventory = new Gadget[GameData.maxNumOfPropInPropInventory] private Gadget[] propInventory = new Gadget[GameData.maxNumOfPropInPropInventory]
{new NullProp(), new NullProp(),new NullProp() }; {new NullProp(), new NullProp(),new NullProp() };
public Gadget[] PropInventory public Gadget[] PropInventory


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

@@ -8,7 +8,7 @@ namespace GameClass.GameObj
{ {
protected readonly object actionLock = new(); protected readonly object actionLock = new();
public object ActionLock => actionLock; public object ActionLock => actionLock;
//player.actionLock>其他.actionLock
//player.actionLock>其他.actionLock/其他Lock,应当避免两个player的actionlock互锁
private readonly ReaderWriterLockSlim moveReaderWriterLock = new(); private readonly ReaderWriterLockSlim moveReaderWriterLock = new();
public ReaderWriterLockSlim MoveReaderWriterLock => moveReaderWriterLock; public ReaderWriterLockSlim MoveReaderWriterLock => moveReaderWriterLock;
//规定moveReaderWriterLock<actionLock //规定moveReaderWriterLock<actionLock


+ 1
- 1
logic/Server/CopyInfo.cs View File

@@ -203,7 +203,7 @@ namespace Server
Type = Transformation.ToBulletType(bombedBullet.bulletHasBombed.TypeOfBullet), Type = Transformation.ToBulletType(bombedBullet.bulletHasBombed.TypeOfBullet),
X = bombedBullet.bulletHasBombed.Position.x, X = bombedBullet.bulletHasBombed.Position.x,
Y = bombedBullet.bulletHasBombed.Position.y, Y = bombedBullet.bulletHasBombed.Position.y,
FacingDirection = bombedBullet.FacingDirection.Angle(),
FacingDirection = bombedBullet.facingDirection.Angle(),
MappingId = bombedBullet.MappingID, MappingId = bombedBullet.MappingID,
BombRange = bombedBullet.bulletHasBombed.BulletBombRange BombRange = bombedBullet.bulletHasBombed.BulletBombRange
} }


Loading…
Cancel
Save