Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: basic structure of logic #11

Merged
merged 19 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
404 changes: 404 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions dependency/proto/Proto.sln
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32328.378
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Proto", "Proto.csproj", "{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CB1C0B2E-5D0E-4420-94B5-FE8AECC7E106}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32328.378
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Proto", "Proto.csproj", "{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9A3CDD7-7852-4220-A2AA-2B986E0C19E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CB1C0B2E-5D0E-4420-94B5-FE8AECC7E106}
EndGlobalSection
EndGlobal
68 changes: 34 additions & 34 deletions dependency/proto/Protos.csproj
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<!--<ItemGroup>
<None Remove="Message2Clients.proto" />
<None Remove="Message2Server.proto" />
<None Remove="MessageType.proto" />
<None Remove="Services.proto" />
</ItemGroup>-->
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.24.4" />
<PackageReference Include="Grpc" Version="2.46.6" />
<PackageReference Include="Grpc.Core" Version="2.46.6" />
<PackageReference Include="Grpc.Tools" Version="2.54.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Protobuf Include="Message2Clients.proto" />
<Protobuf Include="Message2Server.proto" />
<Protobuf Include="MessageType.proto" />
<Protobuf Include="Services.proto" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

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

<!--<ItemGroup>
<None Remove="Message2Clients.proto" />
<None Remove="Message2Server.proto" />
<None Remove="MessageType.proto" />
<None Remove="Services.proto" />
</ItemGroup>-->

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.24.4" />
<PackageReference Include="Grpc" Version="2.46.6" />
<PackageReference Include="Grpc.Core" Version="2.46.6" />
<PackageReference Include="Grpc.Tools" Version="2.54.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Protobuf Include="Message2Clients.proto" />
<Protobuf Include="Message2Server.proto" />
<Protobuf Include="MessageType.proto" />
<Protobuf Include="Services.proto" />
</ItemGroup>

