* - Starting work on AxiosCSV

* - Adding CustomProperties field to Glee2D Layer object (this is because Layers can have custom properties)
* - Passing Layer to Items in Glee2D library
* - Adding public virtual bool LoadTextureItem(TextureItem textureitem) to AxiosGameScreen
This commit is contained in:
Nathan Adams
2012-07-20 22:11:10 -05:00
parent c0ef5e2a94
commit 0fb31c3b0f
11 changed files with 49 additions and 23 deletions

View File

@@ -23,9 +23,9 @@ namespace Axios.Engine.Gleed2D
{
}
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache, Layer layer)
{
base.load(gameScreen, ref cache);
base.load(gameScreen, ref cache, layer);
if (gameScreen.LoadCircleItem(this))
{
_body = BodyFactory.CreateCircle(gameScreen.World, Radius, 1f);

View File

@@ -49,7 +49,7 @@ namespace Axios.Engine.Gleed2D
/// Called by Level.FromFile(filename) on each Item after the deserialization process.
/// Should be overriden and can be used to load anything needed by the Item (e.g. a texture).
/// </summary>
public virtual void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
public virtual void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache, Layer layer)
{
}

View File

@@ -35,6 +35,11 @@ namespace Axios.Engine.Gleed2D
/// </summary>
public Vector2 ScrollSpeed;
/// <summary>
/// A Dictionary containing any user-defined Properties.
/// </summary>
public SerializableDictionary CustomProperties;
public Layer()
{

View File

@@ -67,7 +67,7 @@ namespace Axios.Engine.Gleed2D
foreach (Item item in layer.Items)
{
item.CustomProperties.RestoreItemAssociations(level);
item.load(gameScreen, ref cache);
item.load(gameScreen, ref cache, layer);
}
}
@@ -86,7 +86,7 @@ namespace Axios.Engine.Gleed2D
foreach (Item item in layer.Items)
{
item.CustomProperties.RestoreItemAssociations(level);
item.load(gameScreen, ref cache);
item.load(gameScreen, ref cache, layer);
}
}

View File

@@ -26,9 +26,9 @@ namespace Axios.Engine.Gleed2D
{
}
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache, Layer layer)
{
base.load(gameScreen, ref cache);
base.load(gameScreen, ref cache, layer);
if (gameScreen.LoadPathItem(this))
{
Vertices v = new Vertices(LocalPoints.Length);

View File

@@ -22,11 +22,12 @@ namespace Axios.Engine.Gleed2D
public RectangleItem()
{
}
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache, Layer layer)
{
base.load(gameScreen, ref cache);
base.load(gameScreen, ref cache, layer);
if (gameScreen.LoadRectangleItem(this))
{
_body = BodyFactory.CreateRectangle(gameScreen.World, ConvertUnits.ToSimUnits(Width), ConvertUnits.ToSimUnits(Height), 1f);

View File

@@ -58,7 +58,7 @@ namespace Axios.Engine.Gleed2D
/// exists as an asset in your project.
/// Loading is done in the Item's load() method.
/// </summary>
Texture2D texture;
public Texture2D texture;
/// <summary>
/// The item's origin relative to the upper left corner of the texture. Usually the middle of the texture.
@@ -66,6 +66,8 @@ namespace Axios.Engine.Gleed2D
/// </summary>
public Vector2 Origin;
public Layer Layer;
public TextureItem()
{
@@ -77,8 +79,10 @@ namespace Axios.Engine.Gleed2D
/// You must provide your own implementation. However, you can rely on all public fields being
/// filled by the level deserialization process.
/// </summary>
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache, Layer layer)
{
this.Layer = layer;
base.load(gameScreen, ref cache, layer);
//throw new NotImplementedException();
//TODO: provide your own implementation of how a TextureItem loads its assets
@@ -90,8 +94,10 @@ namespace Axios.Engine.Gleed2D
cache[asset_name] = gameScreen.ScreenManager.Game.Content.Load<Texture2D>(asset_name);
}
this.texture = cache[asset_name];
Visible = gameScreen.LoadTextureItem(this);
//this.texture = cm.Load<Texture2D>(asset_name);
}
public override void draw(SpriteBatch sb)