This commit is contained in:
riedel 2023-05-11 19:07:47 +02:00
parent 1fd19f9fac
commit 4bd02c5459
19 changed files with 125 additions and 110 deletions

View file

@ -5,7 +5,7 @@ VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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 EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WPFGame", "..\WPFGame\WPFGame\WPFGame.csproj", "{4F2DC7EE-24BA-4383-9AB6-EBA46EB191DF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrpticonGameHelper", "..\WPFGame\WPFGame\OrpticonGameHelper.csproj", "{4F2DC7EE-24BA-4383-9AB6-EBA46EB191DF}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View file

@ -1 +0,0 @@


View file

@ -1 +0,0 @@


View file

@ -21,7 +21,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\WPFGame\WPFGame\WPFGame.csproj" /> <ProjectReference Include="..\..\WPFGame\WPFGame\OrpticonGameHelper.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -109,7 +109,7 @@
<None Update="Resources\Car.png"> <None Update="Resources\Car.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="Resources\CNRGN Builder.ttf"> <None Update="Resources\Fonts\CNRGN Builder.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="Resources\Error.png"> <None Update="Resources\Error.png">
@ -118,7 +118,7 @@
<None Update="Resources\Garage.png"> <None Update="Resources\Garage.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="Resources\helicopter.mp3"> <None Update="Resources\Audio\helicopter.mp3">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="Resources\Helicopter.png"> <None Update="Resources\Helicopter.png">

View file

@ -5,7 +5,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using WPFGame; using OrpticonGameHelper;
using OrpticonGameHelper.Classes.Elements;
namespace CityGame.Classes.Entities namespace CityGame.Classes.Entities
{ {
@ -49,7 +50,8 @@ namespace CityGame.Classes.Entities
{ {
OCanvas canvas = new OCanvas(); OCanvas canvas = new OCanvas();
Image car = new SourcedImage(PNGFile); Image car = new SourcedImage(PNGFile);
car.Effects.Add(new OutlineEffect()); car.ZIndex = 99;
car.Effects.Add(selectedEffect);
canvas.Children.Add(car); canvas.Children.Add(car);
var light = new LightSource { Radius = 128, Angle = 64, Intensity = 2, Color = Color.White, Type = LightSourceType.Spotlight, Rotation = -90, RotationOrigin = new Point(MainWindow.TileSize / 2, MainWindow.TileSize / 2) }; var light = new LightSource { Radius = 128, Angle = 64, Intensity = 2, Color = Color.White, Type = LightSourceType.Spotlight, Rotation = -90, RotationOrigin = new Point(MainWindow.TileSize / 2, MainWindow.TileSize / 2) };

View file

@ -1,5 +1,6 @@
using CityGame.Classes.Rendering; using CityGame.Classes.Rendering;
using CityGame.Classes.World; using CityGame.Classes.World;
using OrpticonGameHelper.Classes.Effects;
namespace CityGame.Classes.Entities namespace CityGame.Classes.Entities
{ {
@ -18,6 +19,7 @@ namespace CityGame.Classes.Entities
public long Time { get; set; } public long Time { get; set; }
public OCanvas Object { get; set; } public OCanvas Object { get; set; }
public bool SingleSelect { get; set; } public bool SingleSelect { get; set; }
protected OutlineEffect selectedEffect = new OutlineEffect();
public OCanvas GetImage() public OCanvas GetImage()
{ {
return Object; return Object;
@ -41,6 +43,11 @@ namespace CityGame.Classes.Entities
} }
public abstract void Tick(long deltaTime); public abstract void Tick(long deltaTime);
public void BaseTick(long deltaTime)
{
if (selectedEffect is not null)
selectedEffect.Visible = this == MainWindow.Selected;
}
int ISelectable.X() int ISelectable.X()
{ {

View file

@ -1,10 +1,5 @@
using CityGame.Classes.Rendering; using CityGame.Classes.Rendering;
using System; using OrpticonGameHelper.Classes.Elements;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WPFGame;
namespace CityGame.Classes.Entities namespace CityGame.Classes.Entities
{ {
@ -19,7 +14,7 @@ namespace CityGame.Classes.Entities
public override OCanvas Render() public override OCanvas Render()
{ {
return new SourcedImage("ManholeCover.png"); return new SourcedImage("ManholeCover.png") { ZIndex = 98, Effects = { selectedEffect } };
} }
public override void Tick(long deltaTime) public override void Tick(long deltaTime)

View file

@ -3,7 +3,8 @@ using CityGame.Classes.World;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Audio;
using System; using System;
using WPFGame; using OrpticonGameHelper;
using OrpticonGameHelper.Classes.Elements;
namespace CityGame.Classes.Entities namespace CityGame.Classes.Entities
{ {
@ -32,10 +33,16 @@ namespace CityGame.Classes.Entities
Sound.Apply3D(MainWindow.SoundEffectListener, emitter); Sound.Apply3D(MainWindow.SoundEffectListener, emitter);
OCanvas canvas = new OCanvas(); OCanvas canvas = new OCanvas();
canvas.ZIndex = 100;
Heli1 = new SourcedImage("Helicopter.png"); Heli1 = new SourcedImage("Helicopter.png");
Heli2 = new SourcedImage("HelicopterFlight.png"); Heli2 = new SourcedImage("HelicopterFlight.png");
Blades1 = new SourcedImage("HelicopterBlades.png"); Blades1 = new SourcedImage("HelicopterBlades.png") { ZIndex = 10 };
Blades2 = new SourcedImage("HelicopterBlades2.png"); Blades2 = new SourcedImage("HelicopterBlades2.png") { ZIndex = 10 };
Heli1.Effects.Add(selectedEffect);
Heli2.Effects.Add(selectedEffect);
Blades1.Effects.Add(selectedEffect);
Blades2.Effects.Add(selectedEffect);
Heli1.Visible = false; Heli1.Visible = false;
Blades2.Visible = false; Blades2.Visible = false;

View file

@ -0,0 +1,16 @@
using OrpticonGameHelper.Classes.Elements.RUI.Attributes;
namespace CityGame.Classes.Menu
{
public class GenerationSettings
{
[RUITextField(TextColor = 0xFFFF0000, Lines = 2)]
public string WelcomeText { get; set; } = "Welcome!\nTest";
[RUITextField(TextColor = 0xFF00FF00, Lines = 2)]
public int Seed { get; set; } = 0;
public GenerationSettings()
{
}
}
}

View file

@ -0,0 +1,17 @@
using OrpticonGameHelper;
using OrpticonGameHelper.Classes.Elements;
using OrpticonGameHelper.Classes.Elements.RUI;
namespace CityGame.Classes.Menu
{
public class MenuWindow : Window
{
public MenuWindow()
{
UICanvas = new Canvas();
UICanvas.Children.Add(new ReflectedUIWindow(new GenerationSettings(), "CNRGN Builder", 24) { Height = 1080, Width = 300 });
Show();
}
}
}

View file

@ -1,4 +1,4 @@
using WPFGame; using OrpticonGameHelper.Classes.Elements;
namespace CityGame.Classes.Rendering namespace CityGame.Classes.Rendering
{ {

View file

@ -24,7 +24,7 @@ namespace CityGame.Classes.Rendering
int.TryParse(rotation, out int rot); int.TryParse(rotation, out int rot);
Rotation = rot; Rotation = rot;
} }
public static Pattern Calculate(Tile[,] Grid, int x, int y, params TileType[] allowed) public static Pattern Calculate(Tile[,] Grid, int x, int y, bool allowDiagonal = true, params TileType[] allowed)
{ {
Func<int, int, bool> IsAdjacent = (X, Y) => Func<int, int, bool> IsAdjacent = (X, Y) =>
{ {
@ -33,34 +33,40 @@ namespace CityGame.Classes.Rendering
return allowed.Contains(Grid[X, Y].Type); return allowed.Contains(Grid[X, Y].Type);
}; };
if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("8"); if (allowDiagonal)
{
if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("8");
if (IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("7"); if (IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("7");
if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("7", "90"); if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("7", "90");
if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("7", "180"); if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("7", "180");
if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("7", "270"); if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("7", "270");
if (IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x + 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("5"); if (IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x + 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1)) return new Pattern("5");
if (IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y + 1)) return new Pattern("5", "180"); if (IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y + 1)) return new Pattern("5", "180");
if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y)) return new Pattern("5", "270"); if (IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y)) return new Pattern("5", "270");
if (IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y)) return new Pattern("5", "90"); if (IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y + 1) && IsAdjacent(x - 1, y) && IsAdjacent(x + 1, y)) return new Pattern("5", "90");
if (IsAdjacent(x - 1, y) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x + 1, y)) return new Pattern("4"); if (IsAdjacent(x - 1, y) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x + 1, y)) return new Pattern("4");
if (IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y) && IsAdjacent(x + 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("4", "90"); if (IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y) && IsAdjacent(x + 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("4", "90");
if (IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("4", "180"); if (IsAdjacent(x + 1, y) && IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("4", "180");
if (IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1)) return new Pattern("4", "270"); if (IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1)) return new Pattern("4", "270");
if (IsAdjacent(x + 1, y) && IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y - 1)) return new Pattern("4m"); if (IsAdjacent(x + 1, y) && IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y - 1)) return new Pattern("4m");
if (IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1)) return new Pattern("4m", "90"); if (IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y) && IsAdjacent(x, y - 1) && IsAdjacent(x + 1, y - 1)) return new Pattern("4m", "90");
if (IsAdjacent(x - 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y) && IsAdjacent(x + 1, y + 1)) return new Pattern("4m", "180"); if (IsAdjacent(x - 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x + 1, y) && IsAdjacent(x + 1, y + 1)) return new Pattern("4m", "180");
if (IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y + 1)) return new Pattern("4m", "270"); if (IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y + 1)) return new Pattern("4m", "270");
}
if (IsAdjacent(x + 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y) && IsAdjacent(x, y - 1)) return new Pattern("4c"); if (IsAdjacent(x + 1, y) && IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y) && IsAdjacent(x, y - 1)) return new Pattern("4c");
if (IsAdjacent(x + 1, y) && IsAdjacent(x + 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("3"); if (allowDiagonal)
if (IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("3", "90"); {
if (IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1)) return new Pattern("3", "180"); if (IsAdjacent(x + 1, y) && IsAdjacent(x + 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("3");
if (IsAdjacent(x + 1, y) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x, y - 1)) return new Pattern("3", "270"); if (IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y + 1) && IsAdjacent(x, y + 1)) return new Pattern("3", "90");
if (IsAdjacent(x - 1, y) && IsAdjacent(x - 1, y - 1) && IsAdjacent(x, y - 1)) return new Pattern("3", "180");
if (IsAdjacent(x + 1, y) && IsAdjacent(x + 1, y - 1) && IsAdjacent(x, y - 1)) return new Pattern("3", "270");
}
if (IsAdjacent(x, y - 1) && IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y)) return new Pattern("3c"); if (IsAdjacent(x, y - 1) && IsAdjacent(x, y + 1) && IsAdjacent(x - 1, y)) return new Pattern("3c");
if (IsAdjacent(x + 1, y) && IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y)) return new Pattern("3c", "90"); if (IsAdjacent(x + 1, y) && IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y)) return new Pattern("3c", "90");

View file

@ -1,5 +1,5 @@
using CityGame.Classes.World; using CityGame.Classes.World;
using WPFGame; using OrpticonGameHelper.Classes.Elements;
namespace CityGame.Classes.Rendering namespace CityGame.Classes.Rendering
{ {
@ -27,64 +27,64 @@ namespace CityGame.Classes.Rendering
if (Grid[x, y].BlockID % 30 == 1) theme = "Blue"; if (Grid[x, y].BlockID % 30 == 1) theme = "Blue";
if (Grid[x, y].BlockID % 30 == 2) theme = "Red"; if (Grid[x, y].BlockID % 30 == 2) theme = "Red";
if (Grid[x, y].BlockID % 30 == 3) theme = "Green"; if (Grid[x, y].BlockID % 30 == 3) theme = "Green";
Pattern pattern = Pattern.Calculate(Grid, x, y, TileType.Skyscraper, TileType.Garage, TileType.Helipad); Pattern pattern = Pattern.Calculate(Grid, x, y, true, TileType.Skyscraper, TileType.Garage, TileType.Helipad);
if (pattern.PatternCode == "1" && MainWindow.random.Next(0, 3) == 0) return new SourcedImage("ParkingLot" + theme + ".png:" + pattern.Rotation); if (pattern.PatternCode == "1" && MainWindow.random.Next(0, 3) == 0) return new SourcedImage("ParkingLot" + theme + ".png:" + pattern.Rotation) { ZIndex = 25 };
if (pattern.PatternCode == "3" && MainWindow.random.Next(0, 12) == 0) pattern.PatternCode = "3a"; if (pattern.PatternCode == "3" && MainWindow.random.Next(0, 12) == 0) pattern.PatternCode = "3a";
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) { ZIndex = 25 };
if (theme == "Blue" && pattern.PatternCode == "8" && MainWindow.random.Next(0, 4) == 0) Grid[x, y].Type = TileType.Helipad; if (theme == "Blue" && pattern.PatternCode == "8" && MainWindow.random.Next(0, 4) == 0) Grid[x, y].Type = TileType.Helipad;
else if (theme == "Blue" && pattern.PatternCode == "5" && MainWindow.random.Next(0, 2) == 0) Grid[x, y].Type = TileType.Garage; else if (theme == "Blue" && pattern.PatternCode == "5" && MainWindow.random.Next(0, 2) == 0) Grid[x, y].Type = TileType.Garage;
else if (theme == "Blue" && pattern.PatternCode == "0") Grid[x, y].Type = TileType.Garage; else if (theme == "Blue" && pattern.PatternCode == "0") Grid[x, y].Type = TileType.Garage;
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)); 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) { ZIndex = 50 });
if (pattern.PatternCode == "5" && Grid[x, y].Type == TileType.Garage) canvas.Children.Add(new SourcedImage("Garage.png:" + pattern.Rotation)); if (pattern.PatternCode == "5" && Grid[x, y].Type == TileType.Garage) canvas.Children.Add(new SourcedImage("Garage.png:" + pattern.Rotation) { ZIndex = 50 });
if (pattern.PatternCode == "0" && Grid[x, y].Type == TileType.Garage) canvas.Children.Add(new SourcedImage("Garage.png:270")); if (pattern.PatternCode == "0" && Grid[x, y].Type == TileType.Garage) canvas.Children.Add(new SourcedImage("Garage.png:270") { ZIndex = 50 });
if (Grid[x,y].Type == TileType.Helipad) canvas.Children.Add(new SourcedImage("Helipad.png")); if (Grid[x,y].Type == TileType.Helipad) canvas.Children.Add(new SourcedImage("Helipad.png") { ZIndex = 50 });
Grid[x, y].Pattern = pattern; Grid[x, y].Pattern = pattern;
return canvas; return canvas;
} }
if (type == TileType.Lake || type == TileType.River) if (type == TileType.Lake || type == TileType.River)
{ {
Pattern pattern = Pattern.Calculate(Grid, x, y, TileType.Lake, TileType.Bridge, TileType.River, TileType.HighwayBridge); Pattern pattern = Pattern.Calculate(Grid, x, y, true, TileType.Lake, TileType.Bridge, TileType.River, TileType.HighwayBridge);
Grid[x, y].Pattern = pattern; Grid[x, y].Pattern = pattern;
return new SourcedImage("Lake" + pattern.PatternCode + ".png:" + pattern.Rotation, tooltip); return new SourcedImage("Lake" + pattern.PatternCode + ".png:" + pattern.Rotation, tooltip) { ZIndex = 1 };
} }
if (type == TileType.Park) if (type == TileType.Park)
{ {
Pattern pattern = Pattern.Calculate(Grid, x, y, TileType.Park, TileType.Path); Pattern pattern = Pattern.Calculate(Grid, x, y, true, TileType.Park, TileType.Path);
Grid[x, y].Pattern = pattern; Grid[x, y].Pattern = pattern;
OCanvas canvas = new SourcedImage("Park" + pattern.PatternCode + ".png:" + pattern.Rotation); OCanvas canvas = new SourcedImage("Park" + pattern.PatternCode + ".png:" + pattern.Rotation);
if (MainWindow.random.Next(0, 4) == 0) canvas.Children.Add(new SourcedImage("Tree.png:" + MainWindow.random.Next(0, 4) * 90, tooltip)); if (MainWindow.random.Next(0, 4) == 0) canvas.Children.Add(new SourcedImage("Tree.png:" + MainWindow.random.Next(0, 4) * 90, tooltip));
canvas.ZIndex = 1;
return canvas; return canvas;
} }
if (type == TileType.Road) if (type == TileType.Road)
{ {
Pattern pattern = Pattern.Calculate(Grid, x, y, TileType.Road, TileType.Path, TileType.Bridge, TileType.Highway, TileType.HighwayBridge); Pattern pattern = Pattern.Calculate(Grid, x, y, false, TileType.Road, TileType.Path, TileType.Bridge, TileType.Highway, TileType.HighwayBridge, TileType.Garage);
Grid[x, y].Pattern = pattern; Grid[x, y].Pattern = pattern;
if (pattern.PatternCode == "2c") pattern.Rotation += 270; if (pattern.PatternCode == "2c") pattern.Rotation += 270;
if (pattern.PatternCode == "1") pattern.Rotation += 180; if (pattern.PatternCode == "1") pattern.Rotation += 180;
return new SourcedImage("Road" + pattern.PatternCode + ".png:" + pattern.Rotation, tooltip); return new SourcedImage("Road" + pattern.PatternCode + ".png:" + pattern.Rotation, tooltip) { ZIndex = 2 };
} }
if (type == TileType.Highway) if (type == TileType.Highway)
{ {
Pattern pattern = Pattern.Calculate(Grid, x, y, TileType.Road, TileType.Path, TileType.Bridge, TileType.Highway, TileType.HighwayBridge); Pattern pattern = Pattern.Calculate(Grid, x, y, false, TileType.Road, TileType.Path, TileType.Bridge, TileType.Highway, TileType.HighwayBridge, TileType.Garage);
Grid[x, y].Pattern = pattern; Grid[x, y].Pattern = pattern;
if (pattern.PatternCode == "2c") pattern.Rotation += 270; if (pattern.PatternCode == "2c") pattern.Rotation += 270;
if (pattern.PatternCode == "1") pattern.Rotation += 180; if (pattern.PatternCode == "1") pattern.Rotation += 180;
return new SourcedImage("Highway" + pattern.PatternCode + ".png:" + pattern.Rotation, tooltip); return new SourcedImage("Highway" + pattern.PatternCode + ".png:" + pattern.Rotation, tooltip) { ZIndex = 2 };
} }
if (type == TileType.Path) if (type == TileType.Path)
{ {
Pattern roadpattern = Pattern.Calculate(Grid, x, y, TileType.Road, TileType.Path, TileType.Bridge, TileType.Highway, TileType.HighwayBridge); Pattern roadpattern = Pattern.Calculate(Grid, x, y, false, TileType.Road, TileType.Path, TileType.Bridge, TileType.Highway, TileType.HighwayBridge, TileType.Garage);
Pattern parkpattern = Pattern.Calculate(Grid, x, y, TileType.Path, TileType.Park); Pattern parkpattern = Pattern.Calculate(Grid, x, y, true, TileType.Path, TileType.Park);
Grid[x, y].Pattern = roadpattern; Grid[x, y].Pattern = roadpattern;
if (roadpattern.PatternCode == "2c") roadpattern.Rotation += 270; if (roadpattern.PatternCode == "2c") roadpattern.Rotation += 270;
if (roadpattern.PatternCode == "1") roadpattern.Rotation += 180; if (roadpattern.PatternCode == "1") roadpattern.Rotation += 180;
Image path = new SourcedImage("Path" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip); Image path = new SourcedImage("Path" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip) { ZIndex = 50 };
Image park = new SourcedImage("Park" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation); Image park = new SourcedImage("Park" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation) { ZIndex = 25 };
OCanvas result = new OCanvas(); OCanvas result = new OCanvas();
result.Children.Add(park); result.Children.Add(park);
@ -93,32 +93,34 @@ namespace CityGame.Classes.Rendering
} }
if (type == TileType.Bridge) if (type == TileType.Bridge)
{ {
Pattern roadpattern = Pattern.Calculate(Grid, x, y, TileType.Road, TileType.Bridge, TileType.Path, TileType.Highway, TileType.HighwayBridge); Pattern roadpattern = Pattern.Calculate(Grid, x, y, false, TileType.Road, TileType.Bridge, TileType.Path, TileType.Highway, TileType.HighwayBridge, TileType.Garage);
Pattern parkpattern = Pattern.Calculate(Grid, x, y, TileType.Bridge, TileType.Lake, TileType.River, TileType.HighwayBridge); Pattern parkpattern = Pattern.Calculate(Grid, x, y, true, TileType.Bridge, TileType.Lake, TileType.River, TileType.HighwayBridge);
Grid[x, y].Pattern = roadpattern; Grid[x, y].Pattern = roadpattern;
if (roadpattern.PatternCode == "2c") roadpattern.Rotation += 270; if (roadpattern.PatternCode == "2c") roadpattern.Rotation += 270;
if (roadpattern.PatternCode == "1") roadpattern.Rotation += 180; if (roadpattern.PatternCode == "1") roadpattern.Rotation += 180;
Image path = new SourcedImage("Bridge" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip); Image path = new SourcedImage("Bridge" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip) { ZIndex = 50 };
Image park = new SourcedImage("Lake" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation); Image park = new SourcedImage("Lake" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation) { ZIndex = 25 };
OCanvas result = new OCanvas(); OCanvas result = new OCanvas();
result.Children.Add(park); result.Children.Add(park);
result.Children.Add(path); result.Children.Add(path);
result.ZIndex = 2;
return result; return result;
} }
if (type == TileType.HighwayBridge) if (type == TileType.HighwayBridge)
{ {
Pattern roadpattern = Pattern.Calculate(Grid, x, y, TileType.Road, TileType.Bridge, TileType.Path, TileType.Highway, TileType.HighwayBridge); Pattern roadpattern = Pattern.Calculate(Grid, x, y, false, TileType.Road, TileType.Bridge, TileType.Path, TileType.Highway, TileType.HighwayBridge, TileType.Garage);
Pattern parkpattern = Pattern.Calculate(Grid, x, y, TileType.Bridge, TileType.Lake, TileType.River, TileType.HighwayBridge); Pattern parkpattern = Pattern.Calculate(Grid, x, y, true, TileType.Bridge, TileType.Lake, TileType.River, TileType.HighwayBridge);
Grid[x, y].Pattern = roadpattern; Grid[x, y].Pattern = roadpattern;
if (roadpattern.PatternCode == "2c") roadpattern.Rotation += 270; if (roadpattern.PatternCode == "2c") roadpattern.Rotation += 270;
if (roadpattern.PatternCode == "1") roadpattern.Rotation += 180; if (roadpattern.PatternCode == "1") roadpattern.Rotation += 180;
Image path = new SourcedImage("HighwayBridge" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip); Image path = new SourcedImage("HighwayBridge" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip) { ZIndex = 50 };
Image park = new SourcedImage("Lake" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation); Image park = new SourcedImage("Lake" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation) { ZIndex = 25 };
OCanvas result = new OCanvas(); OCanvas result = new OCanvas();
result.Children.Add(park); result.Children.Add(park);
result.Children.Add(path); result.Children.Add(path);
result.ZIndex = 2;
return result; return result;
} }
return new SourcedImage("Error.png", tooltip); return new SourcedImage("Error.png", tooltip);

