diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs index 2de5c64..696e262 100644 --- a/logic/GameClass/GameObj/Character/Character.cs +++ b/logic/GameClass/GameObj/Character/Character.cs @@ -359,7 +359,7 @@ namespace GameClass.GameObj { get { - if (PlayerState == PlayerStateType.Null && IsMoving) return PlayerStateType.Moving; + if (playerState == PlayerStateType.Null && IsMoving) return PlayerStateType.Moving; return playerState; } set diff --git a/logic/GameClass/GameObj/Map/Generator.cs b/logic/GameClass/GameObj/Map/Generator.cs index 1b4d59b..97b8bab 100644 --- a/logic/GameClass/GameObj/Map/Generator.cs +++ b/logic/GameClass/GameObj/Map/Generator.cs @@ -16,26 +16,26 @@ namespace GameClass.GameObj public override bool IsRigid => true; public override ShapeType Shape => ShapeType.Square; - private int degreeOfFRepair = 0; - public int DegreeOfFRepair + private int degreeOfRepair = 0; + public int DegreeOfRepair { - get => degreeOfFRepair; + get => degreeOfRepair; set { lock (gameObjLock) { - if (degreeOfFRepair < GameData.degreeOfFixedGenerator)//不允许正常破坏已经修好的发电机 - if (value < 0) degreeOfFRepair = 0; - else degreeOfFRepair = value > GameData.degreeOfFixedGenerator ? GameData.degreeOfFixedGenerator : value; + if (degreeOfRepair < GameData.degreeOfFixedGenerator)//不允许正常破坏已经修好的发电机 + if (value < 0) degreeOfRepair = 0; + else degreeOfRepair = value > GameData.degreeOfFixedGenerator ? GameData.degreeOfFixedGenerator : value; } } } public bool Repair(int addDegree) { - if (DegreeOfFRepair == GameData.degreeOfFixedGenerator) return false; - DegreeOfFRepair += addDegree; - if (DegreeOfFRepair == GameData.degreeOfFixedGenerator) + if (DegreeOfRepair == GameData.degreeOfFixedGenerator) return false; + DegreeOfRepair += addDegree; + if (DegreeOfRepair == GameData.degreeOfFixedGenerator) return true; else return false; } diff --git a/logic/Gaming/ActionManager.cs b/logic/Gaming/ActionManager.cs index 6632946..0d21e32 100644 --- a/logic/Gaming/ActionManager.cs +++ b/logic/Gaming/ActionManager.cs @@ -2,6 +2,7 @@ using System.Threading; using GameClass.GameObj; using GameEngine; +using Preparation.Interface; using Preparation.Utility; using Timothy.FrameRateTask; @@ -21,7 +22,7 @@ namespace Gaming return true; } - public bool Stop(Character player) + public static bool Stop(Character player) { if (player.Commandable()) { @@ -55,7 +56,7 @@ namespace Gaming gameMap.GameObjLockDict[GameObjType.Generator].ExitReadLock(); } - if (generatorForFix == null || generatorForFix.DegreeOfFRepair == GameData.degreeOfFixedGenerator) + if (generatorForFix == null || generatorForFix.DegreeOfRepair == GameData.degreeOfFixedGenerator) return false; player.PlayerState = PlayerStateType.Fixing; @@ -64,7 +65,7 @@ namespace Gaming () => { new FrameRateTaskExecutor( - loopCondition: () => player.PlayerState == PlayerStateType.Fixing && gameMap.Timer.IsGaming && generatorForFix.DegreeOfFRepair < GameData.degreeOfFixedGenerator && GameData.ApproachToInteract(player.Position, generatorForFix.Position), + loopCondition: () => player.PlayerState == PlayerStateType.Fixing && gameMap.Timer.IsGaming && generatorForFix.DegreeOfRepair < GameData.degreeOfFixedGenerator && GameData.ApproachToInteract(player.Position, generatorForFix.Position), loopToDo: () => { generatorForFix.Repair(player.FixSpeed * GameData.frameDuration); @@ -74,7 +75,7 @@ namespace Gaming ) .Start(); - if (generatorForFix.DegreeOfFRepair >= GameData.degreeOfFixedGenerator) + if (generatorForFix.DegreeOfRepair >= GameData.degreeOfFixedGenerator) { Doorway exit = (Doorway)gameMap.GameObjDict[GameObjType.Doorway][1]; if (!exit.PowerSupply) @@ -84,7 +85,7 @@ namespace Gaming { int numOfFixedGenerator = 0; foreach (Generator generator in gameMap.GameObjDict[GameObjType.Generator]) - if (generator.DegreeOfFRepair == GameData.degreeOfFixedGenerator) + if (generator.DegreeOfRepair == GameData.degreeOfFixedGenerator) ++numOfFixedGenerator; if (numOfFixedGenerator >= GameData.numOfGeneratorRequiredForRepair) { @@ -284,7 +285,6 @@ namespace Gaming return true; } - public bool OpenChest(Character player) { if ((!player.Commandable()) || player.PlayerState == PlayerStateType.OpeningTheChest) @@ -320,7 +320,7 @@ namespace Gaming for (int i = 0; i < GameData.maxNumOfPropInChest; ++i) { Prop prop = chestToOpen.PropInChest[i]; - chestToOpen.PropInChest[i] = null; + chestToOpen.PropInChest[i] = new NullProp(); prop.ReSetPos(player.Position, gameMap.GetPlaceType(player.Position)); gameMap.Add(prop); } @@ -353,13 +353,13 @@ namespace Gaming { new FrameRateTaskExecutor( - loopCondition: () => player.PlayerState == PlayerStateType.ClimbingThroughWindows && gameMap.Timer.IsGaming, - loopToDo: () => { }, - timeInterval: GameData.frameDuration, - finallyReturn: () => 0, - maxTotalDuration: (int)((windowToPlayer + windowForClimb.Position - player.Position).Length() / player.MoveSpeed) - ) - .Start(); + loopCondition: () => player.PlayerState == PlayerStateType.ClimbingThroughWindows && gameMap.Timer.IsGaming, + loopToDo: () => { }, + timeInterval: GameData.frameDuration, + finallyReturn: () => 0, + maxTotalDuration: (int)((windowToPlayer + windowForClimb.Position - player.Position).Length() / player.MoveSpeed) + ) + .Start(); if (player.PlayerState != PlayerStateType.ClimbingThroughWindows) { windowForClimb.WhoIsClimbing = null; @@ -370,13 +370,13 @@ namespace Gaming player.MoveSpeed = player.SpeedOfClimbingThroughWindows; MovePlayer(player, (int)(windowToPlayer.Length() * 3.0 / player.MoveSpeed), (-1 * windowToPlayer).Angle()); new FrameRateTaskExecutor( - loopCondition: () => player.PlayerState == PlayerStateType.ClimbingThroughWindows && player.IsMoving && gameMap.Timer.IsGaming, - loopToDo: () => { }, - timeInterval: GameData.frameDuration, - finallyReturn: () => 0, - maxTotalDuration: (int)(windowToPlayer.Length() * 3.0 / player.MoveSpeed) - ) - .Start(); + loopCondition: () => player.PlayerState == PlayerStateType.ClimbingThroughWindows && player.IsMoving && gameMap.Timer.IsGaming, + loopToDo: () => { }, + timeInterval: GameData.frameDuration, + finallyReturn: () => 0, + maxTotalDuration: (int)(windowToPlayer.Length() * 3.0 / player.MoveSpeed) + ) + .Start(); XY PosJumpOff = windowForClimb.Position - 2 * windowToPlayer; player.ReSetPos(PosJumpOff, gameMap.GetPlaceType(PosJumpOff)); player.MoveSpeed = player.buffManager.ReCalculateFloatBuff(BuffType.AddSpeed, player.OrgMoveSpeed, GameData.MaxSpeed, GameData.MinSpeed); @@ -392,6 +392,67 @@ namespace Gaming return true; } + public bool LockOrOpenDoor(Character player) + { + if (!(player.Commandable()) || player.PlayerState == PlayerStateType.LockingOrOpeningTheDoor) + return false; + Door? doorToLock = (Door?)gameMap.OneForInteract(player.Position, GameObjType.Door); + if (doorToLock == null) + return false; + bool flag = false; + foreach (Prop prop in player.PropInventory) + { + switch (prop.GetPropType()) + { + case PropType.Key3: + if (doorToLock.Place == PlaceType.Door3) + flag = true; + break; + case PropType.Key5: + if (doorToLock.Place == PlaceType.Door5) + flag = true; + break; + case PropType.Key6: + if (doorToLock.Place == PlaceType.Door6) + flag = true; + break; + default: + break; + } + if (flag) break; + } + if (!flag) return false; + + player.PlayerState = PlayerStateType.LockingOrOpeningTheDoor; + + /* new Thread + ( + () => + { + new FrameRateTaskExecutor( + loopCondition: () => doorToLock.IsOpening && player.PlayerState == PlayerStateType.OpeningTheDoorWay && gameMap.Timer.IsGaming && doorToLock.OpenDegree < GameData.degreeOfOpenedDoorway && GameData.ApproachToInteract(player.Position, doorToLock.Position), + loopToDo: () => + { + doorToLock.OpenDegree += GameData.frameDuration; + }, + timeInterval: GameData.frameDuration, + finallyReturn: () => 0 + ) + + .Start(); + doorToLock.IsOpening = false; + if (doorToLock.OpenDegree >= GameData.degreeOfOpenedDoorway) + { + if (player.PlayerState == PlayerStateType.OpeningTheDoorWay) + player.PlayerState = PlayerStateType.Null; + } + } + + ) + { IsBackground = true }.Start(); + */ + return true; + } /* private void ActivateMine(Character player, Mine mine) diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs index 074819f..c7d90aa 100644 --- a/logic/Gaming/Game.cs +++ b/logic/Gaming/Game.cs @@ -139,8 +139,8 @@ namespace Gaming { if (XY.Distance(newPlayer.Position, generator.Position) <= newPlayer.AlertnessRadius) { - if ((double)newPlayer.AlertnessRadius * generator.DegreeOfFRepair / GameData.degreeOfFixedGenerator / XY.Distance(newPlayer.Position, generator.Position) > bgmVolume) - bgmVolume = (double)newPlayer.AlertnessRadius * generator.DegreeOfFRepair / GameData.degreeOfFixedGenerator / XY.Distance(newPlayer.Position, generator.Position); + if ((double)newPlayer.AlertnessRadius * generator.DegreeOfRepair / GameData.degreeOfFixedGenerator / XY.Distance(newPlayer.Position, generator.Position) > bgmVolume) + bgmVolume = (double)newPlayer.AlertnessRadius * generator.DegreeOfRepair / GameData.degreeOfFixedGenerator / XY.Distance(newPlayer.Position, generator.Position); } } if (bgmVolume > 0) @@ -278,7 +278,7 @@ namespace Gaming Character? player = gameMap.FindPlayer(playerID); if (player != null) { - return actionManager.Stop(player); + return ActionManager.Stop(player); } return false; } diff --git a/logic/Server/CopyInfo.cs b/logic/Server/CopyInfo.cs index 8cf6550..0765668 100644 --- a/logic/Server/CopyInfo.cs +++ b/logic/Server/CopyInfo.cs @@ -329,7 +329,7 @@ namespace Server msg.ClassroomMessage = new(); msg.ClassroomMessage.X = generator.Position.x; msg.ClassroomMessage.Y = generator.Position.y; - msg.ClassroomMessage.Progress = generator.DegreeOfFRepair; + msg.ClassroomMessage.Progress = generator.DegreeOfRepair; return msg; } private static MessageOfObj Gate(Doorway doorway) @@ -347,7 +347,7 @@ namespace Server msg.ChestMessage = new(); msg.ChestMessage.X=chest.Position.x; msg.ChestMessage.Y=chest.Position.y; - // msg.ChestMessage.Progress=generator.DegreeOfFRepair; + // msg.ChestMessage.Progress=generator.DegreeOfRepair; return msg; }*/ }