diff --git a/CityGame.sln b/CityGame.sln index 5f86bc4..d9181fa 100644 --- a/CityGame.sln +++ b/CityGame.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 17.3.32929.385 MinimumVisualStudioVersion = 10.0.40219.1 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}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrpticonGameHelper", "..\WPFGame\WPFGame\OrpticonGameHelper.csproj", "{4F2DC7EE-24BA-4383-9AB6-EBA46EB191DF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/CityGame/App.xaml b/CityGame/App.xaml deleted file mode 100644 index 5f28270..0000000 --- a/CityGame/App.xaml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/CityGame/App.xaml.cs b/CityGame/App.xaml.cs deleted file mode 100644 index 5f28270..0000000 --- a/CityGame/App.xaml.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/CityGame/CityGame.csproj b/CityGame/CityGame.csproj index 088528d..c012527 100644 --- a/CityGame/CityGame.csproj +++ b/CityGame/CityGame.csproj @@ -21,7 +21,7 @@ - + @@ -109,7 +109,7 @@ PreserveNewest - + Always @@ -118,7 +118,7 @@ PreserveNewest - + Always diff --git a/CityGame/Classes/Entities/Car.cs b/CityGame/Classes/Entities/Car.cs index f666b06..44c76fc 100644 --- a/CityGame/Classes/Entities/Car.cs +++ b/CityGame/Classes/Entities/Car.cs @@ -5,7 +5,8 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using WPFGame; +using OrpticonGameHelper; +using OrpticonGameHelper.Classes.Elements; namespace CityGame.Classes.Entities { @@ -49,7 +50,8 @@ namespace CityGame.Classes.Entities { OCanvas canvas = new OCanvas(); Image car = new SourcedImage(PNGFile); - car.Effects.Add(new OutlineEffect()); + car.ZIndex = 99; + car.Effects.Add(selectedEffect); 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) }; diff --git a/CityGame/Classes/Entities/Entity.cs b/CityGame/Classes/Entities/Entity.cs index 116d29d..d16304b 100644 --- a/CityGame/Classes/Entities/Entity.cs +++ b/CityGame/Classes/Entities/Entity.cs @@ -1,5 +1,6 @@ using CityGame.Classes.Rendering; using CityGame.Classes.World; +using OrpticonGameHelper.Classes.Effects; namespace CityGame.Classes.Entities { @@ -18,6 +19,7 @@ namespace CityGame.Classes.Entities public long Time { get; set; } public OCanvas Object { get; set; } public bool SingleSelect { get; set; } + protected OutlineEffect selectedEffect = new OutlineEffect(); public OCanvas GetImage() { return Object; @@ -41,6 +43,11 @@ namespace CityGame.Classes.Entities } public abstract void Tick(long deltaTime); + public void BaseTick(long deltaTime) + { + if (selectedEffect is not null) + selectedEffect.Visible = this == MainWindow.Selected; + } int ISelectable.X() { diff --git a/CityGame/Classes/Entities/GasPipe.cs b/CityGame/Classes/Entities/GasPipe.cs index a1ec760..2e20886 100644 --- a/CityGame/Classes/Entities/GasPipe.cs +++ b/CityGame/Classes/Entities/GasPipe.cs @@ -1,10 +1,5 @@ using CityGame.Classes.Rendering; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using WPFGame; +using OrpticonGameHelper.Classes.Elements; namespace CityGame.Classes.Entities { @@ -19,7 +14,7 @@ namespace CityGame.Classes.Entities public override OCanvas Render() { - return new SourcedImage("ManholeCover.png"); + return new SourcedImage("ManholeCover.png") { ZIndex = 98, Effects = { selectedEffect } }; } public override void Tick(long deltaTime) diff --git a/CityGame/Classes/Entities/Helicopter.cs b/CityGame/Classes/Entities/Helicopter.cs index b89217d..96e2882 100644 --- a/CityGame/Classes/Entities/Helicopter.cs +++ b/CityGame/Classes/Entities/Helicopter.cs @@ -3,7 +3,8 @@ using CityGame.Classes.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using System; -using WPFGame; +using OrpticonGameHelper; +using OrpticonGameHelper.Classes.Elements; namespace CityGame.Classes.Entities { @@ -32,10 +33,16 @@ namespace CityGame.Classes.Entities Sound.Apply3D(MainWindow.SoundEffectListener, emitter); OCanvas canvas = new OCanvas(); + canvas.ZIndex = 100; Heli1 = new SourcedImage("Helicopter.png"); Heli2 = new SourcedImage("HelicopterFlight.png"); - Blades1 = new SourcedImage("HelicopterBlades.png"); - Blades2 = new SourcedImage("HelicopterBlades2.png"); + Blades1 = new SourcedImage("HelicopterBlades.png") { ZIndex = 10 }; + 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; Blades2.Visible = false; diff --git a/CityGame/Classes/Menu/GenerationSettings.cs b/CityGame/Classes/Menu/GenerationSettings.cs new file mode 100644 index 0000000..87f5c8d --- /dev/null +++ b/CityGame/Classes/Menu/GenerationSettings.cs @@ -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() + { + + } + } +} \ No newline at end of file diff --git a/CityGame/Classes/Menu/MenuWindow.cs b/CityGame/Classes/Menu/MenuWindow.cs new file mode 100644 index 0000000..3637b02 --- /dev/null +++ b/CityGame/Classes/Menu/MenuWindow.cs @@ -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(); + } + } +} \ No newline at end of file diff --git a/CityGame/Classes/Rendering/OCanvas.cs b/CityGame/Classes/Rendering/OCanvas.cs index 6cf953f..21917e2 100644 --- a/CityGame/Classes/Rendering/OCanvas.cs +++ b/CityGame/Classes/Rendering/OCanvas.cs @@ -1,4 +1,4 @@ -using WPFGame; +using OrpticonGameHelper.Classes.Elements; namespace CityGame.Classes.Rendering { diff --git a/CityGame/Classes/Rendering/Pattern.cs b/CityGame/Classes/Rendering/Pattern.cs index ce1eb71..d082406 100644 --- a/CityGame/Classes/Rendering/Pattern.cs +++ b/CityGame/Classes/Rendering/Pattern.cs @@ -24,7 +24,7 @@ namespace CityGame.Classes.Rendering int.TryParse(rotation, out int 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 IsAdjacent = (X, Y) => { @@ -33,34 +33,40 @@ namespace CityGame.Classes.Rendering 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 - 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, 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 + 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 - 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, 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 - 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, 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 - 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) && 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 + 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 - 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 + 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 + 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 - 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 + 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 - 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 + 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 (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 (allowDiagonal) + { + 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", "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 + 1, y) && IsAdjacent(x, y - 1) && IsAdjacent(x - 1, y)) return new Pattern("3c", "90"); diff --git a/CityGame/Classes/Rendering/Renderer.cs b/CityGame/Classes/Rendering/Renderer.cs index e838f78..75eb517 100644 --- a/CityGame/Classes/Rendering/Renderer.cs +++ b/CityGame/Classes/Rendering/Renderer.cs @@ -1,5 +1,5 @@ using CityGame.Classes.World; -using WPFGame; +using OrpticonGameHelper.Classes.Elements; 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 == 2) theme = "Red"; if (Grid[x, y].BlockID % 30 == 3) theme = "Green"; - Pattern pattern = Pattern.Calculate(Grid, x, y, TileType.Skyscraper, TileType.Garage, TileType.Helipad); - if (pattern.PatternCode == "1" && MainWindow.random.Next(0, 3) == 0) return new SourcedImage("ParkingLot" + theme + ".png:" + pattern.Rotation); + 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) { ZIndex = 25 }; 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"; - 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; 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 (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 == "0" && Grid[x, y].Type == TileType.Garage) canvas.Children.Add(new SourcedImage("Garage.png:270")); - if (Grid[x,y].Type == TileType.Helipad) canvas.Children.Add(new SourcedImage("Helipad.png")); + 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") { ZIndex = 50 }); + if (Grid[x,y].Type == TileType.Helipad) canvas.Children.Add(new SourcedImage("Helipad.png") { ZIndex = 50 }); Grid[x, y].Pattern = pattern; - return canvas; } 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; - 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) { - 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; 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)); + canvas.ZIndex = 1; return canvas; } 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; if (pattern.PatternCode == "2c") pattern.Rotation += 270; 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) { - 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; if (pattern.PatternCode == "2c") pattern.Rotation += 270; 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) { - Pattern roadpattern = Pattern.Calculate(Grid, x, y, TileType.Road, TileType.Path, TileType.Bridge, TileType.Highway, TileType.HighwayBridge); - Pattern parkpattern = Pattern.Calculate(Grid, x, y, TileType.Path, TileType.Park); + 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, true, TileType.Path, TileType.Park); Grid[x, y].Pattern = roadpattern; if (roadpattern.PatternCode == "2c") roadpattern.Rotation += 270; if (roadpattern.PatternCode == "1") roadpattern.Rotation += 180; - Image path = new SourcedImage("Path" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip); - Image park = new SourcedImage("Park" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation); + Image path = new SourcedImage("Path" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip) { ZIndex = 50 }; + Image park = new SourcedImage("Park" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation) { ZIndex = 25 }; OCanvas result = new OCanvas(); result.Children.Add(park); @@ -93,32 +93,34 @@ namespace CityGame.Classes.Rendering } if (type == TileType.Bridge) { - Pattern roadpattern = Pattern.Calculate(Grid, x, y, TileType.Road, TileType.Bridge, TileType.Path, TileType.Highway, TileType.HighwayBridge); - Pattern parkpattern = Pattern.Calculate(Grid, x, y, TileType.Bridge, TileType.Lake, TileType.River, 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, true, TileType.Bridge, TileType.Lake, TileType.River, TileType.HighwayBridge); Grid[x, y].Pattern = roadpattern; if (roadpattern.PatternCode == "2c") roadpattern.Rotation += 270; if (roadpattern.PatternCode == "1") roadpattern.Rotation += 180; - Image path = new SourcedImage("Bridge" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip); - Image park = new SourcedImage("Lake" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation); + Image path = new SourcedImage("Bridge" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip) { ZIndex = 50 }; + Image park = new SourcedImage("Lake" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation) { ZIndex = 25 }; OCanvas result = new OCanvas(); result.Children.Add(park); result.Children.Add(path); + result.ZIndex = 2; return result; } if (type == TileType.HighwayBridge) { - Pattern roadpattern = Pattern.Calculate(Grid, x, y, TileType.Road, TileType.Bridge, TileType.Path, TileType.Highway, TileType.HighwayBridge); - Pattern parkpattern = Pattern.Calculate(Grid, x, y, TileType.Bridge, TileType.Lake, TileType.River, 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, true, TileType.Bridge, TileType.Lake, TileType.River, TileType.HighwayBridge); Grid[x, y].Pattern = roadpattern; if (roadpattern.PatternCode == "2c") roadpattern.Rotation += 270; if (roadpattern.PatternCode == "1") roadpattern.Rotation += 180; - Image path = new SourcedImage("HighwayBridge" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip); - Image park = new SourcedImage("Lake" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation); + Image path = new SourcedImage("HighwayBridge" + roadpattern.PatternCode + ".png:" + roadpattern.Rotation, tooltip) { ZIndex = 50 }; + Image park = new SourcedImage("Lake" + parkpattern.PatternCode + ".png:" + parkpattern.Rotation) { ZIndex = 25 }; OCanvas result = new OCanvas(); result.Children.Add(park); result.Children.Add(path); + result.ZIndex = 2; return result; } return new SourcedImage("Error.png", tooltip); diff --git a/CityGame/Classes/World/Tile.cs b/CityGame/Classes/World/Tile.cs index 5102d10..22fe192 100644 --- a/CityGame/Classes/World/Tile.cs +++ b/CityGame/Classes/World/Tile.cs @@ -1,5 +1,5 @@ using CityGame.Classes.Rendering; -using WPFGame; +using OrpticonGameHelper.Classes.Elements; namespace CityGame.Classes.World { diff --git a/CityGame/MainWindow.xaml.cs b/CityGame/MainWindow.cs similarity index 99% rename from CityGame/MainWindow.xaml.cs rename to CityGame/MainWindow.cs index 265c178..70e5ecf 100644 --- a/CityGame/MainWindow.xaml.cs +++ b/CityGame/MainWindow.cs @@ -9,9 +9,9 @@ using Microsoft.Xna.Framework.Input; using SimplexNoise; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; -using WPFGame; +using OrpticonGameHelper; +using OrpticonGameHelper.Classes.Elements; using static CityGame.Classes.Entities.Car; namespace CityGame @@ -502,9 +502,7 @@ namespace CityGame 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) @@ -523,6 +521,7 @@ namespace CityGame deltaTime = (long)time.ElapsedGameTime.TotalMilliseconds; entity.Time = milliseconds; entity.Tick(deltaTime); + entity.BaseTick(deltaTime); if (entity.Object is null) { diff --git a/CityGame/MainWindow.xaml b/CityGame/MainWindow.xaml deleted file mode 100644 index 0c6d5c3..0000000 --- a/CityGame/MainWindow.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - diff --git a/CityGame/Program.cs b/CityGame/Program.cs index 42df02f..89bba1b 100644 --- a/CityGame/Program.cs +++ b/CityGame/Program.cs @@ -1,33 +1,8 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using WPFGame; - -namespace CityGame +namespace CityGame { public class Program { 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() - { - - } - } } \ No newline at end of file diff --git a/CityGame/Resources/helicopter.mp3 b/CityGame/Resources/Audio/helicopter.mp3 similarity index 100% rename from CityGame/Resources/helicopter.mp3 rename to CityGame/Resources/Audio/helicopter.mp3 diff --git a/CityGame/Resources/CNRGN Builder.ttf b/CityGame/Resources/Fonts/CNRGN Builder.ttf similarity index 100% rename from CityGame/Resources/CNRGN Builder.ttf rename to CityGame/Resources/Fonts/CNRGN Builder.ttf