Merge branch 'lua'

Conflicts:
	DepthsBelow/DepthsBelow/Core.cs
	DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj
This commit is contained in:
Simon Holmberg
2012-10-17 01:55:30 +02:00
14 changed files with 626 additions and 352 deletions
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
+213 -201
View File
@@ -1,201 +1,213 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.IO;
using DepthsBelow.GUI; using System.Linq;
using Microsoft.Xna.Framework; using DepthsBelow.GUI;
using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media; using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace DepthsBelow
{ namespace DepthsBelow
/// <summary> {
/// This is the main type for your game /// <summary>
/// </summary> /// This is the main type for your game
public class Core : Microsoft.Xna.Framework.Game /// </summary>
{ public class Core : Microsoft.Xna.Framework.Game
public static GraphicsDeviceManager GraphicsDeviceManager; {
SpriteBatch spriteBatch; public static GraphicsDeviceManager GraphicsDeviceManager;
SpriteBatch spriteBatch;
public Camera Camera;
public Lua Lua;
public bool PlayerTurn = true;
public static MouseInput MouseInput; public Camera Camera;
public static KeyboardInput KeyboardInput;
public List<Soldier> Squad; public bool PlayerTurn = true;
public List<SmallEnemy> Swarm; public static MouseInput MouseInput;
public List<Shot> Volley; public static KeyboardInput KeyboardInput;
public static Map Map; public List<Soldier> Squad;
public List<SmallEnemy> Swarm;
public SmallEnemy TestMonster; public List<Shot> Volley;
public static Map Map;
public Core()
{ public SmallEnemy TestMonster;
GraphicsDeviceManager = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content"; public Core()
{
GraphicsDeviceManager.PreferredBackBufferWidth = 1280; GraphicsDeviceManager = new GraphicsDeviceManager(this);
GraphicsDeviceManager.PreferredBackBufferHeight = 720; Content.RootDirectory = "Content";
GraphicsDeviceManager.IsFullScreen = false;
GraphicsDeviceManager.PreferredBackBufferWidth = 1280;
//graphics.SynchronizeWithVerticalRetrace = false; GraphicsDeviceManager.PreferredBackBufferHeight = 720;
this.IsFixedTimeStep = false; GraphicsDeviceManager.IsFullScreen = false;
GraphicsDeviceManager.ApplyChanges();
//graphics.SynchronizeWithVerticalRetrace = false;
this.IsMouseVisible = true; this.IsFixedTimeStep = false;
} GraphicsDeviceManager.ApplyChanges();
/// <summary> this.IsMouseVisible = true;
/// 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 GameServices.AddService<GraphicsDevice>(GraphicsDevice);
/// related content. Calling base.Initialize will enumerate through any components GameServices.AddService<ContentManager>(Content);
/// and initialize them as well. }
/// </summary>
protected override void Initialize() /// <summary>
{ /// Allows the game to perform any initialization it needs to before starting to run.
// TODO: Add your initialization logic here /// This is where it can query for any required services and load any non-graphic
Camera = new Camera(this); /// related content. Calling base.Initialize will enumerate through any components
Squad = new List<Soldier>(); /// and initialize them as well.
Swarm = new List<SmallEnemy>(); /// </summary>
Volley = new List<Shot>(); protected override void Initialize()
{
TestMonster = new SmallEnemy(this, ref Swarm); // TODO: Add your initialization logic here
Camera = new Camera(this);
base.Initialize(); Squad = new List<Soldier>();
} Swarm = new List<SmallEnemy>();
Volley = new List<Shot>();
/// <summary>
/// LoadContent will be called once per game and is the place to load TestMonster = new SmallEnemy(this, ref Swarm);
/// all of your content.
/// </summary> // Run scripts after everything is initialized
protected override void LoadContent() Lua = new Lua();
{ Lua.LoadScripts();
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice); base.Initialize();
}
Map = Content.Load<Map>("maps/Cave.Level1");
// Load map objects /// <summary>
Map.ParseObjects(this); /// LoadContent will be called once per game and is the place to load
/// all of your content.
// TODO: use this.Content to load your game content here /// </summary>
Soldier.LoadContent(this); protected override void LoadContent()
SmallEnemy.LoadContent(this); {
Shot.LoadContent(this); // Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
MouseInput = new MouseInput(this);
MouseInput.LoadContent(); Map = Content.Load<Map>("maps/Cave.Level1");
KeyboardInput = new KeyboardInput(this); // Load map objects
Map.ParseObjects(this);
TestMonster.X = 12;
TestMonster.Y = 4; // TODO: use this.Content to load your game content here
Soldier.LoadContent(this);
//frame.Add(text); SmallEnemy.LoadContent(this);
} Shot.LoadContent(this);
/// <summary> MouseInput = new MouseInput(this);
/// UnloadContent will be called once per game and is the place to unload MouseInput.LoadContent();
/// all content. KeyboardInput = new KeyboardInput(this);
/// </summary>
protected override void UnloadContent() TestMonster.X = 12;
{ TestMonster.Y = 4;
// TODO: Unload any non ContentManager content here
} //frame.Add(text);
}
/// <summary>
/// Allows the game to run logic such as updating the world, /// <summary>
/// checking for collisions, gathering input, and playing audio. /// UnloadContent will be called once per game and is the place to unload
/// </summary> /// all content.
/// <param name="gameTime">Provides a snapshot of timing values.</param> /// </summary>
protected override void Update(GameTime gameTime) protected override void UnloadContent()
{ {
// Allows the game to exit // TODO: Unload any non ContentManager content here
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) }
this.Exit();
/// <summary>
Camera.Update(gameTime); /// Allows the game to run logic such as updating the world,
MouseInput.Update(gameTime); /// checking for collisions, gathering input, and playing audio.
KeyboardInput.Update(gameTime); /// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
// Update soldiers in squad protected override void Update(GameTime gameTime)
foreach (var soldier in Squad) {
soldier.Update(gameTime); // Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
foreach (var body in Swarm) this.Exit();
body.Update(gameTime);
Camera.Update(gameTime);
foreach (var bullet in Volley) MouseInput.Update(gameTime);
bullet.Update(gameTime); KeyboardInput.Update(gameTime);
TestMonster.Update(gameTime); // Update soldiers in squad
GUIManager.Update(gameTime); foreach (var soldier in Squad)
soldier.Update(gameTime);
base.Update(gameTime);
} foreach (var body in Swarm)
body.Update(gameTime);
public int FindDistance(Vector2 target, Vector2 start)
{ foreach (var bullet in Volley)
Vector2 combine = new Vector2(target.X - start.X, target.Y - start.Y); bullet.Update(gameTime);
int result = 0; TestMonster.Update(gameTime);
int firstRestult = (int)Math.Sqrt((int)combine.X^2 + (int)combine.Y^2); GUIManager.Update(gameTime);
result = (int)Vector2.Distance(target, start); base.Update(gameTime);
}
return result;
} public int FindDistance(Vector2 target, Vector2 start)
{
/// <summary> Vector2 combine = new Vector2(target.X - start.X, target.Y - start.Y);
/// This is called when the game should draw itself.
/// </summary> int result = 0;
/// <param name="gameTime">Provides a snapshot of timing values.</param> int firstRestult = (int)Math.Sqrt((int)combine.X^2 + (int)combine.Y^2);
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,
Camera.Transform); /// <summary>
/// This is called when the game should draw itself.
// Draw the level /// </summary>
Map.Draw(spriteBatch); /// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
// Draw units {
foreach (var soldier in Squad) GraphicsDevice.Clear(Color.Black);
{
var sr = soldier.GetComponent<Component.SpriteRenderer>(); // Start drawing using the Camera transform
if (sr != null) spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null,
sr.Draw(spriteBatch); Camera.Transform);
}
foreach (var body in Swarm) // Draw the level
{ Map.Draw(spriteBatch);
var sr = body.GetComponent<Component.SpriteRenderer>();
if (sr != null) // Draw units
sr.Draw(spriteBatch); foreach (var soldier in Squad)
} {
foreach (var bullet in Volley) var sr = soldier.GetComponent<Component.SpriteRenderer>();
{ if (sr != null)
var sr = bullet.GetComponent<Component.SpriteRenderer>(); sr.Draw(spriteBatch);
if (sr != null) }
sr.Draw(spriteBatch); foreach (var body in Swarm)
} {
var sr = body.GetComponent<Component.SpriteRenderer>();
// Draw mouse input visuals if (sr != null)
MouseInput.Draw(spriteBatch); sr.Draw(spriteBatch);
}
TestMonster.GetComponent<Component.SpriteRenderer>().Draw(spriteBatch); foreach (var bullet in Volley)
{
spriteBatch.End(); var sr = bullet.GetComponent<Component.SpriteRenderer>();
if (sr != null)
// Start drawing GUI components sr.Draw(spriteBatch);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, null, null, null, Matrix.Identity); }
GUIManager.Draw(spriteBatch);
spriteBatch.End(); // Draw mouse input visuals
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);
}
}
}
+47
View File
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
namespace DepthsBelow
{
static class CustomExtensions
{
/// <summary>
/// Load all content within a certain folder. The function
/// returns a dictionary where the file name, without type
/// extension, is the key and the texture object is the value.
///
/// The contentFolder parameter has to be relative to the
/// game.Content.RootDirectory folder.
///
/// http://danielsaidi.wordpress.com/2010/01/26/xna-load-all-content-files-in-a-folder/
/// </summary>
/// <typeparam name="T">The content type.</typeparam>
/// <param name="contentManager">The content manager for which content is to be loaded.</param>
/// <param name="contentFolder">The game project root folder relative folder path.</param>
/// <returns>A list of loaded content objects.</returns>
public static Dictionary<String, T> LoadContent<T>(this ContentManager contentManager, string contentFolder)
{
//Load directory info, abort if none
DirectoryInfo dir = new DirectoryInfo(contentManager.RootDirectory + "\\" + contentFolder);
if (!dir.Exists)
throw new DirectoryNotFoundException();
//Init the resulting list
Dictionary<String, T> result = new Dictionary<String, T>();
//Load all files that matches the file filter
FileInfo[] files = dir.GetFiles("*.*");
foreach (FileInfo file in files)
{
string key = Path.GetFileNameWithoutExtension(file.Name);
result[key] = contentManager.Load<T>(contentFolder + "/" + key);
}
//Return the result
return result;
}
}
}
+9 -7
View File
@@ -10,7 +10,7 @@
<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>
@@ -73,6 +73,10 @@
<SignManifests>true</SignManifests> <SignManifests>true</SignManifests>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="LuaInterface, Version=2.0.0.16708, Culture=neutral, processorArchitecture=x86">
<HintPath>..\..\LuaInterface\LuaInterface.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86"> <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
@@ -107,22 +111,19 @@
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Xml">
<Private>False</Private>
</Reference>
<Reference Include="System.Core"> <Reference Include="System.Core">
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System.Xml.Linq">
<Private>False</Private>
</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="GameServices.cs" />
<Compile Include="Interface.cs" /> <Compile Include="Interface.cs" />
<Compile Include="Lua.cs" />
<Compile Include="Shot.cs" /> <Compile Include="Shot.cs" />
<Compile Include="Component\Shooting.cs" /> <Compile Include="Component\Shooting.cs" />
<Compile Include="GUIManager.cs" /> <Compile Include="GUIManager.cs" />
@@ -191,6 +192,7 @@
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" />
<None Include="DepthsBelow_TemporaryKey.pfx" /> <None Include="DepthsBelow_TemporaryKey.pfx" />
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
+6
View File
@@ -3,6 +3,7 @@ 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.Graphics; using Microsoft.Xna.Framework.Graphics;
namespace DepthsBelow.GUI namespace DepthsBelow.GUI
@@ -86,6 +87,11 @@ namespace DepthsBelow.GUI
GUIManager.Remove(this); GUIManager.Remove(this);
} }
public void SetTexture(string fileName)
{
Texture = GameServices.GetService<ContentManager>().Load<Texture2D>(fileName);
}
public virtual void Update(GameTime gameTime) public virtual void Update(GameTime gameTime)
{ {
foreach (var child in Children) foreach (var child in Children)
+35
View File
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
namespace DepthsBelow
{
/*
* http://roy-t.nl/index.php/2010/08/25/xna-accessing-contentmanager-and-graphicsdevice-anywhere-anytime-the-gameservicecontainer/
*/
public static class GameServices
{
private static GameServiceContainer container;
public static GameServiceContainer Instance
{
get { return container ?? (container = new GameServiceContainer()); }
}
public static T GetService<T>()
{
return (T)Instance.GetService(typeof(T));
}
public static void AddService<T>(T service)
{
Instance.AddService(typeof(T), service);
}
public static void RemoveService<T>()
{
Instance.RemoveService(typeof(T));
}
}
}
+111
View File
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DepthsBelow.GUI;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
namespace DepthsBelow
{
// TODO: The frames created here must be disposed correctly when the Lua context is disposed
static class LuaGUI
{
public static GUI.Frame CreateFrame()
{
return new Frame();
}
public static GUI.Frame CreateFrame(GUI.Frame parent)
{
return new GUI.Frame(parent);
}
public static GUI.Button CreateButton()
{
return new Button();
}
public static GUI.Button CreateButton(GUI.Frame parent)
{
return new GUI.Button(parent);
}
}
public class Lua
{
private LuaInterface.Lua lua;
public Lua()
{
ResetContext();
ExposeLibraries();
/*lua.DoString(@"
local frame = CreateFrame('Frame');
frame.X = 100;
local button = CreateFrame('Button', frame);
button:SetTexture('images/Enter');
button.Width = 100;
button.Height = 50;
button.OnClick = function(clickPos)
Console.WriteLine(clickPos.X .. ' ' .. clickPos.Y);
end
");*/
}
public void ExposeLibraries()
{
lua.NewTable("Console");
lua.RegisterFunction("Console.Write", null, typeof(System.Console).GetMethod("Write", new Type[] { typeof(string) }));
lua.RegisterFunction("Console.WriteLine", null, typeof(System.Console).GetMethod("WriteLine", new Type[] { typeof(string) }));
// Register GUI creation functions
lua.RegisterFunction("_CreateFrame", null, typeof(LuaGUI).GetMethod("CreateFrame", new Type[] { }));
lua.RegisterFunction("_CreateFrameAsChild", null, typeof(LuaGUI).GetMethod("CreateFrame", new Type[] { typeof(GUI.Frame) }));
lua.RegisterFunction("_CreateButton", null, typeof(LuaGUI).GetMethod("CreateButton", new Type[] { }));
lua.RegisterFunction("_CreateButtonAsChild", null, typeof(LuaGUI).GetMethod("CreateButton", new Type[] { typeof(GUI.Frame) }));
lua.NewTable("GUI");
/*
* Because Lua can't dynamically call overloads of registered functions, a generic Lua function needs to do the decision making.
* This way we can also dynamically create different frame classes with the same function.
*/
lua.DoString(@"
CreateFrame = function(frameType, parent)
frameType = string.lower(frameType):gsub('^%l', string.upper)
if (parent == nil) then
return _G['_Create' .. frameType]()
else
return _G['_Create' .. frameType .. 'AsChild'](parent)
end
end
");
}
public void ResetContext()
{
if (lua != null)
lua.Dispose();
lua = new LuaInterface.Lua();
}
public void LoadScripts()
{
// Load scripts from script folder
// HACK: This needs to load files on the fly instead of loading precompiled files by the content manager.
// http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_2 maybe?
var scripts = GameServices.GetService<ContentManager>().LoadContent<string>("scripts");
foreach (var script in scripts)
{
try
{
lua.DoString(script.Value);
}
catch (LuaInterface.LuaException e)
{
Console.WriteLine("Lua error: " + e.Message);
}
}
}
}
}
+155 -144
View File
@@ -1,145 +1,156 @@
<?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>
<ItemGroup> <ItemGroup>
<Compile Include="images\Monster.png"> <Compile Include="images\Monster.png">
<Name>Monster</Name> <Name>Monster</Name>
<Importer>TextureImporter</Importer> <Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor> <Processor>TextureProcessor</Processor>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="images\Enter.bmp"> <Compile Include="images\Enter.bmp">
<Name>Enter</Name> <Name>Enter</Name>
<Importer>TextureImporter</Importer> <Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor> <Processor>TextureProcessor</Processor>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Arial.spritefont"> <Compile Include="Arial.spritefont">
<Name>Arial</Name> <Name>Arial</Name>
<Importer>FontDescriptionImporter</Importer> <Importer>FontDescriptionImporter</Importer>
<Processor>FontDescriptionProcessor</Processor> <Processor>FontDescriptionProcessor</Processor>
</Compile> <SubType>Designer</SubType>
</ItemGroup> </Compile>
<ItemGroup> </ItemGroup>
<Compile Include="images\Shot2.bmp"> <ItemGroup>
<Name>Shot2</Name> <Compile Include="images\Shot2.bmp">
<Importer>TextureImporter</Importer> <Name>Shot2</Name>
<Processor>TextureProcessor</Processor> <Importer>TextureImporter</Importer>
</Compile> <Processor>TextureProcessor</Processor>
</ItemGroup> </Compile>
<ItemGroup> </ItemGroup>
<Compile Include="images\FireBall.PNG"> <ItemGroup>
<Name>Shot</Name> <Compile Include="images\FireBall.PNG">
<Importer>TextureImporter</Importer> <Name>Shot</Name>
<Processor>TextureProcessor</Processor> <Importer>TextureImporter</Importer>
</Compile> <Processor>TextureProcessor</Processor>
</ItemGroup> </Compile>
<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. <ItemGroup>
Other similar extension points exist, see Microsoft.Common.targets. <Compile Include="scripts\gui.lua">
<Target Name="BeforeBuild"> <Name>gui</Name>
</Target> <Importer>LuaImporter</Importer>
<Target Name="AfterBuild"> </Compile>
</Target> <Compile Include="scripts\test.lua">
--> <Name>test</Name>
<Importer>LuaImporter</Importer>
</Compile>
</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>
+10
View File
@@ -0,0 +1,10 @@
local frame = CreateFrame('Frame');
frame.X = 100;
local button = CreateFrame('Button', frame);
button:SetTexture('images/Enter');
button.Width = 100;
button.Height = 50;
button.OnClick = function(clickPos)
Console.WriteLine(clickPos.X .. ' ' .. clickPos.Y);
end
+1
View File
@@ -0,0 +1 @@
Console.WriteLine("Test.lua loaded");
@@ -27,6 +27,7 @@
<Private>False</Private> <Private>False</Private>
<SpecificVersion>True</SpecificVersion> <SpecificVersion>True</SpecificVersion>
</Reference> </Reference>
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<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>
<SpecificVersion>True</SpecificVersion> <SpecificVersion>True</SpecificVersion>
@@ -49,6 +50,7 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="LuaImporter.cs" />
<Compile Include="MapProcessor.cs" /> <Compile Include="MapProcessor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
+31
View File
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
// TODO: replace this with the type you want to import.
using TImport = System.String;
namespace DepthsBelowContentPipeline
{
/// <summary>
/// This class will be instantiated by the XNA Framework Content Pipeline
/// to import a file from disk into the specified type, TImport.
///
/// This should be part of a Content Pipeline Extension Library project.
///
/// TODO: change the ContentImporter attribute to specify the correct file
/// extension, display name, and default processor for this importer.
/// </summary>
[ContentImporter(".lua", DisplayName = "LUA Importer", DefaultProcessor = "LuaProcessor")]
public class LuaImporter : ContentImporter<TImport>
{
public override TImport Import(string filename, ContentImporterContext context)
{
return System.IO.File.ReadAllText(filename);
}
}
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.