</Project>
37 changes: 37 additions & 0 deletions logic/Client/Client.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32328.378
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client.csproj", "{5AD8481D-90EF-410C-BD48-355DB97EEAB3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Playback", "..\..\playback\Playback\Playback.csproj", "{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protos", "..\..\dependency\proto\Protos.csproj", "{A0F72D3B-9A82-48EB-90AF-B3770151AD83}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Release|Any CPU.Build.0 = Release|Any CPU
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Debug|Any CPU.Build.0 = Debug|Any CPU
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Release|Any CPU.ActiveCfg = Release|Any CPU
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Release|Any CPU.Build.0 = Release|Any CPU
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {89A74B1B-445C-49EB-9C93-506DC243C227}
EndGlobalSection
EndGlobal
Binary file added logic/Client/Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions logic/GameClass/GameObj/Bullet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Preparation.Interface;
using Preparation.Utility;

namespace GameClass.GameObj;

public abstract class Bullet : ObjOfShip
{
public abstract double BulletBombRange { get; }
public abstract double AttackDistance { get; }
public AtomicInt AP { get; } = new(0);
public abstract int Speed { get; }
public abstract int CastTime { get; }
public abstract int SwingTime { get; }
public abstract int CD { get; }
public abstract int MaxBulletNum { get; }
public override bool IsRigid => true; // 默认为true
public override ShapeType Shape => ShapeType.Circle; // 默认为圆形
public abstract BulletType TypeOfBullet { get; }
public abstract bool CanAttack(GameObj target);
public abstract bool CanBeBombed(GameObjType gameObjType);
public override bool IgnoreCollideExecutor(IGameObj targetObj)
{
if (targetObj == Parent) return true;
if (targetObj.Type == GameObjType.Bullet)
return true;
return false;
}
public Bullet(Ship ship, int radius, XY Position) :
base(Position, radius, GameObjType.Bullet)
{
this.CanMove.SetReturnOri(true);
this.MoveSpeed.SetReturnOri(this.Speed);
this.Parent = ship;
}
}
37 changes: 37 additions & 0 deletions logic/GameClass/GameObj/Bullets/Arc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Preparation.Utility;
using System;

namespace GameClass.GameObj.Bullets;

internal sealed class Arc : Bullet
{
public Arc(Ship ship, XY pos, int radius = GameData.BulletRadius) :
base(ship, radius, pos)
{
Random random = new Random();
this.AP.SetReturnOri(random.Next(GameData.ArcDamageMin, GameData.ArcDamageMax));
}
public override double BulletBombRange => 0;
public override double AttackDistance => GameData.ArcRange;
public override int Speed => GameData.ArcSpeed;
public override int CastTime => GameData.ArcCastTime;
public override int SwingTime => GameData.ArcSwingTime;
private const int cd = GameData.ArcSwingTime;
public override int CD => cd;
public const int maxBulletNum = 1;
public override int MaxBulletNum => maxBulletNum;
public override BulletType TypeOfBullet => BulletType.Arc;
public override bool CanAttack(GameObj target)
{
//if (target.Type == GameObjType.Ship
// || target.Type == GameObjType.Construction
// || target.Type == GameObjType.Wormhole
// || target.Type == GameObjType.Home)
// return true;
return false;
}
public override bool CanBeBombed(GameObjType gameObjType)
{
return false;
}
}
19 changes: 19 additions & 0 deletions logic/GameClass/GameObj/Bullets/BulletFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Preparation.Utility;

namespace GameClass.GameObj.Bullets;

public static class BulletFactory
{
public static Bullet? GetBullet(Ship ship, XY pos, BulletType bulletType)
{
return bulletType switch
{
BulletType.Laser => new Laser(ship, pos),
BulletType.Plasma => new Plasma(ship, pos),
BulletType.Shell => new Shell(ship, pos),
BulletType.Missile => new Missile(ship, pos),
BulletType.Arc => new Arc(ship, pos),
_ => null,
};
}
}
37 changes: 37 additions & 0 deletions logic/GameClass/GameObj/Bullets/Laser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Preparation.Interface;
using Preparation.Utility;
using System;
using System.Threading;

namespace GameClass.GameObj.Bullets;

internal sealed class Laser : Bullet
{
public Laser(Ship ship, XY pos, int radius = GameData.BulletRadius) :
base(ship, radius, pos)
{
this.AP.SetReturnOri(GameData.LaserDamage);
}
public override double BulletBombRange => 0;
public override double AttackDistance => GameData.LaserRange;
public override int Speed => GameData.LaserSpeed;
public override int CastTime => GameData.LaserCastTime;
public override int SwingTime => GameData.LaserSwingTime;
private const int cd = GameData.LaserSwingTime;
public override int CD => cd;
public override int MaxBulletNum => 1;
public override BulletType TypeOfBullet => BulletType.Laser;
public override bool CanAttack(GameObj target)
{
//if (target.Type == GameObjType.Ship
// || target.Type == GameObjType.Construction
// || target.Type == GameObjType.Wormhole
// || target.Type == GameObjType.Home)
// return true;
return false;
}
public override bool CanBeBombed(GameObjType gameObjType)
{
return false;
}
}
36 changes: 36 additions & 0 deletions logic/GameClass/GameObj/Bullets/Missile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Preparation.Utility;

namespace GameClass.GameObj.Bullets;

internal sealed class Missile : Bullet
{
public Missile(Ship ship, XY pos, int radius = GameData.BulletRadius) :
base(ship, radius, pos)
{
this.AP.SetReturnOri(GameData.MissileDamage);
}
public override double BulletBombRange => GameData.MissileBombRange;
public override double AttackDistance => GameData.MissileRange;
public override int Speed => GameData.MissileSpeed;
public override int CastTime => GameData.MissileCastTime;
public override int SwingTime => GameData.ShellSwingTime;
private const int cd = GameData.ShellSwingTime;
public override int CD => cd;
public const int maxBulletNum = 1;
public override int MaxBulletNum => maxBulletNum;
public override BulletType TypeOfBullet => BulletType.Missile;
public override bool CanAttack(GameObj target)
{
//if (target.Type == GameObjType.Ship
// || target.Type == GameObjType.Construction
// || target.Type == GameObjType.Wormhole
// || target.Type == GameObjType.Home)
// return true;
return false;
}
public override bool CanBeBombed(GameObjType gameObjType)
{
//return true;
return false;
}
}
35 changes: 35 additions & 0 deletions logic/GameClass/GameObj/Bullets/Plasma.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Preparation.Utility;

namespace GameClass.GameObj.Bullets;

internal sealed class Plasma : Bullet
{
public Plasma(Ship ship, XY pos, int radius = GameData.BulletRadius) :
base(ship, radius, pos)
{
this.AP.SetReturnOri(GameData.PlasmaDamage);
}
public override double BulletBombRange => 0;
public override double AttackDistance => GameData.PlasmaRange;
public override int Speed => GameData.PlasmaSpeed;
public override int CastTime => GameData.PlasmaCastTime;
public override int SwingTime => GameData.PlasmaSwingTime;
private const int cd = GameData.PlasmaSwingTime;
public override int CD => cd;
public const int maxBulletNum = 1;
public override int MaxBulletNum => maxBulletNum;
public override BulletType TypeOfBullet => BulletType.Plasma;
public override bool CanAttack(GameObj target)
{
//if (target.Type == GameObjType.Ship
// || target.Type == GameObjType.Construction
// || target.Type == GameObjType.Wormhole
// || target.Type == GameObjType.Home)
// return true;
return false;
}
public override bool CanBeBombed(GameObjType gameObjType)
{
return false;
}
}
Loading
Loading