Skip to content

Commit

Permalink
Merge pull request #48 from Hang-THU/dev
Browse files Browse the repository at this point in the history
feat: ✨ LogicUpdate
  • Loading branch information
Xyberoid authored Nov 23, 2024
2 parents 2918bc4 + 661e965 commit ae98b10
Show file tree
Hide file tree
Showing 18 changed files with 569 additions and 7 deletions.
10 changes: 5 additions & 5 deletions logic/GameClass/GameObj/Areas/Construction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public class Construction(XY initPos)
public AtomicLong TeamID { get; } = new(long.MaxValue);
public InVariableRange<long> 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
Expand All @@ -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)
{
Expand Down
28 changes: 27 additions & 1 deletion logic/GameClass/GameObj/Character.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,6 +18,8 @@ public class Character : Movable, ICharacter
public InVariableRange<long> HP { get; }
public InVariableRange<long> AttackPower { get; }
public InVariableRange<long> AttackSize { get; }
public InVariableRange<long> Shield { get; }
public InVariableRange<long> Shoes { get; }//移速加成(注意是加成值,实际移速为基础移速+移速加成)
public CharacterType CharacterType { get; }
private CharacterState characterState1 = CharacterState.NULL_CHARACTER_STATE;
private CharacterState characterState2 = CharacterState.DECEASED;
Expand Down Expand Up @@ -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;
}
}


32 changes: 32 additions & 0 deletions logic/GameClass/GameObj/Occupations/BaiLongma.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
33 changes: 33 additions & 0 deletions logic/GameClass/GameObj/Occupations/HongHaier.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
32 changes: 32 additions & 0 deletions logic/GameClass/GameObj/Occupations/JiuLing.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
32 changes: 32 additions & 0 deletions logic/GameClass/GameObj/Occupations/Monkid.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
32 changes: 32 additions & 0 deletions logic/GameClass/GameObj/Occupations/NiuMowang.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
24 changes: 24 additions & 0 deletions logic/GameClass/GameObj/Occupations/OccupationFactory.cs
Original file line number Diff line number Diff line change
@@ -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(),
};
}
}
32 changes: 32 additions & 0 deletions logic/GameClass/GameObj/Occupations/Pawn.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
32 changes: 32 additions & 0 deletions logic/GameClass/GameObj/Occupations/ShaWujing.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
32 changes: 32 additions & 0 deletions logic/GameClass/GameObj/Occupations/SunWukong.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
32 changes: 32 additions & 0 deletions logic/GameClass/GameObj/Occupations/TangSeng.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
Loading

0 comments on commit ae98b10

Please sign in to comment.