migrate from perforce

This commit is contained in:
2026-04-19 01:16:27 +02:00
commit d161a20915
1810 changed files with 1156171 additions and 0 deletions

0
.gitignore vendored Normal file
View File

21
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "firefox",
"request": "launch",
"name": "Launch in Firefox",
"url": "http://localhost:4200",
"preLaunchTask": "npm: start",
"sourceMaps": true,
"trace": true,
"webRoot": "${workspaceFolder}",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
}
]
}

115
HexTowerDefense.csproj Normal file
View File

@@ -0,0 +1,115 @@
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.TypeScript.MSBuild.5.7.1\build\Microsoft.TypeScript.MSBuild.props" Condition="Exists('packages\Microsoft.TypeScript.MSBuild.5.7.1\build\Microsoft.TypeScript.MSBuild.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TypeScriptHTMLApp1</RootNamespace>
<AssemblyName>TypeScriptHTMLApp1</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Content Include="htd.css" />
<Content Include="tsconfig.json" />
<Content Include="package.json" />
<None Include="packages.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="index.html" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Content Include="views\**" />
</ItemGroup>
<ItemGroup>
<Content Include="src\**" />
</ItemGroup>
<ItemGroup>
<Content Include="images\**" />
</ItemGroup>
<ItemGroup>
<Service Include="{4A0DDDB5-7A95-4FBF-97CC-616D07737A77}" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>10202</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:10202/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.TypeScript.MSBuild.5.7.1\build\Microsoft.TypeScript.MSBuild.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.TypeScript.MSBuild.5.7.1\build\Microsoft.TypeScript.MSBuild.props'))" />
<Error Condition="!Exists('packages\Microsoft.TypeScript.MSBuild.5.7.1\build\Microsoft.TypeScript.MSBuild.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.TypeScript.MSBuild.5.7.1\build\Microsoft.TypeScript.MSBuild.targets'))" />
</Target>
<Import Project="packages\Microsoft.TypeScript.MSBuild.5.7.1\build\Microsoft.TypeScript.MSBuild.targets" Condition="Exists('packages\Microsoft.TypeScript.MSBuild.5.7.1\build\Microsoft.TypeScript.MSBuild.targets')" />
</Project>

25
HexTowerDefense.sln Normal file
View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35201.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexTowerDefense", "HexTowerDefense.csproj", "{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {06274111-DD20-4926-A466-F8925CE5EEA8}
EndGlobalSection
EndGlobal

30
Web.Debug.config Normal file
View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>

31
Web.Release.config Normal file
View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>

11
Web.config Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
</system.web>
</configuration>

7
dist/GameData/EEnemySize.js vendored Normal file
View File

@@ -0,0 +1,7 @@
export var EEnemySize;
(function (EEnemySize) {
EEnemySize[EEnemySize["Normal"] = 0] = "Normal";
EEnemySize[EEnemySize["Tiny"] = 1] = "Tiny";
EEnemySize[EEnemySize["Huge"] = 2] = "Huge";
})(EEnemySize || (EEnemySize = {}));
//# sourceMappingURL=EEnemySize.js.map

1
dist/GameData/EEnemySize.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"EEnemySize.js","sourceRoot":"","sources":["../../src/GameData/EEnemySize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,+CAAM,CAAA;IACN,2CAAI,CAAA;IACJ,2CAAI,CAAA;AACR,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB"}

View File

@@ -0,0 +1,5 @@
export var EProjectileEffectType;
(function (EProjectileEffectType) {
EProjectileEffectType[EProjectileEffectType["Damage"] = 0] = "Damage";
})(EProjectileEffectType || (EProjectileEffectType = {}));
//# sourceMappingURL=EProjectileEffectType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EProjectileEffectType.js","sourceRoot":"","sources":["../../src/GameData/EProjectileEffectType.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,qBAEX;AAFD,WAAY,qBAAqB;IAC7B,qEAAU,CAAA;AACd,CAAC,EAFW,qBAAqB,KAArB,qBAAqB,QAEhC"}

13
dist/GameData/GdEnemy.js vendored Normal file
View File

@@ -0,0 +1,13 @@
export class GdEnemy {
speed = 0;
static addEnemies(gdRoot) {
gdRoot.enemies.push(createEnemy0());
}
}
function createEnemy0() {
return {
...new GdEnemy(),
speed: 2
};
}
//# sourceMappingURL=GdEnemy.js.map

1
dist/GameData/GdEnemy.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"GdEnemy.js","sourceRoot":"","sources":["../../src/GameData/GdEnemy.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,OAAO;IACT,KAAK,GAAW,CAAC,CAAC;IAEzB,MAAM,CAAC,UAAU,CAAC,MAAc;QAC5B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IACxC,CAAC;CACJ;AAED,SAAS,YAAY;IACjB,OAAO;QACH,GAAG,IAAI,OAAO,EAAE;QAChB,KAAK,EAAE,CAAC;KACX,CAAC;AACN,CAAC"}

103
dist/GameData/GdImage.js vendored Normal file
View File

@@ -0,0 +1,103 @@
async function loadImageAsync(url) {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img); // Resolve the promise when the image loads
img.onerror = (error) => reject(new Error(`Failed to load image at ${url}`)); // Reject on error
img.src = url; // Start loading the image
});
}
export class GdImage {
static async addImagesAsync(gdRoot) {
const images = [
"projectile.svg",
"tower-0.svg",
"cell-highlighted.svg",
"cell-entry-1.svg",
"cell-entry-2.svg",
"cell-entry-3.svg",
"cell-entry-4.svg",
"cell-entry-6.svg",
"cell-entry-8.svg",
"cell-entry-12.svg",
"cell-entry-16.svg",
"cell-entry-24.svg",
"cell-entry-32.svg",
"cell-entry-33.svg",
"cell-entry-48.svg",
"cell-blocked-0.svg",
"cell-blocked-1.svg",
"cell-blocked-2.svg",
"cell-blocked-3.svg",
"cell-blocked-4.svg",
"cell-blocked-5.svg",
"cell-blocked-6.svg",
"cell-blocked-7.svg",
"cell-blocked-8.svg",
"cell-blocked-9.svg",
"cell-blocked-10.svg",
"cell-blocked-11.svg",
"cell-blocked-12.svg",
"cell-blocked-13.svg",
"cell-blocked-14.svg",
"cell-blocked-15.svg",
"cell-blocked-16.svg",
"cell-blocked-17.svg",
"cell-blocked-18.svg",
"cell-blocked-19.svg",
"cell-blocked-20.svg",
"cell-blocked-21.svg",
"cell-blocked-22.svg",
"cell-blocked-23.svg",
"cell-blocked-24.svg",
"cell-blocked-25.svg",
"cell-blocked-26.svg",
"cell-blocked-27.svg",
"cell-blocked-28.svg",
"cell-blocked-29.svg",
"cell-blocked-30.svg",
"cell-blocked-31.svg",
"cell-blocked-32.svg",
"cell-blocked-33.svg",
"cell-blocked-34.svg",
"cell-blocked-35.svg",
"cell-blocked-36.svg",
"cell-blocked-37.svg",
"cell-blocked-38.svg",
"cell-blocked-39.svg",
"cell-blocked-40.svg",
"cell-blocked-41.svg",
"cell-blocked-42.svg",
"cell-blocked-43.svg",
"cell-blocked-44.svg",
"cell-blocked-45.svg",
"cell-blocked-46.svg",
"cell-blocked-47.svg",
"cell-blocked-48.svg",
"cell-blocked-49.svg",
"cell-blocked-50.svg",
"cell-blocked-51.svg",
"cell-blocked-52.svg",
"cell-blocked-53.svg",
"cell-blocked-54.svg",
"cell-blocked-55.svg",
"cell-blocked-56.svg",
"cell-blocked-57.svg",
"cell-blocked-58.svg",
"cell-blocked-59.svg",
"cell-blocked-60.svg",
"cell-blocked-61.svg",
"cell-blocked-62.svg",
"cell-blocked-63.svg",
"cell.svg",
"enemy-0.svg",
"wall.png",
];
for (const url of images)
await this.loadAsync(gdRoot, url);
}
static async loadAsync(gdRoot, url) {
const image = await loadImageAsync("images/" + url);
gdRoot.images[url] = image;
}
}
//# sourceMappingURL=GdImage.js.map

1
dist/GameData/GdImage.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"GdImage.js","sourceRoot":"","sources":["../../src/GameData/GdImage.ts"],"names":[],"mappings":"AAEA,KAAK,UAAU,cAAc,CAAC,GAAW;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;QACx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BAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,qBAAqB;YACrB,UAAU;YACV,aAAa;YACb,UAAU;SACb,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,MAAM;YACpB,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,GAAW;QACtD,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC;QACpD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC/B,CAAC;CACJ"}

58
dist/GameData/GdLevel.js vendored Normal file
View File

@@ -0,0 +1,58 @@
import { Hex } from "../Util/index.js";
import { EEnemySize } from "./index.js";
export class GdLevel {
radius = 0;
currency = 0;
walls = [];
enemySpawns = [];
enemyTargets = [];
enemyRoutes = [];
waves = [];
static addLevels(gdRoot) {
gdRoot.levels.push(createLevel0());
}
}
function createLevel0() {
return {
...new GdLevel(),
radius: 9,
currency: 1500,
walls: [
new Hex(0, 0)
],
enemySpawns: [
new Hex(-9, -1),
new Hex(-9, 0),
new Hex(-9, 1)
],
enemyTargets: [
new Hex(8, -1),
new Hex(9, 0),
new Hex(8, 1)
],
enemyRoutes: [
[0, 0],
[0, 1],
[0, 2],
[1, 0],
[1, 1],
[1, 2],
[2, 0],
[2, 1],
[2, 2],
],
waves: [
{ enemy: 0, size: EEnemySize.Normal, amount: 10, gain: 3, hitpoints: 10 },
{ enemy: 0, size: EEnemySize.Normal, amount: 10, gain: 5, hitpoints: 20 },
{ enemy: 0, size: EEnemySize.Tiny, amount: 50, gain: 7, hitpoints: 5 },
{ enemy: 0, size: EEnemySize.Normal, amount: 15, gain: 10, hitpoints: 30 },
{ enemy: 0, size: EEnemySize.Huge, amount: 3, gain: 50, hitpoints: 200 },
{ enemy: 0, size: EEnemySize.Normal, amount: 10, gain: 10, hitpoints: 60 },
{ enemy: 0, size: EEnemySize.Normal, amount: 10, gain: 15, hitpoints: 70 },
{ enemy: 0, size: EEnemySize.Normal, amount: 15, gain: 20, hitpoints: 80 },
{ enemy: 0, size: EEnemySize.Normal, amount: 15, gain: 25, hitpoints: 90 },
{ enemy: 0, size: EEnemySize.Huge, amount: 3, gain: 100, hitpoints: 500 },
]
};
}
//# sourceMappingURL=GdLevel.js.map

1
dist/GameData/GdLevel.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"GdLevel.js","sourceRoot":"","sources":["../../src/GameData/GdLevel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AAExD,MAAM,OAAO,OAAO;IACT,MAAM,GAAW,CAAC,CAAC;IACnB,QAAQ,GAAW,CAAC,CAAC;IACrB,KAAK,GAAU,EAAE,CAAC;IAClB,WAAW,GAAU,EAAE,CAAC;IACxB,YAAY,GAAU,EAAE,CAAC;IACzB,WAAW,GAAe,EAAE,CAAC;IAC7B,KAAK,GAAa,EAAE,CAAC;IAE5B,MAAM,CAAC,SAAS,CAAC,MAAc;QAC3B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IACvC,CAAC;CACJ;AAED,SAAS,YAAY;IACjB,OAAO;QACH,GAAG,IAAI,OAAO,EAAE;QAChB,MAAM,EAAE,CAAC;QACT,QAAQ,EAAE,IAAI;QACd,KAAK,EAA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,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;YAC1E,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAI,MAAM,EAAE,CAAC,EAAG,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE;YAC3E,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;YAC1E,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;YAC1E,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;YAC1E,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;YAC1E,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAI,MAAM,EAAE,CAAC,EAAG,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE;SAC/E;KACJ,CAAC;AACN,CAAC"}

