Switch to MonoGame using WPFGame
This commit is contained in:
parent
84b21df283
commit
76c15e72ca
22 changed files with 351 additions and 227 deletions
|
|
@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.3.32929.385
|
VisualStudioVersion = 17.3.32929.385
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CityGame", "CityGame\CityGame.csproj", "{5D76B596-FC17-4F47-B5C6-D811DE04F806}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CityGame", "CityGame\CityGame.csproj", "{5D76B596-FC17-4F47-B5C6-D811DE04F806}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WPFGame", "..\WPFGame\WPFGame\WPFGame.csproj", "{4F2DC7EE-24BA-4383-9AB6-EBA46EB191DF}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
@ -15,6 +17,10 @@ Global
|
||||||
{5D76B596-FC17-4F47-B5C6-D811DE04F806}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{5D76B596-FC17-4F47-B5C6-D811DE04F806}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{5D76B596-FC17-4F47-B5C6-D811DE04F806}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5D76B596-FC17-4F47-B5C6-D811DE04F806}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{5D76B596-FC17-4F47-B5C6-D811DE04F806}.Release|Any CPU.Build.0 = Release|Any CPU
|
{5D76B596-FC17-4F47-B5C6-D811DE04F806}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{4F2DC7EE-24BA-4383-9AB6-EBA46EB191DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{4F2DC7EE-24BA-4383-9AB6-EBA46EB191DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{4F2DC7EE-24BA-4383-9AB6-EBA46EB191DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{4F2DC7EE-24BA-4383-9AB6-EBA46EB191DF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Configuration;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace CityGame
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for App.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class App : Application
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
[assembly: ThemeInfo(
|
|
||||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
|
||||||
//(used if a resource is not found in the page,
|
|
||||||
// or application resource dictionaries)
|
|
||||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
|
||||||
//(used if a resource is not found in the page,
|
|
||||||
// app, or any theme specific resource dictionaries)
|
|
||||||
)]
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
using System;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using WPFGame;
|
||||||
|
|
||||||
namespace CityGame
|
namespace CityGame
|
||||||
{
|
{
|
||||||
|
|
@ -25,7 +26,7 @@ namespace CityGame
|
||||||
Y = (float)value.Y * MainWindow.TileSize;
|
Y = (float)value.Y * MainWindow.TileSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public float Speed { get; set; } = 256;
|
public float Speed { get; set; } = 128;
|
||||||
public override OCanvas Render()
|
public override OCanvas Render()
|
||||||
{
|
{
|
||||||
return new SourcedImage("Car.png");
|
return new SourcedImage("Car.png");
|
||||||
|
|
@ -40,7 +41,7 @@ namespace CityGame
|
||||||
{
|
{
|
||||||
if (Target is not null)
|
if (Target is not null)
|
||||||
{
|
{
|
||||||
if(Object is not null) Object.ToolTip = Target.ToString();
|
//if(Object is not null) Object.ToolTip = Target.ToString();
|
||||||
if (Path is null)
|
if (Path is null)
|
||||||
{
|
{
|
||||||
Path = MainWindow.pathfinder.FindPath(Point.Convert(), ((Point)Target).Convert()).Select(x => x.Convert()).ToArray();
|
Path = MainWindow.pathfinder.FindPath(Point.Convert(), ((Point)Target).Convert()).Select(x => x.Convert()).ToArray();
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,9 @@
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>False</UseWPF>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Remove="Resources\BlueTint.hlsl" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AStarLite" Version="1.1.0" />
|
<PackageReference Include="AStarLite" Version="1.1.0" />
|
||||||
<PackageReference Include="Microsoft.HLSL.CSharpVB" Version="1.0.2" />
|
<PackageReference Include="Microsoft.HLSL.CSharpVB" Version="1.0.2" />
|
||||||
|
|
@ -19,7 +15,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PixelShader Include="Resources\BlueTint.hlsl" />
|
<ProjectReference Include="..\..\WPFGame\WPFGame\WPFGame.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -39,82 +35,100 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="Resources\Building0.png">
|
<None Update="Resources\Building0.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building1.png">
|
<None Update="Resources\Building1.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building2.png">
|
<None Update="Resources\Building2.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building2c.png">
|
<None Update="Resources\Building2c.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building3.png">
|
<None Update="Resources\Building3.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building3a.png">
|
<None Update="Resources\Building3a.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building3ab.png">
|
<None Update="Resources\Building3ab.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building3c.png">
|
<None Update="Resources\Building3c.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building4.png">
|
<None Update="Resources\Building4.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building4c.png">
|
<None Update="Resources\Building4c.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building4m.png">
|
<None Update="Resources\Building4m.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building5.png">
|
<None Update="Resources\Building5.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building7.png">
|
<None Update="Resources\Building7.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Building8.png">
|
<None Update="Resources\Building8.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Car.png">
|
<None Update="Resources\Car.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Error.png">
|
<None Update="Resources\Error.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Resources\Garage.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Resources\Helicopter.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Resources\HelicopterBlades.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Resources\HelicopterBlades2.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Resources\HelicopterFlight.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Resources\Helipad.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\ParkingLot.png">
|
<None Update="Resources\ParkingLot.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Road2.png">
|
<None Update="Resources\Road2.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Road4c.png">
|
<None Update="Resources\Road4c.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Road2c.png">
|
<None Update="Resources\Road2c.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Road1.png">
|
<None Update="Resources\Road1.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Road3c.png">
|
<None Update="Resources\Road3c.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Tree.png">
|
<None Update="Resources\Tree.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Vent1.png">
|
<None Update="Resources\Vent1.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Vent2.png">
|
<None Update="Resources\Vent2.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Resources\Vent3.png">
|
<None Update="Resources\Vent3.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
/*
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Effects;
|
|
||||||
|
|
||||||
namespace CityGame
|
namespace CityGame
|
||||||
{
|
{
|
||||||
public class CustomShader : ShaderEffect
|
public class CustomShader : ShaderEffect
|
||||||
|
|
@ -32,4 +29,4 @@ namespace CityGame
|
||||||
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(CustomShader), 0);
|
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(CustomShader), 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
@ -1,13 +1,40 @@
|
||||||
namespace CityGame
|
namespace CityGame
|
||||||
{
|
{
|
||||||
public abstract class Entity
|
public abstract class Entity : ISelectable
|
||||||
{
|
{
|
||||||
public float X { get; set; }
|
public float X { get; set; }
|
||||||
public float Y { get; set; }
|
public float Y { get; set; }
|
||||||
public float Rotation { get; set; }
|
public float Rotation { get; set; }
|
||||||
public long Time { get; set; }
|
public long Time { get; set; }
|
||||||
public OCanvas Object { get; set; }
|
public OCanvas Object { get; set; }
|
||||||
|
|
||||||
|
public OCanvas GetImage()
|
||||||
|
{
|
||||||
|
return Object;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract OCanvas Render();
|
public abstract OCanvas Render();
|
||||||
|
|
||||||
|
public bool RunAction(ISelectable target)
|
||||||
|
{
|
||||||
|
if(this is Helicopter heli)
|
||||||
|
{
|
||||||
|
heli.Target = target;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void Tick(long deltaTime);
|
public abstract void Tick(long deltaTime);
|
||||||
|
|
||||||
|
int ISelectable.X()
|
||||||
|
{
|
||||||
|
return (int)X;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ISelectable.Y()
|
||||||
|
{
|
||||||
|
return (int)Y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace CityGame
|
namespace CityGame
|
||||||
|
|
|
||||||
69
CityGame/Helicopter.cs
Normal file
69
CityGame/Helicopter.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
using WPFGame;
|
||||||
|
|
||||||
|
namespace CityGame
|
||||||
|
{
|
||||||
|
public class Helicopter : Entity
|
||||||
|
{
|
||||||
|
public float Speed { get; set; } = 256;
|
||||||
|
public bool Landed = false;
|
||||||
|
Image Heli1;
|
||||||
|
Image Heli2;
|
||||||
|
Image Blades1;
|
||||||
|
Image Blades2;
|
||||||
|
int RotorState = 0;
|
||||||
|
public ISelectable Target;
|
||||||
|
bool Move;
|
||||||
|
public override OCanvas Render()
|
||||||
|
{
|
||||||
|
OCanvas canvas = new OCanvas();
|
||||||
|
Heli1 = new SourcedImage("Helicopter.png");
|
||||||
|
Heli2 = new SourcedImage("HelicopterFlight.png");
|
||||||
|
Blades1 = new SourcedImage("HelicopterBlades.png");
|
||||||
|
Blades2 = new SourcedImage("HelicopterBlades2.png");
|
||||||
|
|
||||||
|
Heli1.Visible = false;
|
||||||
|
Blades2.Visible = false;
|
||||||
|
|
||||||
|
canvas.Children.Add(Heli1);
|
||||||
|
canvas.Children.Add(Heli2);
|
||||||
|
canvas.Children.Add(Blades1);
|
||||||
|
canvas.Children.Add(Blades2);
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Tick(long deltaTime)
|
||||||
|
{
|
||||||
|
if (Heli1 is null) return;
|
||||||
|
long ms = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
if (ms / 250 % 2 == 0)
|
||||||
|
{
|
||||||
|
Blades1.Visible = false;
|
||||||
|
Blades2.Visible = true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Blades1.Visible = true;
|
||||||
|
Blades2.Visible = false;
|
||||||
|
}
|
||||||
|
if (Target is not null)
|
||||||
|
{
|
||||||
|
IntPoint nextTarget = new IntPoint(Target.X(), Target.Y());
|
||||||
|
Vector2 travel = new Vector2((float)nextTarget.X - X, (float)nextTarget.Y - Y);
|
||||||
|
if (travel.Length() < MainWindow.TileSize * 1) Move = false;
|
||||||
|
if (travel.Length() > MainWindow.TileSize * 3) Move = true;
|
||||||
|
Vector2 direction = Vector2.Normalize(travel);
|
||||||
|
float degrees = (float)(Math.Atan2(direction.Y, direction.X) * (180 / Math.PI)) + 90;
|
||||||
|
Rotation = degrees;
|
||||||
|
float Speedmulti = 1;
|
||||||
|
if (travel.Length() < MainWindow.TileSize * 3) Speedmulti = (travel.Length() - MainWindow.TileSize) / (MainWindow.TileSize * 2);
|
||||||
|
var possibleDistance = Speed * Speedmulti * deltaTime / 1000;
|
||||||
|
var finalDistance = Math.Min(possibleDistance, travel.Length());
|
||||||
|
Vector2 travelFinal = direction * finalDistance;
|
||||||
|
X += travelFinal.X;
|
||||||
|
Y += travelFinal.Y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
CityGame/ISelectable.cs
Normal file
10
CityGame/ISelectable.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace CityGame
|
||||||
|
{
|
||||||
|
public interface ISelectable
|
||||||
|
{
|
||||||
|
public OCanvas GetImage();
|
||||||
|
public bool RunAction(ISelectable target);
|
||||||
|
public int X();
|
||||||
|
public int Y();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,32 +1,58 @@
|
||||||
using AStar;
|
using AStar;
|
||||||
using AStar.Options;
|
using AStar.Options;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
using SimplexNoise;
|
using SimplexNoise;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.WebSockets;
|
using WPFGame;
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
|
|
||||||
namespace CityGame
|
namespace CityGame
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public class Program { public static void Main() { new MainWindow(); } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for MainWindow.xaml
|
/// Interaction logic for MainWindow.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
public ISelectable GetSelectableFromClick(MouseState click)
|
||||||
|
{
|
||||||
|
Point point = new Point(click.X, click.Y);
|
||||||
|
point.X -= (int)Canvas.GetLeft(CameraCanvas);
|
||||||
|
point.Y -= (int)Canvas.GetTop(CameraCanvas);
|
||||||
|
point.X = (int)(point.X / CameraCanvas.ScaleX);
|
||||||
|
point.Y = (int)(point.Y / CameraCanvas.ScaleY);
|
||||||
|
|
||||||
|
foreach (Entity entity in Entities)
|
||||||
|
{
|
||||||
|
double diff = new Vector2((int)entity.X + TileSize / 2 - point.X, (int)entity.Y + TileSize / 2 - point.Y).Length();
|
||||||
|
if (diff < TileSize / 2) return entity;
|
||||||
|
}
|
||||||
|
int x = point.X / TileSize;
|
||||||
|
int y = point.Y / TileSize;
|
||||||
|
if (x < 0 || y < 0) return null;
|
||||||
|
if (x > Grid.GetLength(0) - 1 || y > Grid.GetLength(1) - 1) return null;
|
||||||
|
|
||||||
|
return Grid[x, y];
|
||||||
|
}
|
||||||
|
public static Entity GetEntityFromImage(Image image)
|
||||||
|
{
|
||||||
|
foreach (Entity entity in Entities)
|
||||||
|
{
|
||||||
|
if (entity.Object == image.Parent) return entity;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public static Tile? GetTileFromImage(Image image)
|
||||||
|
{
|
||||||
|
double x = Canvas.GetLeft(image.Parent) / TileSize;
|
||||||
|
double y = Canvas.GetTop(image.Parent) / TileSize;
|
||||||
|
if (x % 1 != 0 || y % 1 != 0) return null;
|
||||||
|
return Grid[(int)x, (int)y];
|
||||||
|
}
|
||||||
public static Random random;
|
public static Random random;
|
||||||
public static bool MouseIsDown = false;
|
public static bool MouseIsDown = false;
|
||||||
public static Point MousePos = new Point(0, 0);
|
public static Point MousePos = new Point(0, 0);
|
||||||
|
|
@ -36,6 +62,15 @@ namespace CityGame
|
||||||
public static List<Tile> npcWalkable = new List<Tile>();
|
public static List<Tile> npcWalkable = new List<Tile>();
|
||||||
public static List<Entity> Entities { get; set; } = new List<Entity>();
|
public static List<Entity> Entities { get; set; } = new List<Entity>();
|
||||||
public const int TileSize = 64;
|
public const int TileSize = 64;
|
||||||
|
public static Tile[,] Grid;
|
||||||
|
public static ISelectable Selected;
|
||||||
|
public static OCanvas[,] ImageGrid;
|
||||||
|
|
||||||
|
Canvas MainCanvas = new OCanvas();
|
||||||
|
Canvas BGCanvas = new OCanvas();
|
||||||
|
Canvas GameCanvas = new OCanvas();
|
||||||
|
Canvas CameraCanvas = new OCanvas();
|
||||||
|
Canvas UICanvas = new OCanvas();
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
#region | Texture Conversions |
|
#region | Texture Conversions |
|
||||||
|
|
@ -63,11 +98,7 @@ namespace CityGame
|
||||||
ImageConverter.ChangeColor("Error", "ErrorRed", new Dictionary<string, string> { { "#000000", "#ff0000" } });
|
ImageConverter.ChangeColor("Error", "ErrorRed", new Dictionary<string, string> { { "#000000", "#ff0000" } });
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
InitializeComponent();
|
int seed = 8;
|
||||||
|
|
||||||
#region | Map Generation |
|
|
||||||
#region | Map Generation Constants |
|
|
||||||
int seed = 3;
|
|
||||||
|
|
||||||
Noise.Seed = seed;
|
Noise.Seed = seed;
|
||||||
|
|
||||||
|
|
@ -93,12 +124,10 @@ namespace CityGame
|
||||||
int minBlockHeight = 3;
|
int minBlockHeight = 3;
|
||||||
int minBlockWidth = 3;
|
int minBlockWidth = 3;
|
||||||
|
|
||||||
int NPCCount = 1;
|
int NPCCount = (int)Math.Ceiling(mapHeight * mapWidth / 100f);
|
||||||
|
|
||||||
random = new Random(seed);
|
random = new Random(seed);
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region | Map Initialization |
|
#region | Map Initialization |
|
||||||
Tile[,] InitialGrid = new Tile[mapWidth, mapHeight];
|
Tile[,] InitialGrid = new Tile[mapWidth, mapHeight];
|
||||||
|
|
||||||
|
|
@ -179,9 +208,6 @@ namespace CityGame
|
||||||
IntermediateGrid[x * 2 + 1, y * 2].Y = y * 2;
|
IntermediateGrid[x * 2 + 1, y * 2].Y = y * 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region | Roads and Bridges |
|
|
||||||
Dictionary<int, bool> decidedBridges = new Dictionary<int, bool>();
|
Dictionary<int, bool> decidedBridges = new Dictionary<int, bool>();
|
||||||
pathfindingGrid = new short[doubleWidth, doubleHeight];
|
pathfindingGrid = new short[doubleWidth, doubleHeight];
|
||||||
pathfindingGridDesperate = new short[doubleWidth, doubleHeight];
|
pathfindingGridDesperate = new short[doubleWidth, doubleHeight];
|
||||||
|
|
@ -214,10 +240,6 @@ namespace CityGame
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region | Pathfinding |
|
|
||||||
|
|
||||||
int mainRoadCount = random.Next(1, 5);
|
int mainRoadCount = random.Next(1, 5);
|
||||||
for (int m = 0; m < mainRoadCount; m++)
|
for (int m = 0; m < mainRoadCount; m++)
|
||||||
{
|
{
|
||||||
|
|
@ -228,20 +250,20 @@ namespace CityGame
|
||||||
if (variant == 0)
|
if (variant == 0)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = random.Next(0, doubleHeight);
|
int y = random.Next(0 + 2, doubleHeight - 2);
|
||||||
startPoint = new IntPoint(x, y);
|
startPoint = new IntPoint(x, y);
|
||||||
endPoint = new IntPoint(doubleWidth, y);
|
endPoint = new IntPoint(doubleWidth, y);
|
||||||
step = new IntPoint(1, 0);
|
step = new IntPoint(1, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int x = random.Next(0, doubleWidth);
|
int x = random.Next(0 + 2, doubleWidth - 2);
|
||||||
int y = 0;
|
int y = 0;
|
||||||
startPoint = new IntPoint(x, y);
|
startPoint = new IntPoint(x, y);
|
||||||
endPoint = new IntPoint(x, doubleHeight);
|
endPoint = new IntPoint(x, doubleHeight);
|
||||||
step = new IntPoint(0, 1);
|
step = new IntPoint(0, 1);
|
||||||
}
|
}
|
||||||
while(startPoint != endPoint)
|
while (startPoint != endPoint)
|
||||||
{
|
{
|
||||||
int x = (int)startPoint.X;
|
int x = (int)startPoint.X;
|
||||||
int y = (int)startPoint.Y;
|
int y = (int)startPoint.Y;
|
||||||
|
|
@ -280,7 +302,7 @@ namespace CityGame
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
Tile[,] Grid = IntermediateGrid;
|
Grid = IntermediateGrid;
|
||||||
//for(int y = 0; y < mapHeight; y++)
|
//for(int y = 0; y < mapHeight; y++)
|
||||||
//{
|
//{
|
||||||
// for(int x = 0; x < mapWidth; x++)
|
// for(int x = 0; x < mapWidth; x++)
|
||||||
|
|
@ -292,33 +314,18 @@ namespace CityGame
|
||||||
mapHeight *= 2;
|
mapHeight *= 2;
|
||||||
mapWidth *= 2;
|
mapWidth *= 2;
|
||||||
|
|
||||||
#endregion
|
ImageGrid = new OCanvas[doubleWidth, doubleHeight];
|
||||||
|
|
||||||
Show();
|
|
||||||
|
|
||||||
#region | Rendering |
|
|
||||||
|
|
||||||
Canvas MainCanvas = new OCanvas();
|
|
||||||
Canvas BGCanvas = new OCanvas();
|
|
||||||
Canvas GameCanvas = new OCanvas();
|
|
||||||
Canvas CameraCanvas = new OCanvas();
|
|
||||||
Canvas UICanvas = new OCanvas();
|
|
||||||
|
|
||||||
Canvas.SetLeft(CameraCanvas, 0);
|
Canvas.SetLeft(CameraCanvas, 0);
|
||||||
Canvas.SetTop(CameraCanvas, 0);
|
Canvas.SetTop(CameraCanvas, 0);
|
||||||
|
|
||||||
RenderOptions.SetEdgeMode(GameCanvas, EdgeMode.Aliased);
|
|
||||||
|
|
||||||
MainCanvas.Children.Add(CameraCanvas);
|
MainCanvas.Children.Add(CameraCanvas);
|
||||||
MainCanvas.Children.Add(UICanvas);
|
MainCanvas.Children.Add(UICanvas);
|
||||||
|
|
||||||
CameraCanvas.Children.Add(BGCanvas);
|
CameraCanvas.Children.Add(BGCanvas);
|
||||||
CameraCanvas.Children.Add(GameCanvas);
|
CameraCanvas.Children.Add(GameCanvas);
|
||||||
|
|
||||||
MainCanvas.HorizontalAlignment = HorizontalAlignment.Left;
|
ContentCanvas = MainCanvas;
|
||||||
MainCanvas.VerticalAlignment = VerticalAlignment.Top;
|
|
||||||
|
|
||||||
Content = MainCanvas;
|
|
||||||
|
|
||||||
int tileSize = TileSize;
|
int tileSize = TileSize;
|
||||||
for (int x = 0; x < mapWidth; x++)
|
for (int x = 0; x < mapWidth; x++)
|
||||||
|
|
@ -327,95 +334,24 @@ namespace CityGame
|
||||||
{
|
{
|
||||||
Canvas image = Renderer.Render(Grid[x, y].Type, x, y, Grid);
|
Canvas image = Renderer.Render(Grid[x, y].Type, x, y, Grid);
|
||||||
|
|
||||||
image.Height = tileSize;
|
|
||||||
image.Width = tileSize;
|
|
||||||
|
|
||||||
RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.NearestNeighbor);
|
|
||||||
|
|
||||||
Canvas.SetLeft(image, x * tileSize);
|
Canvas.SetLeft(image, x * tileSize);
|
||||||
Canvas.SetTop(image, y * tileSize);
|
Canvas.SetTop(image, y * tileSize);
|
||||||
|
|
||||||
|
ImageGrid[x, y] = (OCanvas)image;
|
||||||
|
|
||||||
//image.Opacity = pathfindingGrid[y, x];
|
//image.Opacity = pathfindingGrid[y, x];
|
||||||
|
|
||||||
GameCanvas.Children.Add(image);
|
GameCanvas.Children.Add(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
foreach (Image image in SourcedImage.GetObjectsBySourceFile("Helipad.png"))
|
||||||
|
|
||||||
#region | Controls |
|
|
||||||
|
|
||||||
MainCanvas.MouseDown += (a, b) => MouseIsDown = true;
|
|
||||||
MainCanvas.MouseUp += (a, b) => MouseIsDown = false;
|
|
||||||
MainCanvas.MouseMove += (a, b) =>
|
|
||||||
{
|
{
|
||||||
if (MouseIsDown)
|
float x = (float)Canvas.GetLeft(image.Parent);
|
||||||
{
|
float y = (float)Canvas.GetTop(image.Parent);
|
||||||
var newpos = PointToScreen(Mouse.GetPosition(this));
|
|
||||||
var diff = newpos - MousePos;
|
Entities.Add(new Helicopter { X = x, Y = y });
|
||||||
Canvas.SetLeft(CameraCanvas, Canvas.GetLeft(CameraCanvas) + diff.X);
|
|
||||||
Canvas.SetTop(CameraCanvas, Canvas.GetTop(CameraCanvas) + diff.Y);
|
|
||||||
}
|
}
|
||||||
MousePos = PointToScreen(Mouse.GetPosition(this));
|
|
||||||
};
|
|
||||||
|
|
||||||
ScaleTransform scale = new ScaleTransform(1, 1);
|
|
||||||
CameraCanvas.RenderTransform = scale;
|
|
||||||
|
|
||||||
MainCanvas.MouseWheel += (a, b) =>
|
|
||||||
{
|
|
||||||
float multi = 0.952f;
|
|
||||||
if (b.Delta > 0) multi = 1.05f;
|
|
||||||
|
|
||||||
scale.ScaleX *= multi;
|
|
||||||
scale.ScaleY *= multi;
|
|
||||||
|
|
||||||
if (b.Delta < 0)
|
|
||||||
{
|
|
||||||
scale.ScaleX = Math.Floor(scale.ScaleX * 100) / 100f;
|
|
||||||
scale.ScaleY = Math.Floor(scale.ScaleY * 100) / 100f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scale.ScaleX = Math.Ceiling(scale.ScaleX * 100) / 100f;
|
|
||||||
scale.ScaleY = Math.Ceiling(scale.ScaleY * 100) / 100f;
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.WriteLine(scale.ScaleX);
|
|
||||||
};
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region | Entities |
|
|
||||||
|
|
||||||
DispatcherTimer EntityLoop = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1 / 10) };
|
|
||||||
EntityLoop.Tick += (a, b) =>
|
|
||||||
{
|
|
||||||
long milliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
|
||||||
foreach (Entity entity in Entities)
|
|
||||||
{
|
|
||||||
long delta = milliseconds - entity.Time;
|
|
||||||
entity.Time = milliseconds;
|
|
||||||
entity.Tick(delta);
|
|
||||||
|
|
||||||
if (entity.Object is null)
|
|
||||||
{
|
|
||||||
entity.Object = entity.Render();
|
|
||||||
RenderOptions.SetBitmapScalingMode(entity.Object, BitmapScalingMode.NearestNeighbor);
|
|
||||||
var rt = new RotateTransform(entity.Rotation);
|
|
||||||
rt.CenterX = MainWindow.TileSize / 2;
|
|
||||||
rt.CenterY = MainWindow.TileSize / 2;
|
|
||||||
entity.Object.RenderTransform = rt;
|
|
||||||
GameCanvas.Children.Add(entity.Object);
|
|
||||||
}
|
|
||||||
((RotateTransform)entity.Object.RenderTransform).Angle = entity.Rotation;
|
|
||||||
Canvas.SetLeft(entity.Object, entity.X);
|
|
||||||
Canvas.SetTop(entity.Object, entity.Y);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
EntityLoop.Start();
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
for (int n = 0; n < NPCCount; n++)
|
for (int n = 0; n < NPCCount; n++)
|
||||||
{
|
{
|
||||||
|
|
@ -430,13 +366,7 @@ namespace CityGame
|
||||||
Car.CarEvent reset = car =>
|
Car.CarEvent reset = car =>
|
||||||
{
|
{
|
||||||
Tile targetTile = npcWalkable[random.Next(0, npcWalkable.Count)];
|
Tile targetTile = npcWalkable[random.Next(0, npcWalkable.Count)];
|
||||||
DispatcherTimer delay = new DispatcherTimer { Interval = TimeSpan.FromSeconds(random.Next(1, 5)) };
|
|
||||||
delay.Tick += (a, b) =>
|
|
||||||
{
|
|
||||||
car.Target = new Point(targetTile.X, targetTile.Y);
|
car.Target = new Point(targetTile.X, targetTile.Y);
|
||||||
delay.Stop();
|
|
||||||
};
|
|
||||||
delay.Start();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
car.JourneyFinished += reset;
|
car.JourneyFinished += reset;
|
||||||
|
|
@ -444,6 +374,75 @@ namespace CityGame
|
||||||
|
|
||||||
Entities.Add(car);
|
Entities.Add(car);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
int swv;
|
||||||
|
protected override void Update(GameTime time)
|
||||||
|
{
|
||||||
|
MouseState state = Mouse.GetState();
|
||||||
|
|
||||||
|
if (state.MiddleButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
var newpos = new Point(state.X, state.Y);
|
||||||
|
var diff = newpos - MousePos;
|
||||||
|
Canvas.SetLeft(CameraCanvas, Canvas.GetLeft(CameraCanvas) + diff.X);
|
||||||
|
Canvas.SetTop(CameraCanvas, Canvas.GetTop(CameraCanvas) + diff.Y);
|
||||||
|
}
|
||||||
|
MousePos = new Point(state.X, state.Y);
|
||||||
|
|
||||||
|
|
||||||
|
float delta = state.ScrollWheelValue - swv;
|
||||||
|
swv = state.ScrollWheelValue;
|
||||||
|
if (delta != 0)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(delta);
|
||||||
|
}
|
||||||
|
float multi = 1.05f;
|
||||||
|
if (delta < 0) multi = 1 / multi;
|
||||||
|
|
||||||
|
if (delta != 0)
|
||||||
|
{
|
||||||
|
CameraCanvas.ScaleX *= multi;
|
||||||
|
CameraCanvas.ScaleY *= multi;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.LeftButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
ISelectable select = GetSelectableFromClick(state);
|
||||||
|
if (select is not null)
|
||||||
|
{
|
||||||
|
if (Selected is not null) Selected.GetImage().Opacity = 1;
|
||||||
|
Selected = select;
|
||||||
|
Selected.GetImage().Opacity = 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (state.RightButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
ISelectable select = GetSelectableFromClick(state);
|
||||||
|
if (select is not null)
|
||||||
|
{
|
||||||
|
Selected.RunAction(select);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long milliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||||
|
foreach (Entity entity in Entities)
|
||||||
|
{
|
||||||
|
long deltaTime = milliseconds - entity.Time;
|
||||||
|
entity.Time = milliseconds;
|
||||||
|
entity.Tick(deltaTime);
|
||||||
|
|
||||||
|
if (entity.Object is null)
|
||||||
|
{
|
||||||
|
entity.Object = entity.Render();
|
||||||
|
GameCanvas.Children.Add(entity.Object);
|
||||||
|
}
|
||||||
|
entity.Object.Rotation = (int)entity.Rotation;
|
||||||
|
Canvas.SetLeft(entity.Object, entity.X);
|
||||||
|
Canvas.SetTop(entity.Object, entity.Y);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Windows.Controls;
|
using WPFGame;
|
||||||
|
|
||||||
namespace CityGame
|
namespace CityGame
|
||||||
{
|
{
|
||||||
|
|
@ -12,8 +12,6 @@ namespace CityGame
|
||||||
}
|
}
|
||||||
public OCanvas() : base()
|
public OCanvas() : base()
|
||||||
{
|
{
|
||||||
this.Height = 100;
|
|
||||||
this.Width = 100;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Windows.Controls;
|
using WPFGame;
|
||||||
|
|
||||||
namespace CityGame
|
namespace CityGame
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +32,10 @@ namespace CityGame
|
||||||
if (pattern.PatternCode == "3" && MainWindow.random.Next(0, 12) == 1) pattern.PatternCode = "3ab";
|
if (pattern.PatternCode == "3" && MainWindow.random.Next(0, 12) == 1) pattern.PatternCode = "3ab";
|
||||||
OCanvas canvas = new SourcedImage("Building"+ theme + pattern.PatternCode + ".png:" + pattern.Rotation, tooltip);
|
OCanvas canvas = new SourcedImage("Building"+ theme + pattern.PatternCode + ".png:" + pattern.Rotation, tooltip);
|
||||||
|
|
||||||
if (MainWindow.random.Next(0, 10) == 0 && pattern.PatternCode != "3a") canvas.Children.Add(new SourcedImage("Vent" + (MainWindow.random.Next(0, 3) + 1) + ".png:" + (MainWindow.random.Next(0, 4) * 90)));
|
if (theme == "Blue" && pattern.PatternCode == "8" && MainWindow.random.Next(0, 4) == 0) canvas.Children.Add(new SourcedImage("Helipad.png"));
|
||||||
|
else if (theme == "Blue" && pattern.PatternCode == "5" && MainWindow.random.Next(0, 2) == 0) canvas.Children.Add(new SourcedImage("Garage.png:" + pattern.Rotation));
|
||||||
|
else if (theme == "Blue" && pattern.PatternCode == "0") canvas.Children.Add(new SourcedImage("Garage.png:270"));
|
||||||
|
else if (MainWindow.random.Next(0, 10) == 0 && pattern.PatternCode != "3a") canvas.Children.Add(new SourcedImage("Vent" + (MainWindow.random.Next(0, 3) + 1) + ".png:" + (MainWindow.random.Next(0, 4) * 90)));
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
Texture2D inputTexture : register(t0);
|
|
||||||
SamplerState inputSampler : register(s0);
|
|
||||||
|
|
||||||
float4 main(float2 uv : TEXCOORD) : SV_Target
|
|
||||||
{
|
|
||||||
float4 color = inputTexture.Sample(inputSampler, uv);
|
|
||||||
float4 grayscaleColor = float4(dot(color.rgb, float3(0.299, 0.587, 0.114)), dot(color.rgb, float3(0.299, 0.587, 0.114)), dot(color.rgb, float3(0.299, 0.587, 0.114)), color.a);
|
|
||||||
return grayscaleColor;
|
|
||||||
}
|
|
||||||
BIN
CityGame/Resources/Garage.png
Normal file
BIN
CityGame/Resources/Garage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 298 B |
BIN
CityGame/Resources/Helicopter.png
Normal file
BIN
CityGame/Resources/Helicopter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 502 B |
BIN
CityGame/Resources/HelicopterBlades.png
Normal file
BIN
CityGame/Resources/HelicopterBlades.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 423 B |
BIN
CityGame/Resources/HelicopterBlades2.png
Normal file
BIN
CityGame/Resources/HelicopterBlades2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 298 B |
BIN
CityGame/Resources/HelicopterFlight.png
Normal file
BIN
CityGame/Resources/HelicopterFlight.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 630 B |
BIN
CityGame/Resources/Helipad.png
Normal file
BIN
CityGame/Resources/Helipad.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 650 B |
|
|
@ -3,15 +3,24 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using WPFGame;
|
||||||
using System.Windows.Controls;
|
/*
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
|
|
||||||
namespace CityGame
|
namespace CityGame.OldSourcedImage
|
||||||
{
|
{
|
||||||
public class SourcedImage : Image
|
public class SourcedImage : Image
|
||||||
{
|
{
|
||||||
|
public static List<SourcedImage> GetObjectsBySourceFile(params string[] files)
|
||||||
|
{
|
||||||
|
List<SourcedImage> objects = new List<SourcedImage>();
|
||||||
|
foreach(string file in files)
|
||||||
|
{
|
||||||
|
if (!ObjectsBySourceFile.ContainsKey(file)) continue;
|
||||||
|
foreach (var image in ObjectsBySourceFile[file]) objects.Add(image);
|
||||||
|
}
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
static Dictionary<string, List<SourcedImage>> ObjectsBySourceFile = new Dictionary<string, List<SourcedImage>>();
|
||||||
public Dictionary<string, string> Alternatives = new Dictionary<string, string>()
|
public Dictionary<string, string> Alternatives = new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{"Path3.png", "Path3c.png" }
|
{"Path3.png", "Path3c.png" }
|
||||||
|
|
@ -49,6 +58,11 @@ namespace CityGame
|
||||||
{
|
{
|
||||||
uri = Alternatives[uri];
|
uri = Alternatives[uri];
|
||||||
}
|
}
|
||||||
|
if(!ObjectsBySourceFile.ContainsKey(uri))
|
||||||
|
{
|
||||||
|
ObjectsBySourceFile.Add(uri, new List<SourcedImage>());
|
||||||
|
}
|
||||||
|
ObjectsBySourceFile[uri].Add(this);
|
||||||
uri = Environment.CurrentDirectory + "\\Resources\\" + uri;
|
uri = Environment.CurrentDirectory + "\\Resources\\" + uri;
|
||||||
if (loadedSources.ContainsKey(src))
|
if (loadedSources.ContainsKey(src))
|
||||||
{
|
{
|
||||||
|
|
@ -65,4 +79,4 @@ namespace CityGame
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
@ -1,10 +1,30 @@
|
||||||
namespace CityGame
|
namespace CityGame
|
||||||
{
|
{
|
||||||
public struct Tile
|
public struct Tile : ISelectable
|
||||||
{
|
{
|
||||||
public int BlockID;
|
public int BlockID;
|
||||||
public TileType Type;
|
public TileType Type;
|
||||||
public int X;
|
public int X;
|
||||||
public int Y;
|
public int Y;
|
||||||
|
|
||||||
|
public OCanvas GetImage()
|
||||||
|
{
|
||||||
|
return MainWindow.ImageGrid[X, Y];
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RunAction(ISelectable target)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ISelectable.X()
|
||||||
|
{
|
||||||
|
return X * MainWindow.TileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ISelectable.Y()
|
||||||
|
{
|
||||||
|
return Y * MainWindow.TileSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue