Browse Source

build: 👷 add map and character

TAT
tags/0.1.0
shangfengh 3 years ago
parent
commit
6933e26548
16 changed files with 622 additions and 3 deletions
  1. +3
    -0
      logic/.gitignore
  2. +13
    -0
      logic/GameClass/GameClass.csproj
  3. +172
    -0
      logic/GameClass/GameObj/Character.BuffManager.cs
  4. +51
    -0
      logic/GameClass/GameObj/Character.SkillManager.cs
  5. +156
    -0
      logic/GameClass/GameObj/Map/Map.cs
  6. +32
    -0
      logic/GameClass/GameObj/Map/MapGameTimer.cs
  7. +77
    -0
      logic/GameClass/GameObj/Map/MapInfo.cs
  8. +19
    -0
      logic/GameClass/GameObj/Map/Wall.cs
  9. +20
    -0
      logic/GameClass/GameObj/OutOfBoundBlock.cs
  10. +1
    -1
      logic/GameEngine/MoveEngine.cs
  11. +14
    -0
      logic/Gaming/Gaming.csproj
  12. +2
    -0
      logic/Preparation/GameData/GameData.cs
  13. +8
    -0
      logic/Preparation/Interface/IOutOfBound.cs
  14. +11
    -0
      logic/Preparation/Preparation.csproj
  15. +13
    -2
      logic/Preparation/Utility/EnumType.cs
  16. +30
    -0
      logic/logic.sln

+ 3
- 0
logic/.gitignore View File

@@ -399,3 +399,6 @@ FodyWeavers.xsd

#THUAI playback file
*.thuaipb

Client/
CSharpInterface/

+ 13
- 0
logic/GameClass/GameClass.csproj View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\GameEngine\GameEngine.csproj" />
<ProjectReference Include="..\Preparation\Preparation.csproj" />
</ItemGroup>

</Project>

+ 172
- 0
logic/GameClass/GameObj/Character.BuffManager.cs View File

@@ -0,0 +1,172 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using Preparation.Utility;
using Preparation.GameData;

