Created and implemented EntityManager. PixelTransform and GridTransform phased out.

This commit is contained in:
Simon Holmberg
2012-10-17 23:44:58 +02:00
parent 8e1f18d233
commit c59ff9778a
11 changed files with 352 additions and 450 deletions
@@ -1,46 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
namespace DepthsBelow.Component
{
[Obsolete("Deprecated in favour of Component.Transform")]
public class GridTransform : Component
{
public Point Position;
public int X
{
get
{
return Position.X;
}
set
{
Position.X = value;
}
}
public int Y
{
get
{
return Position.Y;
}
set
{
Position.Y = value;
}
}
public GridTransform(Entity parent) : base(parent)
{
Position = Point.Zero;
}
public Vector2 ToWorld()
{
return Grid.GridToWorld(Position);
}
}
}
@@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
namespace DepthsBelow.Component
{
[Obsolete("Deprecated in favour of Component.Transform")]
public class PixelTransform : Component
{
public Vector2 Position;
public float X
{
get
{
return Position.X;
}
set
{
Position.X = value;
}
}
public float Y
{
get
{
return Position.Y;
}
set
{
Position.Y = value;
}
}
public float Rotation;
public Vector2 Origin;
public PixelTransform(Entity parent)
: base(parent)
{
Position = Vector2.Zero;
Rotation = 0.0f;
Origin = Vector2.Zero;
}
public Point ToGrid()
{
return Grid.WorldToGrid(Position);
}
}
}
+16 -45
View File
@@ -22,7 +22,9 @@ namespace DepthsBelow
public static GraphicsDeviceManager GraphicsDeviceManager;
SpriteBatch spriteBatch;
public Lua Lua;
public Lua Lua;
public EntityManager EntityManager;
public Camera Camera;
@@ -63,14 +65,13 @@ namespace DepthsBelow
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
// TODO: Add your initialization logic here
EntityManager = new EntityManager();
Camera = new Camera(this);
Squad = new List<Soldier>();
Swarm = new List<SmallEnemy>();
Volley = new List<Shot>();
TestMonster = new SmallEnemy(this, ref Swarm);
// Run scripts after everything is initialized
Lua = new Lua();
Lua.LoadScripts();
@@ -92,20 +93,18 @@ namespace DepthsBelow
Map.ParseObjects(this);
// TODO: use this.Content to load your game content here
Soldier.LoadContent(this);
SmallEnemy.LoadContent(this);
Shot.LoadContent(this);
Soldier.LoadContent();
SmallEnemy.LoadContent();
Shot.LoadContent();
MouseInput = new MouseInput(this);
MouseInput.LoadContent();
KeyboardInput = new KeyboardInput(this);
KeyboardInput = new KeyboardInput(this);
TestMonster = new SmallEnemy(EntityManager, ref Swarm);
TestMonster.X = 12;
TestMonster.Y = 4;
Swarm.Add(TestMonster);
TestMonster.X = 12;
TestMonster.Y = 4;
//frame.AddChild(text);
}
/// <summary>
@@ -132,17 +131,8 @@ namespace DepthsBelow
MouseInput.Update(gameTime);
KeyboardInput.Update(gameTime);
// Update soldiers in squad
foreach (var soldier in Squad)
soldier.Update(gameTime);
EntityManager.Update(gameTime);
foreach (var body in Swarm)
body.Update(gameTime);
foreach (var bullet in Volley)
bullet.Update(gameTime);
TestMonster.Update(gameTime);
GUIManager.Update(gameTime);
base.Update(gameTime);
@@ -163,25 +153,8 @@ namespace DepthsBelow
// Draw the level
Map.Draw(spriteBatch);
// Draw units
foreach (var soldier in Squad)
{
var sr = soldier.GetComponent<Component.SpriteRenderer>();
if (sr != null)
sr.Draw(spriteBatch);
}
foreach (var body in Swarm)
{
var sr = body.GetComponent<Component.SpriteRenderer>();
if (sr != null)
sr.Draw(spriteBatch);
}
foreach (var bullet in Volley)
{
var sr = bullet.GetComponent<Component.SpriteRenderer>();
if (sr != null)
sr.Draw(spriteBatch);
}
// Draw entities
EntityManager.Draw(spriteBatch);
// Draw mouse input visuals
MouseInput.Draw(spriteBatch);
@@ -197,7 +170,5 @@ namespace DepthsBelow
base.Draw(gameTime);
}
}
}
+201 -202
View File
@@ -1,204 +1,203 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{94683C5B-052D-4143-96D8-35C67E831000}</ProjectGuid>
<ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DepthsBelow</RootNamespace>
<AssemblyName>DepthsBelow</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
<XnaPlatform>Windows</XnaPlatform>
<XnaProfile>HiDef</XnaProfile>
<XnaCrossPlatformGroupID>faa0577e-a03e-43cf-89c7-0a03f4c22717</XnaCrossPlatformGroupID>
<XnaOutputType>Game</XnaOutputType>
<ApplicationIcon>Game.ico</ApplicationIcon>
<Thumbnail>GameThumbnail.png</Thumbnail>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x86\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<PlatformTarget>x86</PlatformTarget>
<XnaCompressContent>false</XnaCompressContent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\x86\Release</OutputPath>
<DefineConstants>TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<PlatformTarget>x86</PlatformTarget>
<XnaCompressContent>true</XnaCompressContent>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>ECE66DEF071576E8D2F7D57232C0569623E3E2DF</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>DepthsBelow_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="LuaInterface, Version=2.0.0.16708, Culture=neutral, processorArchitecture=x86">
<HintPath>..\..\LuaInterface\LuaInterface.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.GamerServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Video, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Avatar, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="mscorlib">
<Private>False</Private>
</Reference>
<Reference Include="System">
<Private>False</Private>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Core">
<Private>False</Private>
</Reference>
<Reference Include="System.Net">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Camera.cs" />
<Compile Include="CustomExtensions.cs" />
<Compile Include="GameServices.cs" />
<Compile Include="Interface.cs" />
<Compile Include="Lua.cs" />
<Compile Include="Shot.cs" />
<Compile Include="Component\Stat.cs" />
<Compile Include="GUIManager.cs" />
<Compile Include="GUI\Button.cs" />
<Compile Include="GUI\Frame.cs" />
<Compile Include="GUI\Text.cs" />
<Compile Include="KeyboardInput.cs" />
<Compile Include="Component\PathFinder.cs" />
<Compile Include="Component\Transform.cs" />
<Compile Include="Grid.cs" />
<Compile Include="Component\Collision.cs" />
<Compile Include="Component\Component.cs" />
<Compile Include="Component\GridTransform.cs" />
<Compile Include="Core.cs" />
<Compile Include="Entity.cs" />
<Compile Include="Map.cs" />
<Compile Include="MouseInput.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Component\SpriteRenderer.cs" />
<Compile Include="RenderHelpers.cs" />
<Compile Include="SmallEnemy.cs" />
<Compile Include="Soldier.cs" />
<Compile Include="Component\PixelTransform.cs" />
<Compile Include="Utility.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Game.ico" />
<Content Include="GameThumbnail.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AStar\AStar.csproj">
<Project>{CD3F949D-54AA-4D38-99DB-92905A375D84}</Project>
<Name>AStar</Name>
</ProjectReference>
<ProjectReference Include="..\DepthsBelowContent\DepthsBelowContent.contentproj">
<Name>DepthsBelowContent %28Content%29</Name>
<XnaReferenceType>Content</XnaReferenceType>
<Project>{433A77A2-DE52-4875-A4EF-232CF59C2DD3}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Xna.Framework.4.0">
<Visible>False</Visible>
<ProductName>Microsoft XNA Framework Redistributable 4.0</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="DepthsBelow_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{94683C5B-052D-4143-96D8-35C67E831000}</ProjectGuid>
<ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DepthsBelow</RootNamespace>
<AssemblyName>DepthsBelow</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
<XnaPlatform>Windows</XnaPlatform>
<XnaProfile>HiDef</XnaProfile>
<XnaCrossPlatformGroupID>faa0577e-a03e-43cf-89c7-0a03f4c22717</XnaCrossPlatformGroupID>
<XnaOutputType>Game</XnaOutputType>
<ApplicationIcon>Game.ico</ApplicationIcon>
<Thumbnail>GameThumbnail.png</Thumbnail>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x86\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<PlatformTarget>x86</PlatformTarget>
<XnaCompressContent>false</XnaCompressContent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\x86\Release</OutputPath>
<DefineConstants>TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<PlatformTarget>x86</PlatformTarget>
<XnaCompressContent>true</XnaCompressContent>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>ECE66DEF071576E8D2F7D57232C0569623E3E2DF</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>DepthsBelow_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="LuaInterface, Version=2.0.0.16708, Culture=neutral, processorArchitecture=x86">
<HintPath>..\..\LuaInterface\LuaInterface.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.GamerServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Video, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Avatar, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Reference Include="mscorlib">
<Private>False</Private>
</Reference>
<Reference Include="System">
<Private>False</Private>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Core">
<Private>False</Private>
</Reference>
<Reference Include="System.Net">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Camera.cs" />
<Compile Include="CustomExtensions.cs" />
<Compile Include="EntityManager.cs" />
<Compile Include="GameServices.cs" />
<Compile Include="Interface.cs" />
<Compile Include="Lua.cs" />
<Compile Include="Shot.cs" />
<Compile Include="Component\Stat.cs" />
<Compile Include="GUIManager.cs" />
<Compile Include="GUI\Button.cs" />
<Compile Include="GUI\Frame.cs" />
<Compile Include="GUI\Text.cs" />
<Compile Include="KeyboardInput.cs" />
<Compile Include="Component\PathFinder.cs" />
<Compile Include="Component\Transform.cs" />
<Compile Include="Grid.cs" />
<Compile Include="Component\Collision.cs" />
<Compile Include="Component\Component.cs" />
<Compile Include="Core.cs" />
<Compile Include="Entity.cs" />
<Compile Include="Map.cs" />
<Compile Include="MouseInput.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Component\SpriteRenderer.cs" />
<Compile Include="RenderHelpers.cs" />
<Compile Include="SmallEnemy.cs" />
<Compile Include="Soldier.cs" />
<Compile Include="Utility.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Game.ico" />
<Content Include="GameThumbnail.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AStar\AStar.csproj">
<Project>{CD3F949D-54AA-4D38-99DB-92905A375D84}</Project>
<Name>AStar</Name>
</ProjectReference>
<ProjectReference Include="..\DepthsBelowContent\DepthsBelowContent.contentproj">
<Name>DepthsBelowContent %28Content%29</Name>
<XnaReferenceType>Content</XnaReferenceType>
<Project>{433A77A2-DE52-4875-A4EF-232CF59C2DD3}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Xna.Framework.4.0">
<Visible>False</Visible>
<ProductName>Microsoft XNA Framework Redistributable 4.0</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="DepthsBelow_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.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.
@@ -206,5 +205,5 @@
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
+27 -17
View File
@@ -6,13 +6,11 @@ using Microsoft.Xna.Framework;
namespace DepthsBelow
{
public class Entity
public class Entity : IDisposable
{
List<Component.Component> Components;
public Component.Transform Transform;
public Component.PixelTransform pixelTransform;
public Component.GridTransform gridTransform;
public Component.Stat stat;
public int X
{
get { return this.Transform.Grid.X; }
@@ -28,23 +26,35 @@ namespace DepthsBelow
{
this.Transform.Grid.Y = value;
}
}
protected Core core;
public Entity(Core core)
{
this.core = core;
}
private EntityManager entityManager;
public Entity(EntityManager entityManager)
{
this.entityManager = entityManager;
entityManager.Add(this);
Components = new List<Component.Component>();
Transform = new Component.Transform(this);
AddComponent(Transform);
pixelTransform = new Component.PixelTransform(this);
AddComponent(pixelTransform);
gridTransform = new Component.GridTransform(this);
AddComponent(gridTransform);
stat = new Component.Stat(this);
AddComponent(stat);
}
public virtual void Dispose()
{
}
public virtual void Remove()
{
entityManager.Remove(this);
Dispose();
}
public virtual void Kill()
{
Remove();
}
public T GetComponent<T>() where T : Component.Component
+55
View File
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace DepthsBelow
{
public class EntityManager : IDisposable
{
private List<Entity> entities;
public EntityManager()
{
entities = new List<Entity>();
}
public void Dispose()
{
foreach (var entity in entities)
entity.Dispose();
}
public void Add(Entity entity)
{
entities.Add(entity);
}
public void Remove(Entity entity)
{
entities.Remove(entity);
}
public void Reset()
{
foreach (var entity in entities)
entity.Dispose();
entities.Clear();
}
public void Update(GameTime gameTime)
{
foreach (var entity in entities)
entity.Update(gameTime);
}
public void Draw(SpriteBatch spriteBatch)
{
foreach (var entity in entities)
entity.GetComponent<Component.SpriteRenderer>().Draw(spriteBatch);
}
}
}
+2 -2
View File
@@ -82,7 +82,7 @@ namespace DepthsBelow
{
if (soldier.Selected == true && soldier.Fired == false)
{
core.Volley.Add(new Shot(core));
core.Volley.Add(new Shot(core.EntityManager));
soldier.Fired = true;
foreach (var shot in core.Volley)
{
@@ -139,7 +139,7 @@ namespace DepthsBelow
current = 0;
if (soldier.Selected == true && soldier.Fired == false && hit == true)
{
core.Volley.Add(new Shot(core));
core.Volley.Add(new Shot(core.EntityManager));
soldier.Fired = true;
foreach (var shot in core.Volley)
{
+1 -1
View File
@@ -72,7 +72,7 @@ namespace DepthsBelow
{
if (mapObject.Type == "SquadStart")
{
var soldier = new Soldier(core, ref core.Squad);
var soldier = new Soldier(core.EntityManager, ref core.Squad);
// HACK: For some reason, the tile object coordinates are offset by one tile on the Y-axis in the Tiled map file (https://github.com/bjorn/tiled/issues/91)
var mapObjectPos = new Vector2(mapObject.Bounds.X, mapObject.Bounds.Y - Grid.TileSize);
var mapObjectGridPos = Grid.WorldToGrid(mapObjectPos);
+8 -22
View File
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using DepthsBelow.Component;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
@@ -28,11 +29,11 @@ namespace DepthsBelow
public Vector2 direction = Vector2.Zero;
public Shot(Core core)
: base(core)
public Shot(EntityManager entityManager)
: base(entityManager)
{
if (Texture == null)
LoadContent(core);
LoadContent();
Transform.World.Origin = new Vector2(16, 16);
@@ -44,9 +45,9 @@ namespace DepthsBelow
AddComponent(cc);
}
public static void LoadContent(Core core)
{
Texture = core.Content.Load<Texture2D>("images/Shot");
public static void LoadContent()
{
Texture = GameServices.GetService<ContentManager>().Load<Texture2D>("images/Shot");
}
public override void Update(GameTime gameTime)
{
@@ -55,21 +56,6 @@ namespace DepthsBelow
float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
List<Point> soldierCollisions = new List<Point>();
foreach (var body in core.Swarm)
{
if (this.GetComponent<Collision>().Rectangle.Intersects(body.GetComponent<Collision>().Rectangle))
{
}
}
foreach (var soldier in core.Squad)
{
if (this.GetComponent<Collision>().Rectangle.Intersects(soldier.GetComponent<Collision>().Rectangle))
{
}
}
// HACK: Make this work properly with other speeds...
float speed = 4f;
Transform.World.Position += speed * direction;
+20 -28
View File
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using DepthsBelow.Component;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
@@ -30,11 +31,11 @@ namespace DepthsBelow
}
}
public SmallEnemy(Core core, ref List<SmallEnemy> swarm)
: base(core)
public SmallEnemy(EntityManager entityManager, ref List<SmallEnemy> swarm)
: base(entityManager)
{
if (Texture == null)
LoadContent(core);
LoadContent();
this.Swarm = swarm;
@@ -48,13 +49,17 @@ namespace DepthsBelow
AddComponent(cc);
var pfc = new PathFinder(this);
AddComponent(pfc);
stat.Life = 2;
stat.Defence = 0;
stat.Strength = 5000;
stat.GetAim = 100;
stat.GetDodge = 50;
AddComponent(pfc);
var stat = new Component.Stat(this)
{
Life = 2,
Defence = 0,
Strength = 5000,
GetAim = 100,
GetDodge = 50
};
AddComponent(stat);
}
public bool Selected
@@ -67,9 +72,9 @@ namespace DepthsBelow
}
}
public static void LoadContent(Core core)
{
Texture = core.Content.Load<Texture2D>("images/Monster");
public static void LoadContent()
{
Texture = GameServices.GetService<ContentManager>().Load<Texture2D>("images/Monster");
}
public override void Update(GameTime gameTime)
@@ -85,6 +90,7 @@ namespace DepthsBelow
{
List<Point> soldierCollisions = new List<Point>();
// Collision with moving units
foreach (var body in Swarm)
{
if (body != this)
@@ -99,20 +105,6 @@ namespace DepthsBelow
}
}
foreach (var soldier in core.Squad)
{
var pathFinder = soldier.GetComponent<PathFinder>();
var position = nextNode.Position;
if (soldier.Transform.Grid == position)
{
soldierCollisions.Add(soldier.Transform.Grid);
GetComponent<PathFinder>().RecreatePath(soldierCollisions);
nextNode = GetComponent<PathFinder>().Next();
break;
}
Utility.HitTest(this, soldier, Utility.CalculateHitChance(this, soldier));
}
if (nextNode != null)
{
var nodeWorldPos = Grid.GridToWorld(nextNode.Position);
+22 -36
View File
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using DepthsBelow.Component;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
@@ -41,12 +42,13 @@ namespace DepthsBelow
{
currentStep = value;
}
}
public Soldier(Core core, ref List<Soldier> squad) : base(core)
}
public Soldier(EntityManager entityManager, ref List<Soldier> squad)
: base(entityManager)
{
if (Texture == null)
LoadContent(core);
LoadContent();
this.Squad = squad;
@@ -60,13 +62,17 @@ namespace DepthsBelow
AddComponent(cc);
var pfc = new PathFinder(this);
AddComponent(pfc);
stat.Life = 10;
stat.Defence = 10;
stat.Strength = 10;
stat.GetAim = 10;
stat.GetDodge = 20;
AddComponent(pfc);
var stat = new Component.Stat(this)
{
Life = 10,
Defence = 10,
Strength = 10,
GetAim = 10,
GetDodge = 20
};
AddComponent(stat);
}
public bool Selected
@@ -79,9 +85,9 @@ namespace DepthsBelow
}
}
public static void LoadContent(Core core)
public static void LoadContent()
{
Texture = core.Content.Load<Texture2D>("images/soldier2");
Texture = GameServices.GetService<ContentManager>().Load<Texture2D>("images/soldier2");
}
public override void Update(GameTime gameTime)
@@ -97,6 +103,7 @@ namespace DepthsBelow
{
List<Point> soldierCollisions = new List<Point>();
// Collision with units at a standstill
foreach (var soldier in Squad)
{
if (soldier != this && !soldier.GetComponent<PathFinder>().IsMoving)
@@ -104,14 +111,8 @@ namespace DepthsBelow
soldierCollisions.Add(soldier.Transform.Grid);
}
}
foreach (var enemy in core.Swarm)
{
if (!enemy.GetComponent<PathFinder>().IsMoving)
{
soldierCollisions.Add(enemy.Transform.Grid);
}
}
// Collision with moving units
foreach (var soldier in Squad)
{
if (soldier != this)
@@ -127,18 +128,6 @@ namespace DepthsBelow
}
}
}
foreach (var enemy in core.Swarm)
{
var pathFinder = enemy.GetComponent<PathFinder>();
var position = nextNode.Position;
if (enemy.Transform.Grid == position)
{
soldierCollisions.Add(enemy.Transform.Grid);
GetComponent<PathFinder>().RecreatePath(soldierCollisions);
nextNode = GetComponent<PathFinder>().Next();
break;
}
}
if (nextNode != null)
{
@@ -169,10 +158,7 @@ namespace DepthsBelow
}
}
}
}
/**/
}
}
}