Steps nie pyka
@ -41,10 +41,14 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="RoutePlanningEngine.cs" />
|
||||
<Compile Include="DFS.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CzokoŚmieciarka.DataModels.GeneralModels\CzokoŚmieciarka.DataModels.GeneralModels.csproj">
|
||||
<Project>{a3d5da96-69d7-463f-b1ee-6fc70716e3b2}</Project>
|
||||
<Name>CzokoŚmieciarka.DataModels.GeneralModels</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CzokoŚmieciarka.DataModels\CzokoŚmieciarka.DataModels.csproj">
|
||||
<Project>{f2e11fee-c5ac-47d2-ba9c-819909b6dff7}</Project>
|
||||
<Name>CzokoŚmieciarka.DataModels</Name>
|
||||
|
@ -1,116 +0,0 @@
|
||||
using CzokoŚmieciarka.DataModels.Enums;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.RoutePlanningEngine;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
using CzokoŚmieciarka.DataModels.Models.Steps;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Czoko_Smieciarka.AI_Naive
|
||||
{
|
||||
public class RoutePlanningEngine : IRoutePlanningEngine
|
||||
{
|
||||
public IGarbageCollector Collector { get; }
|
||||
public IEnumerable<IGarbageLocalization> Cans { get; }
|
||||
public IEnumerable<ADump> Dumps { get; }
|
||||
|
||||
|
||||
|
||||
enum State { TravelToDump, TravelToCan, Wait, Finish }
|
||||
public Coords Destination { get; set; }
|
||||
public object DestinationObject { get; set; }
|
||||
private State CurrentState { get; set; }
|
||||
|
||||
public void PerformStep()
|
||||
{
|
||||
PerformMove();
|
||||
}
|
||||
|
||||
public RoutePlanningEngine(IGarbageCollector collector, IEnumerable<IGarbageLocalization> cans, IEnumerable<ADump> dumps)
|
||||
{
|
||||
this.Collector = collector;
|
||||
this.Cans = cans;
|
||||
this.Dumps = dumps;
|
||||
this.CurrentState = State.Wait;
|
||||
}
|
||||
|
||||
|
||||
private bool PerformMove()
|
||||
{
|
||||
|
||||
switch (CurrentState)
|
||||
{
|
||||
case State.TravelToDump:
|
||||
if (Destination == Collector.Coords)
|
||||
{
|
||||
var dump = (DestinationObject as ADump);
|
||||
var step = new SpillStep(Collector, dump, dump.TypeOfGarbage);
|
||||
step.Invoke();
|
||||
this.CurrentState = State.Wait;
|
||||
}
|
||||
else
|
||||
{
|
||||
var dif = Destination - Collector.Coords;
|
||||
Direction nextDirection = (dif.X == 0) ?
|
||||
((dif.Y > 0) ? Direction.Up : Direction.Down) :
|
||||
((dif.X > 0) ? Direction.Right : Direction.Left);
|
||||
|
||||
var step = new MoveStep(nextDirection, Collector);
|
||||
step.Invoke();
|
||||
}
|
||||
break;
|
||||
case State.TravelToCan:
|
||||
if (Destination == Collector.Coords)
|
||||
{
|
||||
var garbage = (DestinationObject as IGarbageLocalization);
|
||||
foreach (var item in garbage.TrashCans)
|
||||
{
|
||||
var step = new CollectStep(Collector, garbage, item.TypeOfGarbage);
|
||||
step.Invoke();
|
||||
}
|
||||
|
||||
this.CurrentState = State.Wait;
|
||||
}
|
||||
else
|
||||
{
|
||||
var dif = Destination - Collector.Coords;
|
||||
Direction nextDirection = (dif.X == 0) ?
|
||||
((dif.Y > 0) ? Direction.Up : Direction.Down) :
|
||||
((dif.X > 0) ? Direction.Right : Direction.Left);
|
||||
|
||||
var step = new MoveStep(nextDirection, Collector);
|
||||
step.Invoke();
|
||||
}
|
||||
break;
|
||||
case State.Wait:
|
||||
var notEmpty = Collector.TrashContainers.Where(i => i.FillPercent > 0);
|
||||
if (notEmpty.Any())
|
||||
{
|
||||
var destDump = Dumps.First(i => i.TypeOfGarbage == notEmpty.First().TypeOfGarbage);
|
||||
this.Destination = destDump.Coords;
|
||||
this.CurrentState = State.TravelToDump;
|
||||
}
|
||||
else
|
||||
{
|
||||
var notEmptyCans = Cans.Where(i => i.TrashCans.Any(j => j.FillPercent > 0));
|
||||
if (notEmptyCans.Any())
|
||||
{
|
||||
this.Destination = notEmptyCans.First().Coords;
|
||||
this.CurrentState = State.TravelToCan;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CurrentState = State.Finish;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case State.Finish:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.GeneralModels.Models
|
||||
{
|
||||
public class Dump : ADump
|
||||
{
|
||||
public Dump(ITypeOfGarbage typeOfGarbage, int maxVolume, Coords localization) : base(typeOfGarbage, maxVolume, localization)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.GeneralModels.Models
|
||||
{
|
||||
public class GarbageCollector : AGarbageCollector
|
||||
{
|
||||
public GarbageCollector(Coords startPosition, IEnumerable<AGarbageCollectorContainer> trashContainers, int columns, int rows) : base(startPosition, trashContainers, columns, rows)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -42,27 +42,12 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Enums\GarbageTypes.cs" />
|
||||
<Compile Include="Exceptions.cs" />
|
||||
<Compile Include="Enums\Directions.cs" />
|
||||
<Compile Include="Exceptions\OutOfGridException.cs" />
|
||||
<Compile Include="Interfaces\GarbageCollector\AGarbageCollector.cs" />
|
||||
<Compile Include="Interfaces\GarbageCollector\IGarbageCollector.cs" />
|
||||
<Compile Include="Interfaces\Garbage\AGarbage.cs" />
|
||||
<Compile Include="Interfaces\Garbage\IGarbage.cs" />
|
||||
<Compile Include="Interfaces\TrashCans\ADump.cs" />
|
||||
<Compile Include="Interfaces\IGarbageLocalization.cs" />
|
||||
<Compile Include="Interfaces\ITypeOfGarbage.cs" />
|
||||
<Compile Include="Interfaces\RoutePlanningEngine\IRoutePlanningEngine.cs" />
|
||||
<Compile Include="Interfaces\TrashCans\AGarbageCollectorContainer.cs" />
|
||||
<Compile Include="Interfaces\TrashCans\ATrashCan.cs" />
|
||||
<Compile Include="Interfaces\IStep.cs" />
|
||||
<Compile Include="Models\Coords.cs" />
|
||||
<Compile Include="Models\Map.cs" />
|
||||
<Compile Include="Models\Steps\CollectStep.cs" />
|
||||
<Compile Include="Models\Steps\MoveStep.cs" />
|
||||
<Compile Include="Models\Steps\SpillStep.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Enums\" />
|
||||
<Folder Include="Interfaces\" />
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Exceptions
|
||||
{
|
||||
public class OutOfGridException : Exception
|
||||
{
|
||||
public OutOfGridException()
|
||||
{
|
||||
}
|
||||
public OutOfGridException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public OutOfGridException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces
|
||||
{
|
||||
public interface IStep
|
||||
{
|
||||
void Invoke();
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces.Road
|
||||
{
|
||||
public interface IRoad
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces.Road
|
||||
{
|
||||
public interface IRoad2
|
||||
{
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces.RoutePlanningEngine
|
||||
{
|
||||
public interface IRoutePlanningEngine
|
||||
{
|
||||
void PerformStep();
|
||||
}
|
||||
}
|
@ -3,62 +3,31 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.136
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.DataModels", "Components\CzokoŚmieciarka.DataModels\CzokoŚmieciarka.DataModels.csproj", "{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.DataModels.GeneralModels", "Components\CzokoŚmieciarka.DataModels.GeneralModels\CzokoŚmieciarka.DataModels.GeneralModels.csproj", "{A3D5DA96-69D7-463F-B1EE-6FC70716E3B2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.WPFv2", "Interface\CzokoŚmieciarka.WPFv2\CzokoŚmieciarka.WPFv2.csproj", "{2BADDDA9-A77C-4FB2-9F28-4DAE712E8947}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.AI_Naive", "Components\CzokoŚmieciarka.AI_Naive\CzokoŚmieciarka.AI_Naive.csproj", "{10E77BBE-55E1-483D-A456-0E94EAC9B24A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.MonoGame", "Interface\CzokoŚmieciarka.MonoGame\CzokoŚmieciarka.MonoGame.csproj", "{3A27CBFB-44DF-4B1D-B776-770FCA3DF905}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGameView", "MonoGameView\MonoGameView.csproj", "{EBE9431C-9B66-4300-B288-7A0F7B899415}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Release|x86.Build.0 = Release|Any CPU
|
||||
{A3D5DA96-69D7-463F-B1EE-6FC70716E3B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A3D5DA96-69D7-463F-B1EE-6FC70716E3B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A3D5DA96-69D7-463F-B1EE-6FC70716E3B2}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{A3D5DA96-69D7-463F-B1EE-6FC70716E3B2}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{A3D5DA96-69D7-463F-B1EE-6FC70716E3B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A3D5DA96-69D7-463F-B1EE-6FC70716E3B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A3D5DA96-69D7-463F-B1EE-6FC70716E3B2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{A3D5DA96-69D7-463F-B1EE-6FC70716E3B2}.Release|x86.Build.0 = Release|Any CPU
|
||||
{2BADDDA9-A77C-4FB2-9F28-4DAE712E8947}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2BADDDA9-A77C-4FB2-9F28-4DAE712E8947}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2BADDDA9-A77C-4FB2-9F28-4DAE712E8947}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{2BADDDA9-A77C-4FB2-9F28-4DAE712E8947}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{2BADDDA9-A77C-4FB2-9F28-4DAE712E8947}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2BADDDA9-A77C-4FB2-9F28-4DAE712E8947}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2BADDDA9-A77C-4FB2-9F28-4DAE712E8947}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{2BADDDA9-A77C-4FB2-9F28-4DAE712E8947}.Release|x86.Build.0 = Release|Any CPU
|
||||
{10E77BBE-55E1-483D-A456-0E94EAC9B24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{10E77BBE-55E1-483D-A456-0E94EAC9B24A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{10E77BBE-55E1-483D-A456-0E94EAC9B24A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{10E77BBE-55E1-483D-A456-0E94EAC9B24A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{10E77BBE-55E1-483D-A456-0E94EAC9B24A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{10E77BBE-55E1-483D-A456-0E94EAC9B24A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{10E77BBE-55E1-483D-A456-0E94EAC9B24A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{10E77BBE-55E1-483D-A456-0E94EAC9B24A}.Release|x86.Build.0 = Release|Any CPU
|
||||
{3A27CBFB-44DF-4B1D-B776-770FCA3DF905}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{3A27CBFB-44DF-4B1D-B776-770FCA3DF905}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{3A27CBFB-44DF-4B1D-B776-770FCA3DF905}.Debug|x86.Build.0 = Debug|x86
|
||||
{3A27CBFB-44DF-4B1D-B776-770FCA3DF905}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{3A27CBFB-44DF-4B1D-B776-770FCA3DF905}.Release|x86.ActiveCfg = Release|x86
|
||||
{3A27CBFB-44DF-4B1D-B776-770FCA3DF905}.Release|x86.Build.0 = Release|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Debug|ARM.ActiveCfg = Debug|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Debug|x86.Build.0 = Debug|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Release|ARM.ActiveCfg = Release|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Release|x64.ActiveCfg = Release|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Release|x86.ActiveCfg = Release|x86
|
||||
{EBE9431C-9B66-4300-B288-7A0F7B899415}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -73,6 +73,7 @@
|
||||
<Compile Include="Models\Dump.cs" />
|
||||
<Compile Include="Models\GarbageCollector.cs" />
|
||||
<Compile Include="Models\House.cs" />
|
||||
<Compile Include="Models\ImageContainer.cs" />
|
||||
<Compile Include="Models\Road.cs" />
|
||||
<Compile Include="Models\Road2.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
@ -101,20 +102,6 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Components\CzokoŚmieciarka.AI_Naive\CzokoŚmieciarka.AI_Naive.csproj">
|
||||
<Project>{10e77bbe-55e1-483d-a456-0e94eac9b24a}</Project>
|
||||
<Name>CzokoŚmieciarka.AI_Naive</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Components\CzokoŚmieciarka.DataModels.GeneralModels\CzokoŚmieciarka.DataModels.GeneralModels.csproj">
|
||||
<Project>{a3d5da96-69d7-463f-b1ee-6fc70716e3b2}</Project>
|
||||
<Name>CzokoŚmieciarka.DataModels.GeneralModels</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Components\CzokoŚmieciarka.DataModels\CzokoŚmieciarka.DataModels.csproj">
|
||||
<Project>{f2e11fee-c5ac-47d2-ba9c-819909b6dff7}</Project>
|
||||
<Name>CzokoŚmieciarka.DataModels</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -13,7 +13,6 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Czoko_Smieciarka.AI_Naive;
|
||||
using CzokoŚmieciarka.DataModels.Enums;
|
||||
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
@ -34,7 +33,6 @@ namespace CzokoŚmieciarka.WPFv2
|
||||
IWPFObject[,] Objects = new IWPFObject[Columns,Rows];
|
||||
private IEnumerable<AGarbageCollectorContainer> GarbageCollectorContainers;
|
||||
private WPFGarbageCollector garbageCollector;
|
||||
private RoutePlanningEngine routePlanningEngine;
|
||||
public MainWindow()
|
||||
{
|
||||
|
||||
@ -133,14 +131,7 @@ namespace CzokoŚmieciarka.WPFv2
|
||||
Board.Children.Add(Objects[1, 3].Image);
|
||||
|
||||
|
||||
routePlanningEngine = new RoutePlanningEngine(garbageCollector,
|
||||
new List<IGarbageLocalization>()
|
||||
{
|
||||
new GarbageLocalization(house.Coords,house.TrashCans)
|
||||
},
|
||||
new List<ADump>()
|
||||
{
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace CzokoŚmieciarka.WPFv2.Models
|
||||
{
|
||||
public sealed class ImageContainer
|
||||
{
|
||||
private static ImageContainer _Instance = null;
|
||||
|
||||
private Dictionary<string, Image> Images;
|
||||
|
||||
|
||||
public static ImageContainer Instance {
|
||||
get {
|
||||
if (_Instance == null)
|
||||
{
|
||||
_Instance = new ImageContainer();
|
||||
}
|
||||
return _Instance;
|
||||
}
|
||||
}
|
||||
|
||||
public ImageContainer()
|
||||
{
|
||||
Images = new Dictionary<string, Image>();
|
||||
Images.Add("Road", new Image { Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png")) });
|
||||
}
|
||||
|
||||
|
||||
public Image GetImage(string s)
|
||||
{
|
||||
return Images[s];
|
||||
}
|
||||
}
|
||||
}
|
@ -7,32 +7,24 @@ using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.WPFv2.Interfaces;
|
||||
|
||||
namespace CzokoŚmieciarka.WPFv2.Models
|
||||
{
|
||||
class Road : IWPFObject
|
||||
class Road : IWPFObject, IRoad
|
||||
{
|
||||
public Image Image
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Image
|
||||
{
|
||||
Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png")),
|
||||
Width = 100,
|
||||
Height = 100
|
||||
};
|
||||
return ImageContainer.Instance.GetImage("Road");
|
||||
}
|
||||
}
|
||||
|
||||
public Road()
|
||||
{
|
||||
//Image = new Image()
|
||||
//{
|
||||
// Source =
|
||||
// new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png"))
|
||||
//};
|
||||
|
||||
}
|
||||
|
||||
public Coords Coords { get; set; }
|
||||
|
@ -7,10 +7,11 @@ using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
using CzokoŚmieciarka.WPFv2.Interfaces;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
|
||||
namespace CzokoŚmieciarka.WPFv2.Models
|
||||
{
|
||||
class Road2 : IWPFObject
|
||||
class Road2 : IWPFObject, IRoad
|
||||
{
|
||||
public string ImagePath { get; set; }
|
||||
public Image Image { get; set; }
|
||||
|
105
Trunk/MonoGameView/Algorithms/DFS.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.Algorithms
|
||||
{
|
||||
public class DFS
|
||||
{
|
||||
public DFS()
|
||||
{
|
||||
}
|
||||
int count = 0;
|
||||
|
||||
|
||||
public List<IStep> BestPath(ContentManager content, AGarbageCollector collector, object[,] grid)
|
||||
{
|
||||
var r=Search(content, collector, grid, 0).Key;
|
||||
Console.WriteLine(count);
|
||||
return r;
|
||||
}
|
||||
|
||||
List<IStep> PossibleSteps(ContentManager content, AGarbageCollector collector, object[,] grid)
|
||||
{
|
||||
|
||||
|
||||
var result = new List<IStep>();
|
||||
var moveSteps = new List<IStep>()
|
||||
{
|
||||
new MoveStep(Direction.Up),
|
||||
new MoveStep(Direction.Down),
|
||||
new MoveStep(Direction.Left),
|
||||
new MoveStep(Direction.Right)
|
||||
};
|
||||
var filteredMoveSteps = new List<IStep>();
|
||||
foreach (var item in moveSteps)
|
||||
{
|
||||
var copyCollector = (AGarbageCollector)collector.Clone(content);
|
||||
var copyGrid = (object[,])grid.Clone();
|
||||
try
|
||||
{
|
||||
item.Invoke(copyCollector, grid);
|
||||
var gcx = copyCollector.Coords.X;
|
||||
var gcy = copyCollector.Coords.Y;
|
||||
if (grid[gcx, gcy] is IRoad1 || grid[gcx, gcy] is IGarbageLocalization || grid[gcx, gcy] is ADump)
|
||||
{
|
||||
result.Add(item);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
KeyValuePair<List<IStep>, int> Search(ContentManager content, AGarbageCollector collector, object[,] grid, int length)
|
||||
{
|
||||
count++;
|
||||
if (length > 40) return new KeyValuePair<List<IStep>, int>(new List<IStep>(), length);
|
||||
var possibleSteps = PossibleSteps(content, collector, grid);
|
||||
|
||||
foreach (var item in possibleSteps)
|
||||
{
|
||||
var copyCollector = (AGarbageCollector)collector.Clone(content);
|
||||
var copyGrid = (object[,])grid.Clone();
|
||||
|
||||
|
||||
//if (copyGrid[copyCollector.Coords.X, copyCollector.Coords.Y] is IRoad1) copyGrid[copyCollector.Coords.X, copyCollector.Coords.Y] = new Road2();
|
||||
item.Invoke(copyCollector, copyGrid);
|
||||
var s = Search(content, copyCollector, copyGrid, length + 1);
|
||||
if (s.Key != null)
|
||||
{
|
||||
s.Key.Insert(0, item);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return new KeyValuePair<List<IStep>, int>(null, length);
|
||||
/*var min = int.MaxValue;
|
||||
var min_index = 0;
|
||||
for (int i = 0; i < mapped.Count; i++)
|
||||
{
|
||||
if (mapped.ElementAt(i).Value <= min)
|
||||
{
|
||||
min = mapped.ElementAt(i).Value;
|
||||
min_index = i;
|
||||
}
|
||||
}
|
||||
return mapped.ElementAt(min_index);
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
75
Trunk/MonoGameView/Content/Content.mgcb
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
#----------------------------- Global Properties ----------------------------#
|
||||
|
||||
/outputDir:bin/$(Platform)
|
||||
/intermediateDir:obj/$(Platform)
|
||||
/platform:Windows
|
||||
/config:
|
||||
/profile:Reach
|
||||
/compress:False
|
||||
|
||||
#-------------------------------- References --------------------------------#
|
||||
|
||||
|
||||
#---------------------------------- Content ---------------------------------#
|
||||
|
||||
#begin collector.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:collector.png
|
||||
|
||||
#begin grass.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:grass.png
|
||||
|
||||
#begin house.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:house.png
|
||||
|
||||
#begin road1.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:road1.png
|
||||
|
||||
#begin road2.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:road2.png
|
||||
|
BIN
Trunk/MonoGameView/Content/Dumps/glass.png
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Trunk/MonoGameView/Content/Dumps/organic.png
Normal file
After Width: | Height: | Size: 100 KiB |
BIN
Trunk/MonoGameView/Content/Dumps/paper.png
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
Trunk/MonoGameView/Content/Dumps/plasticmetal.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
Trunk/MonoGameView/Content/collector.png
Normal file
After Width: | Height: | Size: 369 B |
BIN
Trunk/MonoGameView/Content/grass.png
Normal file
After Width: | Height: | Size: 184 B |
BIN
Trunk/MonoGameView/Content/house.png
Normal file
After Width: | Height: | Size: 420 B |
BIN
Trunk/MonoGameView/Content/road1.png
Normal file
After Width: | Height: | Size: 180 B |
BIN
Trunk/MonoGameView/Content/road2.png
Normal file
After Width: | Height: | Size: 193 B |
@ -1,4 +1,4 @@
|
||||
namespace CzokoŚmieciarka.DataModels.Enums
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Enums
|
||||
{
|
||||
public enum Direction
|
||||
{
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Enums
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Enums
|
||||
{
|
||||
public enum GarbageType
|
||||
{
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Exceptions
|
||||
{
|
||||
public class WrongPositionException : Exception
|
||||
{
|
||||
@ -26,4 +26,20 @@ namespace CzokoŚmieciarka.DataModels
|
||||
}
|
||||
}
|
||||
|
||||
public class OutOfGridException : Exception
|
||||
{
|
||||
public OutOfGridException()
|
||||
{
|
||||
}
|
||||
public OutOfGridException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public OutOfGridException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage
|
||||
{
|
||||
public abstract class AGarbage : IGarbage
|
||||
{
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage
|
||||
{
|
||||
public interface IGarbage : ICloneable
|
||||
{
|
@ -3,13 +3,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Exceptions;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Exceptions;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector
|
||||
{
|
||||
public abstract class AGarbageCollector : IGarbageCollector
|
||||
public abstract class AGarbageCollector : IGarbageCollector, ICloneable
|
||||
{
|
||||
public AGarbageCollector(Coords startPosition, IEnumerable<AGarbageCollectorContainer> trashContainers, int columns, int rows)
|
||||
{
|
||||
@ -57,11 +58,15 @@ namespace CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector
|
||||
Coords.X += 1;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
public virtual object Clone(ContentManager content)
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<AGarbageCollectorContainer> TrashContainers { get; }
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,10 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector
|
||||
{
|
||||
public interface IGarbageCollector : ICloneable
|
||||
{
|
10
Trunk/MonoGameView/DataModels/Interfaces/IDrawables.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||
{
|
||||
public interface IDrawables
|
||||
{
|
||||
void Draw(ContentManager content, SpriteBatch spriteBatch, int size);
|
||||
}
|
||||
}
|
@ -3,10 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||
{
|
||||
public interface IGarbageLocalization
|
||||
{
|
12
Trunk/MonoGameView/DataModels/Interfaces/IHouse.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||
{
|
||||
public interface IHouse
|
||||
{
|
||||
}
|
||||
}
|
12
Trunk/MonoGameView/DataModels/Interfaces/IRoad.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||
{
|
||||
public interface IRoad
|
||||
{
|
||||
}
|
||||
}
|
12
Trunk/MonoGameView/DataModels/Interfaces/IRoad1.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||
{
|
||||
public interface IRoad1
|
||||
{
|
||||
}
|
||||
}
|
12
Trunk/MonoGameView/DataModels/Interfaces/IRoad2.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||
{
|
||||
public interface IRoad2
|
||||
{
|
||||
}
|
||||
}
|
9
Trunk/MonoGameView/DataModels/Interfaces/IStep.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||
{
|
||||
public interface IStep
|
||||
{
|
||||
void Invoke(IGarbageCollector collector, object [,] grid);
|
||||
}
|
||||
}
|
@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Enums;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||
{
|
||||
public interface ITypeOfGarbage
|
||||
{
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.RoutePlanningEngine
|
||||
{
|
||||
public interface IRoutePlanningEngine
|
||||
{
|
||||
IEnumerable<IStep> ReturnSteps();
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces.TrashCans
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
||||
{
|
||||
public abstract class ADump : ATrashCan
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces.TrashCans
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
||||
{
|
||||
public abstract class AGarbageCollectorContainer : ATrashCan
|
||||
{
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Interfaces.TrashCans
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
||||
{
|
||||
public abstract class ATrashCan
|
||||
{
|
55
Trunk/MonoGameView/DataModels/MapLoader.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
using MonoGameView.DataModels.Models;
|
||||
|
||||
namespace MonoGameView.DataModels
|
||||
{
|
||||
public class MapLoader
|
||||
{
|
||||
public void Load(out int size, out object[,] grid, string filename)
|
||||
{
|
||||
XmlDocument xml = new XmlDocument();
|
||||
xml.Load(filename);
|
||||
XmlNode node = xml.GetElementsByTagName("Map").Item(0);
|
||||
XmlNode sizeNode = node.SelectSingleNode("/Map/Size");
|
||||
size = Convert.ToInt32(sizeNode.InnerText);
|
||||
grid = new object[size,size];
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
for (int y = 0; y < size; y++)
|
||||
{
|
||||
grid[x, y] = new Grass(new Coords(x,y));
|
||||
}
|
||||
}
|
||||
foreach(XmlNode objectNode in node.SelectNodes("/Map/Objects/Object"))
|
||||
{
|
||||
XmlNode positionNode;
|
||||
int x;
|
||||
int y;
|
||||
switch (objectNode.SelectSingleNode("Type").InnerText)
|
||||
{
|
||||
case "Road":
|
||||
positionNode = objectNode.SelectSingleNode("Position");
|
||||
x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText);
|
||||
y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText);
|
||||
Road1 road = new Road1(new Coords(x,y));
|
||||
grid[x, y] = road;
|
||||
break;
|
||||
case "House":
|
||||
positionNode = objectNode.SelectSingleNode("Position");
|
||||
x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText);
|
||||
y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText);
|
||||
House house = new House(new Coords(x,y));
|
||||
grid[x, y] = house;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Models
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||
{
|
||||
public class Coords
|
||||
{
|
||||
@ -35,5 +35,20 @@ namespace CzokoŚmieciarka.DataModels.Models
|
||||
{
|
||||
return new Coords(a.X - b.X, a.Y - b.Y);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
13
Trunk/MonoGameView/DataModels/Models/Dump.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
||||
{
|
||||
public class Dump : ADump
|
||||
{
|
||||
public Dump(ITypeOfGarbage typeOfGarbage, int maxVolume, Coords localization) : base(typeOfGarbage, maxVolume, localization)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.GeneralModels.Models
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
||||
{
|
||||
public class Garbage : AGarbage
|
||||
{
|
33
Trunk/MonoGameView/DataModels/Models/GarbageCollector.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||
{
|
||||
public class GarbageCollector : AGarbageCollector, IDrawables
|
||||
{
|
||||
public GarbageCollector(Coords c, List<AGarbageCollectorContainer> l, int rows, int cols) : base(c,l,rows,cols)
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw(ContentManager content, SpriteBatch batch,int size)
|
||||
{
|
||||
batch.Draw(content.Load<Texture2D>("collector"), new Rectangle(Coords.X*500/size, Coords.Y*500/size, 500/size, 500/size), Color.White);
|
||||
}
|
||||
|
||||
|
||||
public override object Clone(ContentManager content)
|
||||
{
|
||||
var cloneList = new List<AGarbageCollectorContainer>();
|
||||
return new GarbageCollector(new Coords(Coords.X,Coords.Y), cloneList, rows,columns);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.GeneralModels.Models
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
||||
{
|
||||
public class GarbageCollectorContainer : AGarbageCollectorContainer
|
||||
{
|
@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.GeneralModels.Models
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
||||
{
|
||||
public class GarbageLocalization : IGarbageLocalization
|
||||
{
|
28
Trunk/MonoGameView/DataModels/Models/Grass.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace MonoGameView.DataModels.Models
|
||||
{
|
||||
public class Grass : IDrawables
|
||||
{
|
||||
private Coords Coords;
|
||||
|
||||
public Grass(Coords coords)
|
||||
{
|
||||
Coords = coords;
|
||||
}
|
||||
|
||||
public void Draw(ContentManager content, SpriteBatch batch, int size)
|
||||
{
|
||||
batch.Draw(content.Load<Texture2D>("grass"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
26
Trunk/MonoGameView/DataModels/Models/House.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||
{
|
||||
public class House : IDrawables
|
||||
{
|
||||
private Coords Coords;
|
||||
|
||||
public House(Coords coords)
|
||||
{
|
||||
Coords = coords;
|
||||
}
|
||||
public void Draw(ContentManager content, SpriteBatch batch, int size)
|
||||
{
|
||||
batch.Draw(content.Load<Texture2D>("house"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,9 +4,10 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Models
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||
{
|
||||
public class Map
|
||||
{
|
27
Trunk/MonoGameView/DataModels/Models/Road1.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||
{
|
||||
public class Road1 :IRoad1
|
||||
{
|
||||
private Coords Coords;
|
||||
|
||||
public Road1(Coords coords)
|
||||
{
|
||||
Coords = coords;
|
||||
}
|
||||
|
||||
public void Draw(ContentManager content, SpriteBatch batch, int size)
|
||||
{
|
||||
batch.Draw(content.Load<Texture2D>("grass"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
13
Trunk/MonoGameView/DataModels/Models/Road2.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||
{
|
||||
public class Road2 : IRoad2
|
||||
{
|
||||
}
|
||||
}
|
@ -3,26 +3,24 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Models.Steps
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
||||
{
|
||||
public class CollectStep : IStep
|
||||
{
|
||||
public CollectStep(IGarbageCollector garbageCollector, IGarbageLocalization garbageLocalization, ITypeOfGarbage typeOfGarbage)
|
||||
public CollectStep(ITypeOfGarbage typeOfGarbage)
|
||||
{
|
||||
this._garbageCollector = garbageCollector;
|
||||
this._garbageLocalization = garbageLocalization;
|
||||
this._typeOfGarbage = typeOfGarbage;
|
||||
}
|
||||
|
||||
private IGarbageCollector _garbageCollector;
|
||||
private ITypeOfGarbage _typeOfGarbage;
|
||||
private IGarbageLocalization _garbageLocalization;
|
||||
|
||||
public void Invoke()
|
||||
public void Invoke(IGarbageCollector garbageCollector, object [,] grid)
|
||||
{
|
||||
/*
|
||||
if(_garbageCollector.Coords != _garbageLocalization.Coords)
|
||||
throw new WrongPositionException("Śmieciarka nie jest w miejscu oderbania śmieci");
|
||||
|
||||
@ -33,6 +31,7 @@ namespace CzokoŚmieciarka.DataModels.Models.Steps
|
||||
throw new TrashContainerNotFound($"Nie znaleziono kontenera na {_typeOfGarbage.GarbageType}.");
|
||||
|
||||
_garbageCollector.TrashContainers.First(t => t.TypeOfGarbage == _typeOfGarbage).AddGarbage(garbage);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
@ -3,25 +3,27 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Enums;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Models.Steps
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
||||
{
|
||||
public class MoveStep : IStep
|
||||
{
|
||||
public MoveStep(Direction direction, IGarbageCollector garbageCollector)
|
||||
public MoveStep(Direction direction)
|
||||
{
|
||||
this._garbageCollector = garbageCollector;
|
||||
this._direction = direction;
|
||||
}
|
||||
|
||||
private Direction _direction;
|
||||
private IGarbageCollector _garbageCollector;
|
||||
|
||||
public void Invoke()
|
||||
public void Invoke(IGarbageCollector _garbageCollector, object[,] grid)
|
||||
{
|
||||
if(grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y] is Road1)
|
||||
grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y] = new Road2();
|
||||
switch (_direction)
|
||||
{
|
||||
case Direction.Up: _garbageCollector.MoveUp(); break;
|
@ -3,26 +3,23 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.Models.Steps
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
||||
{
|
||||
public class SpillStep : IStep
|
||||
{
|
||||
public SpillStep(IGarbageCollector garbageCollector, ADump dump, ITypeOfGarbage typeOfGarbage)
|
||||
public SpillStep(ITypeOfGarbage typeOfGarbage)
|
||||
{
|
||||
this._garbageCollector = garbageCollector;
|
||||
this._dump = dump;
|
||||
this._typeOfGarbage = typeOfGarbage;
|
||||
}
|
||||
|
||||
private IGarbageCollector _garbageCollector;
|
||||
private ADump _dump;
|
||||
private ITypeOfGarbage _typeOfGarbage;
|
||||
|
||||
public void Invoke()
|
||||
{
|
||||
public void Invoke(IGarbageCollector garbageCollector, object [,] grid)
|
||||
{/*
|
||||
if(_garbageCollector.Coords != _dump.Coords)
|
||||
throw new WrongPositionException("Śmieciarka nie na terenie podanego wyspiska");
|
||||
|
||||
@ -36,7 +33,7 @@ namespace CzokoŚmieciarka.DataModels.Models.Steps
|
||||
.Select(t => t.TakeGarbage())
|
||||
.Aggregate((a, b) => a + b);
|
||||
|
||||
_dump.AddGarbage(garbage);
|
||||
_dump.AddGarbage(garbage);*/
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.GeneralModels.Models
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
||||
{
|
||||
public class TrashCan : ATrashCan
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
using CzokoŚmieciarka.DataModels.Enums;
|
||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
|
||||
namespace CzokoŚmieciarka.DataModels.GeneralModels.Models
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
||||
{
|
||||
public class TypeOfGarbage : ITypeOfGarbage
|
||||
{
|
146
Trunk/MonoGameView/Game1.cs
Normal file
@ -0,0 +1,146 @@
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CzokoŚmieciarka.MonoGameView.Algorithms;
|
||||
using MonoGameView.DataModels;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the main type for your game.
|
||||
/// </summary>
|
||||
public class Game1 : Game
|
||||
{
|
||||
private static int size;
|
||||
GraphicsDeviceManager graphics;
|
||||
SpriteBatch spriteBatch;
|
||||
Texture2D road1;
|
||||
Texture2D road2;
|
||||
Texture2D grass;
|
||||
Texture2D house;
|
||||
MapLoader mapLoader = new MapLoader();
|
||||
Vector2 roadPos;
|
||||
float timer;
|
||||
const float TIMER = 0.2f;
|
||||
int stepN;
|
||||
List<IStep> steps;
|
||||
GarbageCollector collector;
|
||||
object[,] grid;
|
||||
public Game1()
|
||||
{
|
||||
graphics = new GraphicsDeviceManager(this);
|
||||
Content.RootDirectory = "Content";
|
||||
graphics.PreferredBackBufferWidth = 500;
|
||||
graphics.PreferredBackBufferHeight = 500;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Allows the game to perform any initialization it needs to before starting to run.
|
||||
/// This is where it can query for any required services and load any non-graphic
|
||||
/// related content. Calling base.Initialize will enumerate through any components
|
||||
/// and initialize them as well.
|
||||
/// </summary>
|
||||
protected override void Initialize()
|
||||
{
|
||||
// TODO: Add your initialization logic here
|
||||
roadPos = new Vector2(0, 0);
|
||||
timer = 0.2f;
|
||||
|
||||
mapLoader.Load(out size,out grid,"map.xml");
|
||||
collector = new GarbageCollector(new Coords(0, 0), new List<AGarbageCollectorContainer>(), size, size);
|
||||
|
||||
|
||||
stepN = 0;
|
||||
var dfs = new DFS();
|
||||
steps = dfs.BestPath(Content, collector, grid);
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LoadContent will be called once per game and is the place to load
|
||||
/// all of your content.
|
||||
/// </summary>
|
||||
protected override void LoadContent()
|
||||
{
|
||||
// Create a new SpriteBatch, which can be used to draw textures.
|
||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
road1 = Content.Load<Texture2D>("road1");
|
||||
road2 = Content.Load<Texture2D>("road2");
|
||||
grass = Content.Load<Texture2D>("grass");
|
||||
house = Content.Load<Texture2D>("house");
|
||||
// TODO: use this.Content to load your game content here
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UnloadContent will be called once per game and is the place to unload
|
||||
/// game-specific content.
|
||||
/// </summary>
|
||||
protected override void UnloadContent()
|
||||
{
|
||||
Content.Unload();
|
||||
// TODO: Unload any non ContentManager content here
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the game to run logic such as updating the world,
|
||||
/// checking for collisions, gathering input, and playing audio.
|
||||
/// </summary>
|
||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||
protected override void Update(GameTime gameTime)
|
||||
{
|
||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
Exit();
|
||||
var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
timer -= elapsed;
|
||||
if (timer<0)
|
||||
{
|
||||
timer = TIMER;
|
||||
if (steps.Any())
|
||||
{
|
||||
steps.First().Invoke(collector, grid);
|
||||
steps.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
// TODO: Add your update logic here
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called when the game should draw itself.
|
||||
/// </summary>
|
||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||
protected override void Draw(GameTime gameTime)
|
||||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
spriteBatch.Begin();
|
||||
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
for (int y = 0; y < size; y++)
|
||||
{
|
||||
if (grid[x, y] is Road1) spriteBatch.Draw(road1, new Rectangle(x*500 / size, y*500 / size, 500/size, 500/size),Color.White);
|
||||
else if (grid[x,y] is Road2) spriteBatch.Draw(road2, new Rectangle(x * 500 / size, y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||
else if (grid[x, y] is House) spriteBatch.Draw(house, new Rectangle(x * 500 / size, y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||
else spriteBatch.Draw(grass, new Rectangle(x * 500 / size, y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||
}
|
||||
}
|
||||
collector.Draw(Content, spriteBatch, size);
|
||||
|
||||
spriteBatch.End();
|
||||
// TODO: Add your drawing code here
|
||||
|
||||
base.Draw(gameTime);
|
||||
}
|
||||
}
|
||||
}
|
BIN
Trunk/MonoGameView/Icon.ico
Normal file
After Width: | Height: | Size: 144 KiB |
111
Trunk/MonoGameView/MonoGameView.csproj
Normal file
@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EBE9431C-9B66-4300-B288-7A0F7B899415}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MonoGameView</RootNamespace>
|
||||
<AssemblyName>MonoGameView</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MonoGamePlatform>Windows</MonoGamePlatform>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWS</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Algorithms\DFS.cs" />
|
||||
<Compile Include="DataModels\Enums\Directions.cs" />
|
||||
<Compile Include="DataModels\Enums\GarbageTypes.cs" />
|
||||
<Compile Include="DataModels\Exceptions\Exceptions.cs" />
|
||||
<Compile Include="DataModels\Interfaces\GarbageCollector\AGarbageCollector.cs" />
|
||||
<Compile Include="DataModels\Interfaces\GarbageCollector\IGarbageCollector.cs" />
|
||||
<Compile Include="DataModels\Interfaces\Garbage\AGarbage.cs" />
|
||||
<Compile Include="DataModels\Interfaces\Garbage\IGarbage.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IDrawables.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IGarbageLocalization.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IHouse.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IRoad.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IRoad1.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IRoad2.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IStep.cs" />
|
||||
<Compile Include="DataModels\Interfaces\ITypeOfGarbage.cs" />
|
||||
<Compile Include="DataModels\Interfaces\RoutePlanningEngine\IRoutePlanningEngine.cs" />
|
||||
<Compile Include="DataModels\Interfaces\TrashCans\ADump.cs" />
|
||||
<Compile Include="DataModels\Interfaces\TrashCans\AGarbageCollectorContainer.cs" />
|
||||
<Compile Include="DataModels\Interfaces\TrashCans\ATrashCan.cs" />
|
||||
<Compile Include="DataModels\MapLoader.cs" />
|
||||
<Compile Include="DataModels\Models\Coords.cs" />
|
||||
<Compile Include="DataModels\Models\Dump.cs" />
|
||||
<Compile Include="DataModels\Models\Garbage.cs" />
|
||||
<Compile Include="DataModels\Models\GarbageCollectorContainer.cs" />
|
||||
<Compile Include="DataModels\Models\GarbageLocalization.cs" />
|
||||
<Compile Include="DataModels\Models\Grass.cs" />
|
||||
<Compile Include="DataModels\Models\House.cs" />
|
||||
<Compile Include="DataModels\Models\Map.cs" />
|
||||
<Compile Include="DataModels\Models\Road1.cs" />
|
||||
<Compile Include="DataModels\Models\Road2.cs" />
|
||||
<Compile Include="DataModels\Models\Steps\CollectStep.cs" />
|
||||
<Compile Include="DataModels\Models\Steps\MoveStep.cs" />
|
||||
<Compile Include="DataModels\Models\Steps\SpillStep.cs" />
|
||||
<Compile Include="DataModels\Models\TrashCan.cs" />
|
||||
<Compile Include="DataModels\Models\TypeOfGarbage.cs" />
|
||||
<Compile Include="Game1.cs" />
|
||||
<Compile Include="DataModels\Models\GarbageCollector.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework">
|
||||
<HintPath>$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Icon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="Content\Content.mgcb" />
|
||||
<None Include="app.config" />
|
||||
<None Include="app.manifest" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
22
Trunk/MonoGameView/Program.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView
|
||||
{
|
||||
#if WINDOWS || LINUX
|
||||
/// <summary>
|
||||
/// The main class.
|
||||
/// </summary>
|
||||
public static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
using (var game = new Game1())
|
||||
game.Run();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
36
Trunk/MonoGameView/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MonoGameView")]
|
||||
[assembly: AssemblyProduct("MonoGameView")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0ff0f801-46a1-4452-8feb-12cb0986ff52")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
3
Trunk/MonoGameView/app.config
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
|
42
Trunk/MonoGameView/app.manifest
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MonoGameView"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on and is
|
||||
is designed to work with. Uncomment the appropriate elements and Windows will
|
||||
automatically selected the most compatible environment. -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
</assembly>
|