| @@ -138,13 +138,13 @@ namespace Constants | |||||
| SCCI int moveSpeed = basicStudentSpeed * 9 / 10; | SCCI int moveSpeed = basicStudentSpeed * 9 / 10; | ||||
| SCCI int maxHp = basicHp * 10; | SCCI int maxHp = basicHp * 10; | ||||
| SCCI int maxAddiction = basicMaxGamingAddiction * 10; | SCCI int maxAddiction = basicMaxGamingAddiction * 10; | ||||
| SCCI int fixSpeed = (int)(basicFixSpeed * 0.4); | |||||
| SCCI int fixSpeed = (int)(basicFixSpeed * 50 / 123); | |||||
| SCCI int encourageSpeed = basicEncourageSpeed * 8 / 10; | SCCI int encourageSpeed = basicEncourageSpeed * 8 / 10; | ||||
| SCCI double concealment = 0.5; | SCCI double concealment = 0.5; | ||||
| SCCI int alertnessRadius = basicStudentAlertnessRadius * 3 / 4; | |||||
| SCCI int alertnessRadius = basicStudentAlertnessRadius * 2 / 3; | |||||
| SCCI int viewRange = basicStudentViewRange * 8 / 10; | SCCI int viewRange = basicStudentViewRange * 8 / 10; | ||||
| SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking; | SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking; | ||||
| SCCI int speedOfClimbingThroughWindows = (int)(basicStudentSpeedOfClimbingThroughWindows * 0.82); | |||||
| SCCI int speedOfClimbingThroughWindows = (int)(basicStudentSpeedOfClimbingThroughWindows * 1000 / 1222); | |||||
| SCCI int speedOfOpenChest = basicSpeedOfOpenChest; | SCCI int speedOfOpenChest = basicSpeedOfOpenChest; | ||||
| }; | }; | ||||
| @@ -377,7 +377,7 @@ namespace Constants | |||||
| struct Strike | struct Strike | ||||
| { | { | ||||
| SCCI double BulletBombRange = 0; | SCCI double BulletBombRange = 0; | ||||
| SSC double BulletAttackRange = basicAttackShortRange; | |||||
| SCCI double BulletAttackRange = basicAttackShortRange; | |||||
| SCCI int ap = basicApOfTricker * 16 / 15; | SCCI int ap = basicApOfTricker * 16 / 15; | ||||
| SCCI int Speed = basicBulletMoveSpeed * 125 / 148; | SCCI int Speed = basicBulletMoveSpeed * 125 / 148; | ||||
| SCCI bool IsRemoteAttack = false; | SCCI bool IsRemoteAttack = false; | ||||
| @@ -385,7 +385,7 @@ namespace Constants | |||||
| SCCI int CastTime = basicCastTime * 16 / 25; | SCCI int CastTime = basicCastTime * 16 / 25; | ||||
| SCCI int Backswing = basicBackswing; | SCCI int Backswing = basicBackswing; | ||||
| SCCI int RecoveryFromHit = basicRecoveryFromHit; | SCCI int RecoveryFromHit = basicRecoveryFromHit; | ||||
| SCCI int cd = basicBackswing * 3 / 4; | |||||
| SCCI int cd = basicBackswing; | |||||
| SCCI int maxBulletNum = 1; | SCCI int maxBulletNum = 1; | ||||
| }; | }; | ||||
| } // namespace Constants | } // namespace Constants | ||||
| @@ -159,14 +159,14 @@ class Teacher: | |||||
| moveSpeed = (int)(0.9 * Constants.basicStudentSpeed) | moveSpeed = (int)(0.9 * Constants.basicStudentSpeed) | ||||
| maxHp = (int)(10.0 * Constants.basicHp) | maxHp = (int)(10.0 * Constants.basicHp) | ||||
| maxAddiction = (int)(10.0 * Constants.basicMaxGamingAddiction) | maxAddiction = (int)(10.0 * Constants.basicMaxGamingAddiction) | ||||
| LearnSpeed = (int)(0.4 * Constants.basicLearnSpeed) | |||||
| LearnSpeed = (int)( Constants.basicLearnSpeed* 50//123) | |||||
| EncourageSpeed = (int)(0.8 * Constants.basicEncourageSpeed) | EncourageSpeed = (int)(0.8 * Constants.basicEncourageSpeed) | ||||
| concealment = 0.5 * Constants.basicConcealment | concealment = 0.5 * Constants.basicConcealment | ||||
| alertnessRadius = (int)(0.75 * Constants.basicStudentAlertnessRadius) | |||||
| alertnessRadius = (int)(Constants.basicStudentAlertnessRadius * 2 // 3) | |||||
| viewRange = (int)(0.8 * Constants.basicStudentViewRange) | viewRange = (int)(0.8 * Constants.basicStudentViewRange) | ||||
| speedOfOpeningOrLocking = (int)(1.0 * Constants.basicSpeedOfOpeningOrLocking) | speedOfOpeningOrLocking = (int)(1.0 * Constants.basicSpeedOfOpeningOrLocking) | ||||
| speedOfClimbingThroughWindows = (int)( | speedOfClimbingThroughWindows = (int)( | ||||
| 0.82 * Constants.basicStudentSpeedOfClimbingThroughWindows | |||||
| Constants.basicStudentSpeedOfClimbingThroughWindows* 1000 // 1222 | |||||
| ) | ) | ||||
| speedOfOpenChest = (int)(1.0 * Constants.basicSpeedOfOpenChest) | speedOfOpenChest = (int)(1.0 * Constants.basicSpeedOfOpenChest) | ||||
| @@ -197,9 +197,7 @@ class Robot: | |||||
| alertnessRadius = (int)(0.0 * Constants.basicStudentAlertnessRadius) | alertnessRadius = (int)(0.0 * Constants.basicStudentAlertnessRadius) | ||||
| viewRange = (int)(0.0 * Constants.basicStudentViewRange) | viewRange = (int)(0.0 * Constants.basicStudentViewRange) | ||||
| speedOfOpeningOrLocking = (int)(0.0 * Constants.basicSpeedOfOpeningOrLocking) | speedOfOpeningOrLocking = (int)(0.0 * Constants.basicSpeedOfOpeningOrLocking) | ||||
| speedOfClimbingThroughWindows = (int)( | |||||
| 0.0008 * Constants.basicStudentSpeedOfClimbingThroughWindows | |||||
| ) | |||||
| speedOfClimbingThroughWindows = 1 | |||||
| speedOfOpenChest = (int)(0.8 * Constants.basicSpeedOfOpenChest) | speedOfOpenChest = (int)(0.8 * Constants.basicSpeedOfOpenChest) | ||||
| @@ -209,7 +207,7 @@ class TechOtaku: | |||||
| maxAddiction = (int)(1.0 * Constants.basicMaxGamingAddiction) | maxAddiction = (int)(1.0 * Constants.basicMaxGamingAddiction) | ||||
| LearnSpeed = (int)(0.9 * Constants.basicLearnSpeed) | LearnSpeed = (int)(0.9 * Constants.basicLearnSpeed) | ||||
| EncourageSpeed = (int)(1.0 * Constants.basicEncourageSpeed) | EncourageSpeed = (int)(1.0 * Constants.basicEncourageSpeed) | ||||
| concealment = 1.0 * Constants.basicConcealment | |||||
| concealment = 1.1 * Constants.basicConcealment | |||||
| alertnessRadius = (int)(1.0 * Constants.basicStudentAlertnessRadius) | alertnessRadius = (int)(1.0 * Constants.basicStudentAlertnessRadius) | ||||
| viewRange = (int)(0.9 * Constants.basicStudentViewRange) | viewRange = (int)(0.9 * Constants.basicStudentViewRange) | ||||
| speedOfOpeningOrLocking = (int)(1.0 * Constants.basicSpeedOfOpeningOrLocking) | speedOfOpeningOrLocking = (int)(1.0 * Constants.basicSpeedOfOpeningOrLocking) | ||||
| @@ -296,7 +294,7 @@ class UseKnife: | |||||
| class UseRobot: | class UseRobot: | ||||
| skillCD = (int)(0.0667 * Constants.commonSkillCD) | |||||
| skillCD = (int)(2 * Constants.commonSkillCD // 30) | |||||
| durationTime = (int)(0.0 * Constants.commonSkillTime) | durationTime = (int)(0.0 * Constants.commonSkillTime) | ||||
| @@ -306,7 +304,7 @@ class WriteAnswers: | |||||
| class SummonGolem: | class SummonGolem: | ||||
| skillCD = (int)(1.25 * Constants.commonSkillCD) | |||||
| skillCD = (int)(4 * Constants.commonSkillCD//3) | |||||
| durationTime = (int)(6.0 * Constants.commonSkillTime) | durationTime = (int)(6.0 * Constants.commonSkillTime) | ||||
| @@ -366,5 +364,5 @@ class Strike: | |||||
| CastTime = Constants.basicCastTime * 16 // 25 | CastTime = Constants.basicCastTime * 16 // 25 | ||||
| Backswing = Constants.basicBackswing | Backswing = Constants.basicBackswing | ||||
| RecoveryFromHit = Constants.basicRecoveryFromHit | RecoveryFromHit = Constants.basicRecoveryFromHit | ||||
| cd = Constants.basicBackswing * 3 // 4 | |||||
| cd = Constants.basicBackswing | |||||
| maxBulletNum = 1 | maxBulletNum = 1 | ||||
| @@ -52,7 +52,7 @@ namespace GameClass.GameObj | |||||
| public Bullet(Character player, int radius, XY Position) : | public Bullet(Character player, int radius, XY Position) : | ||||
| base(Position, radius, GameObjType.Bullet) | base(Position, radius, GameObjType.Bullet) | ||||
| { | { | ||||
| this.canMove = true; | |||||
| this.ReSetCanMove(true); | |||||
| this.MoveSpeed = this.Speed; | this.MoveSpeed = this.Speed; | ||||
| this.hasSpear = player.TryUseSpear(); | this.hasSpear = player.TryUseSpear(); | ||||
| this.Parent = player; | this.Parent = player; | ||||
| @@ -50,7 +50,7 @@ namespace GameClass.GameObj | |||||
| protected Character(XY initPos, int initRadius, CharacterType characterType) : | protected Character(XY initPos, int initRadius, CharacterType characterType) : | ||||
| base(initPos, initRadius, GameObjType.Character) | base(initPos, initRadius, GameObjType.Character) | ||||
| { | { | ||||
| this.canMove = true; | |||||
| this.ReSetCanMove(true); | |||||
| this.score = 0; | this.score = 0; | ||||
| this.buffManager = new BuffManager(); | this.buffManager = new BuffManager(); | ||||
| this.occupation = OccupationFactory.FindIOccupation(characterType); | this.occupation = OccupationFactory.FindIOccupation(characterType); | ||||
| @@ -362,7 +362,7 @@ namespace GameClass.GameObj | |||||
| lock (actionLock) | lock (actionLock) | ||||
| { | { | ||||
| if (playerState == PlayerStateType.Moving) | if (playerState == PlayerStateType.Moving) | ||||
| return (IsMoving == 1) ? PlayerStateType.Moving : PlayerStateType.Null; | |||||
| return (IsMoving) ? PlayerStateType.Moving : PlayerStateType.Null; | |||||
| return playerState; | return playerState; | ||||
| } | } | ||||
| } | } | ||||
| @@ -594,17 +594,9 @@ namespace GameClass.GameObj | |||||
| { | { | ||||
| lock (actionLock) | lock (actionLock) | ||||
| { | { | ||||
| MoveReaderWriterLock.EnterWriteLock(); | |||||
| try | |||||
| { | |||||
| canMove = false; | |||||
| isRemoved = true; | |||||
| } | |||||
| finally | |||||
| { | |||||
| MoveReaderWriterLock.ExitWriteLock(); | |||||
| } | |||||
| playerState = playerStateType; | |||||
| TryToRemove(); | |||||
| ReSetCanMove(false); | |||||
| SetPlayerState(playerStateType); | |||||
| position = GameData.PosWhoDie; | position = GameData.PosWhoDie; | ||||
| } | } | ||||
| } | } | ||||
| @@ -29,40 +29,23 @@ namespace GameClass.GameObj | |||||
| protected XY facingDirection = new(1, 0); | protected XY facingDirection = new(1, 0); | ||||
| public abstract XY FacingDirection { get; } | public abstract XY FacingDirection { get; } | ||||
| protected bool canMove; | |||||
| public abstract bool CanMove { get; } | public abstract bool CanMove { get; } | ||||
| public abstract bool IsRigid { get; } | public abstract bool IsRigid { get; } | ||||
| public abstract ShapeType Shape { get; } | public abstract ShapeType Shape { get; } | ||||
| protected bool isRemoved = false; | |||||
| public virtual bool IsRemoved | |||||
| protected int isRemoved = 0; | |||||
| public bool IsRemoved | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| gameObjReaderWriterLock.EnterReadLock(); | |||||
| try | |||||
| { | |||||
| return isRemoved; | |||||
| } | |||||
| finally | |||||
| { | |||||
| gameObjReaderWriterLock.ExitReadLock(); | |||||
| } | |||||
| return (Interlocked.CompareExchange(ref isRemoved, 0, 0) == 1); | |||||
| } | } | ||||
| } | } | ||||
| public virtual void TryToRemove() | public virtual void TryToRemove() | ||||
| { | { | ||||
| gameObjReaderWriterLock.EnterWriteLock(); | |||||
| try | |||||
| { | |||||
| isRemoved = true; | |||||
| } | |||||
| finally | |||||
| { | |||||
| gameObjReaderWriterLock.ExitWriteLock(); | |||||
| } | |||||
| Interlocked.Exchange(ref isRemoved, 1); | |||||
| } | } | ||||
| public int Radius { get; } | public int Radius { get; } | ||||
| @@ -48,10 +48,10 @@ namespace GameClass.GameObj | |||||
| } | } | ||||
| private int isMoving = 0; | private int isMoving = 0; | ||||
| public int IsMoving | |||||
| public bool IsMoving | |||||
| { | { | ||||
| get => Interlocked.CompareExchange(ref isMoving, 0, 0); | |||||
| set => Interlocked.Exchange(ref isMoving, value); | |||||
| get => (Interlocked.CompareExchange(ref isMoving, 0, 0) == 1); | |||||
| set => Interlocked.Exchange(ref isMoving, value ? 1 : 0); | |||||
| } | } | ||||
| // 移动,改变坐标 | // 移动,改变坐标 | ||||
| @@ -62,15 +62,7 @@ namespace GameClass.GameObj | |||||
| { | { | ||||
| lock (actionLock) | lock (actionLock) | ||||
| { | { | ||||
| moveReaderWriterLock.EnterReadLock(); | |||||
| try | |||||
| { | |||||
| if (!canMove || isRemoved) return -1; | |||||
| } | |||||
| finally | |||||
| { | |||||
| moveReaderWriterLock.ExitReadLock(); | |||||
| } | |||||
| if (!CanMove || IsRemoved) return -1; | |||||
| if (stateNo != stateNum) return -1; | if (stateNo != stateNum) return -1; | ||||
| facingDirection = moveVec; | facingDirection = moveVec; | ||||
| this.position += moveVec; | this.position += moveVec; | ||||
| @@ -87,49 +79,15 @@ namespace GameClass.GameObj | |||||
| } | } | ||||
| } | } | ||||
| private int canMove; | |||||
| public override bool CanMove | public override bool CanMove | ||||
| { | { | ||||
| get | |||||
| { | |||||
| moveReaderWriterLock.EnterReadLock(); | |||||
| try | |||||
| { | |||||
| return canMove; | |||||
| } | |||||
| finally | |||||
| { | |||||
| moveReaderWriterLock.ExitReadLock(); | |||||
| } | |||||
| } | |||||
| get => (Interlocked.CompareExchange(ref canMove, 0, 0) == 1); | |||||
| } | } | ||||
| public void ReSetCanMove(bool value) | public void ReSetCanMove(bool value) | ||||
| { | { | ||||
| moveReaderWriterLock.EnterWriteLock(); | |||||
| try | |||||
| { | |||||
| canMove = value; | |||||
| } | |||||
| finally | |||||
| { | |||||
| moveReaderWriterLock.ExitWriteLock(); | |||||
| } | |||||
| } | |||||
| public override bool IsRemoved | |||||
| { | |||||
| get | |||||
| { | |||||
| moveReaderWriterLock.EnterReadLock(); | |||||
| try | |||||
| { | |||||
| return isRemoved; | |||||
| } | |||||
| finally | |||||
| { | |||||
| moveReaderWriterLock.ExitReadLock(); | |||||
| } | |||||
| } | |||||
| Interlocked.Exchange(ref canMove, (value ? 1 : 0)); | |||||
| } | } | ||||
| public bool IsAvailableForMove // 是否能接收移动指令 | public bool IsAvailableForMove // 是否能接收移动指令 | ||||
| @@ -138,15 +96,7 @@ namespace GameClass.GameObj | |||||
| { | { | ||||
| lock (actionLock) | lock (actionLock) | ||||
| { | { | ||||
| moveReaderWriterLock.EnterReadLock(); | |||||
| try | |||||
| { | |||||
| return isMoving == 0 && canMove && !isRemoved; | |||||
| } | |||||
| finally | |||||
| { | |||||
| moveReaderWriterLock.ExitReadLock(); | |||||
| } | |||||
| return !IsMoving && CanMove && !IsRemoved; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -24,7 +24,7 @@ namespace GameClass.GameObj | |||||
| public Gadget(XY initPos, int radius = GameData.propRadius) : | public Gadget(XY initPos, int radius = GameData.propRadius) : | ||||
| base(initPos, radius, GameObjType.Gadget) | base(initPos, radius, GameObjType.Gadget) | ||||
| { | { | ||||
| this.canMove = false; | |||||
| this.ReSetCanMove(false); | |||||
| this.MoveSpeed = GameData.propMoveSpeed; | this.MoveSpeed = GameData.propMoveSpeed; | ||||
| } | } | ||||
| } | } | ||||
| @@ -17,7 +17,7 @@ namespace GameClass.GameObj | |||||
| public Item(XY initPos, int radius = GameData.propRadius) : | public Item(XY initPos, int radius = GameData.propRadius) : | ||||
| base(initPos, radius, GameObjType.Item) | base(initPos, radius, GameObjType.Item) | ||||
| { | { | ||||
| this.canMove = false; | |||||
| this.ReSetCanMove(false); | |||||
| this.MoveSpeed = 0; | this.MoveSpeed = 0; | ||||
| } | } | ||||
| } | } | ||||
| @@ -102,7 +102,7 @@ namespace GameEngine | |||||
| lock (obj.ActionLock) | lock (obj.ActionLock) | ||||
| { | { | ||||
| if (!obj.IsAvailableForMove) { EndMove(obj); return; } | if (!obj.IsAvailableForMove) { EndMove(obj); return; } | ||||
| obj.IsMoving = 1; | |||||
| obj.IsMoving = true; | |||||
| } | } | ||||
| new Thread | new Thread | ||||
| @@ -139,7 +139,7 @@ namespace GameEngine | |||||
| if (isEnded) | if (isEnded) | ||||
| { | { | ||||
| obj.IsMoving = 0; | |||||
| obj.IsMoving = false; | |||||
| EndMove(obj); | EndMove(obj); | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -184,7 +184,7 @@ namespace GameEngine | |||||
| } | } | ||||
| if (isEnded) | if (isEnded) | ||||
| { | { | ||||
| obj.IsMoving = 0; | |||||
| obj.IsMoving = false; | |||||
| EndMove(obj); | EndMove(obj); | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -224,7 +224,7 @@ namespace GameEngine | |||||
| } | } | ||||
| } while (flag); | } while (flag); | ||||
| } | } | ||||
| obj.IsMoving = 0; // 结束移动 | |||||
| obj.IsMoving = false; // 结束移动 | |||||
| EndMove(obj); | EndMove(obj); | ||||
| } | } | ||||
| } | } | ||||
| @@ -8,7 +8,7 @@ namespace Preparation.Interface | |||||
| { | { | ||||
| object ActionLock { get; } | object ActionLock { get; } | ||||
| public int MoveSpeed { get; } | public int MoveSpeed { get; } | ||||
| public int IsMoving { get; set; } | |||||
| public bool IsMoving { get; set; } | |||||
| public bool IsRemoved { get; } | public bool IsRemoved { get; } | ||||
| public bool IsAvailableForMove { get; } | public bool IsAvailableForMove { get; } | ||||
| public long StateNum { get; } | public long StateNum { get; } | ||||