From 2fdf444836fec9c55806036645e5d80b90b23245 Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Wed, 22 Mar 2023 01:46:08 +0800 Subject: [PATCH] fix: :bug: fix the update of bgm' --- logic/GameClass/GameObj/Character/Character.cs | 8 +++++++- logic/Gaming/Game.cs | 6 +++--- logic/Preparation/Utility/EnumType.cs | 4 ++-- logic/Server/CopyInfo.cs | 6 +++++- logic/Server/GameServer.cs | 6 ++++-- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs index 0aa7b1f..0fcfec4 100644 --- a/logic/GameClass/GameObj/Character/Character.cs +++ b/logic/GameClass/GameObj/Character/Character.cs @@ -175,7 +175,7 @@ namespace GameClass.GameObj public Dictionary BgmDictionary { get => bgmDictionary; - set + private set { lock (gameObjLock) { @@ -183,6 +183,12 @@ namespace GameClass.GameObj } } } + public void AddBgm(BgmType bgm, double value) + { + if (BgmDictionary.ContainsKey(bgm)) + BgmDictionary[bgm] = value; + else BgmDictionary.Add(bgm, value); + } private int alertnessRadius; public int AlertnessRadius diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs index d11a9c6..074819f 100644 --- a/logic/Gaming/Game.cs +++ b/logic/Gaming/Game.cs @@ -111,7 +111,7 @@ namespace Gaming } } if (bgmVolume > 0) - newPlayer.BgmDictionary.Add(BgmType.StudentIsApproaching, bgmVolume); + newPlayer.AddBgm(BgmType.StudentIsApproaching, bgmVolume); } else { @@ -120,7 +120,7 @@ namespace Gaming if (person.IsGhost()) { if (XY.Distance(newPlayer.Position, person.Position) <= (newPlayer.AlertnessRadius / person.Concealment)) - newPlayer.BgmDictionary.Add(BgmType.GhostIsComing, (double)newPlayer.AlertnessRadius / XY.Distance(newPlayer.Position, person.Position)); + newPlayer.AddBgm(BgmType.GhostIsComing, (double)newPlayer.AlertnessRadius / XY.Distance(newPlayer.Position, person.Position)); break; } } @@ -144,7 +144,7 @@ namespace Gaming } } if (bgmVolume > 0) - newPlayer.BgmDictionary.Add(BgmType.StudentIsApproaching, bgmVolume); + newPlayer.AddBgm(BgmType.StudentIsApproaching, bgmVolume); } diff --git a/logic/Preparation/Utility/EnumType.cs b/logic/Preparation/Utility/EnumType.cs index 33cd49a..5eb3376 100644 --- a/logic/Preparation/Utility/EnumType.cs +++ b/logic/Preparation/Utility/EnumType.cs @@ -126,8 +126,8 @@ namespace Preparation.Utility EmergencyExit = 10, Window = 11, Door3 = 12, - Door4 =13, - Door5 = 14, + Door5 = 13, + Door6 = 14, Chest = 15, } public enum BgmType diff --git a/logic/Server/CopyInfo.cs b/logic/Server/CopyInfo.cs index 6064c86..43771d6 100644 --- a/logic/Server/CopyInfo.cs +++ b/logic/Server/CopyInfo.cs @@ -22,7 +22,11 @@ namespace Server case Preparation.Utility.PlaceType.Chest: return Protobuf.PlaceType.Chest; case Preparation.Utility.PlaceType.Door3: - return Protobuf.PlaceType.Door; + return Protobuf.PlaceType.Door3; + case Preparation.Utility.PlaceType.Door5: + return Protobuf.PlaceType.Door5; + case Preparation.Utility.PlaceType.Door6: + return Protobuf.PlaceType.Door6; case Preparation.Utility.PlaceType.Generator: return Protobuf.PlaceType.Classroom; case Preparation.Utility.PlaceType.Grass: diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index 2106336..5aa96be 100644 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -211,8 +211,10 @@ namespace Server case 9: return Protobuf.PlaceType.Gate; case 10: return Protobuf.PlaceType.HiddenGate; case 11: return Protobuf.PlaceType.Window; - case 12: return Protobuf.PlaceType.Door; - case 13: return Protobuf.PlaceType.Chest; + case 12: return Protobuf.PlaceType.Door3; + case 13: return Protobuf.PlaceType.Door5; + case 14: return Protobuf.PlaceType.Door6; + case 15: return Protobuf.PlaceType.Chest; default: return Protobuf.PlaceType.NullPlaceType; } }