From 1cd52756b837726a4dc0927b94c615740edf0586 Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Mon, 3 Apr 2023 01:00:59 +0800 Subject: [PATCH] feat: :sparkles: add the fuction of nowTime --- logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs | 4 ++-- logic/GameClass/GameObj/Map/MapGameTimer.cs | 8 +++++++- logic/Gaming/CharacterManager .cs | 1 + logic/Preparation/Interface/ITimer.cs | 1 + logic/Server/GameServer.cs | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs b/logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs index ef6e84e..63d9e68 100644 --- a/logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs +++ b/logic/GameClass/GameObj/Bullet/Bullet.Ghost.cs @@ -121,8 +121,8 @@ namespace GameClass.GameObj public override bool IsRemoteAttack => false; public override int CastTime => (int)BulletAttackRange / Speed; - public override int Backswing => 0; - public override int RecoveryFromHit => 0; + public override int Backswing => GameData.basicRecoveryFromHit; + public override int RecoveryFromHit => GameData.basicRecoveryFromHit; public const int cd = GameData.basicCD; public override int CD => cd; public const int maxBulletNum = 1; diff --git a/logic/GameClass/GameObj/Map/MapGameTimer.cs b/logic/GameClass/GameObj/Map/MapGameTimer.cs index bd58100..26760b6 100644 --- a/logic/GameClass/GameObj/Map/MapGameTimer.cs +++ b/logic/GameClass/GameObj/Map/MapGameTimer.cs @@ -1,4 +1,5 @@ -using System.Threading; +using System; +using System.Threading; using Preparation.Interface; namespace GameClass.GameObj @@ -8,8 +9,12 @@ namespace GameClass.GameObj // xfgg说:爱因斯坦说,每个坐标系都有与之绑定的时钟,(x, y, z, ict) 构成四维时空坐标,在洛伦兹变换下满足矢量性(狗头) private readonly GameTimer timer = new(); public ITimer Timer => timer; + public class GameTimer : ITimer { + private int startTime; + public int nowTime() => Environment.TickCount - startTime; + private bool isGaming = false; public bool IsGaming { @@ -30,6 +35,7 @@ namespace GameClass.GameObj if (isGaming) return false; isGaming = true; + startTime = Environment.TickCount; } Thread.Sleep(timeInMilliseconds); isGaming = false; diff --git a/logic/Gaming/CharacterManager .cs b/logic/Gaming/CharacterManager .cs index e432f41..b7dce91 100644 --- a/logic/Gaming/CharacterManager .cs +++ b/logic/Gaming/CharacterManager .cs @@ -213,6 +213,7 @@ namespace Gaming { ghost.AddScore(GameData.TrickerScoreStudentDie); Die(player); + return; } } player.PlayerState = PlayerStateType.Addicted; diff --git a/logic/Preparation/Interface/ITimer.cs b/logic/Preparation/Interface/ITimer.cs index 721c9d0..0379c45 100644 --- a/logic/Preparation/Interface/ITimer.cs +++ b/logic/Preparation/Interface/ITimer.cs @@ -4,6 +4,7 @@ namespace Preparation.Interface public interface ITimer { bool IsGaming { get; set; } + public int nowTime(); public bool StartGame(int timeInMilliseconds); } } diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index 435a889..013320a 100644 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -199,7 +199,7 @@ namespace Server private MessageOfAll GetMessageOfAll() { MessageOfAll msg = new MessageOfAll(); - //msg.GameTime + msg.GameTime = game.GameMap.Timer.nowTime(); msg.SubjectFinished = (int)game.GameMap.NumOfRepairedGenerators; msg.StudentGraduated = (int)game.GameMap.NumOfEscapedStudent; msg.StudentQuited = (int)game.GameMap.NumOfDeceasedStudent;