11
dist/GameData/GdProjectileEffect.js vendored Normal file
View File

@@ -0,0 +1,11 @@
export class GdProjectileEffect {
type;
amount;
speed;
constructor(type, amount, speed) {
this.type = type;
this.amount = amount;
this.speed = speed;
}
}
//# sourceMappingURL=GdProjectileEffect.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GdProjectileEffect.js","sourceRoot":"","sources":["../../src/GameData/GdProjectileEffect.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAkB;IACpB,IAAI,CAAwB;IAC5B,MAAM,CAAS;IACf,KAAK,CAAS;IAErB,YAAY,IAA2B,EAAE,MAAc,EAAE,KAAa;QAClE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ"}

18
dist/GameData/GdRoot.js vendored Normal file
View File

@@ -0,0 +1,18 @@
import { GdEnemy, GdImage, GdLevel, GdSimulation, GdTower } from "./index.js";
export class GdRoot {
images = {};
enemies = [];
towers = [];
levels = [];
simulation = new GdSimulation();
async loadAsync() {
GdEnemy.addEnemies(this);
GdLevel.addLevels(this);
GdTower.addTowers(this);
await GdImage.addImagesAsync(this);
}
image(name) {
return this.images[name];
}
}
//# sourceMappingURL=GdRoot.js.map

1
dist/GameData/GdRoot.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"GdRoot.js","sourceRoot":"","sources":["../../src/GameData/GdRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9E,MAAM,OAAO,MAAM;IACR,MAAM,GAAwC,EAAE,CAAC;IACjD,OAAO,GAAc,EAAE,CAAC;IACxB,MAAM,GAAc,EAAE,CAAC;IACvB,MAAM,GAAc,EAAE,CAAC;IACvB,UAAU,GAAiB,IAAI,YAAY,EAAE,CAAC;IAErD,KAAK,CAAC,SAAS;QACX,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACxB,MAAM,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAqB,CAAC;IACjD,CAAC;CACJ"}

6
dist/GameData/GdSimulation.js vendored Normal file
View File

@@ -0,0 +1,6 @@
export class GdSimulation {
stepsPerSecond = 30;
waveDuration = 15;
spawnDelay = 0.2;
}
//# sourceMappingURL=GdSimulation.js.map

1
dist/GameData/GdSimulation.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"GdSimulation.js","sourceRoot":"","sources":["../../src/GameData/GdSimulation.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,YAAY;IACd,cAAc,GAAW,EAAE,CAAC;IAC5B,YAAY,GAAW,EAAE,CAAC;IAC1B,UAAU,GAAW,GAAG,CAAC;CACnC"}

29
dist/GameData/GdTower.js vendored Normal file
View File

@@ -0,0 +1,29 @@
import { EProjectileEffectType, GdProjectileEffect } from "./index.js";
export class GdTower {
cost = 0;
projectileEffect = null;
projectileRange = 0;
projectileRate = 0;
projectileSize = 0;
aoeEffect = null;
aoeRange = 0;
aoeRate = 0;
static addTowers(gdRoot) {
gdRoot.towers.push(createTower0());
}
;
}
function createTower0() {
return {
...new GdTower(),
cost: 75,
projectileEffect: new GdProjectileEffect(EProjectileEffectType.Damage, 2, 10),
projectileRange: 2,
projectileRate: 5,
projectileSize: 0.2,
aoeEffect: null,
aoeRange: 0,
aoeRate: 0,
};
}
//# sourceMappingURL=GdTower.js.map

1
dist/GameData/GdTower.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"GdTower.js","sourceRoot":"","sources":["../../src/GameData/GdTower.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAU,MAAM,YAAY,CAAC;AAE/E,MAAM,OAAO,OAAO;IACT,IAAI,GAAW,CAAC,CAAC;IACjB,gBAAgB,GAA8B,IAAI,CAAC;IACnD,eAAe,GAAW,CAAC,CAAC;IAC5B,cAAc,GAAW,CAAC,CAAC;IAC3B,cAAc,GAAW,CAAC,CAAC;IAC3B,SAAS,GAA8B,IAAI,CAAC;IAC5C,QAAQ,GAAW,CAAC,CAAC;IACrB,OAAO,GAAW,CAAC,CAAC;IAE3B,MAAM,CAAC,SAAS,CAAC,MAAc;QAC3B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IACvC,CAAC;IAAA,CAAC;CACL;AAED,SAAS,YAAY;IACjB,OAAO;QACH,GAAG,IAAI,OAAO,EAAE;QAChB,IAAI,EAAE,EAAE;QACR,gBAAgB,EAAE,IAAI,kBAAkB,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7E,eAAe,EAAE,CAAC;QAClB,cAAc,EAAE,CAAC;QACjB,cAAc,EAAE,GAAG;QACnB,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;KACb,CAAC;AACN,CAAC"}

9
dist/GameData/GdWave.js vendored Normal file
View File

@@ -0,0 +1,9 @@
import { EEnemySize } from "./index.js";
export class GdWave {
enemy = 0;
size = EEnemySize.Normal;
amount = 0;
gain = 0;
hitpoints = 0;
}
//# sourceMappingURL=GdWave.js.map

1
dist/GameData/GdWave.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"GdWave.js","sourceRoot":"","sources":["../../src/GameData/GdWave.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,OAAO,MAAM;IACR,KAAK,GAAW,CAAC,CAAC;IAClB,IAAI,GAAe,UAAU,CAAC,MAAM,CAAC;IACrC,MAAM,GAAW,CAAC,CAAC;IACnB,IAAI,GAAW,CAAC,CAAC;IACjB,SAAS,GAAW,CAAC,CAAC;CAChC"}

12
dist/GameData/index.js vendored Normal file
View File

@@ -0,0 +1,12 @@
import { EEnemySize } from "./EEnemySize.js";
import { EProjectileEffectType } from "./EProjectileEffectType.js";
import { GdEnemy } from "./GdEnemy.js";
import { GdImage } from "./GdImage.js";
import { GdLevel } from "./GdLevel.js";
import { GdProjectileEffect } from "./GdProjectileEffect.js";
import { GdRoot } from "./GdRoot.js";
import { GdSimulation } from "./GdSimulation.js";
import { GdTower } from "./GdTower.js";
import { GdWave } from "./GdWave.js";
export { EEnemySize, EProjectileEffectType, GdEnemy, GdImage, GdLevel, GdProjectileEffect, GdRoot, GdSimulation, GdTower, GdWave };
//# sourceMappingURL=index.js.map

1
dist/GameData/index.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/GameData/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA"}

2
dist/Simulation/Actions/ISimAction.js vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ISimAction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ISimAction.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/ISimAction.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,11 @@
export class SimActionFireTowers {
execute(simMain) {
const level = simMain.currentLevel;
level.simCells.forEach((simCell) => {
if (simCell.simTower != null) {
simCell.simTower.fireIfAble();
}
});
}
}
//# sourceMappingURL=SimActionFireTowers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimActionFireTowers.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/SimActionFireTowers.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IACrB,OAAO,CAAC,OAAgB;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC;QACnC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAgB,EAAE,EAAE;YACxC,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;gBAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YAClC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}

View File

@@ -0,0 +1,33 @@
import { Hex, Vector2 } from "../../Util/index.js";
export class SimActionMoveEnemies {
execute(simMain) {
const simLevel = simMain.currentLevel;
const deadEnemies = [];
simLevel.simEnemies.forEach((simEnemy, idx) => {
if (simEnemy.dead)
deadEnemies.push(idx);
});
for (const idx of deadEnemies) {
simLevel.simEnemies.splice(idx, 1);
}
for (const simEnemy of simLevel.simEnemies) {
const duration = simEnemy.speed / simMain.gdRoot.simulation.stepsPerSecond;
const t = (simLevel.currentStep - simEnemy.currentPathStep) * duration;
const path2 = simLevel.simCells[simEnemy.path[simEnemy.currentPathIndex + 1]];
if (!path2) {
simEnemy.dead = true;
return;
}
const hex2 = path2.hex;
const pos1 = simEnemy.currentPathPosition;
const pos2 = Hex.toWorld(hex2);
simEnemy.position = Vector2.lerp(pos1, pos2, t);
if (t >= 1) {
simEnemy.currentPathIndex += 1;
simEnemy.currentPathStep = simLevel.currentStep;
simEnemy.onPathUpdated();
}
}
}
}
//# sourceMappingURL=SimActionMoveEnemies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimActionMoveEnemies.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/SimActionMoveEnemies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,MAAM,OAAO,oBAAoB;IACtB,OAAO,CAAC,OAAgB;QAC3B,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;QACtC,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAkB,EAAE,GAAW,EAAE,EAAE;YAC5D,IAAI,QAAQ,CAAC,IAAI;gBACb,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC5B,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACvC,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YACzC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC;YAC3E,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,GAAG,QAAQ,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC;YACvE,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC;YAC9E,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;gBACrB,OAAO;YACX,CAAC;YAED,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC;YACvB,MAAM,IAAI,GAAG,QAAQ,CAAC,mBAAmB,CAAC;YAC1C,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/B,QAAQ,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACT,QAAQ,CAAC,gBAAgB,IAAI,CAAC,CAAC;gBAC/B,QAAQ,CAAC,eAAe,GAAG,QAAQ,CAAC,WAAW,CAAC;gBAChD,QAAQ,CAAC,aAAa,EAAE,CAAC;YAC7B,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}

View File

@@ -0,0 +1,32 @@
export class SimActionMoveProjectiles {
execute(simMain) {
const simLevel = simMain.currentLevel;
const deadProjectiles = [];
simLevel.simProjectiles.forEach((simProjectile, idx) => {
if (simProjectile.dead)
deadProjectiles.push(idx);
});
for (const idx of deadProjectiles) {
simLevel.simProjectiles.splice(idx, 1);
}
simLevel.simProjectiles.forEach((simProjectile) => {
const target = simLevel.simEnemies[simProjectile.targetEnemyIdx];
if (!target || target.dead) {
simProjectile.dead = true;
return;
}
const pos1 = simProjectile.position;
const pos2 = target.position;
const dir = pos2.subtract(pos1);
const len = dir.magnitude();
let duration = simProjectile.speed / simMain.gdRoot.simulation.stepsPerSecond;
if (len < duration) {
duration = len;
simProjectile.dead = true;
target.suffer(simProjectile.gdEffect);
}
simProjectile.position = pos1.add(dir.normalized().multiplyScalar(duration));
});
}
}
//# sourceMappingURL=SimActionMoveProjectiles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimActionMoveProjectiles.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/SimActionMoveProjectiles.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,wBAAwB;IAC1B,OAAO,CAAC,OAAgB;QAC3B,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAwB,CAAC;QAClD,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CAAC,QAAQ,CAAC,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}

View File

