Merge branch 'master' of github.com:sippeangelo/DepthsBelow
This commit is contained in:
+152
-140
@@ -1,140 +1,152 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Audio;
|
using Microsoft.Xna.Framework.Audio;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.GamerServices;
|
using Microsoft.Xna.Framework.GamerServices;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using Microsoft.Xna.Framework.Media;
|
using Microsoft.Xna.Framework.Media;
|
||||||
|
|
||||||
namespace DepthsBelow
|
namespace DepthsBelow
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the main type for your game
|
/// This is the main type for your game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Core : Microsoft.Xna.Framework.Game
|
public class Core : Microsoft.Xna.Framework.Game
|
||||||
{
|
{
|
||||||
GraphicsDeviceManager graphics;
|
GraphicsDeviceManager graphics;
|
||||||
SpriteBatch spriteBatch;
|
SpriteBatch spriteBatch;
|
||||||
|
|
||||||
public Camera Camera;
|
public Camera Camera;
|
||||||
|
|
||||||
public static MouseInput MouseInput;
|
public static MouseInput MouseInput;
|
||||||
public List<Soldier> Squad;
|
public List<Soldier> Squad;
|
||||||
public static Map Map;
|
public List<SmallEnemy> Swarm;
|
||||||
|
public static Map Map;
|
||||||
public Core()
|
|
||||||
{
|
public Core()
|
||||||
graphics = new GraphicsDeviceManager(this);
|
{
|
||||||
Content.RootDirectory = "Content";
|
graphics = new GraphicsDeviceManager(this);
|
||||||
|
Content.RootDirectory = "Content";
|
||||||
graphics.PreferredBackBufferWidth = 1280;
|
|
||||||
graphics.PreferredBackBufferHeight = 720;
|
graphics.PreferredBackBufferWidth = 1280;
|
||||||
graphics.IsFullScreen = false;
|
graphics.PreferredBackBufferHeight = 720;
|
||||||
|
graphics.IsFullScreen = false;
|
||||||
//graphics.SynchronizeWithVerticalRetrace = false;
|
|
||||||
this.IsFixedTimeStep = false;
|
//graphics.SynchronizeWithVerticalRetrace = false;
|
||||||
graphics.ApplyChanges();
|
this.IsFixedTimeStep = false;
|
||||||
|
graphics.ApplyChanges();
|
||||||
this.IsMouseVisible = true;
|
|
||||||
}
|
this.IsMouseVisible = true;
|
||||||
|
}
|
||||||
/// <summary>
|
|
||||||
/// Allows the game to perform any initialization it needs to before starting to run.
|
/// <summary>
|
||||||
/// This is where it can query for any required services and load any non-graphic
|
/// Allows the game to perform any initialization it needs to before starting to run.
|
||||||
/// related content. Calling base.Initialize will enumerate through any components
|
/// This is where it can query for any required services and load any non-graphic
|
||||||
/// and initialize them as well.
|
/// related content. Calling base.Initialize will enumerate through any components
|
||||||
/// </summary>
|
/// and initialize them as well.
|
||||||
protected override void Initialize()
|
/// </summary>
|
||||||
{
|
protected override void Initialize()
|
||||||
// TODO: Add your initialization logic here
|
{
|
||||||
Camera = new Camera(this);
|
// TODO: Add your initialization logic here
|
||||||
Squad = new List<Soldier>();
|
Camera = new Camera(this);
|
||||||
|
Squad = new List<Soldier>();
|
||||||
base.Initialize();
|
Swarm = new List<SmallEnemy>();
|
||||||
}
|
|
||||||
|
base.Initialize();
|
||||||
/// <summary>
|
}
|
||||||
/// LoadContent will be called once per game and is the place to load
|
|
||||||
/// all of your content.
|
/// <summary>
|
||||||
/// </summary>
|
/// LoadContent will be called once per game and is the place to load
|
||||||
protected override void LoadContent()
|
/// all of your content.
|
||||||
{
|
/// </summary>
|
||||||
// Create a new SpriteBatch, which can be used to draw textures.
|
protected override void LoadContent()
|
||||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
{
|
||||||
|
// Create a new SpriteBatch, which can be used to draw textures.
|
||||||
Map = Content.Load<Map>("maps/Cave.Level1");
|
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
// Load map objects
|
|
||||||
Map.ParseObjects(this);
|
Map = Content.Load<Map>("maps/Cave.Level1");
|
||||||
|
// Load map objects
|
||||||
// TODO: use this.Content to load your game content here
|
Map.ParseObjects(this);
|
||||||
Soldier.LoadContent(this);
|
|
||||||
|
// TODO: use this.Content to load your game content here
|
||||||
MouseInput = new MouseInput(this);
|
Soldier.LoadContent(this);
|
||||||
MouseInput.LoadContent();
|
SmallEnemy.LoadContent(this);
|
||||||
}
|
|
||||||
|
MouseInput = new MouseInput(this);
|
||||||
/// <summary>
|
MouseInput.LoadContent();
|
||||||
/// UnloadContent will be called once per game and is the place to unload
|
}
|
||||||
/// all content.
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
protected override void UnloadContent()
|
/// UnloadContent will be called once per game and is the place to unload
|
||||||
{
|
/// all content.
|
||||||
// TODO: Unload any non ContentManager content here
|
/// </summary>
|
||||||
}
|
protected override void UnloadContent()
|
||||||
|
{
|
||||||
/// <summary>
|
// TODO: Unload any non ContentManager content here
|
||||||
/// Allows the game to run logic such as updating the world,
|
}
|
||||||
/// checking for collisions, gathering input, and playing audio.
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
/// Allows the game to run logic such as updating the world,
|
||||||
protected override void Update(GameTime gameTime)
|
/// checking for collisions, gathering input, and playing audio.
|
||||||
{
|
/// </summary>
|
||||||
// Allows the game to exit
|
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
|
protected override void Update(GameTime gameTime)
|
||||||
this.Exit();
|
{
|
||||||
|
// Allows the game to exit
|
||||||
Camera.Update(gameTime);
|
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
|
||||||
MouseInput.Update(gameTime);
|
this.Exit();
|
||||||
|
|
||||||
// Update soldiers in squad
|
Camera.Update(gameTime);
|
||||||
foreach (var soldier in Squad)
|
MouseInput.Update(gameTime);
|
||||||
soldier.Update(gameTime);
|
|
||||||
|
// Update soldiers in squad
|
||||||
base.Update(gameTime);
|
foreach (var soldier in Squad)
|
||||||
}
|
soldier.Update(gameTime);
|
||||||
|
|
||||||
/// <summary>
|
foreach (var body in Swarm)
|
||||||
/// This is called when the game should draw itself.
|
body.Update(gameTime);
|
||||||
/// </summary>
|
|
||||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
base.Update(gameTime);
|
||||||
protected override void Draw(GameTime gameTime)
|
}
|
||||||
{
|
|
||||||
GraphicsDevice.Clear(Color.Black);
|
/// <summary>
|
||||||
|
/// This is called when the game should draw itself.
|
||||||
// Start drawing using the Camera transform
|
/// </summary>
|
||||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null,
|
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||||
Camera.Transform);
|
protected override void Draw(GameTime gameTime)
|
||||||
|
{
|
||||||
// Draw the level
|
GraphicsDevice.Clear(Color.Black);
|
||||||
Map.Draw(spriteBatch);
|
|
||||||
|
// Start drawing using the Camera transform
|
||||||
// Draw units
|
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null,
|
||||||
foreach (var soldier in Squad)
|
Camera.Transform);
|
||||||
{
|
|
||||||
var sr = soldier.GetComponent<Component.SpriteRenderer>();
|
// Draw the level
|
||||||
if (sr != null)
|
Map.Draw(spriteBatch);
|
||||||
sr.Draw(spriteBatch);
|
|
||||||
}
|
// Draw units
|
||||||
|
foreach (var soldier in Squad)
|
||||||
// Draw mouse input visuals
|
{
|
||||||
MouseInput.Draw(spriteBatch);
|
var sr = soldier.GetComponent<Component.SpriteRenderer>();
|
||||||
|
if (sr != null)
|
||||||
spriteBatch.End();
|
sr.Draw(spriteBatch);
|
||||||
|
}
|
||||||
base.Draw(gameTime);
|
foreach (var body in Swarm)
|
||||||
}
|
{
|
||||||
}
|
var sr = body.GetComponent<Component.SpriteRenderer>();
|
||||||
}
|
if (sr != null)
|
||||||
|
sr.Draw(spriteBatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw mouse input visuals
|
||||||
|
MouseInput.Draw(spriteBatch);
|
||||||
|
|
||||||
|
spriteBatch.End();
|
||||||
|
|
||||||
|
base.Draw(gameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,196 +1,197 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectGuid>{94683C5B-052D-4143-96D8-35C67E831000}</ProjectGuid>
|
<ProjectGuid>{94683C5B-052D-4143-96D8-35C67E831000}</ProjectGuid>
|
||||||
<ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>DepthsBelow</RootNamespace>
|
<RootNamespace>DepthsBelow</RootNamespace>
|
||||||
<AssemblyName>DepthsBelow</AssemblyName>
|
<AssemblyName>DepthsBelow</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||||
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
|
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
|
||||||
<XnaPlatform>Windows</XnaPlatform>
|
<XnaPlatform>Windows</XnaPlatform>
|
||||||
<XnaProfile>HiDef</XnaProfile>
|
<XnaProfile>HiDef</XnaProfile>
|
||||||
<XnaCrossPlatformGroupID>faa0577e-a03e-43cf-89c7-0a03f4c22717</XnaCrossPlatformGroupID>
|
<XnaCrossPlatformGroupID>faa0577e-a03e-43cf-89c7-0a03f4c22717</XnaCrossPlatformGroupID>
|
||||||
<XnaOutputType>Game</XnaOutputType>
|
<XnaOutputType>Game</XnaOutputType>
|
||||||
<ApplicationIcon>Game.ico</ApplicationIcon>
|
<ApplicationIcon>Game.ico</ApplicationIcon>
|
||||||
<Thumbnail>GameThumbnail.png</Thumbnail>
|
<Thumbnail>GameThumbnail.png</Thumbnail>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<PublishUrl>publish\</PublishUrl>
|
<PublishUrl>publish\</PublishUrl>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
<InstallFrom>Disk</InstallFrom>
|
<InstallFrom>Disk</InstallFrom>
|
||||||
<UpdateEnabled>false</UpdateEnabled>
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
<UpdateMode>Foreground</UpdateMode>
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
<UpdateInterval>7</UpdateInterval>
|
<UpdateInterval>7</UpdateInterval>
|
||||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
<UpdatePeriodically>false</UpdatePeriodically>
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
<UpdateRequired>false</UpdateRequired>
|
<UpdateRequired>false</UpdateRequired>
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>1</ApplicationRevision>
|
<ApplicationRevision>1</ApplicationRevision>
|
||||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\x86\Debug</OutputPath>
|
<OutputPath>bin\x86\Debug</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
|
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<NoStdLib>true</NoStdLib>
|
<NoStdLib>true</NoStdLib>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<XnaCompressContent>false</XnaCompressContent>
|
<XnaCompressContent>false</XnaCompressContent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\x86\Release</OutputPath>
|
<OutputPath>bin\x86\Release</OutputPath>
|
||||||
<DefineConstants>TRACE;WINDOWS</DefineConstants>
|
<DefineConstants>TRACE;WINDOWS</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<NoStdLib>true</NoStdLib>
|
<NoStdLib>true</NoStdLib>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<XnaCompressContent>true</XnaCompressContent>
|
<XnaCompressContent>true</XnaCompressContent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ManifestCertificateThumbprint>ECE66DEF071576E8D2F7D57232C0569623E3E2DF</ManifestCertificateThumbprint>
|
<ManifestCertificateThumbprint>ECE66DEF071576E8D2F7D57232C0569623E3E2DF</ManifestCertificateThumbprint>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ManifestKeyFile>DepthsBelow_TemporaryKey.pfx</ManifestKeyFile>
|
<ManifestKeyFile>DepthsBelow_TemporaryKey.pfx</ManifestKeyFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<GenerateManifests>true</GenerateManifests>
|
<GenerateManifests>true</GenerateManifests>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SignManifests>true</SignManifests>
|
<SignManifests>true</SignManifests>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.GamerServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework.GamerServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Video, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework.Video, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Avatar, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework.Avatar, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="mscorlib">
|
<Reference Include="mscorlib">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System">
|
<Reference Include="System">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Xml">
|
<Reference Include="System.Xml">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Xml.Linq">
|
<Reference Include="System.Xml.Linq">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Net">
|
<Reference Include="System.Net">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Camera.cs" />
|
<Compile Include="Camera.cs" />
|
||||||
<Compile Include="Component\PathFinder.cs" />
|
<Compile Include="Component\PathFinder.cs" />
|
||||||
<Compile Include="Component\Transform.cs" />
|
<Compile Include="Component\Transform.cs" />
|
||||||
<Compile Include="Grid.cs" />
|
<Compile Include="Grid.cs" />
|
||||||
<Compile Include="Component\Collision.cs" />
|
<Compile Include="Component\Collision.cs" />
|
||||||
<Compile Include="Component\Component.cs" />
|
<Compile Include="Component\Component.cs" />
|
||||||
<Compile Include="Component\GridTransform.cs" />
|
<Compile Include="Component\GridTransform.cs" />
|
||||||
<Compile Include="Core.cs" />
|
<Compile Include="Core.cs" />
|
||||||
<Compile Include="Entity.cs" />
|
<Compile Include="Entity.cs" />
|
||||||
<Compile Include="Map.cs" />
|
<Compile Include="Map.cs" />
|
||||||
<Compile Include="MouseInput.cs" />
|
<Compile Include="MouseInput.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Component\SpriteRenderer.cs" />
|
<Compile Include="Component\SpriteRenderer.cs" />
|
||||||
<Compile Include="Soldier.cs" />
|
<Compile Include="SmallEnemy.cs" />
|
||||||
<Compile Include="Component\PixelTransform.cs" />
|
<Compile Include="Soldier.cs" />
|
||||||
</ItemGroup>
|
<Compile Include="Component\PixelTransform.cs" />
|
||||||
<ItemGroup>
|
</ItemGroup>
|
||||||
<Content Include="Game.ico" />
|
<ItemGroup>
|
||||||
<Content Include="GameThumbnail.png" />
|
<Content Include="Game.ico" />
|
||||||
</ItemGroup>
|
<Content Include="GameThumbnail.png" />
|
||||||
<ItemGroup>
|
</ItemGroup>
|
||||||
<ProjectReference Include="..\..\AStar\AStar.csproj">
|
<ItemGroup>
|
||||||
<Project>{CD3F949D-54AA-4D38-99DB-92905A375D84}</Project>
|
<ProjectReference Include="..\..\AStar\AStar.csproj">
|
||||||
<Name>AStar</Name>
|
<Project>{CD3F949D-54AA-4D38-99DB-92905A375D84}</Project>
|
||||||
</ProjectReference>
|
<Name>AStar</Name>
|
||||||
<ProjectReference Include="..\DepthsBelowContent\DepthsBelowContent.contentproj">
|
</ProjectReference>
|
||||||
<Name>DepthsBelowContent %28Content%29</Name>
|
<ProjectReference Include="..\DepthsBelowContent\DepthsBelowContent.contentproj">
|
||||||
<XnaReferenceType>Content</XnaReferenceType>
|
<Name>DepthsBelowContent %28Content%29</Name>
|
||||||
<Project>{433A77A2-DE52-4875-A4EF-232CF59C2DD3}</Project>
|
<XnaReferenceType>Content</XnaReferenceType>
|
||||||
</ProjectReference>
|
<Project>{433A77A2-DE52-4875-A4EF-232CF59C2DD3}</Project>
|
||||||
</ItemGroup>
|
</ProjectReference>
|
||||||
<ItemGroup>
|
</ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
<ItemGroup>
|
||||||
<Visible>False</Visible>
|
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
||||||
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
|
<Visible>False</Visible>
|
||||||
<Install>true</Install>
|
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
|
||||||
</BootstrapperPackage>
|
<Install>true</Install>
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
</BootstrapperPackage>
|
||||||
<Visible>False</Visible>
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
<Visible>False</Visible>
|
||||||
<Install>false</Install>
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
</BootstrapperPackage>
|
<Install>false</Install>
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
</BootstrapperPackage>
|
||||||
<Visible>False</Visible>
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
<Visible>False</Visible>
|
||||||
<Install>false</Install>
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
</BootstrapperPackage>
|
<Install>false</Install>
|
||||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
</BootstrapperPackage>
|
||||||
<Visible>False</Visible>
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
<ProductName>Windows Installer 3.1</ProductName>
|
<Visible>False</Visible>
|
||||||
<Install>true</Install>
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
</BootstrapperPackage>
|
<Install>true</Install>
|
||||||
<BootstrapperPackage Include="Microsoft.Xna.Framework.4.0">
|
</BootstrapperPackage>
|
||||||
<Visible>False</Visible>
|
<BootstrapperPackage Include="Microsoft.Xna.Framework.4.0">
|
||||||
<ProductName>Microsoft XNA Framework Redistributable 4.0</ProductName>
|
<Visible>False</Visible>
|
||||||
<Install>true</Install>
|
<ProductName>Microsoft XNA Framework Redistributable 4.0</ProductName>
|
||||||
</BootstrapperPackage>
|
<Install>true</Install>
|
||||||
</ItemGroup>
|
</BootstrapperPackage>
|
||||||
<ItemGroup>
|
</ItemGroup>
|
||||||
<None Include="DepthsBelow_TemporaryKey.pfx" />
|
<ItemGroup>
|
||||||
</ItemGroup>
|
<None Include="DepthsBelow_TemporaryKey.pfx" />
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
<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.
|
To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
<Target Name="BeforeBuild">
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
</Target>
|
<Target Name="BeforeBuild">
|
||||||
<Target Name="AfterBuild">
|
</Target>
|
||||||
</Target>
|
<Target Name="AfterBuild">
|
||||||
-->
|
</Target>
|
||||||
|
-->
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,169 +1,190 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using Microsoft.Xna.Framework.Media;
|
using Microsoft.Xna.Framework.Media;
|
||||||
|
|
||||||
namespace DepthsBelow
|
namespace DepthsBelow
|
||||||
{
|
{
|
||||||
public class MouseInput
|
public class MouseInput
|
||||||
{
|
{
|
||||||
Core core;
|
Core core;
|
||||||
MouseState lastMouseState;
|
MouseState lastMouseState;
|
||||||
Rectangle selectionRectangle;
|
Rectangle selectionRectangle;
|
||||||
Texture2D selectionTexture;
|
Texture2D selectionTexture;
|
||||||
Rectangle gridRectangle;
|
Rectangle gridRectangle;
|
||||||
Texture2D gridTexture;
|
Texture2D gridTexture;
|
||||||
|
|
||||||
Vector2 directionStart;
|
Vector2 directionStart;
|
||||||
Vector2 directionNow;
|
Vector2 directionNow;
|
||||||
|
|
||||||
bool checkingDirection = false;
|
bool checkingDirection = false;
|
||||||
|
bool readjust = false;
|
||||||
|
|
||||||
public MouseInput(Core core)
|
|
||||||
{
|
public MouseInput(Core core)
|
||||||
this.core = core;
|
{
|
||||||
|
this.core = core;
|
||||||
selectionRectangle = Rectangle.Empty;
|
|
||||||
gridRectangle = Rectangle.Empty;
|
selectionRectangle = Rectangle.Empty;
|
||||||
}
|
gridRectangle = Rectangle.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadContent()
|
|
||||||
{
|
public void LoadContent()
|
||||||
selectionTexture = new Texture2D(core.GraphicsDevice, 1, 1);
|
{
|
||||||
selectionTexture.SetData(new Color[] { Color.White });
|
selectionTexture = new Texture2D(core.GraphicsDevice, 1, 1);
|
||||||
|
selectionTexture.SetData(new Color[] { Color.White });
|
||||||
gridTexture = new Texture2D(core.GraphicsDevice, 1, 1);
|
|
||||||
gridTexture.SetData(new Color[] { Color.White });
|
gridTexture = new Texture2D(core.GraphicsDevice, 1, 1);
|
||||||
}
|
gridTexture.SetData(new Color[] { Color.White });
|
||||||
|
}
|
||||||
public void Update(GameTime gameTime)
|
|
||||||
{
|
public void Update(GameTime gameTime)
|
||||||
MouseState ms = Mouse.GetState();
|
{
|
||||||
Vector2 mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(ms.X, ms.Y));
|
MouseState ms = Mouse.GetState();
|
||||||
KeyboardState ks = Keyboard.GetState();
|
Vector2 mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(ms.X, ms.Y));
|
||||||
|
KeyboardState ks = Keyboard.GetState();
|
||||||
// Selection rectangle
|
|
||||||
if (ms.LeftButton == ButtonState.Pressed)
|
// Selection rectangle
|
||||||
{
|
if (ms.LeftButton == ButtonState.Pressed)
|
||||||
if (selectionRectangle == Rectangle.Empty)
|
{
|
||||||
{
|
|
||||||
selectionRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 0, 0);
|
if (selectionRectangle == Rectangle.Empty)
|
||||||
}
|
{
|
||||||
else
|
directionStart = mouseWorldPos;
|
||||||
{
|
selectionRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 0, 0);
|
||||||
selectionRectangle.Width = (int)mouseWorldPos.X - selectionRectangle.X;
|
readjust = false;
|
||||||
selectionRectangle.Height = (int)mouseWorldPos.Y - selectionRectangle.Y;
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
// When the mouse is released
|
if (mouseWorldPos.X > directionStart.X && mouseWorldPos.Y < directionStart.Y || mouseWorldPos.X < directionStart.X && mouseWorldPos.Y > directionStart.Y)
|
||||||
if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty)
|
{
|
||||||
{
|
int rectangleX = (int)mouseWorldPos.X - ((int)mouseWorldPos.X - (int)directionStart.X);
|
||||||
// Deselect all units
|
int rectangleY = (int)mouseWorldPos.Y;
|
||||||
if (!ks.IsKeyDown(Keys.LeftControl))
|
int rectangleWidth = (int)mouseWorldPos.X - (int)directionStart.X;
|
||||||
{
|
int rectangleHeight = (int)directionStart.Y - (int)mouseWorldPos.Y;
|
||||||
foreach (var unit in core.Squad)
|
selectionRectangle = new Rectangle(rectangleX, rectangleY, rectangleWidth, rectangleHeight);
|
||||||
unit.Selected = false;
|
readjust = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// Select all units in the rectangle
|
{
|
||||||
foreach (var unit in core.Squad)
|
if (readjust == true)
|
||||||
{
|
{
|
||||||
if (selectionRectangle.Intersects(unit.GetComponent<Component.Collision>().Rectangle))
|
selectionRectangle = new Rectangle((int)directionStart.X, (int)directionStart.Y, 0, 0);
|
||||||
unit.Selected = true;
|
}
|
||||||
}
|
selectionRectangle.Width = (int)mouseWorldPos.X - selectionRectangle.X;
|
||||||
|
selectionRectangle.Height = (int)mouseWorldPos.Y - selectionRectangle.Y;
|
||||||
// Hide the selection rectangle
|
readjust = false;
|
||||||
selectionRectangle = Rectangle.Empty;
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Send orders with right click
|
// When the mouse is released
|
||||||
if (ms.RightButton == ButtonState.Released && lastMouseState.RightButton == ButtonState.Pressed)
|
if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty)
|
||||||
{
|
{
|
||||||
foreach (var unit in core.Squad)
|
// Deselect all units
|
||||||
if (unit.Selected)
|
if (!ks.IsKeyDown(Keys.LeftControl))
|
||||||
{
|
{
|
||||||
unit.GetComponent<Component.PathFinder>().Goal = Grid.WorldToGrid(mouseWorldPos);
|
foreach (var unit in core.Squad)
|
||||||
}
|
unit.Selected = false;
|
||||||
|
}
|
||||||
}
|
|
||||||
if (ms.RightButton == ButtonState.Pressed)
|
// Select all units in the rectangle
|
||||||
{
|
foreach (var unit in core.Squad)
|
||||||
foreach (var unit in core.Squad)
|
{
|
||||||
{
|
if (selectionRectangle.Intersects(unit.GetComponent<Component.Collision>().Rectangle))
|
||||||
if (unit.Selected && gridRectangle.Intersects(unit.GetComponent<Component.Collision>().Rectangle))
|
unit.Selected = true;
|
||||||
{
|
}
|
||||||
checkingDirection = true;
|
|
||||||
directionStart = unit.Transform.World + unit.Transform.World.Origin;
|
// Hide the selection rectangle
|
||||||
}
|
selectionRectangle = Rectangle.Empty;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (checkingDirection == true && ms.RightButton == ButtonState.Pressed)
|
// Send orders with right click
|
||||||
{
|
if (ms.RightButton == ButtonState.Released && lastMouseState.RightButton == ButtonState.Pressed)
|
||||||
foreach (var unit in core.Squad)
|
{
|
||||||
if (unit.Selected)
|
foreach (var unit in core.Squad)
|
||||||
{
|
if (unit.Selected)
|
||||||
directionNow.X = mouseWorldPos.X;
|
{
|
||||||
directionNow.Y = mouseWorldPos.Y;
|
unit.GetComponent<Component.PathFinder>().Goal = Grid.WorldToGrid(mouseWorldPos);
|
||||||
float directionX = mouseWorldPos.X - unit.Transform.World.X;
|
}
|
||||||
float directionY = mouseWorldPos.Y - unit.Transform.World.Y;
|
|
||||||
var mouseDirection = mouseWorldPos;
|
}
|
||||||
mouseDirection.Normalize();
|
if (ms.RightButton == ButtonState.Pressed)
|
||||||
//float angle = (float)Math.Acos(Vector2.Dot(new Vector2(0, 1), mouseDirection)) * MathHelper.TwoPi;
|
{
|
||||||
/*if (directionX < 0)
|
foreach (var unit in core.Squad)
|
||||||
{
|
{
|
||||||
directionX *= -1;
|
if (unit.Selected && gridRectangle.Intersects(unit.GetComponent<Component.Collision>().Rectangle))
|
||||||
unit.GetComponent<Component.Transform>().World.Rotation = (float)Math.Atan(directionY / directionX);
|
{
|
||||||
}
|
checkingDirection = true;
|
||||||
else
|
directionStart = unit.Transform.World + unit.Transform.World.Origin;
|
||||||
{
|
}
|
||||||
*/unit.GetComponent<Component.Transform>().World.Rotation = (float)Math.Atan2(mouseWorldPos.Y - unit.Transform.World.Y, mouseWorldPos.X - unit.Transform.World.X);/*
|
}
|
||||||
}*/
|
}
|
||||||
//Console.WriteLine(angle);
|
if (checkingDirection == true && ms.RightButton == ButtonState.Pressed)
|
||||||
//unit.GetComponent<Component.Transform>().World.Rotation = angle;
|
{
|
||||||
}
|
foreach (var unit in core.Squad)
|
||||||
}
|
if (unit.Selected)
|
||||||
else
|
{
|
||||||
{
|
directionNow.X = mouseWorldPos.X;
|
||||||
checkingDirection = false;
|
directionNow.Y = mouseWorldPos.Y;
|
||||||
}
|
float directionX = mouseWorldPos.X - unit.Transform.World.X;
|
||||||
|
float directionY = mouseWorldPos.Y - unit.Transform.World.Y;
|
||||||
// Grid highlighting
|
var mouseDirection = mouseWorldPos;
|
||||||
Point mouseGridPos = Grid.WorldToGrid(mouseWorldPos);
|
mouseDirection.Normalize();
|
||||||
Vector2 rectWorldPos = Grid.GridToWorld(mouseGridPos);
|
//float angle = (float)Math.Acos(Vector2.Dot(new Vector2(0, 1), mouseDirection)) * MathHelper.TwoPi;
|
||||||
gridRectangle = new Rectangle((int)rectWorldPos.X, (int)rectWorldPos.Y, Grid.TileSize, Grid.TileSize);
|
/*if (directionX < 0)
|
||||||
|
{
|
||||||
lastMouseState = ms;
|
directionX *= -1;
|
||||||
}
|
unit.GetComponent<Component.Transform>().World.Rotation = (float)Math.Atan(directionY / directionX);
|
||||||
|
}
|
||||||
public void Draw(SpriteBatch spriteBatch)
|
else
|
||||||
{
|
{
|
||||||
spriteBatch.Draw(selectionTexture, selectionRectangle, Color.Red * 0.5f);
|
*/unit.GetComponent<Component.Transform>().World.Rotation = (float)Math.Atan2(mouseWorldPos.Y - unit.Transform.World.Y, mouseWorldPos.X - unit.Transform.World.X);/*
|
||||||
spriteBatch.Draw(gridTexture, gridRectangle, Color.Yellow * 0.3f);
|
}*/
|
||||||
|
//Console.WriteLine(angle);
|
||||||
if (checkingDirection == true)
|
//unit.GetComponent<Component.Transform>().World.Rotation = angle;
|
||||||
{
|
}
|
||||||
Texture2D blank = new Texture2D(core.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
|
}
|
||||||
blank.SetData(new[] { Color.White });
|
else
|
||||||
DrawLine(spriteBatch, blank, 2, Color.White, directionStart, directionNow);
|
{
|
||||||
}
|
checkingDirection = false;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
// Grid highlighting
|
||||||
void DrawLine(SpriteBatch batch, Texture2D blank, float width, Color color, Vector2 point1, Vector2 point2)
|
Point mouseGridPos = Grid.WorldToGrid(mouseWorldPos);
|
||||||
{
|
Vector2 rectWorldPos = Grid.GridToWorld(mouseGridPos);
|
||||||
float angle = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
|
gridRectangle = new Rectangle((int)rectWorldPos.X, (int)rectWorldPos.Y, Grid.TileSize, Grid.TileSize);
|
||||||
float length = Vector2.Distance(point1, point2);
|
|
||||||
|
lastMouseState = ms;
|
||||||
batch.Draw(blank, point1, null, color,
|
}
|
||||||
angle, Vector2.Zero, new Vector2(length, width),
|
|
||||||
SpriteEffects.None, 0);
|
public void Draw(SpriteBatch spriteBatch)
|
||||||
}
|
{
|
||||||
}
|
spriteBatch.Draw(selectionTexture, selectionRectangle, Color.Red * 0.5f);
|
||||||
}
|
spriteBatch.Draw(gridTexture, gridRectangle, Color.Yellow * 0.3f);
|
||||||
|
|
||||||
|
if (checkingDirection == true)
|
||||||
|
{
|
||||||
|
Texture2D blank = new Texture2D(core.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
|
||||||
|
blank.SetData(new[] { Color.White });
|
||||||
|
DrawLine(spriteBatch, blank, 2, Color.White, directionStart, directionNow);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawLine(SpriteBatch batch, Texture2D blank, float width, Color color, Vector2 point1, Vector2 point2)
|
||||||
|
{
|
||||||
|
float angle = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
|
||||||
|
float length = Vector2.Distance(point1, point2);
|
||||||
|
|
||||||
|
batch.Draw(blank, point1, null, color,
|
||||||
|
angle, Vector2.Zero, new Vector2(length, width),
|
||||||
|
SpriteEffects.None, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using DepthsBelow.Component;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
|
namespace DepthsBelow
|
||||||
|
{
|
||||||
|
public class SmallEnemy : Entity
|
||||||
|
{
|
||||||
|
public static Texture2D Texture;
|
||||||
|
public Color Color;
|
||||||
|
public static Point Origin;
|
||||||
|
private bool _selected; //I guess as in "currently doing something"
|
||||||
|
|
||||||
|
public List<SmallEnemy> Swarm;
|
||||||
|
|
||||||
|
private PathFinder.Node nextNode;
|
||||||
|
|
||||||
|
public SmallEnemy(Core core, ref List<SmallEnemy> swarm)
|
||||||
|
: base(core)
|
||||||
|
{
|
||||||
|
if (Texture == null)
|
||||||
|
LoadContent(core);
|
||||||
|
|
||||||
|
this.Swarm = swarm;
|
||||||
|
|
||||||
|
Transform.World.Origin = new Vector2(16, 16);
|
||||||
|
|
||||||
|
this.Color = Color.White;
|
||||||
|
var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White };
|
||||||
|
AddComponent(rc);
|
||||||
|
|
||||||
|
var cc = new Collision(this, 32, 32);
|
||||||
|
AddComponent(cc);
|
||||||
|
|
||||||
|
var pfc = new PathFinder(this);
|
||||||
|
AddComponent(pfc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Selected
|
||||||
|
{
|
||||||
|
get { return _selected; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_selected = value;
|
||||||
|
GetComponent<SpriteRenderer>().Color = (value) ? Color.Blue : this.Color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadContent(Core core)
|
||||||
|
{
|
||||||
|
Texture = core.Content.Load<Texture2D>("images/Monster");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
base.Update(gameTime);
|
||||||
|
|
||||||
|
float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
|
||||||
|
|
||||||
|
if (nextNode == null)
|
||||||
|
nextNode = GetComponent<PathFinder>().Next();
|
||||||
|
|
||||||
|
if (nextNode != null)
|
||||||
|
{
|
||||||
|
List<Point> soldierCollisions = new List<Point>();
|
||||||
|
|
||||||
|
foreach (var body in Swarm)
|
||||||
|
{
|
||||||
|
if (body != this)
|
||||||
|
{
|
||||||
|
if (body.Transform.Grid == nextNode.Position)
|
||||||
|
{
|
||||||
|
soldierCollisions.Add(body.Transform.Grid);
|
||||||
|
GetComponent<PathFinder>().RecreatePath(soldierCollisions);
|
||||||
|
nextNode = GetComponent<PathFinder>().Next();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (nextNode != null)
|
||||||
|
{
|
||||||
|
var nodeWorldPos = Grid.GridToWorld(nextNode.Position);
|
||||||
|
// HACK: Make this work properly with other speeds...
|
||||||
|
float speed = 4f;
|
||||||
|
if (Transform.World.X < nodeWorldPos.X)
|
||||||
|
Transform.World.X += speed;
|
||||||
|
if (Transform.World.X > nodeWorldPos.X)
|
||||||
|
Transform.World.X -= speed;
|
||||||
|
if (Transform.World.Y < nodeWorldPos.Y)
|
||||||
|
Transform.World.Y += speed;
|
||||||
|
if (Transform.World.Y > nodeWorldPos.Y)
|
||||||
|
Transform.World.Y -= speed;
|
||||||
|
|
||||||
|
if (Transform.World == nodeWorldPos)
|
||||||
|
nextNode = GetComponent<PathFinder>().Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,110 +1,117 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectGuid>{433A77A2-DE52-4875-A4EF-232CF59C2DD3}</ProjectGuid>
|
<ProjectGuid>{433A77A2-DE52-4875-A4EF-232CF59C2DD3}</ProjectGuid>
|
||||||
<ProjectTypeGuids>{96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
|
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
|
||||||
<OutputPath>bin\$(Platform)\$(Configuration)</OutputPath>
|
<OutputPath>bin\$(Platform)\$(Configuration)</OutputPath>
|
||||||
<ContentRootDirectory>Content</ContentRootDirectory>
|
<ContentRootDirectory>Content</ContentRootDirectory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<RootNamespace>DepthsBelowContent</RootNamespace>
|
<RootNamespace>DepthsBelowContent</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.EffectImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.EffectImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.FBXImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.FBXImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.TextureImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.TextureImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.AudioImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.AudioImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.VideoImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.VideoImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="images\soldier.png">
|
<Compile Include="images\soldier.png">
|
||||||
<Name>soldier</Name>
|
<Name>soldier</Name>
|
||||||
<Importer>TextureImporter</Importer>
|
<Importer>TextureImporter</Importer>
|
||||||
<Processor>TextureProcessor</Processor>
|
<Processor>TextureProcessor</Processor>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="maps\test.tmx">
|
<Compile Include="maps\test.tmx">
|
||||||
<Name>test</Name>
|
<Name>test</Name>
|
||||||
<Importer>TmxImporter</Importer>
|
<Importer>TmxImporter</Importer>
|
||||||
<Processor>MapProcessor</Processor>
|
<Processor>MapProcessor</Processor>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\TiledLib\TiledLib\TiledLib.csproj">
|
<ProjectReference Include="..\..\TiledLib\TiledLib\TiledLib.csproj">
|
||||||
<Project>{EC3F6988-459C-4783-89E9-F34C0CC731C7}</Project>
|
<Project>{EC3F6988-459C-4783-89E9-F34C0CC731C7}</Project>
|
||||||
<Name>TiledLib</Name>
|
<Name>TiledLib</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\DepthsBelowContentPipeline\DepthsBelowContentPipeline.csproj">
|
<ProjectReference Include="..\DepthsBelowContentPipeline\DepthsBelowContentPipeline.csproj">
|
||||||
<Project>{D054E3A6-7E05-4255-984F-69FE40D9137F}</Project>
|
<Project>{D054E3A6-7E05-4255-984F-69FE40D9137F}</Project>
|
||||||
<Name>DepthsBelowContentPipeline</Name>
|
<Name>DepthsBelowContentPipeline</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="maps\tilesets\aztek.jpg">
|
<Compile Include="maps\tilesets\aztek.jpg">
|
||||||
<Name>aztek</Name>
|
<Name>aztek</Name>
|
||||||
<Importer>TextureImporter</Importer>
|
<Importer>TextureImporter</Importer>
|
||||||
<Processor>TextureProcessor</Processor>
|
<Processor>TextureProcessor</Processor>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="images\soldier2.png">
|
<Compile Include="images\soldier2.png">
|
||||||
<Name>soldier2</Name>
|
<Name>soldier2</Name>
|
||||||
<Importer>TextureImporter</Importer>
|
<Importer>TextureImporter</Importer>
|
||||||
<Processor>TextureProcessor</Processor>
|
<Processor>TextureProcessor</Processor>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="maps\tilesets\collision.png">
|
<Compile Include="maps\tilesets\collision.png">
|
||||||
<Name>collision</Name>
|
<Name>collision</Name>
|
||||||
<Importer>TextureImporter</Importer>
|
<Importer>TextureImporter</Importer>
|
||||||
<Processor>TextureProcessor</Processor>
|
<Processor>TextureProcessor</Processor>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="maps\Cave.Level1.tmx">
|
<Compile Include="maps\Cave.Level1.tmx">
|
||||||
<Name>Cave.Level1</Name>
|
<Name>Cave.Level1</Name>
|
||||||
<Processor>MapProcessor</Processor>
|
<Processor>MapProcessor</Processor>
|
||||||
<Importer>TmxImporter</Importer>
|
<Importer>TmxImporter</Importer>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="maps\tilesets\cave.png">
|
<Compile Include="maps\tilesets\cave.png">
|
||||||
<Name>cave</Name>
|
<Name>cave</Name>
|
||||||
<Importer>TextureImporter</Importer>
|
<Importer>TextureImporter</Importer>
|
||||||
<Processor>TextureProcessor</Processor>
|
<Processor>TextureProcessor</Processor>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
|
<ItemGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<Compile Include="images\Monster.png">
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
<Name>Monster</Name>
|
||||||
<Target Name="BeforeBuild">
|
<Importer>TextureImporter</Importer>
|
||||||
</Target>
|
<Processor>TextureProcessor</Processor>
|
||||||
<Target Name="AfterBuild">
|
</Compile>
|
||||||
</Target>
|
</ItemGroup>
|
||||||
-->
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.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>
|
</Project>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Reference in New Issue
Block a user