namespace GameClass.GameObj
{
public partial class Character
{
private readonly BuffManeger buffManeger;
/// <summary>
/// 角色携带的buff管理器
/// </summary>
private class BuffManeger
{
[StructLayout(LayoutKind.Explicit, Size = 8)]
private struct BuffValue // buff参数联合体类型,可能是int或double
{
[FieldOffset(0)]
public int iValue;
[FieldOffset(0)]
public double lfValue;

public BuffValue(int intValue)
{
this.lfValue = 0.0;
this.iValue = intValue;
}
public BuffValue(double longFloatValue)
{
this.iValue = 0;
this.lfValue = longFloatValue;
}
}

/// <summary>
/// buff列表
/// </summary>
private readonly LinkedList<BuffValue>[] buffList;
private readonly object[] buffListLock;

private void AddBuff(BuffValue bf, int buffTime, BuffType buffType, Action ReCalculateFunc)
{
new Thread
(
() =>
{
LinkedListNode<BuffValue> buffNode;
lock (buffListLock[(int)buffType])
{
buffNode = buffList[(int)buffType].AddLast(bf);
}
ReCalculateFunc();
Thread.Sleep(buffTime);
try
{
lock (buffListLock[(int)buffType])
{
buffList[(int)buffType].Remove(buffNode);
}
}
catch
{
}
ReCalculateFunc();
}
)
{ IsBackground = true }.Start();
}

private int ReCalculateFloatBuff(BuffType buffType, int orgVal, int maxVal, int minVal)
{
double times = 1.0;
lock (buffListLock[(int)buffType])
{
foreach (var add in buffList[(int)buffType])
{
times *= add.lfValue;
}
}
return Math.Max(Math.Min((int)Math.Round(orgVal * times), maxVal), minVal);
}

public void AddMoveSpeed(double add, int buffTime, Action<int> SetNewMoveSpeed, int orgMoveSpeed) => AddBuff(new BuffValue(add), buffTime, BuffType.AddSpeed, () => SetNewMoveSpeed(ReCalculateFloatBuff(BuffType.AddSpeed, orgMoveSpeed, GameData.MaxSpeed, GameData.MinSpeed)));
public bool HasFasterSpeed
{
get {
lock (buffListLock[(int)BuffType.AddSpeed])
{
return buffList[(int)BuffType.AddSpeed].Count != 0;
}
}
}

public void AddShield(int shieldTime) => AddBuff(new BuffValue(), shieldTime, BuffType.Shield, () =>
{});
public bool HasShield
{
get {
lock (buffListLock[(int)BuffType.Shield])
{
return buffList[(int)BuffType.Shield].Count != 0;
}
}
}

public void AddLIFE(int totelTime) => AddBuff(new BuffValue(), totelTime, BuffType.AddLIFE, () =>
{});
public bool HasLIFE
{
get {
lock (buffListLock[(int)BuffType.AddLIFE])
{
return buffList[(int)BuffType.AddLIFE].Count != 0;
}
}
}
public bool TryActivatingLIFE()
{
if (HasLIFE)
{
lock (buffListLock[(int)BuffType.AddLIFE])
{
buffList[(int)BuffType.AddLIFE].Clear();
}
return true;
}
return false;
}

public void AddSpear(int spearTime) => AddBuff(new BuffValue(), spearTime, BuffType.Spear, () =>
{});
public bool HasSpear
{
get {
lock (buffListLock[(int)BuffType.Spear])
{
return buffList[(int)BuffType.Spear].Count != 0;
}
}
}
/// <summary>
/// 清除所有buff
/// </summary>
public void ClearAll()
{
for (int i = 0; i < buffList.Length; ++i)
{
lock (buffListLock[i])
{
buffList[i].Clear();
}
}
}

public BuffManeger()
{
var buffTypeArray = Enum.GetValues(typeof(BuffType));
buffList = new LinkedList<BuffValue>[buffTypeArray.Length];
buffListLock = new object[buffList.Length];
int i = 0;
foreach (BuffType type in buffTypeArray)
{
buffList[i] = new LinkedList<BuffValue>();
buffListLock[i++] = new object();
}
}
}
}
}

+ 51
- 0
logic/GameClass/GameObj/Character.SkillManager.cs View File

@@ -0,0 +1,51 @@
using Preparation.Utility;
using System.Collections.Generic;
using System;

namespace GameClass.GameObj
{
public partial class Character
{
private delegate bool CharacterActiveSkill(Character player); // 返回值:是否成功释放了技能
private delegate void CharacterPassiveSkill(Character player);
private readonly CharacterActiveSkill commonSkill;
private readonly ActiveSkillType commonSkillType;
public ActiveSkillType CommonSkillType => commonSkillType;

private readonly CharacterType passiveSkillType;
public CharacterType PassiveSkillType => passiveSkillType;
public bool UseCommonSkill()
{
return commonSkill(this);
}
private int timeUntilCommonSkillAvailable = 0; // 还剩多少时间可以使用普通技能
public int TimeUntilCommonSkillAvailable
{
get => timeUntilCommonSkillAvailable;
set {
lock (gameObjLock)
timeUntilCommonSkillAvailable = value < 0 ? 0 : value;
}
}

readonly CharacterPassiveSkill passiveSkill;
public void UsePassiveSkill()
{
passiveSkill(this);
return;
}
public Character(XY initPos, int initRadius, PlaceType initPlace, CharacterType passiveSkillType, ActiveSkillType commonSkillType) :
base(initPos, initRadius, initPlace, GameObjType.Character)
{
this.CanMove = true;
this.score = 0;
this.propInventory = null;
this.buffManeger = new BuffManeger();

// UsePassiveSkill(); //创建player时开始被动技能,这一过程也可以放到gamestart时进行
// 这可以放在AddPlayer中做

Debugger.Output(this, "constructed!");
}
}
}

+ 156
- 0
logic/GameClass/GameObj/Map/Map.cs View File

@@ -0,0 +1,156 @@
using System.Collections.Generic;
using System.Threading;
using Preparation.Interface;
using Preparation.Utility;
using Preparation.GameData;
using System;