@@ -0,0 +1,31 @@
import { EEnemySize } from "../../GameData/index.js";
import { SimCommandStartNextWave, SimEnemy } from "../index.js";
export class SimActionSpawnEnemies {
execute(simMain) {
const simLevel = simMain.currentLevel;
const gdLevel = simLevel.gdLevel;
const step = simLevel.currentStep;
const wave = gdLevel.waves[simLevel.currentWave];
let spawnDelay = simMain.gdRoot.simulation.spawnDelay;
switch (wave.size) {
case EEnemySize.Huge:
spawnDelay *= 2;
break;
case EEnemySize.Tiny:
spawnDelay *= 0.5;
break;
}
if (simLevel.enemiesLeftToSpawn > 0 && simLevel.lastEnemySpawnStep + spawnDelay * simMain.gdRoot.simulation.stepsPerSecond <= simLevel.currentStep) {
simLevel.enemiesLeftToSpawn -= 1;
simLevel.lastEnemySpawnStep = step;
const route = Math.floor(Math.random() * gdLevel.enemyRoutes.length);
const enemy = new SimEnemy(simMain.gdRoot, wave, route, simLevel);
enemy.onPathUpdated();
simLevel.simEnemies.push(enemy);
}
if (simLevel.nextWaveStep == step && !!gdLevel.waves[simLevel.currentWave + 1]) {
simMain.addCommand(new SimCommandStartNextWave(simMain.gdRoot, simLevel));
}
}
}
//# sourceMappingURL=SimActionSpawnEnemies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimActionSpawnEnemies.js","sourceRoot":"","sources":["../../../src/Simulation/Actions/SimActionSpawnEnemies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAc,uBAAuB,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAE/F,MAAM,OAAO,qBAAqB;IACvB,OAAO,CAAC,OAAgB;QAC3B,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAwB,CAAC;QAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QACjC,MAAM,IAAI,GAAG,QAAQ,CAA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ACJ"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ISimCommand.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ISimCommand.js","sourceRoot":"","sources":["../../../src/Simulation/Commands/ISimCommand.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,27 @@
import { Hex } from "../../Util/index.js";
import { ECellType } from "../index.js";
export class SimCommandBlockTerrain {
_hex;
_simLevel;
constructor(level, hex) {
this._hex = hex;
this._simLevel = level;
}
execute() {
const simLevel = this._simLevel;
const cellIndex = simLevel.getCellIndex(this._hex);
const cell = simLevel.simCells[cellIndex];
if (cell.type != ECellType.Free || cell.simTower != null || !simLevel.reservePaths(this._hex)) {
return;
}
cell.type = ECellType.Blocked;
simLevel.updateBlockedType(cell);
for (let i = 0; i < 6; ++i) {
const neighbourHex = Hex.neighbour(cell.hex, i);
const neighbourIndex = simLevel.getCellIndex(neighbourHex);
simLevel.updateBlockedType(simLevel.simCells[neighbourIndex]);
}
simLevel.updatePaths();
}
}
//# sourceMappingURL=SimCommandBlockTerrain.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimCommandBlockTerrain.js","sourceRoot":"","sources":["../../../src/Simulation/Commands/SimCommandBlockTerrain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAyB,MAAM,aAAa,CAAC;AAE/D,MAAM,OAAO,sBAAsB;IACvB,IAAI,CAAM;IACV,SAAS,CAAW;IAE5B,YAAY,KAAe,EAAE,GAAQ;QACjC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAEM,OAAO;QACV,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5F,OAAO;QACX,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC;QAC9B,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;YACzB,MAAM,YAAY,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAChD,MAAM,cAAc,GAAG,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;YAC3D,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;CACJ"}

View File

@@ -0,0 +1,42 @@
import { Hex } from "../../Util/index.js";
import { ECellType, SimTower } from "../index.js";
export class SimCommandCreateTower {
_hex;
_simLevel;
_index;
_gdRoot;
constructor(game, level, hex, index) {
this._gdRoot = game;
this._hex = hex;
this._simLevel = level;
this._index = index;
}
execute() {
const level = this._simLevel;
const cellIndex = level.getCellIndex(this._hex);
const cell = level.simCells[cellIndex];
const towerData = this._gdRoot.towers[this._index];
if (cell.type != ECellType.Free) {
return;
}
if (cell.simTower != null) {
return;
}
level.simEnemies.forEach((enemy) => {
const hex = Hex.fromWorld(enemy.position);
const enemyCellIndex = level.getCellIndex(hex);
if (cellIndex == enemyCellIndex) {
return;
}
});
if (level.currency < towerData.cost) {
return;
}
if (level.reservePaths(this._hex)) {
level.currency -= towerData.cost;
cell.simTower = new SimTower(this._gdRoot, level, this._index, this._hex);
level.updatePaths();
}
}
}
//# sourceMappingURL=SimCommandCreateTower.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimCommandCreateTower.js","sourceRoot":"","sources":["../../../src/Simulation/Commands/SimCommandCreateTower.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAmC,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnF,MAAM,OAAO,qBAAqB;IACtB,IAAI,CAAM;IACV,SAAS,CAAW;IACpB,MAAM,CAAS;IACf,OAAO,CAAS;IAExB,YAAY,IAAY,EAAE,KAAe,EAAE,GAAQ,EAAE,KAAa;QAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,OAAO;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnD,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAO;QACX,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QAED,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,KAAe,EAAE,EAAE;YACzC,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC1C,MAAM,cAAc,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAC/C,IAAI,SAAS,IAAI,cAAc,EAAE,CAAC;gBAC9B,OAAO;YACX,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO;QACX,CAAC;QAED,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1E,KAAK,CAAC,WAAW,EAAE,CAAC;QACxB,CAAC;IACL,CAAC;CACJ"}

View File

@@ -0,0 +1,21 @@
export class SimCommandStartNextWave {
_simLevel;
_gdRoot;
constructor(gdRoot, level) {
this._gdRoot = gdRoot;
this._simLevel = level;
}
execute() {
const level = this._simLevel;
const data = level.gdLevel;
level.currentWave += 1;
if (!data.waves[level.currentWave]) {
level.paused = true;
return;
}
level.nextWaveStep = level.currentStep + this._gdRoot.simulation.waveDuration * this._gdRoot.simulation.stepsPerSecond - 1;
level.lastEnemySpawnStep = level.currentStep;
level.enemiesLeftToSpawn = data.waves[level.currentWave].amount;
}
}
//# sourceMappingURL=SimCommandStartNextWave.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimCommandStartNextWave.js","sourceRoot":"","sources":["../../../src/Simulation/Commands/SimCommandStartNextWave.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,uBAAuB;IACxB,SAAS,CAAW;IACpB,OAAO,CAAS;IAExB,YAAY,MAAc,EAAE,KAAe;QACvC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,OAAO;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC;QAC3B,KAAK,CAAC,WAAW,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;YACjC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;YACpB,OAAO;QACX,CAAC;QACD,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,GAAG,CAAC,CAAC;QAC3H,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAAC;QAC7C,KAAK,CAAC,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;IACpE,CAAC;CACJ"}

9
dist/Simulation/Models/ECellType.js vendored Normal file
View File

@@ -0,0 +1,9 @@
export var ECellType;
(function (ECellType) {
ECellType[ECellType["Free"] = 0] = "Free";
ECellType[ECellType["Blocked"] = 1] = "Blocked";
ECellType[ECellType["Entry"] = 2] = "Entry";
ECellType[ECellType["Reserved"] = 3] = "Reserved";
})(ECellType || (ECellType = {}));
;
//# sourceMappingURL=ECellType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ECellType.js","sourceRoot":"","sources":["../../../src/Simulation/Models/ECellType.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACjB,yCAAQ,CAAA;IACR,+CAAW,CAAA;IACX,2CAAS,CAAA;IACT,iDAAQ,CAAA;AACZ,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAAA,CAAC"}

50
dist/Simulation/Models/SimCell.js vendored Normal file
View File

@@ -0,0 +1,50 @@
export class SimCell {
_hex;
_distance;
_type;
_blockedType = -1;
_index;
_simTower = null;
_pathsToTarget = [];
constructor(hex, distance, type, index) {
this._hex = hex;
this._distance = distance;
this._type = type;
this._index = index;
}
;
get hex() {
return this._hex;
}
get distance() {
return this._distance;
}
get type() {
return this._type;
}
set type(value) {
this._type = value;
}
get blockedType() {
return this._blockedType;
}
set blockedType(value) {
this._blockedType = value;
}
get index() {
return this._index;
}
get simTower() {
return this._simTower;
}
set simTower(value) {
this._simTower = value;
}
get pathsToTarget() {
return this._pathsToTarget;
}
set pathsToTarget(value) {
this._pathsToTarget = value;
}
}
//# sourceMappingURL=SimCell.js.map

1
dist/Simulation/Models/SimCell.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"SimCell.js","sourceRoot":"","sources":["../../../src/Simulation/Models/SimCell.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,OAAO;IACR,IAAI,CAAM;IACV,SAAS,CAAS;IAClB,KAAK,CAAY;IACjB,YAAY,GAAW,CAAC,CAAC,CAAC;IAC1B,MAAM,CAAS;IACf,SAAS,GAAoB,IAAI,CAAC;IAClC,cAAc,GAAe,EAAE,CAAC;IAExC,YAAY,GAAQ,EAAE,QAAgB,EAAE,IAAe,EAAE,KAAa;QAClE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAAA,CAAC;IAEF,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI,CAAC,KAAgB;QAC5B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,IAAW,WAAW,CAAC,KAAa;QAChC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,QAAQ,CAAC,KAAe;QAC/B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,IAAW,aAAa,CAAC,KAAiB;QACtC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;IAChC,CAAC;CACJ"}

136
dist/Simulation/Models/SimEnemy.js vendored Normal file
View File

