Browse Source

refactor: 🔒 lock the treatSpeed

dev
shangfengh 2 years ago
parent
commit
898d9af420
3 changed files with 12 additions and 6 deletions
  1. +1
    -1
      logic/GameClass/GameObj/Character/Character.Skill.cs
  2. +9
    -4
      logic/GameClass/GameObj/Character/Character.Student.cs
  3. +2
    -1
      logic/GameClass/GameObj/Moveable.cs

+ 1
- 1
logic/GameClass/GameObj/Character/Character.Skill.cs View File

@@ -36,7 +36,7 @@ namespace GameClass.GameObj
this.buffManager = new BuffManager();
this.occupation = OccupationFactory.FindIOccupation(characterType);
this.MaxHp = this.hp = Occupation.MaxHp;
this.MoveSpeed = this.OrgMoveSpeed = Occupation.MoveSpeed;
this.MoveSpeed = this.orgMoveSpeed = Occupation.MoveSpeed;
this.BulletOfPlayer = this.OriBulletOfPlayer = Occupation.InitBullet;
this.concealment = Occupation.Concealment;
this.alertnessRadius = Occupation.AlertnessRadius;


+ 9
- 4
logic/GameClass/GameObj/Character/Character.Student.cs View File

@@ -32,19 +32,24 @@ namespace GameClass.GameObj
/// </summary>
protected readonly int orgFixSpeed;

private readonly object treatLock = new();
protected int treatSpeed = GameData.basicTreatSpeed;
public int TreatSpeed
{
get => treatSpeed;
get
{
lock (treatLock)
return treatSpeed;
}
set
{
lock (gameObjLock)
lock (treatLock)
{
treatSpeed = value;
}
}
}
public int OrgTreatSpeed { get; protected set; }
protected readonly int orgTreatSpeed;

public int MaxGamingAddiction { get; protected set; }
private int gamingAddiction;
@@ -128,7 +133,7 @@ namespace GameClass.GameObj
public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType)
{
this.orgFixSpeed = this.fixSpeed = ((IStudentType)Occupation).FixSpeed;
this.TreatSpeed = this.OrgTreatSpeed = ((IStudentType)Occupation).TreatSpeed;
this.TreatSpeed = this.orgTreatSpeed = ((IStudentType)Occupation).TreatSpeed;
this.MaxGamingAddiction = ((IStudentType)Occupation).MaxGamingAddiction;
}
}


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

@@ -127,7 +127,8 @@ namespace GameClass.GameObj
/// <summary>
/// 原初移动速度
/// </summary>
public int OrgMoveSpeed { get; protected set; }
protected int orgMoveSpeed;
public int OrgMoveSpeed => orgMoveSpeed;

/* /// <summary>
/// 复活时数据重置


Loading…
Cancel
Save