From f757f11f95cafe9c25ca8f3987ce1248e6857d57 Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Wed, 29 Mar 2023 01:51:56 +0800 Subject: [PATCH] build: :sparkles: build the buff system --- logic/GameClass/GameObj/Bullet/Bullet.cs | 2 +- .../Character/Character.BuffManager.cs | 39 +++++++++++++++++++ .../GameClass/GameObj/Character/Character.cs | 27 ++++++------- logic/GameClass/GameObj/Map/Map.cs | 2 +- .../SkillManager/SkillManager.ActiveSkill.cs | 7 ++-- logic/Preparation/Interface/IOccupation.cs | 34 ++++++++++++++++ logic/Preparation/Utility/EnumType.cs | 2 + 7 files changed, 92 insertions(+), 21 deletions(-) diff --git a/logic/GameClass/GameObj/Bullet/Bullet.cs b/logic/GameClass/GameObj/Bullet/Bullet.cs index 5c50267..a08c6b0 100644 --- a/logic/GameClass/GameObj/Bullet/Bullet.cs +++ b/logic/GameClass/GameObj/Bullet/Bullet.cs @@ -45,7 +45,7 @@ namespace GameClass.GameObj this.place = placeType; this.CanMove = true; this.moveSpeed = this.Speed; - this.hasSpear = player.HasSpear; + this.hasSpear = player.TryUseSpear(); this.Parent = player; } public override bool IsRigid => true; // 默认为true diff --git a/logic/GameClass/GameObj/Character/Character.BuffManager.cs b/logic/GameClass/GameObj/Character/Character.BuffManager.cs index b50f3a4..0a1a9a2 100644 --- a/logic/GameClass/GameObj/Character/Character.BuffManager.cs +++ b/logic/GameClass/GameObj/Character/Character.BuffManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Runtime.InteropServices; using System.Threading; using Preparation.Utility; @@ -183,6 +184,44 @@ namespace GameClass.GameObj } } } + public bool TryUseSpear() + { + if (HasSpear) + { + lock (buffListLock[(int)BuffType.Spear]) + { + buffList[(int)BuffType.Spear].RemoveFirst(); + } + return true; + } + return false; + } + + public void AddClairaudience(int shieldTime) => AddBuff(new BuffValue(), shieldTime, BuffType.Clairaudience, () => + { }); + public bool HasClairaudience + { + get + { + lock (buffListLock[(int)BuffType.Clairaudience]) + { + return buffList[(int)BuffType.Clairaudience].Count != 0; + } + } + } + + public void AddInvisible(int shieldTime) => AddBuff(new BuffValue(), shieldTime, BuffType.Invisible, () => + { }); + public bool HasInvisible + { + get + { + lock (buffListLock[(int)BuffType.Invisible]) + { + return buffList[(int)BuffType.Invisible].Count != 0; + } + } + } /// /// 清除所有buff diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs index 5c5a3cb..81d2502 100644 --- a/logic/GameClass/GameObj/Character/Character.cs +++ b/logic/GameClass/GameObj/Character/Character.cs @@ -123,22 +123,6 @@ namespace GameClass.GameObj }*/ #endregion #region 感知相关的基本属性及方法 - /// - /// 是否在隐身 - /// - private bool isInvisible = false; - public bool IsInvisible - { - get => isInvisible; - set - { - lock (gameObjLock) - { - isInvisible = value; - } - } - } - private Dictionary bgmDictionary = new(); public Dictionary BgmDictionary { @@ -519,6 +503,12 @@ namespace GameClass.GameObj public void AddSpear(int spearTime) => buffManager.AddSpear(spearTime); public bool HasSpear => buffManager.HasSpear; + public void AddClairaudience(int time) => buffManager.AddClairaudience(time); + public bool HasClairaudience => buffManager.HasClairaudience; + + public void AddInvisible(int time) => buffManager.AddInvisible(time); + public bool HasInvisible => buffManager.HasInvisible; + private Array buffTypeArray = Enum.GetValues(typeof(BuffType)); public Dictionary Buff { @@ -568,6 +558,11 @@ namespace GameClass.GameObj return false; } + public bool TryUseSpear() + { + return buffManager.TryUseSpear(); + } + public bool TryUseShield() { if (buffManager.TryUseShield()) diff --git a/logic/GameClass/GameObj/Map/Map.cs b/logic/GameClass/GameObj/Map/Map.cs index 0790ee3..f491cd2 100644 --- a/logic/GameClass/GameObj/Map/Map.cs +++ b/logic/GameClass/GameObj/Map/Map.cs @@ -251,7 +251,7 @@ namespace GameClass.GameObj } public bool CanSee(Character player, GameObj gameObj) { - if ((gameObj.Type == GameObjType.Character) && !((Character)gameObj).IsInvisible) return false; + if ((gameObj.Type == GameObjType.Character) && !((Character)gameObj).HasInvisible) return false; XY pos1 = player.Position; XY pos2 = gameObj.Position; XY del = pos1 - pos2; diff --git a/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs b/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs index 2fbcc28..486c0a4 100644 --- a/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs +++ b/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs @@ -45,13 +45,14 @@ namespace Gaming public static bool BecomeInvisible(Character player) { - return ActiveSkillEffect(player.UseIActiveSkill(ActiveSkillType.BecomeInvisible), player, () => + IActiveSkill activeSkill = player.UseIActiveSkill(ActiveSkillType.BecomeInvisible); + return ActiveSkillEffect(activeSkill, player, () => { - player.IsInvisible = true; + player.AddInvisible(activeSkill.DurationTime); Debugger.Output(player, "become invisible!"); }, () => - { player.IsInvisible = false; }); + { }); } public bool NuclearWeapon(Character player) diff --git a/logic/Preparation/Interface/IOccupation.cs b/logic/Preparation/Interface/IOccupation.cs index cd572eb..087f156 100644 --- a/logic/Preparation/Interface/IOccupation.cs +++ b/logic/Preparation/Interface/IOccupation.cs @@ -64,6 +64,40 @@ namespace Preparation.Interface public int timeOfOpenChest = GameData.basicSpeedOfOpenChest; public int TimeOfOpenChest => timeOfOpenChest; } + public class HoD : IGhost + { + private const int moveSpeed = GameData.basicMoveSpeed * 473 / 380; + public int MoveSpeed => moveSpeed; + + private const int maxHp = GameData.basicHp; + public int MaxHp => maxHp; + + public const int maxBulletNum = 1; + public int MaxBulletNum => maxBulletNum; + + public BulletType InitBullet => BulletType.CommonAttackOfGhost; + + public List ListOfIActiveSkill => new(new ActiveSkillType[] { ActiveSkillType.BecomeInvisible, ActiveSkillType.UseKnife }); + public List ListOfIPassiveSkill => new(new PassiveSkillType[] { }); + + public double concealment = GameData.basicConcealment * 1.5; + public double Concealment => concealment; + + public int alertnessRadius = (int)(GameData.basicAlertnessRadius * 1.3); + public int AlertnessRadius => alertnessRadius; + + public int viewRange = (int)(GameData.basicViewRange * 1.3); + public int ViewRange => viewRange; + + public int timeOfOpeningOrLocking = GameData.basicSpeedOfOpeningOrLocking; + public int TimeOfOpeningOrLocking => timeOfOpeningOrLocking; + + public int speedOfClimbingThroughWindows = GameData.basicGhostSpeedOfClimbingThroughWindows; + public int SpeedOfClimbingThroughWindows => speedOfClimbingThroughWindows; + + public int timeOfOpenChest = GameData.basicSpeedOfOpenChest; + public int TimeOfOpenChest => timeOfOpenChest; + } public class Teacher : IStudent { private const int moveSpeed = GameData.basicMoveSpeed * 3 / 4; diff --git a/logic/Preparation/Utility/EnumType.cs b/logic/Preparation/Utility/EnumType.cs index 4c39f73..ab2e79a 100644 --- a/logic/Preparation/Utility/EnumType.cs +++ b/logic/Preparation/Utility/EnumType.cs @@ -111,6 +111,8 @@ namespace Preparation.Utility Shield = 3, Spear = 4, AddAp = 5, + Clairaudience = 6, + Invisible = 7, } public enum PlaceType