@@ -0,0 +1,136 @@
import { EEnemySize, EProjectileEffectType } from "../../GameData/index.js";
export class SimEnemy {
_index;
_routeIdx;
_startHex;
_endHex;
_path;
_position;
_direction;
_currentPathIndex;
_currentPathStep;
_currentPathPosition;
_dead = false;
_simLevel;
_gdEnemy;
_hitPonts;
_size;
_speed;
_gain;
_gdRoot;
constructor(gdRoot, wave, routeIdx, level) {
const gdLevel = level.gdLevel;
const route = gdLevel.enemyRoutes[routeIdx];
this._gdRoot = gdRoot;
this._index = wave.enemy;
this._simLevel = level;
this._hitPonts = wave.hitpoints;
this._size = wave.size;
this._gain = wave.gain;
this._startHex = gdLevel.enemySpawns[route[0]];
this._endHex = gdLevel.enemyTargets[route[1]];
this._gdEnemy = this._gdRoot.enemies[this._index];
this._currentPathIndex = 0;
this._currentPathStep = level.currentStep;
this._dead = false;
this._routeIdx = routeIdx;
this._path = level.simCells[level.getCellIndex(this._startHex)].pathsToTarget[routeIdx];
this._position = level.simCells[this._path[0]].hex.toWorld();
this._direction = level.simCells[this._path[1]].hex.toWorld().subtract(this._position).normalized();
this._currentPathPosition = this._position;
this._speed = this._gdEnemy.speed;
switch (wave.size) {
case EEnemySize.Tiny:
this._speed *= 2;
break;
case EEnemySize.Huge:
this._speed *= 0.5;
break;
}
}
get path() {
return this._path;
}
set path(value) {
this._path = value;
}
get position() {
return this._position;
}
set position(value) {
this._position = value;
}
get direction() {
return this._direction;
}
get endHex() {
return this._endHex;
}
get currentPathIndex() {
return this._currentPathIndex;
}
set currentPathIndex(value) {
this._currentPathIndex = value;
}
get currentPathStep() {
return this._currentPathStep;
}
set currentPathStep(value) {
this._currentPathStep = value;
}
get currentPathPosition() {
return this._currentPathPosition;
}
get dead() {
return this._dead;
}
set dead(value) {
this._dead = value;
}
get speed() {
return this._speed;
}
get size() {
return this._size;
}
get index() {
return this._index;
}
suffer = (effect) => {
switch (effect.type) {
case EProjectileEffectType.Damage:
{
this._hitPonts -= effect.amount;
if (this._hitPonts <= 0) {
this._simLevel.currency += this._gain;
this._dead = true;
}
break;
}
}
};
onPathUpdated = () => {
const myPos = this._position;
this._currentPathPosition = myPos;
if (this._path == null) {
return;
}
const current = this._path[this._currentPathIndex];
const next = this._path[this._currentPathIndex + 1];
if (!next) {
return;
}
const cells = this._simLevel.simCells;
const pos1 = cells[current].hex.toWorld();
const pos2 = cells[next].hex.toWorld();
const myDir = pos2.subtract(myPos);
const myLen = myDir.magnitude();
const hexDir = pos2.subtract(pos1);
const hexLen = hexDir.magnitude();
if (myLen > hexLen) {
this._path.unshift(this._path[0]);
}
this._direction = myDir.multiplyScalar(1 / myLen);
};
}
//# sourceMappingURL=SimEnemy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimEnemy.js","sourceRoot":"","sources":["../../../src/Simulation/Models/SimEnemy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAA+C,MAAM,yBAAyB,CAAC;AAIzH,MAAM,OAAO,QAAQ;IACT,MAAM,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";
import { ECellType, SimCell } from "../index.js";
export class SimLevel {
static version = 2;
_paused = true;
_currentStep = -1;
_gdLevel;
_highlightedIndex = -1;
_currency = -1;
_stride = -1;
_simCells;
_simEnemies;
_simProjectiles;
_nextWaveStep = -1;
_lastEnemySpawnStep = 0;
_currentWave;
_enemiesLeftToSpawn;
_levelIdx;
_gdRoot;
constructor(gdRoot, levelIdx) {
this._levelIdx = levelIdx;
this._gdRoot = gdRoot;
this._gdLevel = gdRoot.levels[levelIdx];
this._simCells = [];
this._simEnemies = [];
this._simProjectiles = [];
this._currentStep = 0;
this._currency = this._gdLevel.currency;
this._currentWave = 0;
this._enemiesLeftToSpawn = this._gdLevel.waves[0].amount;
const radius = this._gdLevel.radius;
this._stride = 2 * radius + 1;
const h0 = new Hex(0, 0);
for (let y = -radius; y <= radius; ++y) {
for (let x = -radius; x <= radius; ++x) {
const hex = new Hex(x, y);
const distance = Hex.distance(hex, h0);
const type = distance >= radius ? ECellType.Blocked : ECellType.Free;
const cellIndex = this.getCellIndex(hex);
this._simCells[cellIndex] = new SimCell(hex, distance, type, cellIndex);
}
}
this._gdLevel.walls.forEach((wall) => {
const cellIndex = this.getCellIndex(wall);
this._simCells[cellIndex].type = ECellType.Blocked;
});
this._gdLevel.enemySpawns.forEach((hex) => {
const cellIndex = this.getCellIndex(hex);
this._simCells[cellIndex].type = ECellType.Entry;
});
this._gdLevel.enemyTargets.forEach((hex) => {
const cellIndex = this.getCellIndex(hex);
this._simCells[cellIndex].type = ECellType.Entry;
});
this._simCells.forEach((cell) => {
this.updateBlockedType(cell);
});
this.updatePaths();
}
;
get gdLevel() {
return this._gdLevel;
}
get simCells() {
return this._simCells;
}
get simEnemies() {
return this._simEnemies;
}
get simProjectiles() {
return this._simProjectiles;
}
get currentStep() {
return this._currentStep;
}
set currentStep(value) {
this._currentStep = value;
}
get currency() {
return this._currency;
}
set currency(value) {
this._currency = value;
}
get highlightedIndex() {
return this._highlightedIndex;
}
set highlightedIndex(value) {
this._highlightedIndex = value;
}
get paused() {
return this._paused;
}
set paused(value) {
this._paused = value;
}
get currentWave() {
return this._currentWave;
}
set currentWave(value) {
this._currentWave = value;
}
get nextWaveStep() {
return this._nextWaveStep;
}
set nextWaveStep(value) {
this._nextWaveStep = value;
}
get lastEnemySpawnStep() {
return this._lastEnemySpawnStep;
}
set lastEnemySpawnStep(value) {
this._lastEnemySpawnStep = value;
}
get enemiesLeftToSpawn() {
return this._enemiesLeftToSpawn;
}
set enemiesLeftToSpawn(value) {
this._enemiesLeftToSpawn = value;
}
serialize() {
const data = {
version: SimLevel.version,
levelIdx: this._levelIdx,
paused: this._paused,
gdLevel: this._gdLevel,
currentStep: this._currentStep,
highlightedIndex: this._highlightedIndex,
currency: this._currency,
stride: this._stride,
cells: this._simCells,
enemies: this._simEnemies,
projectiles: this._simProjectiles,
nextWaveStep: this._nextWaveStep,
lastEnemySpawnStep: this._lastEnemySpawnStep,
currentWave: this._currentWave,
enemiesLeftToSpawn: this._enemiesLeftToSpawn
};
return btoa(JSON.stringify(data));
}
static deserialize(gdRoot, data) {
const parsedData = JSON.parse(atob(data));
if (parsedData.version != SimLevel.version) {
console.warn('Unsupported version:', parsedData.version);
return null;
}
let level = new SimLevel(gdRoot, parsedData.levelIdx);
level._paused = parsedData.paused;
level._gdLevel = parsedData.gdLevel;
level._currentStep = parsedData.currentStep;
level._highlightedIndex = parsedData.highlightedIndex;
level._currency = parsedData.currency;
level._stride = parsedData.stride;
level._simCells = parsedData.cells;
level._simEnemies = parsedData.enemies;
level._simProjectiles = parsedData.projectiles;
level._nextWaveStep = parsedData.nextWaveStep;
level._lastEnemySpawnStep = parsedData.lastEnemySpawnStep;
level._currentWave = parsedData.currentWave;
level._enemiesLeftToSpawn = parsedData.enemiesLeftToSpawn;
return level;
}
getCellIndex(hex) {
const x = hex.col + this._gdLevel.radius;
const y = hex.row + this._gdLevel.radius;
if (x < 0 || x >= this._stride || y < 0 || y >= this._stride) {
return -1;
}
return y * this._stride + x;
}
getNeighbourCell(cell, direction) {
const hex = cell.hex;
const neighbourHex = Hex.neighbour(hex, direction);
const neighbourIndex = this.getCellIndex(neighbourHex);
return this._simCells[neighbourIndex];
}
updateBlockedType(cell) {
if (cell.type == ECellType.Free) {
cell.blockedType = -1;
return;
}
if (cell.type == ECellType.Entry && cell.blockedType != -1) {
return;
}
let blockedType = 0;
for (let direction = 0; direction < 6; ++direction) {
const neighbourCell = this.getNeighbourCell(cell, direction);
if (!!neighbourCell && neighbourCell.type == ECellType.Free) {
blockedType |= 1 << direction;
}
}
cell.blockedType = blockedType;
}
reservePaths(hexToBlock) {
try {
if (!!hexToBlock) {
const reservedCell = this._simCells[this.getCellIndex(hexToBlock)];
if (reservedCell.type != ECellType.Free || !!reservedCell.simTower)
return false;
reservedCell.type = ECellType.Reserved;
}
return this.updatePaths();
}
finally {
if (!!hexToBlock) {
const reservedCell = this._simCells[this.getCellIndex(hexToBlock)];
if (reservedCell.type == ECellType.Reserved)
reservedCell.type = ECellType.Free;
}
}
}
updatePaths() {
const level = this._gdLevel;
const newRoutePaths = [];
const newEnemyPaths = [];
let invalid = false;
for (const routeIdx in level.enemyRoutes) {
const route = level.enemyRoutes[routeIdx];
const enemySpawnHex = level.enemySpawns[route[0]];
const enemySpawnCell = this._simCells[this.getCellIndex(enemySpawnHex)];
const enemyTargetHex = level.enemyTargets[route[1]];
const enemyTargetCell = this._simCells[this.getCellIndex(enemyTargetHex)];
const path = PathFinding.bfs(this, enemySpawnCell.index, enemyTargetCell.index);
if (path == null) {
invalid = true;
break;
}
newRoutePaths[routeIdx] = path;
}
if (invalid) {
return false;
}
for (let idx in this._simEnemies) {
const simEnemy = this._simEnemies[idx];
const hex = Hex.fromWorld(simEnemy.position);
const startIndex = this.getCellIndex(hex);
const endIndex = this.getCellIndex(simEnemy.endHex);
const path = PathFinding.bfs(this, startIndex, endIndex);
if (path == null) {
invalid = true;
break;
}
newEnemyPaths[idx] = path;
}
if (invalid) {
return false;
}
for (const routeIdx in level.enemyRoutes) {
const route = level.enemyRoutes[routeIdx];
const enemySpawnHex = level.enemySpawns[route[0]];
const enemySpawnCell = this._simCells[this.getCellIndex(enemySpawnHex)];
enemySpawnCell.pathsToTarget[routeIdx] = newRoutePaths[routeIdx];
}
this._simEnemies.forEach((simEnemy, idx) => {
simEnemy.path = newEnemyPaths[idx];
simEnemy.currentPathIndex = 0;
simEnemy.onPathUpdated();
});
return true;
}
}
//# sourceMappingURL=SimLevel.js.map

File diff suppressed because one or more lines are too long

46
dist/Simulation/Models/SimProjectile.js vendored Normal file
View File

@@ -0,0 +1,46 @@
export class SimProjectile {
_gdEffect;
_position;
_targetEnemyIdx = -1;
_spawnStep = -1;
_speed = -1;
_size = -1;
_dead = false;
constructor(level, effect, position, targetEnemyIdx, size) {
this._gdEffect = effect;
this._speed = effect.speed;
this._position = position;
this._size = size;
this._targetEnemyIdx = targetEnemyIdx;
this._spawnStep = level.currentStep;
}
;
get gdEffect() {
return this._gdEffect;
}
get position() {
return this._position;
}
set position(value) {
this._position = value;
}
get targetEnemyIdx() {
return this._targetEnemyIdx;
}
get spawnStep() {
return this._spawnStep;
}
get speed() {
return this._speed;
}
get size() {
return this._size;
}
get dead() {
return this._dead;
}
set dead(value) {
this._dead = value;
}
}
//# sourceMappingURL=SimProjectile.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimProjectile.js","sourceRoot":"","sources":["../../../src/Simulation/Models/SimProjectile.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,aAAa;IACd,SAAS,CAAqB;IAC9B,SAAS,CAAU;IACnB,eAAe,GAAW,CAAC,CAAC,CAAC;IAC7B,UAAU,GAAW,CAAC,CAAC,CAAC;IACxB,MAAM,GAAW,CAAC,CAAC,CAAC;IACpB,KAAK,GAAW,CAAC,CAAC,CAAC;IACnB,KAAK,GAAY,KAAK,CAAC;IAE/B,YAAY,KAAe,EAAE,MAA0B,EAAE,QAAiB,EAAE,cAAsB,EAAE,IAAY;QAC5G,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;IACxC,CAAC;IAAA,CAAC;IAEF,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,QAAQ,CAAC,KAAc;QAC9B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI,CAAC,KAAc;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ"}

100
dist/Simulation/Models/SimTower.js vendored Normal file
View File

