AxiosEngine-old 

AxiosEngine-old Commit Details


Date:2012-05-18 21:15:00 (12 years 7 months ago)
Author:Natalie Adams
Branch:customgleed2dhandling
Commit:ca67e2cb450f
Parents: d25b6764c7e8
Message:Adding support for ability to

override functionality of automated Gleed2D level loading
by adding functions to AxiosGameScreen to override
Changes:
Maxios/Engine/AxiosGameScreen.cs (1 diff)
Maxios/Engine/Gleed2D/CircleItem.cs (1 diff)
Maxios/Engine/Gleed2D/Item.cs (1 diff)
Maxios/Engine/Gleed2D/Level.cs (3 diffs)
Maxios/Engine/Gleed2D/PathItem.cs (1 diff)
Maxios/Engine/Gleed2D/RectangleItem.cs (1 diff)
Maxios/Engine/Gleed2D/TextureItem.cs (2 diffs)

File differences

axios/Engine/AxiosGameScreen.cs
394394
395395
396396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
397412
398413
399414
//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
// System.Drawing is NOT avaiable on WP7 or Xbox
/*
axios/Engine/Gleed2D/CircleItem.cs
2323
2424
2525
26
26
2727
28
29
30
31
32
28
29
30
31
32
33
34
3335
3436
3537
{
}
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);
_body = BodyFactory.CreateCircle(world, Radius, 1f);
_body.Position = ConvertUnits.ToSimUnits(Position);
_body.UserData = this;
base.load(gameScreen, ref cache);
if (gameScreen.LoadCircleItem(this))
{
_body = BodyFactory.CreateCircle(gameScreen.World, Radius, 1f);
_body.Position = ConvertUnits.ToSimUnits(Position);
_body.UserData = this;
}
}
}
axios/Engine/Gleed2D/Item.cs
4949
5050
5151
52
52
5353
54
5455
5556
5657
/// 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(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)
axios/Engine/Gleed2D/Level.cs
5454
5555
5656
57
57
5858
5959
6060
......
6767
6868
6969
70
70
7171
7272
7373
7474
7575
7676
77
77
7878
7979
8080
......
8686
8787
8888
89
89
9090
9191
9292
_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>();
FileStream stream = System.IO.File.Open(filename, FileMode.Open);
foreach (Item item in layer.Items)
{
item.CustomProperties.RestoreItemAssociations(level);
item.load(cm, world, ref cache);
item.load(gameScreen, ref cache);
}
}
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>();
XmlSerializer serializer = new XmlSerializer(typeof(Level));
foreach (Item item in layer.Items)
{
item.CustomProperties.RestoreItemAssociations(level);
item.load(cm, world, ref cache);
item.load(gameScreen, ref cache);
}
}
axios/Engine/Gleed2D/PathItem.cs
2626
2727
2828
29
29
3030
31
31
32
33
34
35
36
3237
33
34
35
36
37
38
39
38
39
40
41
4042
4143
4244
{
}
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.LoadPathItem(this))
{
Vertices v = new Vertices(LocalPoints.Length);
foreach (Vector2 vec in LocalPoints)
v.Add(new Vector2(ConvertUnits.ToSimUnits(vec.X), ConvertUnits.ToSimUnits(vec.Y)));
Vertices v = new Vertices(LocalPoints.Length);
foreach (Vector2 vec in LocalPoints)
v.Add(new Vector2(ConvertUnits.ToSimUnits(vec.X), ConvertUnits.ToSimUnits(vec.Y)));
_body = BodyFactory.CreateLoopShape(world, v);
_body.Position = ConvertUnits.ToSimUnits(this.Position);
_body.UserData = this;
_body = BodyFactory.CreateLoopShape(gameScreen.World, v);
_body.Position = ConvertUnits.ToSimUnits(this.Position);
_body.UserData = this;
}
}
}
axios/Engine/Gleed2D/RectangleItem.cs
2424
2525
2626
27
27
2828
29
29
3030
31
31
3232
3333
3434
{
}
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.UserData = this;
}
axios/Engine/Gleed2D/TextureItem.cs
7777
7878
7979
80
80
8181
8282
8383
......
8787
8888
8989
90
90
9191
9292
9393
/// 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(ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
{
//throw new NotImplementedException();
//or by using the Content Pipeline:
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 = cm.Load<Texture2D>(asset_name);

Archive Download the corresponding diff file

Page rendered in 0.71282s using 14 queries.