Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

fix!(logic): set Nullable as "enable", solve the bug of throwing exception when adding buff. #58

Merged
merged 6 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions communication/Proto/Proto.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions logic/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<ApplicationIcon>EESAST.ico</ApplicationIcon>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions logic/FrameRateTask/FrameRateTask.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

</Project>
3 changes: 2 additions & 1 deletion logic/GameClass/GameClass.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
Expand Down
19 changes: 11 additions & 8 deletions logic/GameClass/GameObj/Character.BuffManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@

namespace GameClass.GameObj
{
public partial class Character
public
partial class Character
{
private readonly BuffManeger buffManeger;
/// <summary>
/// buff管理器,目前为全抄THUAI4(佐以修改部分变量名,变uint为int)
/// 角色携带的buff管理器,目前为全抄THUAI4(佐以修改部分变量名,变uint为int)
/// </summary>
private class BuffManeger
{
private const int BuffTypeNum = 7; // buff的种类个数,即enum BuffType的成员个数

[StructLayout(LayoutKind.Explicit, Size = 8)]
private struct BuffValue // buff参数联合体类型,可能是int或double
{
Expand All @@ -29,6 +28,9 @@ private struct BuffValue // buff参数联合体类型,可能是int或double
public BuffValue(double longFloatValue) { this.iValue = 0; this.lfValue = longFloatValue; }
}

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

Expand Down Expand Up @@ -128,10 +130,12 @@ public bool HasSpear
}
}
}

/// <summary>
/// 清除所有buff
/// </summary>
public void ClearAll()
{
for (int i = 0; i < BuffTypeNum; ++i)
for (int i = 0; i < GameData.BuffTypeNum; ++i)
{
lock (buffListLock[i])
{
Expand All @@ -143,7 +147,7 @@ public void ClearAll()
public BuffManeger()
{

buffList = new LinkedList<BuffValue>[BuffTypeNum];
buffList = new LinkedList<BuffValue>[GameData.BuffTypeNum];
for (int i = 0; i < buffList.Length; ++i)
{
buffList[i] = new LinkedList<BuffValue>();
Expand All @@ -154,7 +158,6 @@ public BuffManeger()
{
buffListLock[i] = new object();
}

}
}
}
Expand Down
5 changes: 5 additions & 0 deletions logic/GameClass/GameObj/Character.SkillManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public Character(XYPosition initPos, int initRadius, PlaceType initPlace, Passiv
{
this.CanMove = true;
this.Type = GameObjType.Character;
this.score = 0;
this.propInventory = null;
this.buffManeger = new BuffManeger();
PassiveSkill pSkill;
CommonSkill cSkill;
switch (passiveSkillType)
Expand Down Expand Up @@ -88,6 +91,8 @@ public Character(XYPosition initPos, int initRadius, PlaceType initPlace, Passiv

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

Debugger.Output(this, "constructed!");
}
}
}
1 change: 1 addition & 0 deletions logic/GameEngine/GameEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions logic/Gaming/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public bool StartGame(int milliSeconds)
foreach (Character player in gameMap.PlayerList)
{
player.CanMove = true;

//这里bug了,不信可以取消注释试试看0.0
//player.AddShield(GameData.shieldTimeAtBirth);
player.AddShield(GameData.shieldTimeAtBirth);
}
}
finally { gameMap.PlayerListLock.ExitReadLock(); }
Expand Down
3 changes: 2 additions & 1 deletion logic/Gaming/Gaming.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
Expand Down
10 changes: 7 additions & 3 deletions logic/Preparation/GameData/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Preparation.GameData
{
public static class GameData
{
#region 基本常数与常方法
public const int numOfPosGridPerCell = 1000; // 每格的【坐标单位】数
public const int numOfStepPerSecond = 20; // 每秒行走的步数
public const int lengthOfMap = 50000; // 地图长度
Expand All @@ -29,6 +30,8 @@ public static int PosGridToCellY(XYPosition pos) // 求坐标所在的格
{
return pos.y / numOfPosGridPerCell;
}
#endregion
#region 角色相关
/// <summary>
/// 玩家相关
/// </summary>
Expand Down Expand Up @@ -56,9 +59,10 @@ public static int PosGridToCellY(XYPosition pos) // 求坐标所在的格
/// </summary>
public const int MinPropTypeNum = 1;
public const int MaxPropTypeNum = 10;
/// <summary>
/// 游戏帧相关
/// </summary>
public const int BuffTypeNum = 7;
#endregion
#region 游戏帧相关
public const long checkInterval = 50; //检查位置标志、补充子弹的帧时长
#endregion
}
}
1 change: 1 addition & 0 deletions logic/Preparation/Preparation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net5.0</TargetFramework>
<ApplicationIcon />
<StartupObject />
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
1 change: 1 addition & 0 deletions logic/Server/Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion logic/Test/Test.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down