@@ -0,0 +1,100 @@
import { Hex } from "../../Util/index.js";
import { SimProjectile } from "../index.js";
export class SimTower {
_lastProjectileStep = -1;
_lastAoeStep = -1;
_gdProjectileEffect;
_projectileRange = -1;
_projectileRate = -1;
_projectileSize = -1;
_gdAoeEffect;
_aoeRange = -1;
_aoeRate = -1;
_gdTower;
_position;
_currentProjectileTarget = -1;
_simLevel;
_index;
_gdRoot;
constructor(gdRoot, level, index, hex) {
this._gdRoot = gdRoot;
this._simLevel = level;
this._position = Hex.toWorld(hex);
this._index = index;
const data = this._gdRoot.towers[index];
this._gdProjectileEffect = data.projectileEffect;
this._projectileRange = data.projectileRange;
this._projectileRate = data.projectileRate;
this._projectileSize = data.projectileSize;
this._gdAoeEffect = data.aoeEffect;
this._aoeRange = data.aoeRange;
this._aoeRate = data.aoeRate;
this._gdTower = data;
}
get index() {
return this._index;
}
fireIfAble() {
const level = this._simLevel;
const currentStep = this._simLevel.currentStep;
if (this.canFireProjectile() && this._gdProjectileEffect != null) {
level.simProjectiles.push(new SimProjectile(level, this._gdProjectileEffect, this._position, this.pickProjectileTarget(), this._projectileSize));
this._lastProjectileStep = currentStep;
}
if (this.canFireAoe()) {
// TODO
}
}
canFireProjectile() {
if (this._gdProjectileEffect == null)
return false;
const currentStep = this._simLevel.currentStep;
if (this._lastProjectileStep == -1 || this._lastProjectileStep + this._projectileRate < currentStep) {
return this.isEnemyInRange(this._projectileRange);
}
return false;
}
canFireAoe() {
const level = this._simLevel;
const currentStep = level.currentStep;
if (this._gdAoeEffect != null) {
if (this._lastAoeStep == -1 || this._lastAoeStep + this._aoeRate < currentStep) {
return this.isEnemyInRange(this._aoeRange);
}
}
return false;
}
pickProjectileTarget() {
if (this._currentProjectileTarget != -1) {
return this._currentProjectileTarget;
}
let minLength = -1;
let candidate = -1;
const level = this._simLevel;
for (let idx = 0; idx < level.simEnemies.length; idx++) {
const enemy = level.simEnemies[idx];
const delta = enemy.currentPathPosition.subtract(this._position);
const length = delta.magnitude();
if (enemy.path != null && length < this._projectileRange) {
const pathLength = enemy.path.length - enemy.currentPathIndex;
if (minLength == -1 || pathLength < minLength) {
candidate = idx;
minLength = pathLength;
}
}
}
return candidate;
}
isEnemyInRange(range) {
const level = this._simLevel;
for (const idx in level.simEnemies) {
const enemy = level.simEnemies[idx];
const delta = enemy.currentPathPosition.subtract(this._position);
const length = delta.magnitude();
if (length < range) {
return true;
}
}
}
}
//# sourceMappingURL=SimTower.js.map

View File

@@ -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G,GAAG,CAAC;oBAChB,SAAS,GAAG,UAAU,CAAC;gBAC3B,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAEO,cAAc,CAAC,KAAa;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YACjC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACpC,MAAM,KAAK,GAAG,KAAK,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACjE,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,IAAI,MAAM,GAAG,KAAK,EAAE,CAAC;gBACjB,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}

68
dist/Simulation/SimMain.js vendored Normal file
View File

@@ -0,0 +1,68 @@
import { SimActionFireTowers, SimActionMoveEnemies, SimActionMoveProjectiles, SimActionSpawnEnemies, SimCommandStartNextWave, SimLevel } from "./index.js";
export class SimMain {
_currentLevel;
_commands = [];
_actions = [];
_gdRoot;
constructor(gdRoot, level) {
this._gdRoot = gdRoot;
this._currentLevel = new SimLevel(gdRoot, level);
this._actions.push(new SimActionMoveEnemies());
this._actions.push(new SimActionSpawnEnemies());
this._actions.push(new SimActionFireTowers());
this._actions.push(new SimActionMoveProjectiles());
if (true || !this.loadModel()) {
this.reload();
}
this._currentLevel.paused = true;
}
get gdRoot() {
return this._gdRoot;
}
get currentLevel() {
return this._currentLevel;
}
executeUntilStep(targetStep) {
this.executeCommands();
while (this._currentLevel.currentStep < targetStep) {
this.executeOneStep();
this._currentLevel.currentStep += 1;
}
}
executeCommands() {
const saveModel = false && this._commands.length != 0;
this._commands.forEach((command) => {
command.execute();
});
this._commands = [];
if (saveModel) {
this.saveModel();
}
}
executeOneStep() {
for (const action of this._actions)
action.execute(this);
}
addCommand(command) {
this._commands[this._commands.length] = command;
}
reload() {
this._currentLevel = new SimLevel(this._gdRoot, 0);
this.saveModel();
this.addCommand(new SimCommandStartNextWave(this._gdRoot, this._currentLevel));
}
loadModel() {
if (!!localStorage.htd) {
const savedLevel = SimLevel.deserialize(this._gdRoot, localStorage.htd);
if (!savedLevel)
return false;
this._currentLevel = savedLevel;
return true;
}
return false;
}
saveModel() {
localStorage.htd = this._currentLevel.serialize();
}
}
//# sourceMappingURL=SimMain.js.map

1
dist/Simulation/SimMain.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"SimMain.js","sourceRoot":"","sources":["../../src/Simulation/SimMain.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,mBAAmB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEpL,MAAM,OAAO,OAAO;IACR,aAAa,CAAW;IACxB,SAAS,GAAkB,EAAE,CAAC;IAC9B,QAAQ,GAAiB,EAAE,CAAC;IAC5B,OAAO,CAAS;IAExB,YAAY,MAAc,EAAE,KAAa;QACrC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC;QACnD,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YAC5B,IAAI,CA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,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IACnF,CAAC;IAEO,SAAS;QACb,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;YACrB,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;YACxE,IAAI,CAAC,UAAU;gBACX,OAAO,KAAK,CAAC;YAEjB,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC;YAChC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,SAAS;QACb,YAAY,CAAC,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;IACtD,CAAC;CACJ"}

19
dist/Simulation/index.js vendored Normal file
View File

@@ -0,0 +1,19 @@
import { SimActionFireTowers } from "./Actions/SimActionFireTowers.js";
import { SimActionMoveEnemies } from "./Actions/SimActionMoveEnemies.js";
import { SimActionMoveProjectiles } from "./Actions/SimActionMoveProjectiles.js";
import { SimActionSpawnEnemies } from "./Actions/SimActionSpawnEnemies.js";
import { SimCommandBlockTerrain } from "./Commands/SimCommandBlockTerrain.js";
import { SimCommandCreateTower } from "./Commands/SimCommandCreateTower.js";
import { SimCommandStartNextWave } from "./Commands/SimCommandStartNextWave.js";
import { ECellType } from "./Models/ECellType.js";
import { SimCell } from "./Models/SimCell.js";
import { SimEnemy } from "./Models/SimEnemy.js";
import { SimLevel } from "./Models/SimLevel.js";
import { SimProjectile } from "./Models/SimProjectile.js";
import { SimTower } from "./Models/SimTower.js";
import { SimMain } from "./SimMain.js";
export { SimActionFireTowers, SimActionMoveEnemies, SimActionMoveProjectiles, SimActionSpawnEnemies };
export { SimCommandBlockTerrain, SimCommandCreateTower, SimCommandStartNextWave };
export { ECellType, SimCell, SimEnemy, SimLevel, SimProjectile, SimTower };
export { SimMain };
//# sourceMappingURL=index.js.map

1
dist/Simulation/index.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Simulation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAc,mBAAmB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAA;AACjH,OAAO,EAAe,sBAAsB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,CAAA;AAC9F,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAC1E,OAAO,EAAE,OAAO,EAAE,CAAA"}

10
dist/Util/EDirection.js vendored Normal file
View File

@@ -0,0 +1,10 @@
export var EDirection;
(function (EDirection) {
EDirection[EDirection["Right"] = 0] = "Right";
EDirection[EDirection["TopRight"] = 1] = "TopRight";
EDirection[EDirection["TopLeft"] = 2] = "TopLeft";
EDirection[EDirection["Left"] = 3] = "Left";
EDirection[EDirection["BottomLeft"] = 4] = "BottomLeft";
EDirection[EDirection["BottomRight"] = 5] = "BottomRight";
})(EDirection || (EDirection = {}));
//# sourceMappingURL=EDirection.js.map

1
dist/Util/EDirection.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"EDirection.js","sourceRoot":"","sources":["../../src/Util/EDirection.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IAClB,6CAAS,CAAA;IACT,mDAAY,CAAA;IACZ,iDAAW,CAAA;IACX,2CAAQ,CAAA;IACR,uDAAc,CAAA;IACd,yDAAe,CAAA;AACnB,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB"}

97
dist/Util/Hex.js vendored Normal file
View File

