axiosengine 

axiosengine Commit Details


Date:2014-12-30 22:07:05 (9 years 11 months ago)
Author:Natalie Adams
Branch:master
Commit:67ab74899fa60e78bc5cde08f180fbd225451280
Parents: 1a04355fdec4dcb21bfd9e884207a4473c8a8ebc
Message:Removing cache from Gleed2D as ContentManager automatically does this Adding cache Adding XOR Shift random class

Changes:

File differences

axios/Axios_WP7.csproj
164164
165165
166166
167
167168
168169
169170
......
179180
180181
181182
183
182184
183185
184186
<Compile Include="Engine\AxiosBreakableGameObject.cs" />
<Compile Include="Engine\ComplexAxiosGameObject.cs" />
<Compile Include="Engine\Data\AxiosCSV.cs" />
<Compile Include="Engine\Data\Cache.cs" />
<Compile Include="Engine\Data\DataEvents.cs" />
<Compile Include="Engine\Data\AxiosDataTable.cs" />
<Compile Include="Engine\DrawableAxiosGameObject.cs" />
<Compile Include="Engine\File\AxiosIsolatedFile.cs" />
<Compile Include="Engine\File\AxiosRegularFile.cs" />
<Compile Include="Engine\File\AxiosTitleFile.cs" />
<Compile Include="Engine\GameServices.cs" />
<Compile Include="Engine\Gleed2D\Camera.cs" />
<Compile Include="Engine\Gleed2D\CircleItem.cs" />
<Compile Include="Engine\Gleed2D\CustomProperty.cs" />
axios/Axios_Windows.csproj
213213
214214
215215
216
216217
217218
218219
220
219221
220222
221223
......
230232
231233
232234
235
233236
234237
235238
<Compile Include="Dynamics\World.cs" />
<Compile Include="Dynamics\WorldCallbacks.cs" />
<Compile Include="Engine\AxiosGameObject.cs" />
<Compile Include="Engine\AxiosRandom.cs" />
<Compile Include="Engine\ComplexAxiosGameObject.cs" />
<Compile Include="Engine\Data\AxiosCSV.cs" />
<Compile Include="Engine\Data\AxiosDataTable.cs" />
<Compile Include="Engine\Data\Cache.cs" />
<Compile Include="Engine\Data\DataEvents.cs" />
<Compile Include="Engine\DrawableAxiosGameObject.cs" />
<Compile Include="Engine\DrawableBreakableAxiosGameObject.cs" />
<Compile Include="Engine\File\AxiosIsolatedFile.cs" />
<Compile Include="Engine\File\AxiosRegularFile.cs" />
<Compile Include="Engine\File\AxiosTitleFile.cs" />
<Compile Include="Engine\GameServices.cs" />
<Compile Include="Engine\Gleed2D\Item.cs" />
<Compile Include="Engine\Gleed2D\PathItem.cs" />
<Compile Include="Engine\Gleed2D\TextureItem.cs" />
axios/Axios_Xbox_360.csproj
158158
159159
160160
161
161162
162163
163164
......
172173
173174
174175
176
175177
176178
177179
<Compile Include="Engine\ComplexAxiosGameObject.cs" />
<Compile Include="Engine\Data\AxiosCSV.cs" />
<Compile Include="Engine\Data\AxiosDataTable.cs" />
<Compile Include="Engine\Data\Cache.cs" />
<Compile Include="Engine\Data\DataEvents.cs" />
<Compile Include="Engine\DrawableAxiosGameObject.cs" />
<Compile Include="Engine\DrawableBreakableAxiosGameObject.cs" />
<Compile Include="Engine\File\AxiosIsolatedFile.cs" />
<Compile Include="Engine\File\AxiosRegularFile.cs" />
<Compile Include="Engine\File\AxiosTitleFile.cs" />
<Compile Include="Engine\GameServices.cs" />
<Compile Include="Engine\Gleed2D\Camera.cs" />
<Compile Include="Engine\Gleed2D\CircleItem.cs" />
<Compile Include="Engine\Gleed2D\CustomProperty.cs" />
axios/Axios_settings.cs
131131
132132
133133
134
135
136
134137
135138
136139
*
* 1.0.1.11 -
* - Adding game services static class
* - Removing cache from Gleed2D as ContentManager automatically does this
* - Adding cache
* - Adding XOR Shift random class
*
*/
#endregion
axios/Engine/AxiosGameScreen.cs
7878
7979
8080
81
82
81
8382
8483
8584
......
494493
495494
496495
496
497497
498498
499
499500
500501
501502
......
523524
524525
525526
527
526528
527529
528530
......
539541
540542
541543
542
544
543545
544546
545547
......
551553
552554
553555
554
556
555557
556558
557559
this._uiobjects = new List<AxiosUIObject>();
prevuiobj = null;
prevuifocusobj = null;
GameServices.AddService<GraphicsDevice>(this.ScreenManager.GraphicsDevice);
GameServices.AddService<ContentManager>(this.ScreenManager.Game.Content);
}
public void LoadLevelFromStream(Stream s)
public override void Unload()
{
//this.IsExiting = true;
//System.Diagnostics.Debugger.Break();
base.Deactivate();
ScreenState = GameStateManagement.ScreenState.TransitionOff;
AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
foreach (AxiosGameObject g in _gameObjects)
g.UnloadContent(this);
_console = null;
}
#endif
}
public virtual void LoadPathItem(PathItemProperties pathitem, Layer l)
{
PathItem p = new PathItem((PathItemProperties)pathitem);
p.load(this, ref cache);
p.load(this);
PathItems[pathitem.Name] = p;
}
public virtual void LoadTextureItem(TextureItemProperties textureitem, Layer l)
{
TextureItem i = new TextureItem((TextureItemProperties)textureitem);
i.load(this, ref cache);
i.load(this);
TextureItems[textureitem.Name] = i;
}
axios/Engine/AxiosRandom.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Axios.Engine
{
// Implemenation of an XORShift
// http://en.wikipedia.org/wiki/Xorshift
// http://stackoverflow.com/questions/6275593/how-to-write-you-own-random-number-algorithm
public class AxiosRandom
{
private static int x;
private static int y;
private static int z;
private static int w;
private static int t = 0;
public void init(int x, int y, int z, int w)
{
AxiosRandom.x = x;
AxiosRandom.y = y;
AxiosRandom.z = z;
AxiosRandom.w = w;
}
public static void init()
{
AxiosRandom.x = generateVector();
AxiosRandom.y = generateVector();
AxiosRandom.z = generateVector();
AxiosRandom.w = generateVector();
}
public static int next()
{
t = x ^ (x << 11);
x = y; y = z; z = w;
return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
}
private static int generateVector()
{
int[] x = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int[] val = new int[9];
for (int i = 0; i < 9; i++)
val[i] = x[GameServices.GetService<Random>().Next(x.Count() - 1)];
return int.Parse(String.Join("", val));
}
}
}
axios/Engine/Data/Cache.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Axios.Engine.Data
{
// Q. What is the point of this?
// A. This is not to cache textures loaded by content manager
// but other data/content that isn't. Use cases include:
// - Any graphics generated during runtime (such as dialogs)
// - Any data that is loaded in during run time (such as maps)
// Content manager performs it's own caching so anything loaded by it
// or the Gameservice - then attempted to load again will not be loaded
// again but rather a reference to it will be returned
// ************************************************
// DANGER WILL ROBINSON DANGER
// ************************************************
// Only store stuff here that you want during the FULL lifecycle of your game
// The cache is never cleared - so a reference will exist for the objects you leave
// You MAY clear the cache by using the clear method or unset
//
// You probably don't want this
// There is no cache...
// This is not the cache you are looking for...
//
public class Cache : Singleton<Cache>
{
private Dictionary<string, object> _cache;
public Cache()
{
_cache = new Dictionary<string, object>();
}
public object get(string key)
{
return _cache[key];
}
public void set(string key, object obj)
{
_cache[key] = obj;
}
public void unset(string key)
{
_cache.Remove(key);
}
public void clear()
{
_cache = new Dictionary<string, object>();
}
}
}
axios/Engine/GameServices.cs
55
66
77
8
8
99
1010
1111
public static class GameServices
{
private static GameServiceContainer container;
private static object lockobj;
private static object lockobj = new object();
public static GameServiceContainer Instance
{
get
axios/Engine/Gleed2D/Item.cs
2020
2121
2222
23
23
2424
2525
2626
/// 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)
{
}
axios/Engine/Gleed2D/PathItem.cs
3030
3131
3232
33
33
3434
35
35
3636
3737
3838
this._item = i;
}
public override void load(AxiosGameScreen gameScreen, ref Dictionary<string, Texture2D> cache)
public override void load(AxiosGameScreen gameScreen)
{
base.load(gameScreen, ref cache);
base.load(gameScreen);
Vertices v = new Vertices(LayerItem.LocalPoints.Count);
foreach (Vector2 vec in LayerItem.LocalPoints)
axios/Engine/Gleed2D/TextureItem.cs
3939
4040
4141
42
42
4343
44
44
4545
4646
4747
4848
4949
5050
51
51
5252
5353
54
55
54
55
5656
5757
5858
/// 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)
{
base.load(gameScreen, ref cache);
base.load(gameScreen);
//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(LayerItem.AssetName))
/*if (!cache.ContainsKey(LayerItem.AssetName))
{
cache[LayerItem.AssetName] = gameScreen.ScreenManager.Game.Content.Load<Texture2D>(LayerItem.AssetName);
}
this.texture = cache[LayerItem.AssetName];
}*/
this.texture = gameScreen.ScreenManager.Game.Content.Load<Texture2D>(LayerItem.AssetName);
//Visible = gameScreen.LoadTextureItem(this);
//this.texture = cm.Load<Texture2D>(asset_name);
axios/ScreenSystem/PhysicsGameScreen.cs
9898
9999
100100
101
101
102102
103103
104104
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
{
if (!coveredByOtherScreen && !otherScreenHasFocus)
if (!coveredByOtherScreen && !otherScreenHasFocus && ScreenState != GameStateManagement.ScreenState.TransitionOff)
{
// variable time step but never less then 30 Hz
if (UseSecondStep)
axios/ScreenSystem/ScreenManager.cs
1919
2020
2121
22
2223
2324
2425
......
149150
150151
151152
153
154
155
156
157
158
159
160
161
162
163
164
152165
153166
154167
using System.IO.IsolatedStorage;
using System.Xml.Linq;
using FarseerPhysics.SamplesFramework;
using Axios.Engine;
#endregion
namespace GameStateManagement
spriteBatch = new SpriteBatch(GraphicsDevice);
font = content.Load<SpriteFont>("menufont");
blankTexture = Game.Content.Load<Texture2D>("Materials/blank");
GameServices.AddService<GraphicsDevice>(this.Game.GraphicsDevice);
GameServices.AddService<ContentManager>(this.Game.Content);
// It is advised to use one instance of Random
// because Random is seeded with the current time
// initilizing random objects too quickly can cause
// the impression of generating the same value
// http://stackoverflow.com/questions/2727538/random-encounter-not-so-random
GameServices.AddService<Random>(new Random());
AxiosRandom.init();
input.LoadContent();
// Tell each of the screens to load their content.
foreach (GameScreen screen in screens)

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.10285s using 14 queries.