namespace GameClass.GameObj
{
public partial class Map : IMap
{

private readonly Dictionary<uint, BirthPoint> birthPointList; // 出生点列表
public Dictionary<uint, BirthPoint> BirthPointList => birthPointList;

private Dictionary<GameObjIdx, IList<IGameObj>> gameObjDict;
public Dictionary<GameObjIdx, IList<IGameObj>> GameObjDict => gameObjDict;
private Dictionary<GameObjIdx, ReaderWriterLockSlim> gameObjLockDict;
public Dictionary<GameObjIdx, ReaderWriterLockSlim> GameObjLockDict => gameObjLockDict;

public readonly uint[,] ProtoGameMap;
public PlaceType GetPlaceType(GameObj obj)
{
try
{
uint type = ProtoGameMap[obj.Position.x / GameData.numOfPosGridPerCell, obj.Position.y / GameData.numOfPosGridPerCell];
if (type == 2)
return PlaceType.Grass1;
else if (type == 3)
return PlaceType.Grass2;
else if (type == 4)
return PlaceType.Grass3;
else
return PlaceType.Land; // 其他情况均返回land
}
catch
{
return PlaceType.Land;
}
}

public PlaceType GetPlaceType(XY pos)
{
try
{
switch (ProtoGameMap[pos.x / GameData.numOfPosGridPerCell, pos.y / GameData.numOfPosGridPerCell])
{
case 2:
return PlaceType.Grass1;
case 3:
return PlaceType.Grass2;
case 4:
return PlaceType.Grass3;
default:
return PlaceType.Land;
}
}
catch
{
return PlaceType.Land;
}
}

public bool IsOutOfBound(IGameObj obj)
{
return obj.Position.x >= GameData.lengthOfMap - obj.Radius || obj.Position.x <= obj.Radius || obj.Position.y >= GameData.lengthOfMap - obj.Radius || obj.Position.y <= obj.Radius;
}
public IOutOfBound GetOutOfBound(XY pos)
{
return new OutOfBoundBlock(pos);
}

public Character? FindPlayer(long playerID)
{
Character? player = null;
gameObjLockDict[GameObjIdx.Player].EnterReadLock();
try
{
foreach (Character person in gameObjDict[GameObjIdx.Player])
{
if (playerID == person.ID)
{
player = person;
break;
}
}
}
finally
{
gameObjLockDict[GameObjIdx.Player].ExitReadLock();
}
return player;
}
public Map(uint[,] mapResource)
{
gameObjDict = new Dictionary<GameObjIdx, IList<IGameObj>>();
gameObjLockDict = new Dictionary<GameObjIdx, ReaderWriterLockSlim>();
foreach (GameObjIdx idx in Enum.GetValues(typeof(GameObjIdx)))
{
if (idx != GameObjIdx.None)
{
gameObjDict.Add(idx, new List<IGameObj>());
gameObjLockDict.Add(idx, new ReaderWriterLockSlim());
}
}

ProtoGameMap = new uint[mapResource.GetLength(0), mapResource.GetLength(1)];
Array.Copy(mapResource, ProtoGameMap, mapResource.Length);

birthPointList = new Dictionary<uint, BirthPoint>(GameData.numOfBirthPoint);

// 将出生点插入
for (int i = 0; i < GameData.rows; ++i)
{
for (int j = 0; j < GameData.cols; ++j)
{
switch (mapResource[i, j])
{
case (uint)MapInfoObjType.Wall:
{
GameObjLockDict[GameObjIdx.Map].EnterWriteLock();
try
{
GameObjDict[GameObjIdx.Map].Add(new Wall(GameData.GetCellCenterPos(i, j)));
}
finally
{
GameObjLockDict[GameObjIdx.Map].ExitWriteLock();
}
break;
}
case (uint)MapInfoObjType.BirthPoint1:
case (uint)MapInfoObjType.BirthPoint2:
case (uint)MapInfoObjType.BirthPoint3:
case (uint)MapInfoObjType.BirthPoint4:
case (uint)MapInfoObjType.BirthPoint5:
{
BirthPoint newBirthPoint = new BirthPoint(GameData.GetCellCenterPos(i, j));
birthPointList.Add(MapInfo.BirthPointEnumToIdx((MapInfoObjType)mapResource[i, j]), newBirthPoint);
GameObjLockDict[GameObjIdx.Map].EnterWriteLock();
try
{
GameObjDict[GameObjIdx.Map].Add(newBirthPoint);
}
finally
{
GameObjLockDict[GameObjIdx.Map].ExitWriteLock();
}
break;
}
}
}
}
}
}
}

