Merge branch 'master' of github.com:sippeangelo/DepthsBelow

This commit is contained in:
2012-10-17 11:28:05 +02:00
9 changed files with 793 additions and 690 deletions
@@ -1,62 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DepthsBelow.Component
{
class Shooting : Component
{
protected int stepsTaken = 0;
protected int distanceToTarget = 0;
protected int panic = 0;
protected int soldierAim = 0;
protected int weaponAccuracy = 0;
protected int enemyDodge = 0;
protected int penaltyRange = 5;
public Shooting(Entity parent) : base (parent)
{
}
public bool targetInSight()
{
return false;
}
public int CalculateChance()
{
int baseHitChance = soldierAim + weaponAccuracy;
int baseDodgeChance = panic + enemyDodge;
int basePenalty = ReturnPenalty(stepsTaken) + (int)(ReturnPenalty(distanceToTarget) / 2);
int chanceToHit = baseHitChance - baseDodgeChance - basePenalty;
return chanceToHit;
}
public int ReturnPenalty(int distance)
{
int penalty = 0;
if (distance >= penaltyRange * 3)
{
penalty = 100;
}
else if (distance >= penaltyRange * 2)
{
distance -= penaltyRange * 2;
penalty = penaltyRange + penaltyRange * 3 + distance * 5;
}
else if (distance >= penaltyRange)
{
distance -= penaltyRange;
penalty = penaltyRange + distance * 3;
}
else
{
penalty = distance;
}
return penalty;
}
}
}
+101
View File
@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DepthsBelow.Component
{
public class Stat : Component
{
protected int hp = 0;
protected int defence = 0;
protected int stepsTaken = 0;
protected int distanceToTarget = 0;
protected int panic = 0;
protected int soldierAim = 100;
protected int weaponAccuracy = 0;
protected int weaponStrength = 0;
protected int ammo = 0;
protected int enemyDodge = 0;
protected int penaltyRange = 5;
public int GetAim
{
get { return soldierAim + weaponAccuracy; }
set { soldierAim = value; }
}
public int GetDodge
{
get { return enemyDodge; }
set { enemyDodge = value; }
}
public int Life
{
get { return hp; }
set
{
hp = value;
if (hp <= 0) {
//If you kill me, I will become stronger than you can ever imagine.
Kill();
}
}
}
public int Defence
{
get { return defence; }
set { defence = value; }
}
public int Strength
{
get { return weaponStrength; }
set { weaponStrength = value; }
}
public void Kill()
{
hp = 0;
}
public int Penalty(int distance)
{
return panic + GetPenalty(stepsTaken) + (int)(GetPenalty(distance) / 2);
}
public Stat(Entity parent) : base (parent)
{
}
public bool targetInSight()
{
return false;
}
public int GetPenalty(int distance)
{
int penalty = 0;
if (distance >= penaltyRange * 3)
{
penalty = 100;
}
else if (distance >= penaltyRange * 2)
{
distance -= penaltyRange * 2;
penalty = penaltyRange + penaltyRange * 3 + distance * 5;
}
else if (distance >= penaltyRange)
{
distance -= penaltyRange;
penalty = penaltyRange + distance * 3;
}
else
{
penalty = distance;
}
return penalty;
}
}
}
+203 -213
View File
@@ -1,213 +1,203 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using DepthsBelow.GUI; using DepthsBelow.GUI;
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
{ {
public static GraphicsDeviceManager GraphicsDeviceManager; public static GraphicsDeviceManager GraphicsDeviceManager;
SpriteBatch spriteBatch; SpriteBatch spriteBatch;
public Lua Lua; public Lua Lua;
public Camera Camera; public Camera Camera;
public bool PlayerTurn = true; public bool PlayerTurn = true;
public static MouseInput MouseInput; public static MouseInput MouseInput;
public static KeyboardInput KeyboardInput; public static KeyboardInput KeyboardInput;
public List<Soldier> Squad; public List<Soldier> Squad;
public List<SmallEnemy> Swarm; public List<SmallEnemy> Swarm;
public List<Shot> Volley; public List<Shot> Volley;
public static Map Map; public static Map Map;
public SmallEnemy TestMonster; public SmallEnemy TestMonster;
public Core() public Core()
{ {
GraphicsDeviceManager = new GraphicsDeviceManager(this); GraphicsDeviceManager = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content"; Content.RootDirectory = "Content";
GraphicsDeviceManager.PreferredBackBufferWidth = 1280; GraphicsDeviceManager.PreferredBackBufferWidth = 1280;
GraphicsDeviceManager.PreferredBackBufferHeight = 720; GraphicsDeviceManager.PreferredBackBufferHeight = 720;
GraphicsDeviceManager.IsFullScreen = false; GraphicsDeviceManager.IsFullScreen = false;
//graphics.SynchronizeWithVerticalRetrace = false; //graphics.SynchronizeWithVerticalRetrace = false;
this.IsFixedTimeStep = false; this.IsFixedTimeStep = false;
GraphicsDeviceManager.ApplyChanges(); GraphicsDeviceManager.ApplyChanges();
this.IsMouseVisible = true; this.IsMouseVisible = true;
GameServices.AddService<GraphicsDevice>(GraphicsDevice); GameServices.AddService<GraphicsDevice>(GraphicsDevice);
GameServices.AddService<ContentManager>(Content); GameServices.AddService<ContentManager>(Content);
} }
/// <summary> /// <summary>
/// Allows the game to perform any initialization it needs to before starting to run. /// 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 /// 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 /// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well. /// and initialize them as well.
/// </summary> /// </summary>
protected override void Initialize() protected override void Initialize()
{ {
// TODO: Add your initialization logic here // TODO: Add your initialization logic here
Camera = new Camera(this); Camera = new Camera(this);
Squad = new List<Soldier>(); Squad = new List<Soldier>();
Swarm = new List<SmallEnemy>(); Swarm = new List<SmallEnemy>();
Volley = new List<Shot>(); Volley = new List<Shot>();
TestMonster = new SmallEnemy(this, ref Swarm); TestMonster = new SmallEnemy(this, ref Swarm);
// Run scripts after everything is initialized // Run scripts after everything is initialized
Lua = new Lua(); Lua = new Lua();
Lua.LoadScripts(); Lua.LoadScripts();
base.Initialize(); base.Initialize();
} }
/// <summary> /// <summary>
/// LoadContent will be called once per game and is the place to load /// LoadContent will be called once per game and is the place to load
/// all of your content. /// all of your content.
/// </summary> /// </summary>
protected override void LoadContent() protected override void LoadContent()
{ {
// Create a new SpriteBatch, which can be used to draw textures. // Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice); spriteBatch = new SpriteBatch(GraphicsDevice);
Map = Content.Load<Map>("maps/Cave.Level1"); Map = Content.Load<Map>("maps/Cave.Level1");
// Load map objects // Load map objects
Map.ParseObjects(this); Map.ParseObjects(this);
// TODO: use this.Content to load your game content here // TODO: use this.Content to load your game content here
Soldier.LoadContent(this); Soldier.LoadContent(this);
SmallEnemy.LoadContent(this); SmallEnemy.LoadContent(this);
Shot.LoadContent(this); Shot.LoadContent(this);
MouseInput = new MouseInput(this); MouseInput = new MouseInput(this);
MouseInput.LoadContent(); MouseInput.LoadContent();
KeyboardInput = new KeyboardInput(this); KeyboardInput = new KeyboardInput(this);
TestMonster.X = 12; Swarm.Add(TestMonster);
TestMonster.Y = 4;
TestMonster.X = 12;
//frame.Add(text); TestMonster.Y = 4;
}
//frame.Add(text);
/// <summary> }
/// UnloadContent will be called once per game and is the place to unload
/// all content. /// <summary>
/// </summary> /// UnloadContent will be called once per game and is the place to unload
protected override void UnloadContent() /// all content.
{ /// </summary>
// TODO: Unload any non ContentManager content here protected override void UnloadContent()
} {
// 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>
/// </summary> /// Allows the game to run logic such as updating the world,
/// <param name="gameTime">Provides a snapshot of timing values.</param> /// checking for collisions, gathering input, and playing audio.
protected override void Update(GameTime gameTime) /// </summary>
{ /// <param name="gameTime">Provides a snapshot of timing values.</param>
// Allows the game to exit protected override void Update(GameTime gameTime)
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) {
this.Exit(); // Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
Camera.Update(gameTime); this.Exit();
MouseInput.Update(gameTime);
KeyboardInput.Update(gameTime); Camera.Update(gameTime);
MouseInput.Update(gameTime);
// Update soldiers in squad KeyboardInput.Update(gameTime);
foreach (var soldier in Squad)
soldier.Update(gameTime); // Update soldiers in squad
foreach (var soldier in Squad)
foreach (var body in Swarm) soldier.Update(gameTime);
body.Update(gameTime);
foreach (var body in Swarm)
foreach (var bullet in Volley) body.Update(gameTime);
bullet.Update(gameTime);
foreach (var bullet in Volley)
TestMonster.Update(gameTime); bullet.Update(gameTime);
GUIManager.Update(gameTime);
TestMonster.Update(gameTime);
base.Update(gameTime); GUIManager.Update(gameTime);
}
base.Update(gameTime);
public int FindDistance(Vector2 target, Vector2 start) }
{
Vector2 combine = new Vector2(target.X - start.X, target.Y - start.Y); /// <summary>
/// This is called when the game should draw itself.
int result = 0; /// </summary>
int firstRestult = (int)Math.Sqrt((int)combine.X^2 + (int)combine.Y^2); /// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
result = (int)Vector2.Distance(target, start); {
GraphicsDevice.Clear(Color.Black);
return result;
} // Start drawing using the Camera transform
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null,
/// <summary> Camera.Transform);
/// This is called when the game should draw itself.
/// </summary> // Draw the level
/// <param name="gameTime">Provides a snapshot of timing values.</param> Map.Draw(spriteBatch);
protected override void Draw(GameTime gameTime)
{ // Draw units
GraphicsDevice.Clear(Color.Black); foreach (var soldier in Squad)
{
// Start drawing using the Camera transform var sr = soldier.GetComponent<Component.SpriteRenderer>();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, if (sr != null)
Camera.Transform); sr.Draw(spriteBatch);
}
// Draw the level foreach (var body in Swarm)
Map.Draw(spriteBatch); {
var sr = body.GetComponent<Component.SpriteRenderer>();
// Draw units if (sr != null)
foreach (var soldier in Squad) sr.Draw(spriteBatch);
{ }
var sr = soldier.GetComponent<Component.SpriteRenderer>(); foreach (var bullet in Volley)
if (sr != null) {
sr.Draw(spriteBatch); var sr = bullet.GetComponent<Component.SpriteRenderer>();
} if (sr != null)
foreach (var body in Swarm) sr.Draw(spriteBatch);
{ }
var sr = body.GetComponent<Component.SpriteRenderer>();
if (sr != null) // Draw mouse input visuals
sr.Draw(spriteBatch); MouseInput.Draw(spriteBatch);
}
foreach (var bullet in Volley) TestMonster.GetComponent<Component.SpriteRenderer>().Draw(spriteBatch);
{
var sr = bullet.GetComponent<Component.SpriteRenderer>(); spriteBatch.End();
if (sr != null)
sr.Draw(spriteBatch); // Start drawing GUI components
} spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, null, null, null, Matrix.Identity);
GUIManager.Draw(spriteBatch);
// Draw mouse input visuals spriteBatch.End();
MouseInput.Draw(spriteBatch);
base.Draw(gameTime);
TestMonster.GetComponent<Component.SpriteRenderer>().Draw(spriteBatch); }
spriteBatch.End();
}
// Start drawing GUI components }
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, null, null, null, Matrix.Identity);
GUIManager.Draw(spriteBatch);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
+202 -201
View File
@@ -1,203 +1,204 @@
<?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="LuaInterface, Version=2.0.0.16708, Culture=neutral, processorArchitecture=x86"> <Reference Include="LuaInterface, Version=2.0.0.16708, Culture=neutral, processorArchitecture=x86">
<HintPath>..\..\LuaInterface\LuaInterface.dll</HintPath> <HintPath>..\..\LuaInterface\LuaInterface.dll</HintPath>
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
</Reference> </Reference>
<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.Core"> <Reference Include="System.Core">
<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="CustomExtensions.cs" /> <Compile Include="CustomExtensions.cs" />
<Compile Include="GameServices.cs" /> <Compile Include="GameServices.cs" />
<Compile Include="Interface.cs" /> <Compile Include="Interface.cs" />
<Compile Include="Lua.cs" /> <Compile Include="Lua.cs" />
<Compile Include="Shot.cs" /> <Compile Include="Shot.cs" />
<Compile Include="Component\Shooting.cs" /> <Compile Include="Component\Stat.cs" />
<Compile Include="GUIManager.cs" /> <Compile Include="GUIManager.cs" />
<Compile Include="GUI\Button.cs" /> <Compile Include="GUI\Button.cs" />
<Compile Include="GUI\Frame.cs" /> <Compile Include="GUI\Frame.cs" />
<Compile Include="GUI\Text.cs" /> <Compile Include="GUI\Text.cs" />
<Compile Include="KeyboardInput.cs" /> <Compile Include="KeyboardInput.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="RenderHelpers.cs" /> <Compile Include="RenderHelpers.cs" />
<Compile Include="SmallEnemy.cs" /> <Compile Include="SmallEnemy.cs" />
<Compile Include="Soldier.cs" /> <Compile Include="Soldier.cs" />
<Compile Include="Component\PixelTransform.cs" /> <Compile Include="Component\PixelTransform.cs" />
</ItemGroup> <Compile Include="Utility.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="App.config" /> <ItemGroup>
<None Include="DepthsBelow_TemporaryKey.pfx" /> <None Include="App.config" />
</ItemGroup> <None Include="DepthsBelow_TemporaryKey.pfx" />
<ItemGroup /> </ItemGroup>
<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. 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. Other similar extension points exist, see Microsoft.Common.targets.
@@ -205,5 +206,5 @@
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
+73 -70
View File
@@ -1,70 +1,73 @@
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;
namespace DepthsBelow namespace DepthsBelow
{ {
public class Entity public class Entity
{ {
List<Component.Component> Components; List<Component.Component> Components;
public Component.Transform Transform; public Component.Transform Transform;
public Component.PixelTransform pixelTransform; public Component.PixelTransform pixelTransform;
public Component.GridTransform gridTransform; public Component.GridTransform gridTransform;
public int X public Component.Stat stat;
{ public int X
get { return this.Transform.Grid.X; } {
set get { return this.Transform.Grid.X; }
{ set
this.Transform.Grid.X = value; {
} this.Transform.Grid.X = value;
} }
public int Y }
{ public int Y
get { return this.Transform.Grid.Y; } {
set get { return this.Transform.Grid.Y; }
{ set
this.Transform.Grid.Y = value; {
} this.Transform.Grid.Y = value;
} }
}
protected Core core;
protected Core core;
public Entity(Core core)
{ public Entity(Core core)
this.core = core; {
this.core = core;
Components = new List<Component.Component>();
Transform = new Component.Transform(this); Components = new List<Component.Component>();
AddComponent(Transform); Transform = new Component.Transform(this);
pixelTransform = new Component.PixelTransform(this); AddComponent(Transform);
AddComponent(pixelTransform); pixelTransform = new Component.PixelTransform(this);
gridTransform = new Component.GridTransform(this); AddComponent(pixelTransform);
AddComponent(gridTransform); gridTransform = new Component.GridTransform(this);
} AddComponent(gridTransform);
stat = new Component.Stat(this);
public T GetComponent<T>() where T : Component.Component AddComponent(stat);
{ }
foreach (Component.Component c in Components)
{ public T GetComponent<T>() where T : Component.Component
if (c is T) {
return (T)c; foreach (Component.Component c in Components)
} {
if (c is T)
return null; return (T)c;
} }
public void AddComponent(Component.Component c) return null;
{ }
Components.Add(c);
} public void AddComponent(Component.Component c)
{
public virtual void Update(GameTime gameTime) Components.Add(c);
{ }
// Update components
foreach (Component.Component c in Components) public virtual void Update(GameTime gameTime)
c.Update(gameTime); {
} // Update components
} foreach (Component.Component c in Components)
} c.Update(gameTime);
}
}
}
+4 -3
View File
@@ -15,7 +15,7 @@ namespace DepthsBelow
Core core; Core core;
bool Enter = false; bool Enter = false;
bool turn; bool turn;
int checkerSpeed = 1; int checkerSpeed = 2;
public KeyboardInput(Core core) public KeyboardInput(Core core)
{ {
@@ -48,13 +48,14 @@ namespace DepthsBelow
core.TestMonster.step = 0; core.TestMonster.step = 0;
core.PlayerTurn = false; core.PlayerTurn = false;
Point target = Point.Zero; Point target = Point.Zero;
int distance = 7000; float distance = 7000;
foreach (var unit in core.Squad) foreach (var unit in core.Squad)
{ {
Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y); Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y);
Vector2 monster = new Vector2(core.TestMonster.Transform.Grid.X, core.TestMonster.Transform.Grid.Y); Vector2 monster = new Vector2(core.TestMonster.Transform.Grid.X, core.TestMonster.Transform.Grid.Y);
int newDistance = core.FindDistance(soldier, monster); float newDistance = Vector2.Distance(soldier, monster);
if (newDistance < distance) if (newDistance < distance)
{ {
target = unit.Transform.Grid; target = unit.Transform.Grid;
+147 -141
View File
@@ -1,142 +1,148 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using DepthsBelow.Component; using DepthsBelow.Component;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
namespace DepthsBelow namespace DepthsBelow
{ {
public class SmallEnemy : Entity public class SmallEnemy : Entity
{ {
public static Texture2D Texture; public static Texture2D Texture;
public Color Color; public Color Color;
public static Point Origin; public static Point Origin;
private bool _selected; //I guess as in "currently doing something" private bool _selected; //I guess as in "currently doing something"
public List<SmallEnemy> Swarm; public List<SmallEnemy> Swarm;
private PathFinder.Node nextNode; private PathFinder.Node nextNode;
public int numberOfSteps = 5; public int numberOfSteps = 5;
public int currentStep = 0; public int currentStep = 0;
public int step public int step
{ {
get { return currentStep; } get { return currentStep; }
set set
{ {
currentStep = value; currentStep = value;
} }
} }
public SmallEnemy(Core core, ref List<SmallEnemy> swarm) public SmallEnemy(Core core, ref List<SmallEnemy> swarm)
: base(core) : base(core)
{ {
if (Texture == null) if (Texture == null)
LoadContent(core); LoadContent(core);
this.Swarm = swarm; this.Swarm = swarm;
Transform.World.Origin = new Vector2(20, 16); Transform.World.Origin = new Vector2(20, 16);
this.Color = Color.White; this.Color = Color.White;
var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White }; var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White };
AddComponent(rc); AddComponent(rc);
var cc = new Collision(this, 32, 32); var cc = new Collision(this, 32, 32);
AddComponent(cc); AddComponent(cc);
var pfc = new PathFinder(this); var pfc = new PathFinder(this);
AddComponent(pfc); AddComponent(pfc);
}
stat.Life = 2;
public bool Selected stat.Defence = 0;
{ stat.Strength = 5;
get { return _selected; } stat.GetAim = 100;
set stat.GetDodge = 10;
{ }
_selected = value;
GetComponent<SpriteRenderer>().Color = (value) ? Color.Blue : this.Color; public bool Selected
} {
} get { return _selected; }
set
public static void LoadContent(Core core) {
{ _selected = value;
Texture = core.Content.Load<Texture2D>("images/Monster"); GetComponent<SpriteRenderer>().Color = (value) ? Color.Blue : this.Color;
} }
}
public override void Update(GameTime gameTime)
{ public static void LoadContent(Core core)
base.Update(gameTime); {
Texture = core.Content.Load<Texture2D>("images/Monster");
float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f; }
if (nextNode == null) public override void Update(GameTime gameTime)
nextNode = GetComponent<PathFinder>().Next(); {
base.Update(gameTime);
if (nextNode != null)
{ float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
List<Point> soldierCollisions = new List<Point>();
if (nextNode == null)
foreach (var body in Swarm) nextNode = GetComponent<PathFinder>().Next();
{
if (body != this) if (nextNode != null)
{ {
if (body.Transform.Grid == nextNode.Position) List<Point> soldierCollisions = new List<Point>();
{
soldierCollisions.Add(body.Transform.Grid); foreach (var body in Swarm)
GetComponent<PathFinder>().RecreatePath(soldierCollisions); {
nextNode = GetComponent<PathFinder>().Next(); if (body != this)
break; {
} if (body.Transform.Grid == nextNode.Position)
} {
} soldierCollisions.Add(body.Transform.Grid);
GetComponent<PathFinder>().RecreatePath(soldierCollisions);
foreach (var soldier in core.Squad) nextNode = GetComponent<PathFinder>().Next();
{ break;
var pathFinder = soldier.GetComponent<PathFinder>(); }
var position = nextNode.Position; }
if (soldier.Transform.Grid == position) }
{
soldierCollisions.Add(soldier.Transform.Grid); foreach (var soldier in core.Squad)
GetComponent<PathFinder>().RecreatePath(soldierCollisions); {
nextNode = GetComponent<PathFinder>().Next(); var pathFinder = soldier.GetComponent<PathFinder>();
break; var position = nextNode.Position;
} if (soldier.Transform.Grid == position)
} {
soldierCollisions.Add(soldier.Transform.Grid);
if (nextNode != null) GetComponent<PathFinder>().RecreatePath(soldierCollisions);
{ nextNode = GetComponent<PathFinder>().Next();
var nodeWorldPos = Grid.GridToWorld(nextNode.Position); break;
// HACK: Make this work properly with other speeds... }
float speed = 4f; }
if (Transform.World.X < nodeWorldPos.X)
Transform.World.X += speed; if (nextNode != null)
if (Transform.World.X > nodeWorldPos.X) {
Transform.World.X -= speed; var nodeWorldPos = Grid.GridToWorld(nextNode.Position);
if (Transform.World.Y < nodeWorldPos.Y) // HACK: Make this work properly with other speeds...
Transform.World.Y += speed; float speed = 4f;
if (Transform.World.Y > nodeWorldPos.Y) if (Transform.World.X < nodeWorldPos.X)
Transform.World.Y -= speed; Transform.World.X += speed;
if (Transform.World.X > nodeWorldPos.X)
if (Transform.World == nodeWorldPos) Transform.World.X -= speed;
{ if (Transform.World.Y < nodeWorldPos.Y)
if (currentStep < numberOfSteps) Transform.World.Y += speed;
{ if (Transform.World.Y > nodeWorldPos.Y)
currentStep++; Transform.World.Y -= speed;
//lastLastNode = lastNode;
//lastNode = nextNode; if (Transform.World == nodeWorldPos)
nextNode = GetComponent<PathFinder>().Next(); {
} if (currentStep < numberOfSteps)
else {
{ currentStep++;
GetComponent<PathFinder>().Stop(); //lastLastNode = lastNode;
} //lastNode = nextNode;
} nextNode = GetComponent<PathFinder>().Next();
} }
else
} {
} GetComponent<PathFinder>().Stop();
} }
}
}
}
}
}
} }
+25
View File
@@ -61,6 +61,12 @@ namespace DepthsBelow
var pfc = new PathFinder(this); var pfc = new PathFinder(this);
AddComponent(pfc); AddComponent(pfc);
stat.Life = 10;
stat.Defence = 10;
stat.Strength = 10;
stat.GetAim = 100;
stat.GetDodge = 20;
} }
public bool Selected public bool Selected
@@ -98,6 +104,13 @@ namespace DepthsBelow
soldierCollisions.Add(soldier.Transform.Grid); soldierCollisions.Add(soldier.Transform.Grid);
} }
} }
foreach (var enemy in core.Swarm)
{
if (!enemy.GetComponent<PathFinder>().IsMoving)
{
soldierCollisions.Add(enemy.Transform.Grid);
}
}
foreach (var soldier in Squad) foreach (var soldier in Squad)
{ {
@@ -114,6 +127,18 @@ 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) if (nextNode != null)
{ {
+38
View File
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
namespace DepthsBelow
{
static class Utility
{
public static int CalculateHitChance(Entity attacker, Entity defender)
{
Component.Stat shooting = attacker.GetComponent<Component.Stat>();
Component.Stat dodging = defender.GetComponent<Component.Stat>();
if (shooting == null || dodging == null)
{
return 0;
}
int baseHitChance = shooting.GetAim;
int baseDodgeChance = dodging.GetDodge;
int basePenalty = shooting.Penalty((int)Vector2.Distance(attacker.GetComponent<Component.Transform>().World.Position, defender.GetComponent<Component.Transform>().World.Position) / Grid.TileSize);
int chanceToHit = baseHitChance - baseDodgeChance - basePenalty;
return chanceToHit;
}
public static bool HitTest(Entity attacker, Entity defender, int chanceToHit)
{
Component.Stat shooting = attacker.GetComponent<Component.Stat>();
Component.Stat dodging = defender.GetComponent<Component.Stat>();
Random rand = new Random();
if (rand.Next(0, 100) < chanceToHit)
{
dodging.Life -= shooting.Strength - dodging.Defence / 2;
return true;
}
return false;
}
}
}