Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMcAssey committed Mar 21, 2014
1 parent 2ca2f25 commit f89e47c
Show file tree
Hide file tree
Showing 35 changed files with 477 additions and 203 deletions.
2 changes: 1 addition & 1 deletion SolarFusion/GameData/PlayerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PlayerData
public string playerName = "";

//Animation
public string playerAsset = "";
public string playerRef = "";
public string defaultAnimation = "";
public float playerScale = 1f;
public int maxFrameCount = 1;
Expand Down
47 changes: 24 additions & 23 deletions SolarFusion/SolarFusion/SolarFusion/Core/.NET/HashSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,60 @@
namespace Containers
{
/// <summary>
/// HashSet for Xbox360.
/// HashSet for Xbox 360 functionality.
/// </summary>
/// <typeparam name="T"></typeparam>
public class HashSet<T> : ICollection<T>
{
private Dictionary<T, short> MyDict;
private Dictionary<T, short> mDict;

public HashSet()
{
MyDict = new Dictionary<T, short>();
this.mDict = new Dictionary<T, short>();
}

public HashSet(IEnumerable enumer)
public HashSet(HashSet<T> from)
{
MyDict = new Dictionary<T, short>();
foreach (T item in enumer)
{
MyDict.Add(item, 0);
}
this.mDict = new Dictionary<T, short>();
foreach (T n in from)
this.mDict.Add(n, 0);
}
// Methods

#region "Methods"
public void Add(T item)
{
// We don't care for the value in dictionary, Keys matter.
MyDict.Add(item, 0);
this.mDict.Add(item, 0);
}

public void Clear()
{
MyDict.Clear();
this.mDict.Clear();
}

public bool Contains(T item)
{
return MyDict.ContainsKey(item);
return this.mDict.ContainsKey(item);
}

public void CopyTo(T[] array, int arrayIndex)
{
throw new NotImplementedException();
foreach (var _item in this.mDict.Keys)
array[arrayIndex++] = _item;
}

public bool Remove(T item)
{
return MyDict.Remove(item);
return this.mDict.Remove(item);
}

public IEnumerator<T> GetEnumerator()
public IEnumerator GetEnumerator()
{
throw new NotImplementedException();
return this.mDict.Keys.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
throw new NotImplementedException();
return this.mDict.Keys.GetEnumerator();
}

public void UnionWith(IEnumerable<T> other)
Expand All @@ -68,21 +67,23 @@ public void UnionWith(IEnumerable<T> other)
{
try
{
MyDict.Add(item, 0);
this.mDict.Add(item, 0);
}
catch (ArgumentException) { }
}
}
#endregion

// Properties
#region "Properties"
public int Count
{
get { return MyDict.Keys.Count; }
get { return this.mDict.Keys.Count; }
}

public bool IsReadOnly
{
get { return false; }
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void X360_ReadFile()
X360_CreateNewFile(); // Creates a new file.
}
}
catch (InvalidOperationException ex01) // Error reading and deserializing the file, so creates a new one.
catch (InvalidOperationException ex) // Error reading and deserializing the file, so creates a new one.
{
if (_stream != null)
_stream.Close(); // Closes the stream if it exists.
Expand Down
16 changes: 4 additions & 12 deletions SolarFusion/SolarFusion/SolarFusion/Core/Entities/EntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,23 @@ public GameObjects DestroyObject(uint id)

public uint[] QueryRegion(Rectangle bounds)
{
HashSet<uint> horizontalMatches = new HashSet<uint>(); //Create a new HashSet to compare matches
HashSet<uint> verticalMatches = new HashSet<uint>();
HashSet<uint> queryMatches = new HashSet<uint>(); //Create a new HashSet to compare matches

Bound left = new Bound(null, bounds.Left, BoundType.Min); //Creates a new bound for left.
int minHorizontalIndex = horizontalAxis.BinarySearch(left); //Searches the axis for the bound and sets it as the minimum amount..

if (minHorizontalIndex < 0) //If its less than zero
{
minHorizontalIndex = ~minHorizontalIndex; //NOT the number
}

Bound right = new Bound(null, bounds.Right, BoundType.Max);
int maxHorizontalIndex = horizontalAxis.BinarySearch(right);

if (maxHorizontalIndex < 0)
{
maxHorizontalIndex = ~maxHorizontalIndex;
}

for (int i = minHorizontalIndex; i < maxHorizontalIndex; i++)
{
horizontalMatches.Add(horizontalAxis[i].Box.GameObjectID); //NEED TO DO
}
if (!queryMatches.Contains(horizontalAxis[i].Box.GameObjectID))
queryMatches.Add(horizontalAxis[i].Box.GameObjectID);

return horizontalMatches.ToArray();
return queryMatches.ToArray();
}

public uint NextID()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace SolarFusion.Core
{
public class Player : GameObjects
{
public bool isSingleplayer = false;
public bool isSingleplayer = false;
public bool isMultiplayer = false;
public bool isHidden = false;
public bool inControl = false;
Expand Down Expand Up @@ -61,6 +61,12 @@ public float PlayerHealth
set { this.Health = value; }
}

public AnimatedSprite PlayerAnimation
{
get { return this.playerAnimation; }
set { this.playerAnimation = value; }
}

public override Rectangle Bounds
{
get { return new Rectangle((int)(Position.X - ((playerAnimation.AnimationWidth * playerAnimation.Scale) / 2f)), (int)(Position.Y - ((playerAnimation.AnimationHeight * playerAnimation.Scale) / 2f)), (int)(playerAnimation.AnimationWidth * playerAnimation.Scale), (int)(playerAnimation.AnimationHeight * playerAnimation.Scale)); }
Expand Down Expand Up @@ -95,7 +101,7 @@ public void moveRight()
{
if (isJumping == false && isOnTop == false)
moveDirection = MoveDirection.Right;

position.X += moveSpeed;
playerAnimation.CurrentAnimation = "right";
}
Expand Down Expand Up @@ -143,7 +149,7 @@ public override void Update(GameTime gameTime)
{
jumpSpeed = jumpSpeed * 1.2f;
}

if (position.Y <= maxHeight || jumpDirection == 1)
{
if (jumpDirection != 1)
Expand Down
2 changes: 1 addition & 1 deletion SolarFusion/SolarFusion/SolarFusion/Core/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Game()
this.Components.Add(this._obj_screenmanager);

this._obj_screenmanager.addScreen(new ScreenBG(), null);
this._obj_screenmanager.addScreen(new ScreenMenuRoot(), PlayerIndex.One);
this._obj_screenmanager.addScreen(new ScreenStart(), PlayerIndex.One);
}

/// <summary>
Expand Down
28 changes: 23 additions & 5 deletions SolarFusion/SolarFusion/SolarFusion/Core/Level/LevelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class LevelManager

private uint _current_level_id = 0;
private PlayerIndex? mControllingPlayer;
private bool isScrolling = false;

// Effects
private CrepuscularRays _effect_sun = null;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void LoadLevel(uint _LevelID, Player _activePlayer, EntityManager _objMan
switch (goData.entCategory) //Swtich by object category.
{
case "PlayerStart":
Vector2 newPos = new Vector2(position.X, (position.Y - ((this._obj_player.Height / 2) / 2)));
Vector2 newPos = new Vector2(position.X, position.Y + ((this._obj_player.Height / 2) / 2));
this._obj_player.Position = newPos;
this._obj_player.floorHeight = position.Y + ((this._obj_player.Height / 2) / 2);
this._obj_player.isSingleplayer = true;
Expand All @@ -111,8 +112,8 @@ public void LoadLevel(uint _LevelID, Player _activePlayer, EntityManager _objMan
}
// !Load Level Objects

this._effect_sun = new CrepuscularRays(this._obj_graphics, this._effect_sun_pos, 2.5f, 0.97f, 0.97f, 0.7f, 0.25f, this._obj_contentmanager.Load<Effect>("Core/Shaders/PostProcessing/LightSourceMask"), this._obj_contentmanager.Load<Texture2D>("Core/Textures/sun_flare"), this._obj_contentmanager.Load<Effect>("Core/Shaders/PostProcessing/LigthRays"));
this._effect_sun_pos = new Vector2(0.2f, 0.38f);
this._effect_sun = new CrepuscularRays(this._obj_graphics, this._effect_sun_pos, 1.5f, 0.97f, 0.97f, 0.1f, 0.25f, this._obj_contentmanager.Load<Effect>("Core/Shaders/PostProcessing/LightSourceMask"), this._obj_contentmanager.Load<Texture2D>("Core/Textures/sun_flare"), this._obj_contentmanager.Load<Effect>("Core/Shaders/PostProcessing/LigthRays"));
this._effect_sun_pos = new Vector2(0.2f, 0.35f);
this._obj_ppmanager.AddEffect(this._effect_sun);
this._obj_scene = new RenderTarget2D(this._obj_graphics, this._obj_graphics.Viewport.Width, this._obj_graphics.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.None);
this._effect_sky_color = new Color(135, 206, 250);
Expand All @@ -122,6 +123,9 @@ public void LoadLevel(uint _LevelID, Player _activePlayer, EntityManager _objMan
this._obj_camera.Zoom = 1.0f;
this._obj_camera.Speed = 60f;
this._obj_entitymanager.camera = this._obj_camera;


this.isScrolling = true;
}

public void UnloadLevel()
Expand All @@ -137,6 +141,16 @@ public void Update(GameTime _gameTime)
{
float timeDiff = (float)_gameTime.ElapsedGameTime.TotalSeconds;
this._effect_sun.LightSource = this._effect_sun_pos;
this._obj_entitymanager.Update(_gameTime);

if ((this._obj_camera.Position.X + (this._obj_viewport.Width / 2)) >= ((this._obj_map.tmWidth * this._obj_map.tmTileWidth) - 10))
this.isScrolling = false; //If player reaches the end of the map, stop the scrolling.

if (this.isScrolling) //If the map is scrolling, do the following:
{
float scrollDelta = (float)_gameTime.ElapsedGameTime.TotalSeconds * this._obj_camera.Speed; //Gets delta to increment camera position.
this._obj_camera.Position += new Vector2(scrollDelta, 0); //Increments the camera speed.
}

foreach (uint goID in this._obj_entitymanager.dynamicObjects) //Checks all the dynamic objects in the level, and loops through updating them.
{
Expand Down Expand Up @@ -197,6 +211,10 @@ public void Update(GameTime _gameTime)
}
}

Rectangle deleteBounds = new Rectangle((int)((this._obj_camera.Position.X - (this._obj_viewport.Width / 2f)) - 50), 0, -4480, this._obj_map.tmHeight * this._obj_map.tmTileHeight); //Sets bounds for deleting objects.
foreach (uint goID in this._obj_entitymanager.QueryRegion(deleteBounds)) //Checks if any objects are in the bounds, and loops through deleting them.
this._obj_entitymanager.DestroyObject(goID); //Delets the object if its in the bounds.

this._obj_player.Update(_gameTime);
}

Expand Down Expand Up @@ -226,8 +244,8 @@ public void Draw(SpriteBatch _sb)

//Draw the post processing effects
_sb.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearClamp, null, null, null, this._obj_camera.calculateTransform());
_sb.Draw(this._obj_ppmanager.mScene, new Rectangle(0, 0, this._obj_graphics.Viewport.Width, this._obj_graphics.Viewport.Height), Color.White);
_sb.Draw(this._obj_scene, new Rectangle(0, 0, this._obj_graphics.Viewport.Width, this._obj_graphics.Viewport.Height), Color.White);
_sb.Draw(this._obj_ppmanager.mScene, new Rectangle((int)(this._obj_camera.Position.X - (this._obj_viewport.Width / 2)), 0, this._obj_graphics.Viewport.Width, this._obj_graphics.Viewport.Height), Color.White);
_sb.Draw(this._obj_scene, new Rectangle((int)(this._obj_camera.Position.X - (this._obj_viewport.Width / 2)), 0, this._obj_graphics.Viewport.Width, this._obj_graphics.Viewport.Height), Color.White);
_sb.End();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public override void update()
/// </summary>
public override void render()
{
this.ScreenManager.GraphicsDevice.Clear(Color.Black);
if ((this.CurrentScreenMode == ScreenMode.MODE_ACTIVE) && (this.ScreenManager.getScreens().Length == 1))
{
this._prev_screens_clean = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class ScreenPause : BaseGUIScreen
/// Constructor.
/// </summary>
public ScreenPause()
: base("- PAUSED -", false, null, false, 1f)
: base("PAUSED", Color.White, false, null, false, 1f)
{
this._is_popup = true;
this._message_alpha = DEFAULT_ALPHA;
}

Expand Down
Loading

0 comments on commit f89e47c

Please sign in to comment.