+ 32
- 0
logic/GameClass/GameObj/Map/MapGameTimer.cs View File

@@ -0,0 +1,32 @@
using System.Threading;
using Preparation.Interface;

namespace GameClass.GameObj
{
public partial class Map
{
// xfgg说:爱因斯坦说,每个坐标系都有与之绑定的时钟,(x, y, z, ict) 构成四维时空坐标,在洛伦兹变换下满足矢量性(狗头)
private readonly GameTimer timer = new();
public ITimer Timer => timer;
public class GameTimer : ITimer
{
private bool isGaming = false;
public bool IsGaming => isGaming;

readonly object isGamingLock = new();

public bool StartGame(int timeInMilliseconds)
{
lock (isGamingLock)
{
if (isGaming)
return false;
isGaming = true;
}
Thread.Sleep(timeInMilliseconds);
isGaming = false;
return true;
}
}
}
}

+ 77
- 0
logic/GameClass/GameObj/Map/MapInfo.cs View File

@@ -0,0 +1,77 @@
using Preparation.Utility;
using Preparation.GameData;

namespace GameClass.GameObj
{
public static class MapInfo
{
/// <summary>
/// 检测物体在哪;不能返回invisible。
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>

public static uint BirthPointEnumToIdx(MapInfoObjType birthPointEnum)
{
uint tmp = (uint)birthPointEnum;
// if (tmp < 5 || tmp > 12) throw new Exception("The parameter of BirthPointEnumToIdx is not a valid birth point enumeration value!");
return tmp - 5;
}
/// <summary>
/// 50*50
/// 1:Wall; 2:Grass1; 3:Grass2 ; 4:Grass3 ; 5~12:BirthPoint ; 13:GemWell
/// </summary>
public static uint[,] defaultMap = new uint[,] {
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
};
}
}

+ 19
- 0
logic/GameClass/GameObj/Map/Wall.cs View File

@@ -0,0 +1,19 @@
using Preparation.Utility;
using Preparation.GameData;