@@ -0,0 +1,97 @@
import { Vector2 } from "./index.js";
class Cube {
x;
y;
z;
constructor(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
}
export class Hex {
col;
row;
constructor(x, y) {
this.col = x;
this.row = y;
}
static offsetDirections = [
[
new Hex(+1, 0),
new Hex(0, -1),
new Hex(-1, -1),
new Hex(-1, 0),
new Hex(-1, +1),
new Hex(0, +1)
],
[
new Hex(+1, 0),
new Hex(+1, -1),
new Hex(0, -1),
new Hex(-1, 0),
new Hex(0, +1),
new Hex(+1, +1),
new Hex(+1, +1)
]
];
static neighbour = (hex, direction) => {
const parity = hex.row & 1;
const dir = Hex.offsetDirections[parity][direction];
return new Hex(hex.col + dir.col, hex.row + dir.row);
};
static distance = (a, b) => {
const ac = Hex.offsetToCube(a);
const bc = Hex.offsetToCube(b);
return Math.max(Math.abs(ac.x - bc.x), Math.abs(ac.y - bc.y), Math.abs(ac.z - bc.z));
};
static offsetToCube = (hex) => {
const x = hex.col - (hex.row - (hex.row & 1)) / 2;
const z = hex.row;
const y = -x - z;
return new Cube(x, y, z);
};
static toWorld = (hex) => {
const x = Math.sqrt(3) * (hex.col + 0.5 * (hex.row & 1));
const y = (3 / 2) * hex.row;
return new Vector2(x, y);
};
toWorld() {
return Hex.toWorld(this);
}
static fromWorld = (coord) => {
const q = (coord.x * Math.sqrt(3)) / 3 - coord.y / 3;
const r = (coord.y * 2) / 3;
const cube = new Cube(q, -q - r, r);
let rx = Math.round(cube.x);
let ry = Math.round(cube.y);
let rz = Math.round(cube.z);
const xDiff = Math.abs(rx - cube.x);
const yDiff = Math.abs(ry - cube.y);
const zDiff = Math.abs(rz - cube.z);
if (xDiff > yDiff && xDiff > zDiff) {
rx = -ry - rz;
}
else if (yDiff > zDiff) {
ry = -rx - rz;
}
else {
rz = -rx - ry;
}
const rounded = new Cube(rx, ry, rz);
const col = rounded.x + (rounded.z - (rounded.z & 1)) / 2;
const row = rounded.z;
return new Hex(col, row);
};
static toPixel = (hex, size) => {
const w = Hex.toWorld(hex);
return new Vector2(w.x * size, w.y * size);
};
toPixel(size) {
return Hex.toPixel(this, size);
}
static fromPixel = (coord, size) => {
return Hex.fromWorld(new Vector2(coord.x / size, coord.y / size));
};
}
//# sourceMappingURL=Hex.js.map

1
dist/Util/Hex.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Hex.js","sourceRoot":"","sources":["../../src/Util/Hex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,IAAI;IACN,CAAC,CAAS;IACV,CAAC,CAAS;IACV,CAAC,CAAS;IAEV,YAAY,CAAS,EAAE,CAAS,EAAE,CAAS;QACvC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;CACJ;AAED,MAAM,OAAO,GAAG;IACL,GAAG,CAAS;IACZ,GAAG,CAAS;IAEn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AAC;YACvB,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;QAClB,CAAC;aAAM,CAAC;YACJ,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;QAClB,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1D,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;QACtB,OAAO,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEK,MAAM,CAAC,OAAO,GAAG,CAAC,GAAQ,EAAE,IAAY,EAAW,EAAE;QACxD,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC,CAAC;IAEK,OAAO,CAAC,IAAY;QACvB,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAEM,MAAM,CAAC,SAAS,GAAG,CAAC,KAAc,EAAE,IAAY,EAAO,EAAE;QAC5D,OAAO,GAAG,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC"}

42
dist/Util/PathFinding.js vendored Normal file
View File

@@ -0,0 +1,42 @@
import { ECellType } from "../Simulation/index.js";
import { Hex } from "./index.js";
export class PathFinding {
static bfs(level, startIndex, endIndex) {
const listToExplore = [startIndex];
let cameFrom = new Array(level.simCells.length);
cameFrom.fill(-1);
while (listToExplore.length > 0) {
const nodeIndex = listToExplore.shift();
const cell = level.simCells[nodeIndex];
for (let i = 0; i < 6; ++i) {
const neighbourHex = Hex.neighbour(cell.hex, i);
const neighbourIndex = level.getCellIndex(neighbourHex);
if (neighbourIndex === -1) {
continue;
}
const neighbourCell = level.simCells[neighbourIndex];
if (neighbourCell.type === ECellType.Blocked || neighbourCell.type === ECellType.Reserved || neighbourCell.simTower !== null) {
continue;
}
if (cameFrom[neighbourIndex] === -1) {
cameFrom[neighbourIndex] = nodeIndex;
if (neighbourIndex !== endIndex) {
listToExplore.push(neighbourIndex);
}
else {
let idx = neighbourIndex;
const path = [idx];
while (idx !== startIndex) {
const prev = cameFrom[idx];
idx = prev;
path.unshift(idx);
}
return path;
}
}
}
}
return null;
}
}
//# sourceMappingURL=PathFinding.js.map

1
dist/Util/PathFinding.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"PathFinding.js","sourceRoot":"","sources":["../../src/Util/PathFinding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,OAAgB,WAAW;IACtB,MAAM,CAAC,GAAG,CAAC,KAAe,EAAE,UAAkB,EAAE,QAAgB;QACnE,MAAM,aAAa,GAAa,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,QAAQ,GAAa,IAAI,KAAK,CAAS,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAClE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAElB,OAAO,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,EAAG,CAAC;YACzC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAEvC,KAAK,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0 +1,72 @@
export class Vector2 {
x;
y;
constructor(x, y) {
this.x = x;
this.y = y;
}
static lerp(a, b, t) {
return a.multiplyScalar(1 - t).add(b.multiplyScalar(t));
}
add(vector) {
return new Vector2(this.x + vector.x, this.y + vector.y);
}
subtract(vector) {
return new Vector2(this.x - vector.x, this.y - vector.y);
}
multiplyScalar(scalar) {
return new Vector2(this.x * scalar, this.y * scalar);
}
dot(vector) {
return this.x * vector.x + this.y * vector.y;
}
cross(vector) {
return this.x * vector.y - this.y * vector.x;
}
magnitude() {
return Math.sqrt(this.x * this.x + this.y * this.y);
}
normalized() {
const magnitude = this.magnitude();
if (magnitude === 0) {
throw new Error("Cannot normalize a vector with magnitude 0");
}
return this.multiplyScalar(1 / magnitude);
}
distance(vector) {
return Math.sqrt((this.x - vector.x) ** 2 + (this.y - vector.y) ** 2);
}
distanceSquared(vector) {
return (this.x - vector.x) ** 2 + (this.y - vector.y) ** 2;
}
limit(max) {
const magnitude = this.magnitude();
if (magnitude > max) {
return this.normalized().multiplyScalar(max);
}
return this;
}
angle() {
return Math.atan2(this.y, this.x);
}
angleBetween(vector) {
const dotProd = this.dot(vector);
const magnitudes = this.magnitude() * vector.magnitude();
if (magnitudes === 0) {
throw new Error("Cannot calculate angle with a zero-magnitude vector");
}
return Math.acos(dotProd / magnitudes);
}
clone() {
return new Vector2(this.x, this.y);
}
equals(vector) {
return this.x === vector.x && this.y === vector.y;
}
rotate(angle) {
const cos = Math.cos(angle);
const sin = Math.sin(angle);
return new Vector2(this.x * cos - this.y * sin, this.x * sin + this.y * cos);
}
}
//# sourceMappingURL=Vector2.js.map

1
dist/Util/Vector2.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Vector2.js","sourceRoot":"","sources":["../../src/Util/Vector2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,OAAO;IACT,CAAC,CAAS;IACV,CAAC,CAAS;IAEjB,YAAY,CAAS,EAAE,CAAS;QAC5B,IAAI,CAAC,CAAC,GAA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,CAAC,qDAAqD,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK;QACR,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM,CAAC,MAAe;QACzB,OAAO,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC;IACtD,CAAC;IAEM,MAAM,CAAC,KAAa;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,OAAO,IAAI,OAAO,CACd,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,GAAG,EAC3B,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,GAAG,CAC9B,CAAC;IACN,CAAC;CACJ"}

6
dist/Util/index.js vendored Normal file
View File

@@ -0,0 +1,6 @@
import { EDirection } from "./EDirection.js";
import { Hex } from "./Hex.js";
import { PathFinding } from "./PathFinding.js";
import { Vector2 } from "./Vector2.js";
export { EDirection, Hex, Vector2, PathFinding };
//# sourceMappingURL=index.js.map

1
dist/Util/index.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Util/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,CAAA"}

2
dist/View/IView.js vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=IView.js.map

1
dist/View/IView.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"IView.js","sourceRoot":"","sources":["../../src/View/IView.ts"],"names":[],"mappings":""}

87
dist/View/ViewGame.js vendored Normal file
View File

@@ -0,0 +1,87 @@
import { ECellType, SimCommandCreateTower, SimMain } from "../Simulation/index.js";
import { Vector2 } from "../Util/index.js";
import { VisMain } from "../Vis/index.js";
export class ViewGame {
_div;
_viewManager;
_canvas = null;
_simMain = null;
_visMain = null;
_gdRoot;
_buttonReload = null;
_buttonStart = null;
constructor(div, gdRoot, viewManager) {
this._gdRoot = gdRoot;
this._div = div;
this._viewManager = viewManager;
this.canvasResized = this.canvasResized.bind(this);
this.canvasMouseMoved = this.canvasMouseMoved.bind(this);
this.canvasMouseDown = this.canvasMouseDown.bind(this);
this.buttonReloadClicked = this.buttonReloadClicked.bind(this);
this.buttonStartClicked = this.buttonStartClicked.bind(this);
}
get div() {
return this._div;
}
activate() {
this._canvas = document.getElementById("canvas-game");
this._buttonReload = document.getElementById("button-reload");
this._buttonStart = document.getElementById("button-start");
this._simMain = new SimMain(this._gdRoot, 0);
this._visMain = new VisMain(this._simMain, this._canvas);
window.addEventListener("resize", this.canvasResized, false);
this._canvas?.addEventListener("mousemove", this.canvasMouseMoved);
this._canvas?.addEventListener("mousedown", this.canvasMouseDown);
this._buttonReload?.addEventListener("click", this.buttonReloadClicked);
this._buttonStart?.addEventListener("click", this.buttonStartClicked);
}
deactivate() {
window.removeEventListener("resize", this.canvasResized, false);
this._canvas?.removeEventListener("mousemove", this.canvasMouseMoved);
this._canvas?.removeEventListener("mousedown", this.canvasMouseDown);
this._buttonReload?.removeEventListener("click", this.buttonReloadClicked);
this._buttonStart?.removeEventListener("click", this.buttonStartClicked);
this._canvas = null;
this._buttonReload = null;
this._buttonStart = null;
this._simMain = null;
this._visMain = null;
}
canvasResized() {
this._visMain?.onResized();
}
buttonReloadClicked() {
this._simMain?.reload();
}
buttonStartClicked() {
if (this._simMain == null) {
return;
}
this._simMain.currentLevel.paused = false;
}
canvasMouseMoved(e) {
const simLevel = this._simMain?.currentLevel;
if (simLevel == null || this._visMain == null) {
return;
}
const rect = this._canvas.getBoundingClientRect();
const hex = this._visMain.visLevel.getHexFromScreenCoords(new Vector2(e.clientX - rect.left, e.clientY - rect.top));
const index = simLevel.getCellIndex(hex);
if (index != -1 && simLevel.simCells[index].type != ECellType.Blocked) {
simLevel.highlightedIndex = index;
}
else {
simLevel.highlightedIndex = -1;
}
}
canvasMouseDown(e) {
const simLevel = this._simMain?.currentLevel;
if (simLevel == null || this._visMain == null) {
return;
}
const rect = this._canvas.getBoundingClientRect();
const hex = this._visMain.visLevel.getHexFromScreenCoords(new Vector2(e.clientX - rect.left, e.clientY - rect.top));
this._simMain?.addCommand(new SimCommandCreateTower(this._gdRoot, simLevel, hex, 0));
}
}
//# sourceMappingURL=ViewGame.js.map

1
dist/View/ViewGame.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ViewGame.js","sourceRoot":"","sources":["../../src/View/ViewGame.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,MAAM,OAAO,QAAQ;IACT,IAAI,CAAS;IACb,YAAY,CAAc;IAC1B,OAAO,GAA6B,IAAI,CAAC;IACzC,QAAQ,GAAmB,IAAI,CAAC;IAChC,QAAQ,GAAmB,IAAI,CAAC;IAChC,OAAO,CAAS;IAChB,aAAa,GAA6B,IAAI,CAAC;IAC/C,YAAY,GAA6B,IAAI,CAAC;IAEtD,YAAY,G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AsB,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACpH,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,qBAAqB,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACzF,CAAC;CACJ"}

27
dist/View/ViewLevels.js vendored Normal file
View File

@@ -0,0 +1,27 @@
import { EViewType } from "./index.js";
export class ViewLevels {
_div;
_buttonGame = null;
_viewManager;
constructor(div, viewManager) {
this._div = div;
this._viewManager = viewManager;
this.buttonGameClicked = this.buttonGameClicked.bind(this);
}
get div() {
return this._div;
}
activate() {
this._buttonGame = document.getElementById("btn-game");
if (!!this._buttonGame) {
this._buttonGame.addEventListener("click", this.buttonGameClicked);
}
}
deactivate() {
this._buttonGame?.removeEventListener("click", this.buttonGameClicked);
}
buttonGameClicked() {
this._viewManager.showView(EViewType.Game);
}
}
//# sourceMappingURL=ViewLevels.js.map

1
dist/View/ViewLevels.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ViewLevels.js","sourceRoot":"","sources":["../../src/View/ViewLevels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAC;AAE3D,MAAM,OAAO,UAAU;IACX,IAAI,CAAS;IACb,WAAW,GAA6B,IAAI,CAAC;IAC7C,YAAY,CAAc;IAElC,YAAY,GAAW,EAAE,WAAwB;QAC7C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAEM,QAAQ;QACX,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAsB,CAAC;QAC5E,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACvE,CAAC;IACL,CAAC;IAEM,UAAU;QACb,IAAI,CAAC,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC3E,CAAC;IAEO,iBAAiB;QACrB,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;CACJ"}

46
dist/View/ViewManager.js vendored Normal file
View File

@@ -0,0 +1,46 @@
import { ViewMenu, ViewLevels, ViewGame } from "./index.js";
export var EViewType;
(function (EViewType) {
EViewType[EViewType["None"] = 0] = "None";
EViewType[EViewType["Menu"] = 1] = "Menu";
EViewType[EViewType["Levels"] = 2] = "Levels";
EViewType[EViewType["Game"] = 3] = "Game";
})(EViewType || (EViewType = {}));
export class ViewManager {
_viewMap;
_currentViewType;
_app;
constructor() {
this._viewMap = new Map();
this._currentViewType = EViewType.None;
this._app = document.getElementById("app");
}
async loadAsync(gdRoot) {
const viewManager = this;
this._viewMap.set(EViewType.Menu, new ViewMenu(await this.loadView("menu"), viewManager));
this._viewMap.set(EViewType.Levels, new ViewLevels(await this.loadView("levels"), viewManager));
this._viewMap.set(EViewType.Game, new ViewGame(await this.loadView("game"), gdRoot, viewManager));
}
showView(viewType) {
const oldView = this._viewMap.get(this._currentViewType);
if (!!oldView) {
oldView.deactivate();
this._currentViewType = EViewType.None;
}
const newView = this._viewMap.get(viewType);
if (!!newView) {
this._app.innerHTML = newView.div;
this._currentViewType = viewType;
newView.activate();
}
}
async loadView(viewName) {
const response = await fetch(`views/${viewName}.html`);
if (!response.ok) {
throw new Error(`Failed to load view: ${viewName}`);
}
const html = await response.text();
return html;
}
}
//# sourceMappingURL=ViewManager.js.map

1
dist/View/ViewManager.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ViewManager.js","sourceRoot":"","sources":["../../src/View/ViewManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACjB,yCAAI,CAAA;IACJ,yCAAI,CAAA;IACJ,6CAAM,CAAA;IACN,yCAAI,CAAA;AACR,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAED,MAAM,OAAO,WAAW;IACZ,QAAQ,CAAwB;IAChC,gBAAgB,CAAY;IAC5B,IAAI,CAAiB;IAE7B;QACI,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;QAC5C,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC,IAAI,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAmB,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,MAAc;QACjC,MAAM,WAAW,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;QAC1F,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;QAChG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IACtG,CAAC;IAEM,QAAQ,CAAC,QAAmB;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACzD,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,UAAU,EAAE,CAAC;YACrB,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC,IAAI,CAAC;QAC3C,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YAEZ,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;YAClC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;YACjC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACvB,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,QAAgB;QACnC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,QAAQ,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}