View file

@ -1,5 +1,5 @@
using CityGame.Classes.Rendering; using CityGame.Classes.Rendering;
using WPFGame; using OrpticonGameHelper.Classes.Elements;
namespace CityGame.Classes.World namespace CityGame.Classes.World
{ {

View file

@ -9,9 +9,9 @@ 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.Linq; using System.Linq;
using WPFGame; using OrpticonGameHelper;
using OrpticonGameHelper.Classes.Elements;
using static CityGame.Classes.Entities.Car; using static CityGame.Classes.Entities.Car;
namespace CityGame namespace CityGame
@ -502,9 +502,7 @@ namespace CityGame
ISelectable select = GetSelectableFromClick(state); ISelectable select = GetSelectableFromClick(state);
if (select is not null) if (select is not null)
{ {
if (Selected is not null) Selected.GetImage().Opacity = 1;
Selected = select; Selected = select;
Selected.GetImage().Opacity = 0.5f;
} }
} }
else if (state.RightButton == ButtonState.Pressed) else if (state.RightButton == ButtonState.Pressed)
@ -523,6 +521,7 @@ namespace CityGame
deltaTime = (long)time.ElapsedGameTime.TotalMilliseconds; deltaTime = (long)time.ElapsedGameTime.TotalMilliseconds;
entity.Time = milliseconds; entity.Time = milliseconds;
entity.Tick(deltaTime); entity.Tick(deltaTime);
entity.BaseTick(deltaTime);
if (entity.Object is null) if (entity.Object is null)
{ {

View file

@ -1,9 +0,0 @@
<Window x:Class="CityGame.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CityGame"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
</Window>

View file

@ -1,33 +1,8 @@
using Microsoft.Xna.Framework; namespace CityGame
using Microsoft.Xna.Framework.Graphics;
using WPFGame;
namespace CityGame
{ {
public class Program { public class Program {
public static void Main() { public static void Main() {
var menu = new MenuWindow(); var menu = new MainWindow();
} }
} }
public class MenuWindow : Window
{
public MenuWindow()
{
UICanvas = new Canvas();
UICanvas.Children.Add(new ReflectedUIWindow(new GenerationSettings(), "CNRGN Builder", 24) { Height = 1080, Width = 300 });
Show();
}
}
public class GenerationSettings
{
[RUITextField(TextColor = 0xFFFF0000, Lines = 2)]
public string WelcomeText { get; set; } = "Welcome!\nTest";
[RUITextField(TextColor = 0xFF00FF00, Lines = 2)]
public int Seed { get; set; } = 0;
public GenerationSettings()
{
}
}
} }