AxiosEngine-old 

AxiosEngine-old Commit Details


Date:2014-06-01 22:02:00 (10 years 6 months ago)
Author:Natalie Adams
Branch:default
Commit:97265e7c111a
Parents: 67ebb6b10501
Message:Updating axiosengine to support latest version of gleed2d

Changes:
Daxios/Engine/Gleed2D/Camera.cs (full)
Daxios/Engine/Gleed2D/CustomProperty.cs (full)
Daxios/Engine/Gleed2D/Layer.cs (full)
Daxios/Engine/Gleed2D/Level.cs (full)
Maxios/Axios_Windows.csproj (4 diffs)
Maxios/Axios_Windows.csproj.user (1 diff)
Maxios/Engine/AxiosGameScreen.cs (6 diffs)
Maxios/Engine/Gleed2D/Item.cs (1 diff)
Maxios/Engine/Gleed2D/PathItem.cs (1 diff)
Maxios/Engine/Gleed2D/TextureItem.cs (3 diffs)

File differences

axios/Axios_Windows.csproj
1010
1111
1212
13
13
14
1415
1516
1617
......
4445
4546
4647
48
49
50
51
52
53
54
4755
4856
4957
......
222230
223231
224232
225
226
227
228233
229
230
231234
232
233235
234236
235237
......
287289
288290
289291
290
291292
292293
293294
<RootNamespace>Axios</RootNamespace>
<AssemblyName>Axios.Windows</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
<XnaPlatform>Windows</XnaPlatform>
<XnaProfile>HiDef</XnaProfile>
<XnaCompressContent>true</XnaCompressContent>
</PropertyGroup>
<ItemGroup>
<Reference Include="Gleed2D.Core">
<HintPath>..\..\..\git\axiosmapeditor\Gleed2D-master\src\Gleed2D.Core\bin\x86\Debug\Gleed2D.Core.dll</HintPath>
</Reference>
<Reference Include="Gleed2D.InGame, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\git\axiosmapeditor\Gleed2D-master\src\Gleed2D.Core\bin\x86\Debug\Gleed2D.InGame.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private>
</Reference>
<Compile Include="Engine\File\AxiosIsolatedFile.cs" />
<Compile Include="Engine\File\AxiosRegularFile.cs" />
<Compile Include="Engine\File\AxiosTitleFile.cs" />
<Compile Include="Engine\Gleed2D\Camera.cs" />
<Compile Include="Engine\Gleed2D\CircleItem.cs" />
<Compile Include="Engine\Gleed2D\CustomProperty.cs" />
<Compile Include="Engine\Gleed2D\Item.cs" />
<Compile Include="Engine\Gleed2D\Layer.cs" />
<Compile Include="Engine\Gleed2D\Level.cs" />
<Compile Include="Engine\Gleed2D\PathItem.cs" />
<Compile Include="Engine\Gleed2D\RectangleItem.cs" />
<Compile Include="Engine\Gleed2D\TextureItem.cs" />
<Compile Include="Engine\Interfaces\IAxiosFile.cs" />
<Compile Include="Engine\Interfaces\IAxiosGameObject.cs" />
<ItemGroup>
<None Include="AxiosEngine.cd" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
<PropertyGroup>
axios/Axios_Windows.csproj.user
11
22
33
4
4
55
66
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
axios/Engine/AxiosGameScreen.cs
1212
1313
1414
15
16
17
18
19
20
21
22
1523
16
1724
1825
1926
......
3643
3744
3845
46
47
48
49
50
51
3952
4053
4154
......
6881
6982
7083
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
71128
72129
73130
......
234291
235292
236293
237
294
238295
239296
240
297
298
299
300
301
302
303
241304
242305
243306
......
250313
251314
252315
316
317
253318
254319
255320
......
459524
460525
461526
462
527
463528
464529
465530
466531
467
532
533
534
535
536
537
538
539
468540
469541
470542
471543
472
544
473545
474
546
547
548
475549
476550
477
478
479
480
551
481552
482553
483554
using Microsoft.Xna.Framework.Graphics;
using GameStateManagement;
using Microsoft.Xna.Framework.Input;
using Axios.Engine.Extensions;
using System.IO;
using System.IO.Compression;
using Gleed2D.InGame;
using Axios.Engine.File;
using System.Xml.Linq;
using Gleed2D.Core;
using System.Diagnostics;
using Axios.Engine.Gleed2D;
using Axios.Engine.Extensions;
namespace Axios.Engine
{
private List<AxiosTimer> _timers;
private List<AxiosUIObject> _uiobjects;
protected Dictionary<string, PathItem> PathItems = new Dictionary<string, PathItem>();
protected Dictionary<string, TextureItem> TextureItems = new Dictionary<string, TextureItem>();
//protected List<TextureItem> TextureItems = new List<TextureItem>();
protected Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();
private AxiosUIObject prevuiobj;
private AxiosUIObject prevuifocusobj;
}
public void LoadLevelFromStream(Stream s)
{
XElement xml = XElement.Load(s);
Level level = LevelLoader.Load(xml);
this.Level = level;
foreach (Layer layer in level.Layers)
{
foreach (LayerItem item in layer.Items)
{
//Debug.WriteLine(item.PropertyType);
switch (item.PropertyType)
{
case "Gleed2D.InGame.PathItemProperties":
this.LoadPathItem((PathItemProperties)item.Properties, layer);
break;
case "Gleed2D.InGame.TextureItemProperties":
this.LoadTextureItem((TextureItemProperties)item.Properties, layer);
break;
default:
this.LoadOtherItem(item.Properties, item.PropertyType, layer);
break;
}
/*Debug.WriteLine(item.Properties.Id);
Debug.WriteLine(item.Properties.Name);
Debug.WriteLine(item.PropertyType);*/
}
}
}
public void LoadLevelFromFile(string s)
{
AxiosTitleFile file = new AxiosTitleFile(s);
this.LoadLevelFromStream(file.GetStream(FileMode.Open));
}
public void LoadLevelFromGZFile(string s)
{
AxiosTitleFile file = new AxiosTitleFile(s);
GZipStream zipstream = new GZipStream(file.GetStream(FileMode.Open), CompressionMode.Decompress);
this.LoadLevelFromStream(zipstream);
}
public Vector2 MouseAimVector(MouseState ms, Vector2 relativeposition)
{
Vector2 ret;
foreach (Layer layer in Level.Layers)
{
Vector2 oldcameraposition = camera.Position;
camera.Position *= layer.ScrollSpeed;
//camera.Position *= layer.ScrollSpeed;
ScreenManager.SpriteBatch.Begin(0, null, null, null, null, null, Camera.View);
layer.draw(ScreenManager.SpriteBatch);
foreach (TextureItem i in TextureItems.Values)
{
if (i.LayerItem.Visible == true)
{
i.draw(ScreenManager.SpriteBatch);
}
}
ScreenManager.SpriteBatch.End();
camera.Position = oldcameraposition;
foreach(AxiosUIObject g in (from x in _uiobjects orderby x.DrawOrder select x))
((IDrawableAxiosGameObject)g).Draw(this, gameTime);
base.Draw(gameTime); //This is placed at the end so that Farseer debug information is visible
}
/// </summary>
/// <param name="circleitem"></param>
/// <returns></returns>
public virtual bool LoadCircleItem(CircleItem circleitem)
public virtual bool LoadCircleItem(object circleitem)
{
return true;
}
public virtual bool LoadPathItem(PathItem pathitem)
public virtual void LoadPathItem(PathItemProperties pathitem, Layer l)
{
PathItem p = new PathItem((PathItemProperties)pathitem);
p.load(this, ref cache);
PathItems[pathitem.Name] = p;
}
public virtual bool LoadRectangleItem(object rectangleitem)
{
return true;
}
public virtual bool LoadRectangleItem(RectangleItem rectangleitem)
public virtual void LoadTextureItem(TextureItemProperties textureitem, Layer l)
{
return true;
TextureItem i = new TextureItem((TextureItemProperties)textureitem);
i.load(this, ref cache);
TextureItems[textureitem.Name] = i;
}
public virtual bool LoadTextureItem(TextureItem textureitem)
{
return true;
}
public virtual void LoadOtherItem(ItemProperties prop, string type, Layer l) { }
}
}
axios/Engine/Gleed2D/Camera.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
namespace Axios.Engine.Gleed2D
{
public class Camera
{
Vector2 position;
public Vector2 Position
{
get
{
return position;
}
set
{
position = value;
updatematrix();
}
}
float rotation;
public float Rotation
{
get
{
return rotation;
}
set
{
rotation = value;
updatematrix();
}
}
float scale;
public float Scale
{
get
{
return scale;
}
set
{
scale = value;
updatematrix();
}
}
public Matrix matrix;
Vector2 viewport; //width and height of the viewport
public Camera(float width, float height)
{
position = Vector2.Zero;
rotation = 0;
scale = 1.0f;
viewport = new Vector2(width, height);
updatematrix();
}
void updatematrix()
{
matrix = Matrix.CreateTranslation(-position.X, -position.Y, 0.0f) *
Matrix.CreateRotationZ(rotation) *
Matrix.CreateScale(scale) *
Matrix.CreateTranslation(viewport.X / 2, viewport.Y / 2, 0.0f);
}
public void updateviewport(float width, float height)
{
viewport.X = width;
viewport.Y = height;
updatematrix();
}
}
}
axios/Engine/Gleed2D/CustomProperty.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Common;
using FarseerPhysics.SamplesFramework;
using FarseerPhysics.Factories;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using System.Xml;
using System.Xml.Serialization;
namespace Axios.Engine.Gleed2D
{
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//
// NEEDED FOR SERIALIZATION. YOU SHOULDN'T CHANGE ANYTHING BELOW!
//
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
public class CustomProperty
{
public string name;
public object value;
public Type type;
public string description;
public CustomProperty()
{
}
public CustomProperty(string n, object v, Type t, string d)
{
name = n;
value = v;
type = t;
description = d;
}
public CustomProperty clone()
{
CustomProperty result = new CustomProperty(name, value, type, description);
return result;
}
}
public class SerializableDictionary : Dictionary<String, CustomProperty>, IXmlSerializable
{
public SerializableDictionary()
: base()
{
}
public SerializableDictionary(SerializableDictionary copyfrom)
: base(copyfrom)
{
string[] keyscopy = new string[Keys.Count];
Keys.CopyTo(keyscopy, 0);
foreach (string key in keyscopy)
{
this[key] = this[key].clone();
}
}
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public void ReadXml(System.Xml.XmlReader reader)
{
bool wasEmpty = reader.IsEmptyElement;
reader.Read();
if (wasEmpty) return;
while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
{
CustomProperty cp = new CustomProperty();
cp.name = reader.GetAttribute("Name");
cp.description = reader.GetAttribute("Description");
string type = reader.GetAttribute("Type");
if (type == "string") cp.type = typeof(string);
if (type == "bool") cp.type = typeof(bool);
if (type == "Vector2") cp.type = typeof(Vector2);
if (type == "Color") cp.type = typeof(Color);
if (type == "Item") cp.type = typeof(Item);
if (cp.type == typeof(Item))
{
cp.value = reader.ReadInnerXml();
this.Add(cp.name, cp);
}
else
{
reader.ReadStartElement("Property");
XmlSerializer valueSerializer = new XmlSerializer(cp.type);
object obj = valueSerializer.Deserialize(reader);
#if WINDOWS
cp.value = Convert.ChangeType(obj, cp.type);
#elif WINDOWS_PHONE || XBOX360
cp.value = Convert.ChangeType(obj, cp.type, null);
#endif
this.Add(cp.name, cp);
reader.ReadEndElement();
}
reader.MoveToContent();
}
reader.ReadEndElement();
}
public void WriteXml(System.Xml.XmlWriter writer)
{
foreach (String key in this.Keys)
{
writer.WriteStartElement("Property");
writer.WriteAttributeString("Name", this[key].name);
if (this[key].type == typeof(string)) writer.WriteAttributeString("Type", "string");
if (this[key].type == typeof(bool)) writer.WriteAttributeString("Type", "bool");
if (this[key].type == typeof(Vector2)) writer.WriteAttributeString("Type", "Vector2");
if (this[key].type == typeof(Color)) writer.WriteAttributeString("Type", "Color");
if (this[key].type == typeof(Item)) writer.WriteAttributeString("Type", "Item");
writer.WriteAttributeString("Description", this[key].description);
if (this[key].type == typeof(Item))
{
Item item = (Item)this[key].value;
if (item != null) writer.WriteString(item.Name);
else writer.WriteString("$null$");
}
else
{
XmlSerializer valueSerializer = new XmlSerializer(this[key].type);
valueSerializer.Serialize(writer, this[key].value);
}
writer.WriteEndElement();
}
}
/// <summary>
/// Must be called after all Items have been deserialized.
/// Restores the Item references in CustomProperties of type Item.
/// </summary>
public void RestoreItemAssociations(Level level)
{
foreach (CustomProperty cp in Values)
{
if (cp.type == typeof(Item)) cp.value = level.getItemByName((string)cp.value);
}
}
}
}
axios/Engine/Gleed2D/Item.cs
88
99
1010
11
1112
1213
1314
14
15
16
17
18
15
1916
20
21
22
23
24
2517
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
4718
4819
4920
5021
5122
52
23
5324
5425
5526
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using FarseerPhysics.Dynamics;
using Gleed2D.InGame;
namespace Axios.Engine.Gleed2D
{
[XmlInclude(typeof(TextureItem))]
[XmlInclude(typeof(RectangleItem))]
[XmlInclude(typeof(CircleItem))]
[XmlInclude(typeof(PathItem))]
public partial class Item
public class Item
{
/// <summary>
/// The name of this item.
/// </summary>
[XmlAttribute()]
public String Name;
/// <summary>
/// Should this item be visible?
/// </summary>
[XmlAttribute()]
public bool Visible;
/// <summary>
/// The item's position in world space.
/// </summary>
public Vector2 Position;
/// <summary>
/// A Dictionary containing any user-defined Properties.
/// </summary>
public SerializableDictionary CustomProperties;
public Item()
{
CustomProperties = new SerializableDictionary();
}
/// <summary>
/// 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, Layer layer)
public virtual void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
{
}
axios/Engine/Gleed2D/Layer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
namespace Axios.Engine.Gleed2D
{
public partial class Layer
{
/// <summary>
/// The name of the layer.
/// </summary>
[XmlAttribute()]
public String Name;
/// <summary>
/// Should this layer be visible?
/// </summary>
[XmlAttribute()]
public bool Visible;
/// <summary>
/// The list of the items in this layer.
/// </summary>
public List<Item> Items;
/// <summary>
/// The Scroll Speed relative to the main camera. The X and Y components are
/// interpreted as factors, so (1;1) means the same scrolling speed as the main camera.
/// Enables parallax scrolling.
/// </summary>
public Vector2 ScrollSpeed;
/// <summary>
/// A Dictionary containing any user-defined Properties.
/// </summary>
public SerializableDictionary CustomProperties;
public Layer()
{
Items = new List<Item>();
ScrollSpeed = Vector2.One;
}
public void draw(SpriteBatch sb)
{
if (!Visible) return;
foreach (Item item in Items) item.draw(sb);
}
}
}
axios/Engine/Gleed2D/Level.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using System.IO;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Common;
using FarseerPhysics.SamplesFramework;
using FarseerPhysics.Factories;
namespace Axios.Engine.Gleed2D
{
public partial class Level
{
private World _world;
/// <summary>
/// The name of the level.
/// </summary>
[XmlAttribute()]
public String Name;
[XmlAttribute()]
public bool Visible;
/// <summary>
/// A Level contains several Layers. Each Layer contains several Items.
/// </summary>
public List<Layer> Layers;
/// <summary>
/// A Dictionary containing any user-defined Properties.
/// </summary>
public SerializableDictionary CustomProperties;
public Level()
{
Visible = true;
Layers = new List<Layer>();
CustomProperties = new SerializableDictionary();
}
public Level(World world)
{
Visible = true;
Layers = new List<Layer>();
CustomProperties = new SerializableDictionary();
_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);
XmlSerializer serializer = new XmlSerializer(typeof(Level));
Level level = (Level)serializer.Deserialize(stream);
stream.Close();
foreach (Layer layer in level.Layers)
{
foreach (Item item in layer.Items)
{
item.CustomProperties.RestoreItemAssociations(level);
item.load(gameScreen, ref cache, layer);
}
}
return level;
}
public static Level FromStream(Stream stream, AxiosGameScreen gameScreen)
{
Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();
XmlSerializer serializer = new XmlSerializer(typeof(Level));
Level level = (Level)serializer.Deserialize(stream);
stream.Close();
foreach (Layer layer in level.Layers)
{
foreach (Item item in layer.Items)
{
item.CustomProperties.RestoreItemAssociations(level);
item.load(gameScreen, ref cache, layer);
}
}
return level;
}
public Item getItemByName(string name)
{
foreach (Layer layer in Layers)
{
foreach (Item item in layer.Items)
{
if (item.Name == name) return item;
}
}
return null;
}
public Layer getLayerByName(string name)
{
foreach (Layer layer in Layers)
{
if (layer.Name == name) return layer;
}
return null;
}
public void draw(SpriteBatch sb)
{
foreach (Layer layer in Layers) layer.draw(sb);
}
}
}
axios/Engine/Gleed2D/PathItem.cs
99
1010
1111
12
1213
1314
1415
15
16
1617
17
18
19
20
21
18
19
20
21
22
23
24
2225
2326
2427
25
28
2629
30
2731
2832
29
33
3034
31
32
33
34
35
36
35
36
37
38
39
3740
38
39
40
41
41
42
43
44
4245
4346
4447
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Gleed2D.InGame;
namespace Axios.Engine.Gleed2D
{
public partial class PathItem : Item
public class PathItem : Item
{
public Vector2[] LocalPoints;
public Vector2[] WorldPoints;
public bool IsPolygon;
public int LineWidth;
public Color LineColor;
private PathItemProperties _item;
public PathItemProperties LayerItem
{
get { return _item; }
set { }
}
Body _body;
public PathItem()
public PathItem(PathItemProperties i)
{
this._item = i;
}
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache, Layer layer)
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
{
base.load(gameScreen, ref cache, layer);
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)));
base.load(gameScreen, ref cache);
Vertices v = new Vertices(LayerItem.LocalPoints.Count);
foreach (Vector2 vec in LayerItem.LocalPoints)
v.Add(new Vector2(ConvertUnits.ToSimUnits(vec.X), ConvertUnits.ToSimUnits(vec.Y)));
_body = BodyFactory.CreateLoopShape(gameScreen.World, v);
_body.Position = ConvertUnits.ToSimUnits(this.Position);
_body.UserData = this;
}
_body = BodyFactory.CreateLoopShape(gameScreen.World, v);
_body.Position = ConvertUnits.ToSimUnits(this.LayerItem.Position);
_body.UserData = this;
}
}
axios/Engine/Gleed2D/TextureItem.cs
1212
1313
1414
15
1516
1617
1718
1819
1920
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
6321
6422
65
66
67
68
69
23
7024
71
25
26
27
28
29
7230
73
74
31
7532
33
7634
7735
7836
......
8139
8240
8341
84
42
8543
86
87
44
8845
8946
9047
9148
9249
9350
94
51
9552
96
53
9754
98
99
55
56
10057
10158
10259
......
10461
10562
10663
107
64
10865
109
110
111
66
67
68
11269
11370
11471
using FarseerPhysics.Common;
using FarseerPhysics.SamplesFramework;
using FarseerPhysics.Factories;
using Gleed2D.InGame;
namespace Axios.Engine.Gleed2D
{
public partial class TextureItem : Item
{
/// <summary>
/// The item's rotation in radians.
/// </summary>
public float Rotation;
/// <summary>
/// The item's scale factor.
/// </summary>
public Vector2 Scale;
/// <summary>
/// The color to tint the item's texture with (use white for no tint).
/// </summary>
public Color TintColor;
/// <summary>
/// If true, the texture is flipped horizontally when drawn.
/// </summary>
public bool FlipHorizontally;
/// <summary>
/// If true, the texture is flipped vertically when drawn.
/// </summary>
public bool FlipVertically;
/// <summary>
/// The path to the texture's filename (including the extension) relative to ContentRootFolder.
/// </summary>
public String texture_filename;
/// <summary>
/// The texture_filename without extension. For using in Content.Load<Texture2D>().
/// </summary>
public String asset_name;
/// <summary>
/// The XNA texture to be drawn. Can be loaded either from file (using "texture_filename")
/// or via the Content Pipeline (using "asset_name") - then you must ensure that the texture
/// exists as an asset in your project.
/// Loading is done in the Item's load() method.
/// </summary>
///
[XmlIgnore]
public Texture2D texture;
/// <summary>
/// The item's origin relative to the upper left corner of the texture. Usually the middle of the texture.
/// Used for placing and rotating the texture when drawn.
/// </summary>
public Vector2 Origin;
private TextureItemProperties _item;
public Layer Layer;
public TextureItemProperties LayerItem
{
get { return _item; }
set { }
}
public TextureItem()
public TextureItem(TextureItemProperties i)
{
this._item = i;
}
/// <summary>
/// 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, Layer layer)
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
{
this.Layer = layer;
base.load(gameScreen, ref cache, layer);
base.load(gameScreen, ref cache);
//throw new NotImplementedException();
//TODO: provide your own implementation of how a TextureItem loads its assets
//for example:
//this.texture = Texture2D.FromFile(<GraphicsDevice>, texture_filename);
//or by using the Content Pipeline:
if (!cache.ContainsKey(asset_name))
if (!cache.ContainsKey(LayerItem.AssetName))
{
cache[asset_name] = gameScreen.ScreenManager.Game.Content.Load<Texture2D>(asset_name);
cache[LayerItem.AssetName] = gameScreen.ScreenManager.Game.Content.Load<Texture2D>(LayerItem.AssetName);
}
this.texture = cache[asset_name];
Visible = gameScreen.LoadTextureItem(this);
this.texture = cache[LayerItem.AssetName];
//Visible = gameScreen.LoadTextureItem(this);
//this.texture = cm.Load<Texture2D>(asset_name);
public override void draw(SpriteBatch sb)
{
if (!Visible) return;
if (!LayerItem.Visible) return;
SpriteEffects effects = SpriteEffects.None;
if (FlipHorizontally) effects |= SpriteEffects.FlipHorizontally;
if (FlipVertically) effects |= SpriteEffects.FlipVertically;
sb.Draw(texture, Position, null, TintColor, Rotation, Origin, Scale, effects, 0);
if (LayerItem.FlipHorizontally) effects |= SpriteEffects.FlipHorizontally;
if (LayerItem.FlipVertically) effects |= SpriteEffects.FlipVertically;
sb.Draw(texture, LayerItem.Position, null, LayerItem.TintColor, LayerItem.Rotation, LayerItem.Origin, LayerItem.Scale, effects, 0);
}
}
}

Archive Download the corresponding diff file

Page rendered in 0.46637s using 14 queries.