From 1c4b062dd7f9285d7f2c2af5bc9d1498416828a9 Mon Sep 17 00:00:00 2001 From: Henry <2280825018@qq.com> Date: Sat, 23 Nov 2024 18:38:02 +0800 Subject: [PATCH] feat: :sparkles: LogicUpdate 1.Add Occupation; 2.Add Character Manager --- logic/GameClass/GameObj/Areas/Construction.cs | 10 +- logic/GameClass/GameObj/Character.cs | 28 +++++- .../GameObj/Occupations/BaiLongma.cs | 32 ++++++ .../GameObj/Occupations/HongHaier.cs | 33 +++++++ .../GameClass/GameObj/Occupations/JiuLing.cs | 32 ++++++ logic/GameClass/GameObj/Occupations/Monkid.cs | 32 ++++++ .../GameObj/Occupations/NiuMowang.cs | 32 ++++++ .../GameObj/Occupations/OccupationFactory.cs | 24 +++++ logic/GameClass/GameObj/Occupations/Pawn.cs | 32 ++++++ .../GameObj/Occupations/ShaWujing.cs | 32 ++++++ .../GameObj/Occupations/SunWukong.cs | 32 ++++++ .../GameClass/GameObj/Occupations/TangSeng.cs | 32 ++++++ .../GameClass/GameObj/Occupations/TieShan.cs | 32 ++++++ .../GameObj/Occupations/ZhiZhujing.cs | 32 ++++++ .../GameClass/GameObj/Occupations/ZhuBajie.cs | 32 ++++++ logic/Gaming/CharacterManager.cs | 98 ++++++++++++++++++- logic/Preparation/Interface/ICharacter.cs | 2 + logic/Preparation/Utility/GameData.cs | 30 ++++++ 18 files changed, 570 insertions(+), 7 deletions(-) create mode 100644 logic/GameClass/GameObj/Occupations/BaiLongma.cs create mode 100644 logic/GameClass/GameObj/Occupations/HongHaier.cs create mode 100644 logic/GameClass/GameObj/Occupations/JiuLing.cs create mode 100644 logic/GameClass/GameObj/Occupations/Monkid.cs create mode 100644 logic/GameClass/GameObj/Occupations/NiuMowang.cs create mode 100644 logic/GameClass/GameObj/Occupations/OccupationFactory.cs create mode 100644 logic/GameClass/GameObj/Occupations/Pawn.cs create mode 100644 logic/GameClass/GameObj/Occupations/ShaWujing.cs create mode 100644 logic/GameClass/GameObj/Occupations/SunWukong.cs create mode 100644 logic/GameClass/GameObj/Occupations/TangSeng.cs create mode 100644 logic/GameClass/GameObj/Occupations/TieShan.cs create mode 100644 logic/GameClass/GameObj/Occupations/ZhiZhujing.cs create mode 100644 logic/GameClass/GameObj/Occupations/ZhuBajie.cs diff --git a/logic/GameClass/GameObj/Areas/Construction.cs b/logic/GameClass/GameObj/Areas/Construction.cs index e7c9b92..9534daf 100644 --- a/logic/GameClass/GameObj/Areas/Construction.cs +++ b/logic/GameClass/GameObj/Areas/Construction.cs @@ -11,10 +11,10 @@ public class Construction(XY initPos) public AtomicLong TeamID { get; } = new(long.MaxValue); public InVariableRange HP { get; } = new(0, GameData.CommunityHP); public override bool IsRigid(bool args = false) => true; - public override ShapeType Shape => ShapeType.Square; + public override ShapeType Shape => ShapeType.SQUARE; private readonly object lockOfConstructionType = new(); - private ConstructionType constructionType = ConstructionType.Null; + private ConstructionType constructionType = ConstructionType.NULL_CONSTRUCTION_TYPE; public ConstructionType ConstructionType { get @@ -29,13 +29,13 @@ public ConstructionType ConstructionType public bool Construct(ConstructionType constructionType, Character character)//这里修改了函数的参数列表删除了int constructSpeed { int constructSpeed; - if (constructionType == ConstructionType.Null) + if (constructionType == ConstructionType.NULL_CONSTRUCTION_TYPE) return false; lock (lockOfConstructionType) { - if (this.constructionType == ConstructionType.Null || HP == 0) + if (this.constructionType == ConstructionType.NULL_CONSTRUCTION_TYPE || HP == 0) { - TeamID.SetROri(ship.TeamID); + TeamID.SetROri(character.TeamID); this.constructionType = constructionType; switch (constructionType) { diff --git a/logic/GameClass/GameObj/Character.cs b/logic/GameClass/GameObj/Character.cs index e7ba619..38d25e4 100644 --- a/logic/GameClass/GameObj/Character.cs +++ b/logic/GameClass/GameObj/Character.cs @@ -1,4 +1,5 @@ -using Preparation.Interface; +using GameClass.GameObj.Occupations; +using Preparation.Interface; using Preparation.Utility; using Preparation.Utility.Value; using Preparation.Utility.Value.SafeValue.Atomic; @@ -17,6 +18,8 @@ public class Character : Movable, ICharacter public InVariableRange HP { get; } public InVariableRange AttackPower { get; } public InVariableRange AttackSize { get; } + public InVariableRange Shield { get; } + public InVariableRange Shoes { get; }//移速加成(注意是加成值,实际移速为基础移速+移速加成) public CharacterType CharacterType { get; } private CharacterState characterState1 = CharacterState.NULL_CHARACTER_STATE; private CharacterState characterState2 = CharacterState.DECEASED; @@ -160,6 +163,29 @@ public bool Commandable() } } + public bool TryToRemoveFromGame(CharacterState state) + { + lock (actionlock) + { + if (SetCharacterState(CharacterState.NULL_CHARACTER_STATE, state) == -1) + return false; + TryToRemove(); + CanMove.SetROri(false); + position = GameData.PosNotInGame; + } + return true; + } + public Character(int radius,CharacterType type,MoneyPool pool): + base(GameData.PosNotInGame,radius,GameObjType.Character) + { + CanMove.SetROri(false); + IsRemoved.SetROri(true); + Occupation = OccupationFactory.FindIOccupation(CharacterType = type); + ViewRange = Occupation.ViewRange; + HP = new(Occupation.MaxHp); + AttackSize = new(Occupation.BaseAttackSize); + MoneyPool = pool; + } } diff --git a/logic/GameClass/GameObj/Occupations/BaiLongma.cs b/logic/GameClass/GameObj/Occupations/BaiLongma.cs new file mode 100644 index 0000000..a3aaaf8 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/BaiLongma.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class BaiLongma:IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.BaiLongmaHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.BaiLongmacost; + public int BaseAttackSize { get; } = GameData.BaiLongmaATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/HongHaier.cs b/logic/GameClass/GameObj/Occupations/HongHaier.cs new file mode 100644 index 0000000..a93111d --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/HongHaier.cs @@ -0,0 +1,33 @@ +using Preparation.Interface; +using Preparation.Utility; + + +namespace GameClass.GameObj.Occupations +{ + public class HongHaier : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.HongHaierHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.HongHaiercost; + public int BaseAttackSize { get; } = GameData.HongHaierATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/JiuLing.cs b/logic/GameClass/GameObj/Occupations/JiuLing.cs new file mode 100644 index 0000000..b9b7573 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/JiuLing.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class JiuLing : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.JiuLingHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = 0; + public int BaseAttackSize { get; } = GameData.JiuLingATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/Monkid.cs b/logic/GameClass/GameObj/Occupations/Monkid.cs new file mode 100644 index 0000000..4629163 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/Monkid.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class Monkid : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.MonkidHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.Monkidcost; + public int BaseAttackSize { get; } = GameData.MonkidATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/NiuMowang.cs b/logic/GameClass/GameObj/Occupations/NiuMowang.cs new file mode 100644 index 0000000..6a51522 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/NiuMowang.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class NiuMowang : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.NiuMowangHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.NiuMowangcost; + public int BaseAttackSize { get; } = GameData.NiuMowangATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/OccupationFactory.cs b/logic/GameClass/GameObj/Occupations/OccupationFactory.cs new file mode 100644 index 0000000..5a2338a --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/OccupationFactory.cs @@ -0,0 +1,24 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public static class OccupationFactory + { + public static IOccupation FindIOccupation(CharacterType charactertype) => charactertype switch + { + CharacterType.TangSeng => new TangSeng(), + CharacterType.SunWukong => new SunWukong(), + CharacterType.ZhuBajie => new ZhuBajie(), + CharacterType.ShaWujing => new ShaWujing(), + CharacterType.BaiLongma => new BaiLongma(), + CharacterType.Monkid => new Monkid(), + CharacterType.JiuLing => new JiuLing(), + CharacterType.HongHaier => new HongHaier(), + CharacterType.NiuMowang => new NiuMowang(), + CharacterType.TieShan => new TieShan(), + CharacterType.ZhiZhujing => new ZhiZhujing(), + CharacterType.Pawn => new Pawn(), + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/Pawn.cs b/logic/GameClass/GameObj/Occupations/Pawn.cs new file mode 100644 index 0000000..1f02ab8 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/Pawn.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class Pawn : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.PawnHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.Pawncost; + public int BaseAttackSize { get; } = GameData.PawnATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/ShaWujing.cs b/logic/GameClass/GameObj/Occupations/ShaWujing.cs new file mode 100644 index 0000000..0d57e56 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/ShaWujing.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class ShaWujing : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.ShaWujingHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.ShaWujingcost; + public int BaseAttackSize { get; } = GameData.ShaWujingATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/SunWukong.cs b/logic/GameClass/GameObj/Occupations/SunWukong.cs new file mode 100644 index 0000000..f1f0be5 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/SunWukong.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class SunWukong : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.SunWukongHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.SunWukongcost; + public int BaseAttackSize { get; } = GameData.SunWukongATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/TangSeng.cs b/logic/GameClass/GameObj/Occupations/TangSeng.cs new file mode 100644 index 0000000..42f0f8d --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/TangSeng.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class TangSeng : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.TangSengHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = 0; + public int BaseAttackSize { get; } = GameData.TangSengATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/TieShan.cs b/logic/GameClass/GameObj/Occupations/TieShan.cs new file mode 100644 index 0000000..1b5bdd4 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/TieShan.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class TieShan : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.TieShanHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.TieShancost; + public int BaseAttackSize { get; } = GameData.TieShanATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/ZhiZhujing.cs b/logic/GameClass/GameObj/Occupations/ZhiZhujing.cs new file mode 100644 index 0000000..3efb5d4 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/ZhiZhujing.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class ZhiZhujing : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.ZhiZhujingHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.ZhiZhujingcost; + public int BaseAttackSize { get; } = GameData.ZhiZhujingATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/GameClass/GameObj/Occupations/ZhuBajie.cs b/logic/GameClass/GameObj/Occupations/ZhuBajie.cs new file mode 100644 index 0000000..c027238 --- /dev/null +++ b/logic/GameClass/GameObj/Occupations/ZhuBajie.cs @@ -0,0 +1,32 @@ +using Preparation.Interface; +using Preparation.Utility; + +namespace GameClass.GameObj.Occupations +{ + public class ZhuBajie : IOccupation + { + public int MoveSpeed { get; } = GameData.NumOfStepPerSecond; + public int MaxHp { get; } = GameData.ZhuBajieHP; + public int ViewRange { get; } = GameData.Viewrange; + public int Cost { get; } = GameData.ZhuBajiecost; + public int BaseAttackSize { get; } = GameData.ZhuBajieATKsize; + public bool IsEquipValid(EquipmentType equiptype) => equiptype switch + { + EquipmentType.SPEEDBOOTS => false, + + EquipmentType.SMALL_HEALTH_POTION => false, + EquipmentType.MEDIUM_HEALTH_POTION => false, + EquipmentType.LARGE_HEALTH_POTION => false, + + EquipmentType.SMALL_SHIELD => false, + EquipmentType.MEDIUM_SHIELD => false, + EquipmentType.LARGE_SHIELD => false, + + EquipmentType.BERSERK_POTION => false, + + EquipmentType.INVISIBILITY_POTION => false, + + _ => false + }; + } +} diff --git a/logic/Gaming/CharacterManager.cs b/logic/Gaming/CharacterManager.cs index c978bc9..e9147f1 100644 --- a/logic/Gaming/CharacterManager.cs +++ b/logic/Gaming/CharacterManager.cs @@ -7,7 +7,103 @@ namespace Gaming { - internal class CharacterManager + public partial class Game { + private readonly CharacterManager characterManager; + private class CharacterManager(Game game, Map gameMap) + { + private readonly Game game = game; + private readonly Map map = gameMap; + public static Character?AddCharacter(long teamID,long playerID,CharacterType charactertype,MoneyPool moneypool) + { + Character newcharacter = new(GameData.CharacterRadius, charactertype, moneypool); + newcharacter.TeamID.SetROri(teamID); + newcharacter.PlayerID.SetROri(playerID); + return newcharacter; + } + + public bool ActivateCharacter(Character character, XY pos) + { + if (character.CharacterState2 != CharacterState.DECEASED) + { + return false; + } + gameMap.Add(character); + character.ReSetPos(pos); + character.SetCharacterState(CharacterState.NULL_CHARACTER_STATE, CharacterState.NULL_CHARACTER_STATE); + return true; + } + + public void BeAttacked(Character character,Character obj) + { + if(obj.TeamID.Get()==character.TeamID.Get()) + { + return; + } + long subHP = obj.AttackPower; + if(character.Shield>0) + { + character.Shield.SubPositiveV(subHP); + } + else + { + character.HP.SubPositiveV(subHP); + } + if(character.HP==0) + { + long score = 0; + if (character.CharacterType == CharacterType.TangSeng || character.CharacterType == CharacterType.JiuLing) + score = 200000; + else if (character.CharacterType == CharacterType.Monkid || character.CharacterType == CharacterType.Pawn) + score = 500; + else + score = character.GetCost(); + //此处缺失加分代码。由于阵营是分明的(妖怪和取经团队,THUAI7阵营并无明显差别),可以直接将得分加至相应阵营。小局结束后再加到队伍得分。 + Remove(character); + } + } + + public void BeAttacked(Character character,long AP)//此部分适用于中立资源攻击及技能攻击 + { + if (character.Shield > 0) + { + character.Shield.SubPositiveV(AP); + } + else + { + character.HP.SubPositiveV(AP); + } + if (character.HP == 0) + { + long score = 0; + if (character.CharacterType == CharacterType.TangSeng || character.CharacterType == CharacterType.JiuLing) + score = 200000; + else if (character.CharacterType == CharacterType.Monkid || character.CharacterType == CharacterType.Pawn) + score = 500; + else + score = character.GetCost(); + //此处缺失加分代码。由于阵营是分明的(妖怪和取经团队,THUAI7阵营并无明显差别),可以直接将得分加至相应阵营。小局结束后再加到队伍得分。 + Remove(character); + } + } + + public static bool Recover(Character character,long recover) + { + if (recover <= 0) + return false; + character.HP.AddPositiveV(recover); + return true; + } + + public void Remove(Character character) + { + if(!character.TryToRemoveFromGame(CharacterState.DECEASED)) + { + return; + } + gameMap.Remove(character); + } + } + } } diff --git a/logic/Preparation/Interface/ICharacter.cs b/logic/Preparation/Interface/ICharacter.cs index 8866433..128fc10 100644 --- a/logic/Preparation/Interface/ICharacter.cs +++ b/logic/Preparation/Interface/ICharacter.cs @@ -7,6 +7,8 @@ public interface ICharacter : IMovable, IPlayer public InVariableRange HP { get; } public InVariableRange AttackPower { get; } public InVariableRange AttackSize { get; } + public InVariableRange Shield { get; } + public InVariableRange Shoes { get; }//移速加成(注意是加成值,实际移速为基础移速+移速加成) public CharacterType CharacterType { get; } public CharacterState CharacterState1 { get; }//主动状态 public CharacterState CharacterState2 { get; }//被动状态 diff --git a/logic/Preparation/Utility/GameData.cs b/logic/Preparation/Utility/GameData.cs index bf81e56..5cc52ac 100644 --- a/logic/Preparation/Utility/GameData.cs +++ b/logic/Preparation/Utility/GameData.cs @@ -24,11 +24,40 @@ public static class GameData public const int ZhiZhujingcost = 3000; public const int Pawncost = 1000; + //character property + public const int TangSengHP = 1000; + public const int SunWukongHP = 200; + public const int ZhuBajieHP = 300; + public const int ShaWujingHP = 150; + public const int BaiLongmaHP = 150; + public const int MonkidHP = 50; + public const int JiuLingHP = 1000; + public const int HongHaierHP = 200; + public const int NiuMowangHP = 300; + public const int TieShanHP = 150; + public const int ZhiZhujingHP = 150; + public const int PawnHP = 50; + + public const int TangSengATKsize = 0; + public const int SunWukongATKsize = 1000; + public const int ZhuBajieATKsize = 2000; + public const int ShaWujingATKsize = 5000; + public const int BaiLongmaATKsize = 5000; + public const int MonkidATKsize = 1000; + public const int JiuLingATKsize = 0; + public const int HongHaierATKsize = 1000; + public const int NiuMowangATKsize = 2000; + public const int TieShanATKsize = 5000; + public const int ZhiZhujingATKsize = 5000; + public const int PawnATKsize = 1000; + public const int NumOfPosGridPerCell = 1000; // 每格的【坐标单位】数 public const int MapLength = 50000; // 地图长度 public const int MapRows = 50; // 行数 public const int MapCols = 50; // 列数 + public const int Viewrange = 8000; + public const int CharacterRadius = 400; public static XY GetCellCenterPos(int x, int y) // 求格子的中心坐标 => new(x * NumOfPosGridPerCell + NumOfPosGridPerCell / 2, @@ -70,5 +99,6 @@ public static bool IsInTheRange(XY pos1, XY pos2, int range) public const int TrapConstructSpeed = 20;//100/5 public const int CageConstructSpeed = 20;//100/5 + public static readonly XY PosNotInGame = new(1, 1); } }