From 037f15f2e4480e255f20c13a7a3c02c898244347 Mon Sep 17 00:00:00 2001 From: Joel Date: Sat, 23 May 2020 13:54:47 +0200 Subject: [PATCH] joined textures --- Game1/Content/Content.mgcb | 48 +++++++++++++++++++++++++++++++++++++ Game1/Game1.cs | 34 ++++++++++++++++++++++++++ Game1/Sources/ML/MLModel.cs | 12 +++++----- 3 files changed, 88 insertions(+), 6 deletions(-) diff --git a/Game1/Content/Content.mgcb b/Game1/Content/Content.mgcb index 4849794..191cc99 100644 --- a/Game1/Content/Content.mgcb +++ b/Game1/Content/Content.mgcb @@ -37,6 +37,18 @@ /processorParam:TextureFormat=Color /build:BerriesIcon.png +#begin Bottom.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Bottom.png + #begin CarronIcon.png /importer:TextureImporter /processor:TextureProcessor @@ -104,6 +116,18 @@ /processorParam:TextureFormat=Color /build:house.png +#begin Left.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Left.png + #begin MaizeIcon.png /importer:TextureImporter /processor:TextureProcessor @@ -224,6 +248,18 @@ /processorParam:TextureFormat=Color /build:PulsesIcon.png +#begin Right.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Right.png + #begin SeedOilIcon.png /importer:TextureImporter /processor:TextureProcessor @@ -284,6 +320,18 @@ /processorParam:TextureFormat=Color /build:TobaccoIcon.png +#begin Top.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Top.png + #begin Tractor.png /importer:TextureImporter /processor:TextureProcessor diff --git a/Game1/Game1.cs b/Game1/Game1.cs index 910a8e4..59611a8 100644 --- a/Game1/Game1.cs +++ b/Game1/Game1.cs @@ -15,6 +15,7 @@ namespace Game1 SpriteBatch spriteBatch; SpriteFont Bold; private Texture2D[] tile = new Texture2D[5]; + private Texture2D[] tileConnected = new Texture2D[5]; private Texture2D[] Crops = new Texture2D[12]; private Texture2D tractor; private Texture2D house; @@ -102,6 +103,11 @@ namespace Game1 tile[2] = Content.Load("Plantable"); tile[3] = Content.Load("Crop"); + tileConnected[0] = Content.Load("Left"); + tileConnected[1] = Content.Load("Top"); + tileConnected[2] = Content.Load("Right"); + tileConnected[3] = Content.Load("Bottom"); + @@ -238,6 +244,34 @@ namespace Game1 spriteBatch.Draw(tile[tractorUnit.getFarm().getCrop(i, j).getStatus()], tilePos, Time.GetTimeOfDay()); + if (i > 0) + { + if (tractorUnit.getFarm().getCrop(i - 1, j).getStatus() == 2 || tractorUnit.getFarm().getCrop(i - 1, j).getStatus() == 3) + { + spriteBatch.Draw(tileConnected[0], tilePos, Time.GetTimeOfDay()); + } + } + if (j > 0) + { + if (tractorUnit.getFarm().getCrop(i, j - 1).getStatus() == 2 || tractorUnit.getFarm().getCrop(i, j - 1).getStatus() == 3) + { + spriteBatch.Draw(tileConnected[1], tilePos, Time.GetTimeOfDay()); + } + } + if (i < input.getSize().X) + { + if (tractorUnit.getFarm().getCrop(i + 1, j).getStatus() == 2 || tractorUnit.getFarm().getCrop(i + 1, j).getStatus() == 3) + { + spriteBatch.Draw(tileConnected[2], tilePos, Time.GetTimeOfDay()); + } + } + if (j < input.getSize().Y) + { + if (tractorUnit.getFarm().getCrop(i, j + 1).getStatus() == 2 || tractorUnit.getFarm().getCrop(i, j + 1).getStatus() == 3) + { + spriteBatch.Draw(tileConnected[3], tilePos, Time.GetTimeOfDay()); + } + } if (tilePos.Intersects(mousePosition)) { spriteBatch.Draw(tile[tractorUnit.getFarm().getCrop(i, j).getStatus()], tilePos, Color.FromNonPremultiplied(0, 0, 20, 40)); diff --git a/Game1/Sources/ML/MLModel.cs b/Game1/Sources/ML/MLModel.cs index 2eec77c..1b44fed 100644 --- a/Game1/Sources/ML/MLModel.cs +++ b/Game1/Sources/ML/MLModel.cs @@ -11,12 +11,12 @@ using Microsoft.ML.Trainers.LightGbm; class MLModel { private static MLContext mlContext = new MLContext(seed: 1); - private static string path = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/Fertilizer_Prediction.csv"; - private static string modelpath = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodel"; - private static string report = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report"; - private static string pathBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/BigFertPredict.csv"; - private static string modelpathBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodelBig"; - private static string reportBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report_BigModel"; + private static string path = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/Fertilizer_Prediction.csv"; + private static string modelpath = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodel"; + private static string report = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report"; + private static string pathBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/BigFertPredict.csv"; + private static string modelpathBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodelBig"; + private static string reportBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_BigModel"; // Loading data, creatin and saving ML model for smaller dataset (100) public static void CreateModel()