27
dist/View/ViewMenu.js vendored Normal file
View File

@@ -0,0 +1,27 @@
import { EViewType } from "./index.js";
export class ViewMenu {
_div;
_buttonLevels = null;
_viewManager;
constructor(div, viewManager) {
this._div = div;
this._viewManager = viewManager;
this.buttonLevelsClicked = this.buttonLevelsClicked.bind(this);
}
get div() {
return this._div;
}
activate() {
this._buttonLevels = document.getElementById("btn-levels");
if (!!this._buttonLevels) {
this._buttonLevels.addEventListener("click", this.buttonLevelsClicked);
}
}
deactivate() {
this._buttonLevels?.removeEventListener("click", this.buttonLevelsClicked);
}
buttonLevelsClicked() {
this._viewManager.showView(EViewType.Levels);
}
}
//# sourceMappingURL=ViewMenu.js.map

1
dist/View/ViewMenu.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ViewMenu.js","sourceRoot":"","sources":["../../src/View/ViewMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAC;AAE3D,MAAM,OAAO,QAAQ;IACT,IAAI,CAAS;IACb,aAAa,GAA6B,IAAI,CAAC;IAC/C,YAAY,CAAc;IAElC,YAAY,GAAW,EAAE,WAAwB;QAC7C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnE,CAAC;IAED,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAEM,QAAQ;QACX,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAsB,CAAC;QAChF,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC3E,CAAC;IACL,CAAC;IAEM,UAAU;QACb,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC/E,CAAC;IAEO,mBAAmB;QACvB,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACJ"}

6
dist/View/index.js vendored Normal file
View File

@@ -0,0 +1,6 @@
import { ViewGame } from "./ViewGame.js";
import { ViewLevels } from "./ViewLevels.js";
import { EViewType, ViewManager } from "./ViewManager.js";
import { ViewMenu } from "./ViewMenu.js";
export { ViewManager, ViewGame, ViewLevels, ViewMenu, EViewType };
//# sourceMappingURL=index.js.map

1
dist/View/index.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/View/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAS,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC"}

2
dist/View/newFile.js vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=newFile.js.map

1
dist/View/newFile.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"newFile.js","sourceRoot":"","sources":["../../src/View/newFile.ts"],"names":[],"mappings":""}

58
dist/Vis/VisEnemy.js vendored Normal file
View File

@@ -0,0 +1,58 @@
import { EEnemySize } from "../GameData/index.js";
import { Vector2 } from "../Util/index.js";
export class VisEnemy {
_positions;
_directions;
_image;
_context;
_simEnemy;
_angle = null;
_gdRoot;
constructor(gdRoot, simEnemy, width, height) {
this._gdRoot = gdRoot;
this._simEnemy = simEnemy;
this._image = document.createElement("canvas");
this._image.width = width;
this._image.height = height;
this._context = this._image.getContext("2d");
this._positions = [simEnemy.position, simEnemy.position];
this._directions = [simEnemy.direction, simEnemy.direction];
}
get positions() {
return this._positions;
}
get image() {
return this._image;
}
advanceStep() {
const prevPos = this._positions[1];
const prevDir = this._directions[1];
this._positions = [prevPos, this._simEnemy.position];
this._directions = [prevDir, this._simEnemy.direction];
}
update(t) {
const directions = this._directions;
const dir = Vector2.lerp(directions[0], directions[1], t);
const angle = Math.atan2(dir.x, -dir.y) - Math.PI / 2;
if (this._angle == angle) {
return;
}
this._angle = angle;
const ctx = this._context;
ctx.clearRect(0, 0, this._image.width, this._image.height);
ctx.save();
ctx.translate(this._image.width / 2, this._image.height / 2);
ctx.rotate(angle);
switch (this._simEnemy.size) {
case EEnemySize.Tiny:
ctx.scale(0.75, 0.75);
break;
case EEnemySize.Huge:
ctx.scale(2, 2);
break;
}
ctx.drawImage(this._gdRoot.image("enemy-" + (this._simEnemy.index | 0) + ".svg"), -this._image.width / 2, -this._image.height / 2, this._image.width, this._image.height);
ctx.restore();
}
}
//# sourceMappingURL=VisEnemy.js.map

1
dist/Vis/VisEnemy.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"VisEnemy.js","sourceRoot":"","sources":["../../src/Vis/VisEnemy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAU,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,OAAO,QAAQ;IACT,UAAU,CAAY;IACtB,WAAW,CAAY;IACvB,MAAM,CAAoB;IAC1B,QAAQ,CAA2B;IACnC,SAAS,CAAW;IACpB,MAAM,GAAkB,IAAI,CAAC;IAC7B,OAAO,CAAS;IAExB,YAAY,MAAc,EAAE,QAAkB,EAAE,KAAa,EAAE,MAAc;QACzE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,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AAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3D,GAAG,CAAC,IAAI,EAAE,CAAC;QACX,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC7D,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YAC1B,KAAK,UAAU,CAAC,IAAI;gBAChB,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACtB,MAAM;YACV,KAAK,UAAU,CAAC,IAAI;gBAChB,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAChB,MAAM;QACd,CAAC;QACD,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1K,GAAG,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACJ"}

225
dist/Vis/VisLevel.js vendored Normal file
View File

