Adding support for ability to
override functionality of automated Gleed2D level loading by adding functions to AxiosGameScreen to override --HG-- branch : customgleed2dhandling
This commit is contained in:
parent
c0d3f3b939
commit
3c0c5a4ded
@ -394,6 +394,21 @@ namespace Axios.Engine
|
|||||||
//CleanUp();
|
//CleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool LoadCircleItem(CircleItem circleitem)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool LoadRectangleItem(RectangleItem rectangleitem)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool LoadPathItem(PathItem pathitem)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
// System.Drawing is NOT avaiable on WP7 or Xbox
|
// System.Drawing is NOT avaiable on WP7 or Xbox
|
||||||
/*
|
/*
|
||||||
|
@ -23,14 +23,16 @@ namespace Axios.Engine.Gleed2D
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
|
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
|
||||||
{
|
{
|
||||||
base.load(cm, world, ref cache);
|
base.load(gameScreen, ref cache);
|
||||||
|
if (gameScreen.LoadCircleItem(this))
|
||||||
_body = BodyFactory.CreateCircle(world, Radius, 1f);
|
{
|
||||||
|
_body = BodyFactory.CreateCircle(gameScreen.World, Radius, 1f);
|
||||||
_body.Position = ConvertUnits.ToSimUnits(Position);
|
_body.Position = ConvertUnits.ToSimUnits(Position);
|
||||||
_body.UserData = this;
|
_body.UserData = this;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,9 @@ namespace Axios.Engine.Gleed2D
|
|||||||
/// Called by Level.FromFile(filename) on each Item after the deserialization process.
|
/// 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).
|
/// Should be overriden and can be used to load anything needed by the Item (e.g. a texture).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
|
public virtual void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void draw(SpriteBatch sb)
|
public virtual void draw(SpriteBatch sb)
|
||||||
|
@ -54,7 +54,7 @@ namespace Axios.Engine.Gleed2D
|
|||||||
_world = world;
|
_world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Level FromFile(string filename, ContentManager cm, World world)
|
public static Level FromFile(string filename, AxiosGameScreen gameScreen)
|
||||||
{
|
{
|
||||||
Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();
|
Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();
|
||||||
FileStream stream = System.IO.File.Open(filename, FileMode.Open);
|
FileStream stream = System.IO.File.Open(filename, FileMode.Open);
|
||||||
@ -67,14 +67,14 @@ namespace Axios.Engine.Gleed2D
|
|||||||
foreach (Item item in layer.Items)
|
foreach (Item item in layer.Items)
|
||||||
{
|
{
|
||||||
item.CustomProperties.RestoreItemAssociations(level);
|
item.CustomProperties.RestoreItemAssociations(level);
|
||||||
item.load(cm, world, ref cache);
|
item.load(gameScreen, ref cache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Level FromStream(FileStream stream, ContentManager cm, World world)
|
public static Level FromStream(FileStream stream, AxiosGameScreen gameScreen)
|
||||||
{
|
{
|
||||||
Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();
|
Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();
|
||||||
XmlSerializer serializer = new XmlSerializer(typeof(Level));
|
XmlSerializer serializer = new XmlSerializer(typeof(Level));
|
||||||
@ -86,7 +86,7 @@ namespace Axios.Engine.Gleed2D
|
|||||||
foreach (Item item in layer.Items)
|
foreach (Item item in layer.Items)
|
||||||
{
|
{
|
||||||
item.CustomProperties.RestoreItemAssociations(level);
|
item.CustomProperties.RestoreItemAssociations(level);
|
||||||
item.load(cm, world, ref cache);
|
item.load(gameScreen, ref cache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,18 +26,20 @@ namespace Axios.Engine.Gleed2D
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
|
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
|
||||||
|
{
|
||||||
|
base.load(gameScreen, ref cache);
|
||||||
|
if (gameScreen.LoadPathItem(this))
|
||||||
{
|
{
|
||||||
base.load(cm, world, ref cache);
|
|
||||||
|
|
||||||
Vertices v = new Vertices(LocalPoints.Length);
|
Vertices v = new Vertices(LocalPoints.Length);
|
||||||
foreach (Vector2 vec in LocalPoints)
|
foreach (Vector2 vec in LocalPoints)
|
||||||
v.Add(new Vector2(ConvertUnits.ToSimUnits(vec.X), ConvertUnits.ToSimUnits(vec.Y)));
|
v.Add(new Vector2(ConvertUnits.ToSimUnits(vec.X), ConvertUnits.ToSimUnits(vec.Y)));
|
||||||
|
|
||||||
_body = BodyFactory.CreateLoopShape(world, v);
|
_body = BodyFactory.CreateLoopShape(gameScreen.World, v);
|
||||||
_body.Position = ConvertUnits.ToSimUnits(this.Position);
|
_body.Position = ConvertUnits.ToSimUnits(this.Position);
|
||||||
_body.UserData = this;
|
_body.UserData = this;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,11 @@ namespace Axios.Engine.Gleed2D
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
|
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
|
||||||
{
|
{
|
||||||
base.load(cm, world, ref cache);
|
base.load(gameScreen, ref cache);
|
||||||
|
|
||||||
_body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(Width), ConvertUnits.ToSimUnits(Height), 1f);
|
_body = BodyFactory.CreateRectangle(gameScreen.World, ConvertUnits.ToSimUnits(Width), ConvertUnits.ToSimUnits(Height), 1f);
|
||||||
_body.Position = ConvertUnits.ToSimUnits(Position) + new Vector2(ConvertUnits.ToSimUnits(Width)/2, ConvertUnits.ToSimUnits(Height)/2);
|
_body.Position = ConvertUnits.ToSimUnits(Position) + new Vector2(ConvertUnits.ToSimUnits(Width)/2, ConvertUnits.ToSimUnits(Height)/2);
|
||||||
_body.UserData = this;
|
_body.UserData = this;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ namespace Axios.Engine.Gleed2D
|
|||||||
/// You must provide your own implementation. However, you can rely on all public fields being
|
/// You must provide your own implementation. However, you can rely on all public fields being
|
||||||
/// filled by the level deserialization process.
|
/// filled by the level deserialization process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void load(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
|
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
|
||||||
{
|
{
|
||||||
//throw new NotImplementedException();
|
//throw new NotImplementedException();
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ namespace Axios.Engine.Gleed2D
|
|||||||
//or by using the Content Pipeline:
|
//or by using the Content Pipeline:
|
||||||
if (!cache.ContainsKey(asset_name))
|
if (!cache.ContainsKey(asset_name))
|
||||||
{
|
{
|
||||||
cache[asset_name] = cm.Load<Texture2D>(asset_name);
|
cache[asset_name] = gameScreen.ScreenManager.Game.Content.Load<Texture2D>(asset_name);
|
||||||
}
|
}
|
||||||
this.texture = cache[asset_name];
|
this.texture = cache[asset_name];
|
||||||
//this.texture = cm.Load<Texture2D>(asset_name);
|
//this.texture = cm.Load<Texture2D>(asset_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user