namespace GameClass.GameObj
{
/// <summary>
/// 墙体
/// </summary>
public class Wall : GameObj
{
public Wall(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, PlaceType.Land, GameObjType.Wall)
{
this.CanMove = false;
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
}
}

+ 20
- 0
logic/GameClass/GameObj/OutOfBoundBlock.cs View File

@@ -0,0 +1,20 @@
using Preparation.Interface;
using Preparation.Utility;

namespace GameClass.GameObj
{
/// <summary>
/// 逻辑墙
/// </summary>
public class OutOfBoundBlock : GameObj, IOutOfBound
{
public OutOfBoundBlock(XY initPos) :
base(initPos, int.MaxValue, PlaceType.Land, GameObjType.OutOfBoundBlock)
{
this.CanMove = false;
}

public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
}
}

+ 1
- 1
logic/GameEngine/MoveEngine.cs View File

@@ -64,7 +64,7 @@ namespace GameEngine
(
() =>
{
if (!obj.IsAvailable&&gameTimer.IsGaming) //不能动就直接return,后面都是能动的情况
if (!obj.IsAvailable && gameTimer.IsGaming) //不能动就直接return,后面都是能动的情况
return;
lock (obj.MoveLock)
obj.IsMoving = true;


+ 14
- 0
logic/Gaming/Gaming.csproj View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\GameClass\GameClass.csproj" />
<ProjectReference Include="..\GameEngine\GameEngine.csproj" />
<ProjectReference Include="..\Preparation\Preparation.csproj" />
</ItemGroup>

</Project>

+ 2
- 0
logic/Preparation/GameData/GameData.cs View File

@@ -33,6 +33,8 @@ namespace Preparation.GameData
{
return PosGridToCellX(pos1) == PosGridToCellX(pos2) && PosGridToCellY(pos1) == PosGridToCellY(pos2);
}

public static int numOfBirthPoint = 5;
#endregion
#region 角色相关
/// <summary>


+ 8
- 0
logic/Preparation/Interface/IOutOfBound.cs View File

@@ -0,0 +1,8 @@

namespace Preparation.Interface
{
public interface IOutOfBound : IGameObj
{
// 接口不定义内容,为引擎使用
}
}

+ 11
- 0
logic/Preparation/Preparation.csproj View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<StartupObject />
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>

+ 13
- 2
logic/Preparation/Utility/EnumType.cs View File

@@ -35,8 +35,6 @@ namespace Preparation.Utility
Grass1 = 3,
Grass2 = 4,
Grass3 = 5,
Grass4 = 6,
Grass5 = 7,
}
public enum BulletType // 子弹类型
{
@@ -93,3 +91,16 @@ namespace Preparation.Utility
PickedProp = 5
}
}
public enum MapInfoObjType
{
Null = 0,
Wall = 1,
Grass1 = 2,
Grass2 = 3,
Grass3 = 4,
BirthPoint1 = 5,
BirthPoint2 = 6,
BirthPoint3 = 7,
BirthPoint4 = 8,
BirthPoint5 = 9,
}

+ 30
- 0
logic/logic.sln View File

@@ -5,6 +5,16 @@ VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "Server\Server.csproj", "{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameClass", "GameClass\GameClass.csproj", "{39D838F6-2B84-49E1-9CAF-1DFF22960B5D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameEngine", "GameEngine\GameEngine.csproj", "{91448D70-61C3-499F-9B27-979E16DC9E64}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gaming", "Gaming\Gaming.csproj", "{BE9E3584-93C0-4E0F-8DAC-967CF4792709}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapGenerator", "MapGenerator\MapGenerator.csproj", "{9BC673F1-14B1-4203-944D-474BD0F64EDC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Preparation", "Preparation\Preparation.csproj", "{E3DC4A37-8A83-40CC-AE47-68E70064C9DB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +25,26 @@ Global
{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}.Release|Any CPU.Build.0 = Release|Any CPU
{39D838F6-2B84-49E1-9CAF-1DFF22960B5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39D838F6-2B84-49E1-9CAF-1DFF22960B5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39D838F6-2B84-49E1-9CAF-1DFF22960B5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39D838F6-2B84-49E1-9CAF-1DFF22960B5D}.Release|Any CPU.Build.0 = Release|Any CPU
{91448D70-61C3-499F-9B27-979E16DC9E64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91448D70-61C3-499F-9B27-979E16DC9E64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91448D70-61C3-499F-9B27-979E16DC9E64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91448D70-61C3-499F-9B27-979E16DC9E64}.Release|Any CPU.Build.0 = Release|Any CPU
{BE9E3584-93C0-4E0F-8DAC-967CF4792709}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE9E3584-93C0-4E0F-8DAC-967CF4792709}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE9E3584-93C0-4E0F-8DAC-967CF4792709}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE9E3584-93C0-4E0F-8DAC-967CF4792709}.Release|Any CPU.Build.0 = Release|Any CPU
{9BC673F1-14B1-4203-944D-474BD0F64EDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BC673F1-14B1-4203-944D-474BD0F64EDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BC673F1-14B1-4203-944D-474BD0F64EDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BC673F1-14B1-4203-944D-474BD0F64EDC}.Release|Any CPU.Build.0 = Release|Any CPU
{E3DC4A37-8A83-40CC-AE47-68E70064C9DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3DC4A37-8A83-40CC-AE47-68E70064C9DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3DC4A37-8A83-40CC-AE47-68E70064C9DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3DC4A37-8A83-40CC-AE47-68E70064C9DB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


Loading…
Cancel
Save