@@ -0,0 +1,225 @@
import { ECellType } from "../Simulation/index.js";
import { Hex, Vector2 } from "../Util/index.js";
import { VisEnemy, VisProjectile } from "./index.js";
export class VisLevel {
_screenCellWidth = -1;
_screenCellHeight = -1;
_screenXOffset = -1;
_screenYOffset = -1;
_hexSize = -1;
_lastStep = -1;
_projectileMap;
_enemyMap;
_background = null;
_simLevel = null;
_visMain;
_simMain;
_gdRoot;
constructor(visMain, simMain, gdRoot) {
this._visMain = visMain;
this._simMain = visMain.simMain;
this._gdRoot = gdRoot;
this._enemyMap = new Map();
this._projectileMap = new Map();
this.reset();
}
reset() {
this._projectileMap.clear();
this._enemyMap.clear();
this._background = null;
}
draw() {
const ctx = this._visMain.context;
const simLevel = this._simMain.currentLevel;
if (simLevel != this._simLevel) {
this.reset();
this._simLevel = simLevel;
}
this.drawBackground();
ctx.globalCompositeOperation = "source-over";
simLevel.simCells.forEach((cell) => {
if (cell.distance > simLevel.gdLevel.radius) {
return;
}
this.drawCell(cell);
});
simLevel.simEnemies.forEach((enemy) => {
this.drawEnemy(enemy);
});
simLevel.simProjectiles.forEach((projectile) => {
this.drawProjectile(projectile);
});
ctx.fillStyle = "white";
ctx.fillText("Currency: " + simLevel.currency, 5, 15);
ctx.fillText("Current wave: " + simLevel.currentWave, 5, 35);
ctx.fillText("Enemies left: " + simLevel.enemiesLeftToSpawn, 5, 55);
ctx.fillText("Current step: " + simLevel.currentStep, 5, 75);
}
updateSize() {
const gdLevel = this._simMain.currentLevel.gdLevel;
const minSize = Math.min(this._visMain.canvas.height, this._visMain.canvas.width * Math.sqrt(3) / 2);
this._hexSize = Math.floor(minSize / (4 * (gdLevel.radius - 1) - 4));
this._screenCellHeight = Math.ceil(2 * this._hexSize);
this._screenCellHeight = Math.ceil(this._screenCellHeight * 0.5) * 2;
this._screenCellWidth = Math.ceil(Math.sqrt(3) / 2 * this._screenCellHeight);
this._screenCellWidth = Math.ceil(this._screenCellWidth * 0.5) * 2;
this._screenXOffset = this._screenCellWidth * (gdLevel.radius + 0.5);
this._screenYOffset = this._screenCellHeight * (gdLevel.radius + 0.5);
const width = this._screenCellWidth * (gdLevel.radius * 2 + 1);
const height = this._screenCellHeight * (gdLevel.radius * 2 + 1);
this._screenXOffset += (this._visMain.canvas.width - width) * 0.5;
this._screenYOffset += (this._visMain.canvas.height - height) * 0.5;
this._screenXOffset = Math.floor(this._screenXOffset);
this._screenYOffset = Math.floor(this._screenYOffset);
this._background = null;
this._enemyMap.clear();
}
updateEveryFrame(currentStep) {
const simLevel = this._simMain.currentLevel;
const t = currentStep - Math.floor(currentStep);
const deadEnemies = [];
simLevel.simEnemies.forEach((simEnemy) => {
if (simEnemy.dead) {
deadEnemies.push(simEnemy);
return;
}
const visEnemy = this._enemyMap.get(simEnemy);
if (!visEnemy) {
this._enemyMap.set(simEnemy, new VisEnemy(this._gdRoot, simEnemy, this._screenCellWidth, this._screenCellHeight));
}
else if (Math.floor(currentStep) != Math.floor(this._lastStep)) {
visEnemy.advanceStep();
}
else {
visEnemy.update(t);
}
});
for (const deadEnemy of deadEnemies) {
this._enemyMap.delete(deadEnemy);
}
const deadProjectiles = [];
simLevel.simProjectiles.forEach((simProjectile) => {
if (simProjectile.dead) {
deadProjectiles.push(simProjectile);
return;
}
const visProjectile = this._projectileMap.get(simProjectile);
if (!visProjectile) {
this._projectileMap.set(simProjectile, new VisProjectile(simProjectile));
}
else if (Math.floor(currentStep) != Math.floor(this._lastStep)) {
visProjectile.advanceStep();
}
});
for (const deadProjectile of deadProjectiles) {
this._projectileMap.delete(deadProjectile);
}
this._lastStep = currentStep;
}
getScreenCoords(hex) {
const coord = Hex.toPixel(hex, this._hexSize);
return new Vector2(coord.x + this._screenXOffset - this._screenCellWidth / 2, coord.y + this._screenYOffset - this._screenCellHeight / 2);
}
getHexFromScreenCoords(coords) {
const x = coords.x - this._screenXOffset;
const y = coords.y - this._screenYOffset;
return Hex.fromPixel(new Vector2(x, y), this._hexSize);
}
drawBackground() {
const ctx = this._visMain.context;
const simLevel = this._simMain.currentLevel;
if (this._background == null) {
const backgroundCanvas = this._visMain.canvas.cloneNode();
const backgroundContext = backgroundCanvas.getContext("2d");
this._background = backgroundCanvas;
simLevel.simCells.forEach((cell) => {
if (cell.distance > simLevel.gdLevel.radius) {
return;
}
if (cell.blockedType != -1 && cell.type == ECellType.Blocked) {
this.drawCellImage(backgroundContext, cell, "cell-blocked-" + (cell.blockedType | 0) + ".svg");
}
});
backgroundContext.globalCompositeOperation = "source-atop";
backgroundContext.fillStyle = this._visMain.wallPattern;
backgroundContext.fillRect(0, 0, this._visMain.canvas.width, this._visMain.canvas.height);
const cellCanvas = this._visMain.canvas.cloneNode();
const cellContext = cellCanvas.getContext("2d");
simLevel.simCells.forEach((cell) => {
if (cell.distance > simLevel.gdLevel.radius) {
return;
}
if (cell.type != ECellType.Entry) {
this.drawCellImage(cellContext, cell, "cell.svg");
}
});
backgroundContext.globalCompositeOperation = "destination-over";
backgroundContext.drawImage(cellCanvas, 0, 0);
backgroundContext.globalCompositeOperation = "source-over";
}
ctx.drawImage(this._background, 0, 0);
}
drawProjectile(simProjectile) {
const visProjectile = this._projectileMap.get(simProjectile);
if (!visProjectile) {
return;
}
const t = this._lastStep - Math.floor(this._lastStep);
const positions = visProjectile.positions;
if (!positions) {
return;
}
const pos = Vector2.lerp(positions[0], positions[1], t);
const width = this._screenCellWidth * simProjectile.size;
const height = this._screenCellHeight * simProjectile.size;
this._visMain.context.drawImage(this._gdRoot.image("projectile.svg"), this._screenXOffset + pos.x * this._hexSize - width / 2, this._screenYOffset + pos.y * this._hexSize - height / 2, width, height);
}
drawEnemy(simEnemy) {
const visEnemy = this._enemyMap.get(simEnemy);
if (!visEnemy) {
return;
}
const t = this._lastStep - Math.floor(this._lastStep);
const positions = visEnemy.positions;
if (!positions) {
return;
}
const pos = Vector2.lerp(positions[0], positions[1], t);
this._visMain.context.drawImage(visEnemy.image, this._screenXOffset + pos.x * this._hexSize - this._screenCellWidth / 2, this._screenYOffset + pos.y * this._hexSize - this._screenCellHeight / 2, this._screenCellWidth, this._screenCellHeight);
}
drawCell(cell) {
this._visMain.context.fillStyle = "rgba(192, 192, 192, 0.25)";
if (cell.type == ECellType.Entry) {
this.drawCellImage(this._visMain.context, cell, "cell-entry-" + (cell.blockedType | 0) + ".svg");
}
const simLevel = this._simMain.currentLevel;
const highlightedCell = simLevel.simCells[simLevel.highlightedIndex];
if (!!highlightedCell) {
let draw = highlightedCell.index == cell.index;
if (draw && highlightedCell.pathsToTarget != null) {
for (const routeIdx in highlightedCell.pathsToTarget) {
for (const idx in highlightedCell.pathsToTarget[routeIdx]) {
if (highlightedCell.pathsToTarget[routeIdx][idx] == highlightedCell.index) {
draw = true;
break;
}
}
}
}
if (draw) {
this.drawCellImage(this._visMain.context, highlightedCell, "cell-highlighted.svg");
this._visMain.context.fillStyle = "rgba(0, 0, 0, 1)";
}
}
if (cell.simTower != null) {
this.drawCellImage(this._visMain.context, cell, "tower-" + (cell.simTower.index | 0) + ".svg");
}
const coords = this.getScreenCoords(cell.hex);
this._visMain.context.fillText("(" + cell.hex.col + ", " + cell.hex.row + ")", coords.x + 10, coords.y + this._screenCellHeight / 2 + 5);
}
drawCellImage(context, cell, name) {
const coords = this.getScreenCoords(cell.hex);
context.drawImage(this._gdRoot.image(name), coords.x, coords.y, this._screenCellWidth, this._screenCellHeight);
}
}
//# sourceMappingURL=VisLevel.js.map

1
dist/Vis/VisLevel.js.map vendored Normal file

File diff suppressed because one or more lines are too long

103
dist/Vis/VisMain.js vendored Normal file
View File

@@ -0,0 +1,103 @@
import { VisLevel } from "./index.js";
export class VisMain {
_canvas;
_context;
_startTimestamp = 0;
_active = true;
_ready = false;
_gap = 0;
_wallPattern;
_visLevel;
_simMain;
constructor(simMain, canvas) {
this._simMain = simMain;
this._canvas = canvas;
this._context = this._canvas.getContext("2d");
this._context.globalCompositeOperation = "source-over";
this._wallPattern = this.createPattern(this._simMain.gdRoot.image("wall.png"), 48);
this._visLevel = new VisLevel(this, this._simMain, this._simMain.gdRoot);
const host = this;
requestAnimationFrame(function step(timestamp) {
host.step(timestamp);
});
}
get simMain() {
return this._simMain;
}
get visLevel() {
return this._visLevel;
}
get canvas() {
return this._canvas;
}
get context() {
return this._context;
}
get wallPattern() {
return this._wallPattern;
}
createPattern(image, size) {
const tempCanvas = document.createElement("canvas");
const tempContext = tempCanvas.getContext("2d");
tempCanvas.width = size;
tempCanvas.height = size;
tempContext.drawImage(image, 0, 0, image.width, image.height, 0, 0, size, size);
return this._context.createPattern(tempCanvas, 'repeat');
}
step(timestamp) {
if (!this._active) {
return;
}
const host = this;
requestAnimationFrame((timestamp) => {
host.step(timestamp);
});
if (!this._startTimestamp) {
this._startTimestamp = timestamp;
}
const simLevel = this._simMain.currentLevel;
let targetStep = (timestamp - this._startTimestamp) * this._simMain.gdRoot.simulation.stepsPerSecond / 1000 - this._gap;
if (simLevel.paused) {
this._gap += targetStep - simLevel.currentStep;
targetStep = simLevel.currentStep;
}
this._simMain.executeUntilStep(targetStep);
this._visLevel.updateEveryFrame(targetStep);
this.onRender();
}
;
onResized() {
const gameHost = document.getElementById("game-host");
const width = gameHost.clientWidth;
const height = gameHost.clientHeight;
const ratio = window.devicePixelRatio;
this._canvas.width = width * ratio;
this._canvas.height = height * ratio;
this._canvas.style.width = width + "px";
this._canvas.style.height = height + "px";
this._context.scale(ratio, ratio);
this._visLevel.updateSize();
}
;
onRender() {
this.clear();
const ctx = this._context;
ctx.font = "12px Tahoma";
const simLevel = this._simMain.currentLevel;
if (!!simLevel) {
if (!this._ready) {
this.onResized();
this._ready = true;
}
this._visLevel.draw();
}
}
;
clear() {
this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);
}
stop() {
this._active = false;
}
}
//# sourceMappingURL=VisMain.js.map

1
dist/Vis/VisMain.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"VisMain.js","sourceRoot":"","sources":["../../src/Vis/VisMain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,OAAO,OAAO;IACR,OAAO,CAAoB;IAC3B,QAAQ,CAA2B;IACnC,eAAe,GAAW,CAAC,CAAC;IAC5B,OAAO,GAAY,IAAI,CAAC;IACxB,MAAM,GAAY,KAAK,CAAC;IACxB,IAA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C;IAEM,KAAK;QACT,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC;IAEO,IAAI;QACR,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB,CAAC;CACJ"}

15
dist/Vis/VisProjectile.js vendored Normal file
View File

@@ -0,0 +1,15 @@
export class VisProjectile {
_positions;
_simProjectile;
constructor(simProjectile) {
this._simProjectile = simProjectile;
this._positions = [simProjectile.position, simProjectile.position];
}
get positions() {
return this._positions;
}
advanceStep() {
this._positions = [this._positions[1], this._simProjectile.position];
}
}
//# sourceMappingURL=VisProjectile.js.map

1
dist/Vis/VisProjectile.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"VisProjectile.js","sourceRoot":"","sources":["../../src/Vis/VisProjectile.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,aAAa;IACd,UAAU,CAAY;IACtB,cAAc,CAAgB;IAEtC,YAAY,aAA4B;QACpC,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvE,CAAC;IAED,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAEM,WAAW;QACd,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IACzE,CAAC;CACJ"}

6
dist/Vis/index.js vendored Normal file
View File

@@ -0,0 +1,6 @@
import { VisEnemy } from "./VisEnemy.js";
import { VisLevel } from "./VisLevel.js";
import { VisMain } from "./VisMain.js";
import { VisProjectile } from "./VisProjectile.js";
export { VisEnemy, VisLevel, VisMain, VisProjectile };
//# sourceMappingURL=index.js.map

1
dist/Vis/index.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Vis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,CAAA"}

10
dist/main.js vendored Normal file
View File

@@ -0,0 +1,10 @@
import { GdRoot } from "./GameData/index.js";
import { EViewType, ViewManager } from "./View/index.js";
document.addEventListener("DOMContentLoaded", async () => {
const gdRoot = new GdRoot();
await gdRoot.loadAsync();
const viewManager = new ViewManager();
await viewManager.loadAsync(gdRoot);
viewManager.showView(EViewType.Menu);
});
//# sourceMappingURL=main.js.map

1
dist/main.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEzD,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;IACrD,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC5B,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC;IAEzB,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IACtC,MAAM,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEpC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC"}

72
htd.css Normal file
View File

@@ -0,0 +1,72 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
background-color: #206030;
overflow: hidden;
}
.view {
}
#app {
width: 100%;
height: 100%;
}
.container {
display: grid;
grid-template-rows: auto 1fr auto;
grid-template-columns: auto 1fr auto;
width: 100%;
height: 100%;
overflow: hidden;
}
.container canvas {
height: 100%;
}
.top-bar {
grid-column: 1 / -1;
grid-row: 1;
background-color: lightgray;
}
.left-bar {
grid-column: 1;
grid-row: 2;
background-color: lightblue;
}
.center {
grid-column: 2;
grid-row: 2;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.center canvas {
max-width: 100%;
max-height: 100%;
display: block;
}
.right-bar {
grid-column: 3;
grid-row: 2;
background-color: lightgreen;
}
.bottom-bar {
grid-column: 1 / -1;
grid-row: 3;
background-color: lightcoral;
}

Some files were not shown because too many files have changed in this diff Show More