diff --git a/.gitignore b/.gitignore index f702560..1427730 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ SolarFusion/GameData/obj/ SolarFusion/DataPipeline/obj/ SolarFusion/DataPipeline/bin/ SolarFusion/GameData/bin/x86/Debug/GameData.dll +SolarFusion/GameData/bin/ diff --git a/SolarFusion/GameData/PlayerData.cs b/SolarFusion/GameData/PlayerData.cs index 522ba5a..f32f79f 100644 --- a/SolarFusion/GameData/PlayerData.cs +++ b/SolarFusion/GameData/PlayerData.cs @@ -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; @@ -22,7 +22,6 @@ public class PlayerData //Settings public float moveSpeed = 1f; public float jumpSpeed = 1f; - public float jumpHeight = 10f; public bool hiddenCharacter = false; } diff --git a/SolarFusion/GameData/bin/Xbox 360/Debug/GameData.dll b/SolarFusion/GameData/bin/Xbox 360/Debug/GameData.dll deleted file mode 100644 index 2a56936..0000000 Binary files a/SolarFusion/GameData/bin/Xbox 360/Debug/GameData.dll and /dev/null differ diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/.NET/HashSet.cs b/SolarFusion/SolarFusion/SolarFusion/Core/.NET/HashSet.cs index a32d6a7..74f33ef 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/.NET/HashSet.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/.NET/HashSet.cs @@ -5,61 +5,61 @@ namespace Containers { /// - /// HashSet for Xbox360. + /// HashSet for Xbox 360 functionality. /// /// public class HashSet : ICollection { - private Dictionary MyDict; + private Dictionary mDict; public HashSet() { - MyDict = new Dictionary(); + this.mDict = new Dictionary(); } - public HashSet(IEnumerable enumer) + public HashSet(HashSet from) { - MyDict = new Dictionary(); - foreach (T item in enumer) - { - MyDict.Add(item, 0); - } + this.mDict = new Dictionary(); + 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); + if(!this.Contains(item)) + 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 GetEnumerator() + public IEnumerator GetEnumerator() { - throw new NotImplementedException(); + return this.mDict.Keys.GetEnumerator(); } - IEnumerator IEnumerable.GetEnumerator() + IEnumerator IEnumerable.GetEnumerator() { - throw new NotImplementedException(); + return this.mDict.Keys.GetEnumerator(); } public void UnionWith(IEnumerable other) @@ -68,21 +68,23 @@ public void UnionWith(IEnumerable 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 } } \ No newline at end of file diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Config/ConfigManager.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Config/ConfigManager.cs index 6ae6687..67da7bc 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Config/ConfigManager.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Config/ConfigManager.cs @@ -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. diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/AI/AI.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/AI/AI.cs index 47b5a0f..c3179f1 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/AI/AI.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/AI/AI.cs @@ -30,7 +30,11 @@ public Vector2 Position set { animation.Position = value; } } - public AI(uint id) : base(id) { } + public AI(uint id) + : base(id) + { + this.Score = 1; + } public override void Update(GameTime gameTime) { diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/AI/Enemy_MercBot.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/AI/Enemy_MercBot.cs index 511b2de..de07bb7 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/AI/Enemy_MercBot.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/AI/Enemy_MercBot.cs @@ -14,19 +14,15 @@ public class Enemy_MercBot : AI public Enemy_MercBot(uint id, ContentManager virtualContent, Vector2 position) : base(id) { - Texture2D tmpTexture = virtualContent.Load("Sprites/Enemies/MercBot"); + Texture2D tmpTexture = virtualContent.Load("Sprites/Enemies/mercbot/spritesheet"); this.animation = new AnimatedSprite(tmpTexture, 3, 3); - this.animation.AddAnimation("idle", 1, 3, 3); this.animation.AddAnimation("left", 2, 3, 3); this.animation.AddAnimation("right", 3, 3, 3); - - this.animation.Position = position; - this.animation.Origin = new Vector2((tmpTexture.Width / 3f) / 2f, (tmpTexture.Height / 3f) / 2f); + this.animation.Position = new Vector2(position.X, position.Y - 15); this.animation.Scale = 1.5f; this.animation.CurrentAnimation = "idle"; this.animation.Loop = true; - this.Health = 100; this.Speed = 1f; } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/EntityManager.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/EntityManager.cs index 326d223..7bc0b74 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/EntityManager.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/EntityManager.cs @@ -25,6 +25,7 @@ public class EntityManager public List dynamicObjects; public List projectileObjects; public Camera2D camera; + protected Vector2 mGravity; //Collision Detection Dictionary boundingBoxes; @@ -32,10 +33,18 @@ public class EntityManager HashSet horizontalOverlaps; HashSet collisions; + #region "Properties" + public Vector2 Gravity + { + get { return this.mGravity; } + } + #endregion + public EntityManager(ContentManager _content) { this.virtualContent = _content; //Gets the ContentManager passed. gameObjects = new Dictionary(); + this.mGravity = new Vector2(0f, -198.0f); createdGameObjects = new Queue(); destroyedGameObjects = new Queue(); @@ -70,10 +79,8 @@ public void Update(GameTime gameTime) while (createdGameObjects.Count > 0) { GameObjects go = createdGameObjects.Dequeue(); - if (go is AI || go is PowerUp || go is LevelObject) - { + if (go is AI || go is PowerUp || go is LevelObject || go is Blast || go is Player) dynamicObjects.Add(go.ID); - } AddGameObject(go); } @@ -81,7 +88,7 @@ public void Update(GameTime gameTime) while (destroyedGameObjects.Count > 0) { GameObjects go = destroyedGameObjects.Dequeue(); - if (go is AI || go is PowerUp || go is LevelObject) + if (go is AI || go is PowerUp || go is LevelObject || go is Blast || go is Player) { dynamicObjects.Remove(go.ID); } @@ -114,31 +121,12 @@ public GameObjects DestroyObject(uint id) public uint[] QueryRegion(Rectangle bounds) { - HashSet horizontalMatches = new HashSet(); //Create a new HashSet to compare matches - HashSet verticalMatches = new HashSet(); - - 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 - } + HashSet queryMatches = new HashSet(); //Create a new HashSet to compare matches + foreach (uint goID in this.dynamicObjects) + if (bounds.Intersects(this.GetObject(goID).Bounds)) + queryMatches.Add(goID); - return horizontalMatches.ToArray(); + return queryMatches.ToArray(); } public uint NextID() @@ -163,15 +151,12 @@ public PowerUp CreatePowerup(PowerUpType powerupType, Vector2 position) case PowerUpType.EnergyBall: powerup = new PowerUp_EnergyBall(id, virtualContent, position); break; - case PowerUpType.Crate: - powerup = new PowerUp_Crate(id, virtualContent, position); - break; - case PowerUpType.Dynamite: - powerup = new PowerUp_Dynamite(id, virtualContent, position); - break; case PowerUpType.Crystal: powerup = new PowerUp_Crystal(id, virtualContent, position); break; + case PowerUpType.Warp: + powerup = new PowerUp_Warp(id, virtualContent, position); + break; default: powerup = new PowerUp_EnergyBall(id, virtualContent, position); break; @@ -202,6 +187,18 @@ public AI CreateEnemy(EnemyType enemyType, Vector2 position) return enemy; } + public Blast CreateBullet(Blast _bullet) + { + QueueGameObjectForCreation(_bullet); + return _bullet; + } + + public Player CreatePlayer(Player _player) + { + QueueGameObjectForCreation(_player); + return _player; + } + public LevelObject CreateLevelObject(LevelObjectType levelObjectType, Vector2 position) { LevelObject levelobject; @@ -212,8 +209,14 @@ public LevelObject CreateLevelObject(LevelObjectType levelObjectType, Vector2 po case LevelObjectType.Solid: levelobject = new LevelObject_Solid(id, virtualContent, position); break; + case LevelObjectType.NonSolid: + levelobject = new LevelObject_NonSolid(id, virtualContent, position); + break; + case LevelObjectType.Crate: + levelobject = new LevelObject_Crate(id, virtualContent, position); + break; default: - levelobject = new LevelObject_Solid(id, virtualContent, position); + levelobject = new LevelObject_Crate(id, virtualContent, position); break; } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/GameObjects.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/GameObjects.cs index add7cd4..357f6fb 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/GameObjects.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/GameObjects.cs @@ -10,10 +10,11 @@ namespace SolarFusion.Core public enum ObjectType { Player = 0, - Enemy = 1, - PowerUp = 2, - LevelObject = 3, - Other = 4, + Enemy, + PowerUp, + LevelObject, + Bullet, + Other, } public enum MoveDirection @@ -29,7 +30,7 @@ public abstract class GameObjects public readonly uint ID; public ObjectType ObjectType = ObjectType.Other; public float LayerDepth; - public int Score = 1; + public int Score = 0; public abstract Rectangle Bounds { get; } public bool Hidden = false; public Rectangle defaultBounds; diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/General/Blast.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/General/Blast.cs new file mode 100644 index 0000000..8b520de --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/General/Blast.cs @@ -0,0 +1,75 @@ +using System; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Content; + +namespace SolarFusion.Core +{ + public class Blast : GameObjects + { + protected static Texture2D mBlastTexture; + protected static Vector2 mBlastTextureOrigin; + protected static float mScale; + protected Vector2 mPosition; + protected float mMaxLife; + protected float mSpeed; + protected float mRotation; + protected bool mDelete = false; + + public bool ForDeletion + { + get { return this.mDelete; } + } + + public Vector2 Position + { + get { return this.mPosition; } + } + + public static Texture2D Texture + { + get { return mBlastTexture; } + } + + public override Rectangle Bounds + { + get { return new Rectangle((int)(this.mPosition.X - (mBlastTexture.Width / 2f)), (int)(this.mPosition.Y - (mBlastTexture.Height / 2f)), Blast.Texture.Width, Blast.Texture.Height); } + } + + public Blast(uint id, Vector2 _position, float _maxLife, float _speed, float _rotation) + : base(id) + { + this.mPosition = _position; + this.mMaxLife = _maxLife; + this.mSpeed = _speed; + this.mRotation = _rotation; + this.ObjectType = ObjectType.Bullet; + } + + public static void Load(ContentManager _content) + { + mBlastTexture = _content.Load("Sprites/Objects/Static/blast/sprite"); + mBlastTextureOrigin = new Vector2(mBlastTexture.Width / 2f, mBlastTexture.Height / 2f); + mScale = 1f; + } + + public override void Update(GameTime gameTime) + { + if (!this.mDelete) + { + this.mPosition.X += this.mSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; + this.mMaxLife -= (float)gameTime.ElapsedGameTime.TotalSeconds; + if (this.mMaxLife <= 0) + this.mDelete = true; + } + } + + public override void Draw(SpriteBatch _sb) + { + if (!this.mDelete || !this.Hidden) + _sb.Draw(mBlastTexture, this.mPosition, null, Color.White, this.mRotation, mBlastTextureOrigin, mScale, SpriteEffects.None, 0f); + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/General/Player.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/General/Player.cs index e06482f..7f51f9d 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/General/Player.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/General/Player.cs @@ -11,43 +11,54 @@ namespace SolarFusion.Core { public class Player : GameObjects { - public bool isSingleplayer = false; + protected EntityManager _obj_entitymanager; + + public bool isSingleplayer = false; public bool isMultiplayer = false; - public bool isHidden = false; public bool inControl = false; - AnimatedSprite playerAnimation; - public string CharacterName = ""; - public float moveSpeed = 1f; - public float jumpSpeed = 1f; - public float jumpHeight = 10f; - public float maxHeight = 0f; - public float jumpDistance = 0f; - public float originalJumpSpeed = 0f; - public int jumpDirection = 0; - public MoveDirection moveDirection = MoveDirection.Idle; - public float floorHeight = 0f; - public float originalFloorHeight = 0f; - Vector2 position = Vector2.Zero; + public bool isGemCollected = false; public bool isJumping = false; - private EntityManager mObjectManager; - private float Health = 100.0f; - public bool isOnTop = false; - public bool addGravity = false; + public bool isUpdateGravity = false; + + protected string mCharacterName = ""; + protected float mMoveSpeed = 1f; + protected MoveDirection mMoveDirection = MoveDirection.Idle; + protected float mFloorHeight = 0f; + protected float mOriginalFloorHeight = 0f; + + protected Vector2 mPosition = Vector2.Zero; + protected Vector2 mVelocity = Vector2.Zero; + protected AnimatedSprite mAnimation; + protected float mHealth = 100.0f; + protected float mJumpSpeed = 1f; + + #region "Properties" + public String CharacterName + { + get { return this.mCharacterName; } + set { this.mCharacterName = value; } + } public Vector2 Position { - get { return position; } - set { position = value; playerAnimation.Position = position; } + get { return this.mPosition; } + set { this.mPosition = value; this.mAnimation.Position = this.mPosition; } + } + + public Vector2 Velocity + { + get { return this.mVelocity; } + set { this.mVelocity = value; } } public int Width { - get { return playerAnimation.AnimationWidth; } + get { return this.mAnimation.AnimationWidth; } } public int Height { - get { return playerAnimation.AnimationHeight; } + get { return this.mAnimation.AnimationHeight; } } public int PlayerScore @@ -57,146 +68,146 @@ public int PlayerScore public float PlayerHealth { - get { return this.Health; } - set { this.Health = value; } + get { return this.mHealth; } + set { this.mHealth = value; } + } + + public float JumpHeight + { + get { return this.mFloorHeight; } + } + + public float OriginalJumpHeight + { + get { return this.mOriginalFloorHeight; } + } + + public AnimatedSprite PlayerAnimation + { + get { return this.mAnimation; } + set { this.mAnimation = 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)); } + get { return new Rectangle((int)(Position.X - ((this.mAnimation.AnimationWidth * this.mAnimation.Scale) / 2f)), (int)(Position.Y - (this.mAnimation.AnimationHeight * this.mAnimation.Scale)), (int)(this.mAnimation.AnimationWidth * this.mAnimation.Scale), (int)(this.mAnimation.AnimationHeight * this.mAnimation.Scale)); } } + #endregion - public Player(uint id, AnimatedSprite spriteAnimation, Vector2 startPosition, float speed, float jHeight, float jSpeed, EntityManager objManager) + public Player(uint id, AnimatedSprite _animation, Vector2 _position, float _speed, float _jumpSpeed, EntityManager _entityManager) : base(id) { - playerAnimation = spriteAnimation; - position = startPosition; - moveSpeed = speed; - jumpHeight = jHeight; - jumpSpeed = jSpeed; - mObjectManager = objManager; + this._obj_entitymanager = _entityManager; + this.mAnimation = _animation; + this.mPosition = _position; + this.mMoveSpeed = _speed; + this.mJumpSpeed = _jumpSpeed; + this.ObjectType = ObjectType.Player; + } + + public void SetFloorHeight(float _floorHeight) + { + if (this.mOriginalFloorHeight == 0f) + this.mOriginalFloorHeight = _floorHeight; + + this.mFloorHeight = _floorHeight; } public void moveLeft() { - if (playerAnimation != null) + if (this.mAnimation != null) { if (isJumping == false) - moveDirection = MoveDirection.Left; + this.mMoveDirection = MoveDirection.Left; - position.X -= moveSpeed; - playerAnimation.CurrentAnimation = "left"; + this.mPosition.X -= this.mMoveSpeed; + this.mAnimation.CurrentAnimation = "left"; } } public void moveRight() { - if (playerAnimation != null) + if (this.mAnimation != null) { - if (isJumping == false && isOnTop == false) - moveDirection = MoveDirection.Right; - - position.X += moveSpeed; - playerAnimation.CurrentAnimation = "right"; + if (this.isJumping == false) + this.mMoveDirection = MoveDirection.Right; + + this.mPosition.X += this.mMoveSpeed; + this.mAnimation.CurrentAnimation = "right"; } } public void moveIdle() { - if (playerAnimation != null) + if (this.mAnimation != null) { - if (isJumping == false && isOnTop == false) - { - moveDirection = MoveDirection.Idle; - } + if (this.isJumping == false) + this.mMoveDirection = MoveDirection.Idle; - playerAnimation.CurrentAnimation = "idle"; + this.mAnimation.CurrentAnimation = "idle"; } } - public void jump() + public void fire() { - if (playerAnimation != null) + if (this.Score >= 2) { - if (position.Y == floorHeight && isJumping == false) + switch (this.mMoveDirection) { - originalJumpSpeed = jumpSpeed; - maxHeight = position.Y - jumpHeight; - isJumping = true; - moveDirection = MoveDirection.Jump; - playerAnimation.CurrentAnimation = "idle"; + case MoveDirection.Left: + this._obj_entitymanager.CreateBullet(new Blast(this._obj_entitymanager.NextID(), new Vector2(this.Position.X - 30, this.Position.Y - (this.PlayerAnimation.AnimationHeight / 2f)), 2f, -250f, 1.5f)); + break; + case MoveDirection.Right: + this._obj_entitymanager.CreateBullet(new Blast(this._obj_entitymanager.NextID(), new Vector2(this.Position.X + 30, this.Position.Y - (this.PlayerAnimation.AnimationHeight / 2f)), 2f, 250f, -1.5f)); + break; + default: + this._obj_entitymanager.CreateBullet(new Blast(this._obj_entitymanager.NextID(), new Vector2(this.Position.X + 30, this.Position.Y - (this.PlayerAnimation.AnimationHeight / 2f)), 2f, 250f, -1.5f)); + break; } + this.Score -= 2; } } - public override void Update(GameTime gameTime) + public void jump() { - if (isJumping) - { - jumpDistance = (float)gameTime.ElapsedGameTime.TotalSeconds * jumpSpeed; - - if (jumpDirection == 0) - { - //Slow Up Speed - } - else + if (this.mAnimation != null) + if (this.isJumping == false) //Only allow 1 Jump { - jumpSpeed = jumpSpeed * 1.2f; - } - - if (position.Y <= maxHeight || jumpDirection == 1) - { - if (jumpDirection != 1) - { - jumpDirection = 1; //Falling Jump Direction - } - position.Y += jumpDistance; - } - else - { - position.Y -= jumpDistance; + this.mPosition.Y -= this.mJumpSpeed; + this.isJumping = true; + this.mAnimation.CurrentAnimation = "idle"; } + } - if (position.Y >= floorHeight) - { - position.Y = floorHeight; - isJumping = false; - jumpDirection = 0; - jumpSpeed = originalJumpSpeed; - } + public override void Update(GameTime gameTime) + { + if (this.mPosition.Y >= this.mFloorHeight && (this.isJumping || this.isUpdateGravity)) + { + this.isJumping = false; + this.mPosition.Y = this.mFloorHeight; + this.mVelocity.Y = 0f; } - if (addGravity == true) + if (this.isJumping || this.isUpdateGravity) { - jumpDistance = (float)gameTime.ElapsedGameTime.TotalSeconds * jumpSpeed; - jumpSpeed = jumpSpeed * 1.2f; - position.Y += jumpDistance; - - if (position.Y >= floorHeight) - { - position.Y = floorHeight; - addGravity = false; - jumpDirection = 0; - jumpSpeed = originalJumpSpeed; - } + this.mVelocity += this._obj_entitymanager.Gravity * (float)gameTime.ElapsedGameTime.TotalSeconds; + this.mPosition -= this.mVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds; + this.isUpdateGravity = false; } - if (playerAnimation != null) + //Update Animation + if (this.mAnimation != null) { - playerAnimation.Position = position; - playerAnimation.Update(gameTime); + this.mAnimation.Position = this.mPosition; + this.mAnimation.Update(gameTime); } } public override void Draw(SpriteBatch spriteBatch) { - if (playerAnimation != null) - { - if (isHidden == false) - { - playerAnimation.Draw(spriteBatch, 1f); - } - } + if (this.mAnimation != null) + if (this.Hidden == false) + this.mAnimation.Draw(spriteBatch, 1f); } } } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject.cs index 6377dd8..4d31fa4 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject.cs @@ -10,15 +10,16 @@ public enum LevelObjectType None = 0, Solid = 1, NonSolid = 2, + Crate = 4, Default = 65536, } public abstract class LevelObject : GameObjects { - protected Rectangle bounds; + public AnimatedSprite animation; public override Rectangle Bounds { - get { return new Rectangle((int)this.defaultBounds.X, (int)this.defaultBounds.Y, this.defaultBounds.Width, this.defaultBounds.Height); } + get { return new Rectangle((int)(animation.Position.X - ((animation.AnimationWidth * animation.Scale) / 2f)), (int)(animation.Position.Y - ((animation.AnimationHeight * animation.Scale) / 2f)), (int)(animation.AnimationWidth * animation.Scale), (int)(animation.AnimationHeight * animation.Scale)); } } protected LevelObjectType type; @@ -26,9 +27,15 @@ public LevelObjectType Type { get { return type; } } - public LevelObject(uint id) : base(id) { } - public override void Update(GameTime gameTime) { } - public override void Draw(SpriteBatch spriteBatch) { } + + public override void Update(GameTime gameTime) + { + animation.Update(gameTime); + } + public override void Draw(SpriteBatch spriteBatch) + { + animation.Draw(spriteBatch, 1f); + } } } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_Crate.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_Crate.cs new file mode 100644 index 0000000..c4280f8 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_Crate.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Content; + +namespace SolarFusion.Core +{ + public class LevelObject_Crate : LevelObject + { + public LevelObject_Crate(uint id, ContentManager virtualContent, Vector2 position) + : base(id) + { + Texture2D tmpTexture = virtualContent.Load("Sprites/Objects/Static/crate/sprite"); + this.animation = new AnimatedSprite(tmpTexture, 1, 1); + this.animation.AddAnimation("idle", 1, 1, 1); + this.animation.Position = new Vector2(position.X, position.Y - 25); + this.animation.Origin = new Vector2(tmpTexture.Width / 2f, tmpTexture.Height / 2f); + this.animation.Scale = 0.5f; + this.animation.CurrentAnimation = "idle"; + this.type = LevelObjectType.Crate; + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_NonSolid.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_NonSolid.cs new file mode 100644 index 0000000..59fbb61 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_NonSolid.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Content; + +namespace SolarFusion.Core +{ + public class LevelObject_NonSolid : LevelObject + { + public LevelObject_NonSolid(uint id, ContentManager virtualContent, Vector2 position) + : base(id) + { + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_Solid.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_Solid.cs index 4031ef1..d034059 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_Solid.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/LevelObjects/LevelObject_Solid.cs @@ -14,7 +14,6 @@ public class LevelObject_Solid : LevelObject public LevelObject_Solid(uint id, ContentManager virtualContent, Vector2 position) : base(id) { - } } } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp.cs index 144d5e1..48bc368 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp.cs @@ -11,9 +11,8 @@ public enum PowerUpType { None = 0, EnergyBall = 1, - Crate = 2, - Dynamite = 4, - Crystal = 8, + Crystal = 2, + Warp = 4, Default = 65536, } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Crate.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Crate.cs deleted file mode 100644 index eb26508..0000000 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Crate.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Content; - -namespace SolarFusion.Core -{ - public class PowerUp_Crate : PowerUp - { - public PowerUp_Crate(uint id, ContentManager virtualContent, Vector2 position) - : base(id) - { - Texture2D tmpTexture = virtualContent.Load("Sprites/Objects/Animated/powerup_crate"); - this.animation = new AnimatedSprite(tmpTexture, 12, 1); - - this.animation.AddAnimation("idle", 1, 12, 15); - this.animation.Position = position; - this.animation.Origin = new Vector2((tmpTexture.Width / 12f) / 2f, tmpTexture.Height / 2f); - this.animation.Scale = 0.5f; - this.animation.CurrentAnimation = "idle"; - this.Score = 10; - this.type = PowerUpType.Crate; - this.animation.Loop = true; - } - } -} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Crystal.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Crystal.cs index 24d0028..6731839 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Crystal.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Crystal.cs @@ -14,17 +14,14 @@ public class PowerUp_Crystal : PowerUp public PowerUp_Crystal(uint id, ContentManager virtualContent, Vector2 position) : base(id) { - Texture2D tmpTexture = virtualContent.Load("Sprites/Objects/Animated/powerup_crystal"); - this.animation = new AnimatedSprite(tmpTexture, 12, 1); - - this.animation.AddAnimation("idle", 1, 12, 15); - this.animation.Position = position; - this.animation.Origin = new Vector2((tmpTexture.Width / 12f) / 2f, tmpTexture.Height / 2f); - this.animation.Scale = 0.5f; + Texture2D tmpTexture = virtualContent.Load("Sprites/Objects/Animated/crystal/spritesheet"); + this.animation = new AnimatedSprite(tmpTexture, 5, 1); + this.animation.AddAnimation("idle", 1, 5, 6); + this.animation.Position = new Vector2(position.X, position.Y - 15); + this.animation.Scale = 1f; this.animation.CurrentAnimation = "idle"; - this.animation.Loop = true; - this.Score = 10; this.type = PowerUpType.Crystal; + this.animation.Loop = true; } } } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Dynamite.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Dynamite.cs deleted file mode 100644 index a47b8de..0000000 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Dynamite.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Content; - -namespace SolarFusion.Core -{ - public class PowerUp_Dynamite : PowerUp - { - public PowerUp_Dynamite(uint id, ContentManager virtualContent, Vector2 position) - : base(id) - { - Texture2D tmpTexture = virtualContent.Load("Sprites/Objects/Animated/powerup_dynamite"); - this.animation = new AnimatedSprite(tmpTexture, 12, 1); - - this.animation.AddAnimation("idle", 1, 12, 15); - this.animation.Position = position; - this.animation.Origin = new Vector2((tmpTexture.Width / 12f) / 2f, tmpTexture.Height / 2f); - this.animation.Scale = 0.5f; - this.animation.CurrentAnimation = "idle"; - this.Score = -10; - this.type = PowerUpType.Dynamite; - this.animation.Loop = true; - } - } -} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_EnergyBall.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_EnergyBall.cs index 3b6c088..872cf9c 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_EnergyBall.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_EnergyBall.cs @@ -14,17 +14,15 @@ public class PowerUp_EnergyBall : PowerUp public PowerUp_EnergyBall(uint id, ContentManager virtualContent, Vector2 position) : base(id) { - Texture2D tmpTexture = virtualContent.Load("Sprites/Objects/Animated/powerup_energyball"); - this.animation = new AnimatedSprite(tmpTexture, 12, 1); - - this.animation.AddAnimation("idle", 1, 12, 15); - this.animation.Position = position; - this.animation.Origin = new Vector2((tmpTexture.Width / 12f) / 2f, tmpTexture.Height / 2f); - this.animation.Scale = 0.5f; + Texture2D tmpTexture = virtualContent.Load("Sprites/Objects/Static/energy_ball/sprite"); + this.animation = new AnimatedSprite(tmpTexture, 1, 1); + this.animation.AddAnimation("idle", 1, 1, 1); + this.animation.Position = new Vector2(position.X, position.Y - 15); + this.animation.Origin = new Vector2(tmpTexture.Width / 2f, tmpTexture.Height / 2f); + this.animation.Scale = 1f; this.animation.CurrentAnimation = "idle"; - this.Score = 10; + this.Score = 1; this.type = PowerUpType.EnergyBall; - this.animation.Loop = true; } } } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Warp.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Warp.cs new file mode 100644 index 0000000..4b7d186 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Entities/PowerUps/PowerUp_Warp.cs @@ -0,0 +1,29 @@ +using System; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Content; + +namespace SolarFusion.Core +{ + public class PowerUp_Warp : PowerUp + { + public PowerUp_Warp(uint id, ContentManager virtualContent, Vector2 position) + : base(id) + { + Texture2D tmpTexture = virtualContent.Load("Sprites/Objects/Animated/warp/spritesheet"); + this.animation = new AnimatedSprite(tmpTexture, 8, 3); + + this.animation.AddAnimation("idle", 1, 8, 15); + this.animation.AddAnimation("end", 2, 7, 6); + this.animation.AddAnimation("start", 3, 4, 3); + this.animation.Position = position; + this.animation.Scale = 1f; + this.animation.Rotation = 1.5f; + this.animation.CurrentAnimation = "idle"; + this.type = PowerUpType.Warp; + this.animation.Loop = true; + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Game.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Game.cs index 962e537..1a7e82d 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Game.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Game.cs @@ -35,7 +35,7 @@ public Game() } catch (Exception ex) { - Environment.Exit(0); + this.Exit(); } try @@ -54,8 +54,8 @@ public Game() this._obj_config.WIN32_CreateNewFile(); #elif XBOX this._obj_config.X360_CreateNewFile(); - this._obj_config.Settings.VIDEO_RES_WIDTH = 1280; - this._obj_config.Settings.VIDEO_RES_HEIGHT = 720; + this._obj_config.Settings.VIDEO_RES_WIDTH = this._obj_graphics.GraphicsDevice.DisplayMode.Width; // Use Full Possible Resolution + this._obj_config.Settings.VIDEO_RES_HEIGHT = this._obj_graphics.GraphicsDevice.DisplayMode.Height; this._obj_config.Settings.VIDEO_FULLSCREEN = true; this._obj_config.Settings.VIDEO_ANTIALIASING = true; this._obj_config.Settings.VIDEO_VSYNC = true; @@ -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); } /// diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Input/InputManager.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Input/InputManager.cs index dcc7880..3e34162 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Input/InputManager.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Input/InputManager.cs @@ -37,7 +37,8 @@ public InputManager() this.AddGamePadInput("PLAY_MOVE_LEFT", SysConfig.INPUT_GAMEPAD_LEFT_STICK, false); this.AddGamePadInput("PLAY_MOVE_RIGHT", SysConfig.INPUT_GAMEPAD_RIGHT_DPAD, false); this.AddGamePadInput("PLAY_MOVE_RIGHT", SysConfig.INPUT_GAMEPAD_RIGHT_STICK, false); - this.AddGamePadInput("PLAY_MOVE_JUMP", SysConfig.INPUT_GAMEPAD_JUMP, false); + this.AddGamePadInput("PLAY_MOVE_JUMP", SysConfig.INPUT_GAMEPAD_JUMP, true); + this.AddGamePadInput("PLAY_WEAPON_FIRE", SysConfig.INPUT_GAMEPAD_FIRE, true); //Add Keyboard Input this.AddKeyboardInput("NAV_UP", SysConfig.INPUT_KEYBOARD_UP, true); @@ -53,7 +54,8 @@ public InputManager() this.AddKeyboardInput("PLAY_MOVE_LEFT", SysConfig.INPUT_KEYBOARD_LEFT, false); this.AddKeyboardInput("PLAY_MOVE_RIGHT", SysConfig.INPUT_KEYBOARD_RIGHT, false); - this.AddKeyboardInput("PLAY_MOVE_JUMP", SysConfig.INPUT_KEYBOARD_JUMP, false); + this.AddKeyboardInput("PLAY_MOVE_JUMP", SysConfig.INPUT_KEYBOARD_JUMP, true); + this.AddKeyboardInput("PLAY_WEAPON_FIRE", SysConfig.INPUT_KEYBOARD_FIRE, true); } public InputHelper NewInput(string action) diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Level/LevelManager.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Level/LevelManager.cs index 8abfbbb..c3d3635 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Level/LevelManager.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Level/LevelManager.cs @@ -14,19 +14,44 @@ using SolarFusion.Core; using SolarFusion.Input; using SolarFusion.Core.Screen; +using SolarFusion.Core.PostProcessing; namespace SolarFusion.Level { public class LevelManager { + private ScreenManager _obj_screenmanager = null; + private InputManager _obj_input = null; private ContentManager _obj_contentmanager = null; + private GraphicsDevice _obj_graphics = null; private Viewport _obj_viewport; + private PostProcessingManager _obj_ppmanager = null; private Camera2D _obj_camera = null; private LevelTilemap _obj_map = null; private EntityManager _obj_entitymanager = null; + private RenderTarget2D _obj_scene = null; + private Player _obj_player = null; + private GameGUI _obj_gui = null; + private uint _current_level_id = 0; - private Player player; - + private bool isStartWarp = false; + private bool isEndWarp = false; + private float mWarpTime = 0f; + private PlayerIndex? mControllingPlayer; + private bool isScrolling = false; + private Texture2D mDebugRectangle; + private bool mDebugEnabled = false; + private Vector2 mPositionOffset = Vector2.Zero; + private List mStartScroll; + private List mEndScroll; + private List mEndAreas; + + // Effects + private CrepuscularRays _effect_sun = null; + private Vector2 _effect_sun_pos = Vector2.Zero; + private Color _effect_sky_color = Color.Black; + // !Effects + // Properties #region "Properties" public uint CurrentGameLevelID @@ -41,89 +66,146 @@ public LevelTilemap CurrentGameMap #endregion // !Properties - public LevelManager(ContentManager _contentmanager, Viewport _viewport) + public LevelManager(ContentManager _contentmanager, GraphicsDevice _graphics, InputManager _input, PlayerIndex? _controllingPlayer, ScreenManager _screenManager, SpriteFont _font) { this._obj_contentmanager = _contentmanager; - this._obj_viewport = _viewport; + this._obj_viewport = _graphics.Viewport; + this._obj_graphics = _graphics; + this._obj_input = _input; + this._obj_ppmanager = new PostProcessingManager(this._obj_graphics); + this._obj_gui = new GameGUI(this._obj_graphics, _font); + this._obj_screenmanager = _screenManager; + this.mControllingPlayer = _controllingPlayer; } public void LoadLevel(uint _LevelID, Player _activePlayer, EntityManager _objManager) { this._obj_map = this._obj_contentmanager.Load("Levels/level_" + _LevelID.ToString() + "/level"); //Load level data from selected level. this._obj_map.LoadContent(this._obj_contentmanager); + this._obj_player = _activePlayer; //Assign player. + this._obj_player.PlayerAnimation.Origin = new Vector2(this._obj_player.PlayerAnimation.Origin.X, this._obj_player.PlayerAnimation.Origin.Y * 2); + this._obj_entitymanager = _objManager; //Assign entity manager + this._obj_entitymanager.CreatePlayer(this._obj_player); this._current_level_id = _LevelID; - + this.mDebugRectangle = this._obj_contentmanager.Load("Sprites/Misc/Static/debug_pixel"); + this.mPositionOffset = new Vector2(0, 25); + this.mDebugEnabled = false; + this.mStartScroll = new List(); + this.mEndScroll = new List(); + this.mEndAreas = new List(); + Blast.Load(this._obj_contentmanager); //Load Weapon Ammo + + // Load Level Objects for (int i = 0; i < this._obj_map.tmGameEntityGroupCount; i++) //Loop over the amount of objects in the level and load them. { for (int j = 0; j < this._obj_map.tmGameEntityGroups[i].GameEntityData.Count(); j++) { GameEntity goData = this._obj_map.tmGameEntityGroups[i].GameEntityData[j]; - Vector2 position = new Vector2(goData.entPosition.Center.X, goData.entPosition.Center.Y); + Vector2 position = new Vector2(goData.entPosition.Center.X, goData.entPosition.Center.Y + this.mPositionOffset.Y); GameObjects go; - - player = _activePlayer; //Assign instances to local class variables. - this._obj_entitymanager = _objManager; switch (goData.entCategory) //Swtich by object category. { case "PlayerStart": - Vector2 newPos = new Vector2(position.X, (position.Y - ((player.Height / 2) / 2))); - player.Position = newPos; - player.floorHeight = position.Y + ((player.Height / 2) / 2); - player.isSingleplayer = true; - player.LayerDepth = this._obj_map.tmGameEntityGroups[i].LayerDepth; + this._obj_player.Position = position; + this._obj_player.SetFloorHeight(position.Y); + this._obj_player.isSingleplayer = true; + this._obj_player.LayerDepth = this._obj_map.tmGameEntityGroups[i].LayerDepth; break; - case "Powerup": //NEED TO FIX - //go = this._obj_entitymanager.CreatePowerup((PowerUpType)Enum.Parse(typeof(PowerUpType), goData.entType, true), position); - //this._obj_map.tmGameEntityGroups[i].GameEntityData[j].entID = go.ID; - //go.LayerDepth = this._obj_map.tmGameEntityGroups[i].LayerDepth; + case "Powerup": + go = this._obj_entitymanager.CreatePowerup((PowerUpType)Enum.Parse(typeof(PowerUpType), goData.entType, true), position); + this._obj_map.tmGameEntityGroups[i].GameEntityData[j].entID = go.ID; + go.LayerDepth = this._obj_map.tmGameEntityGroups[i].LayerDepth; + if (go.ObjectType == ObjectType.PowerUp) + { + PowerUp tmpPowerUp = (PowerUp)go; + if (tmpPowerUp.Type == PowerUpType.Warp) + go.Hidden = true; + } break; - case "Enemy": //NEED TO FIX - //go = this._obj_entitymanager.CreateEnemy((EnemyType)Enum.Parse(typeof(EnemyType), goData.entType, true), position); - //this._obj_map.tmGameEntityGroups[i].GameEntityData[j].entID = go.ID; - //go.LayerDepth = this._obj_map.tmGameEntityGroups[i].LayerDepth; + case "Enemy": + go = this._obj_entitymanager.CreateEnemy((EnemyType)Enum.Parse(typeof(EnemyType), goData.entType, true), position); + this._obj_map.tmGameEntityGroups[i].GameEntityData[j].entID = go.ID; + go.LayerDepth = this._obj_map.tmGameEntityGroups[i].LayerDepth; break; case "LevelObject": go = this._obj_entitymanager.CreateLevelObject((LevelObjectType)Enum.Parse(typeof(LevelObjectType), goData.entType, true), position); this._obj_map.tmGameEntityGroups[i].GameEntityData[j].entID = go.ID; - go.defaultBounds = goData.entPosition; go.LayerDepth = this._obj_map.tmGameEntityGroups[i].LayerDepth; break; + case "StartScroll": + this.mStartScroll.Add(new Rectangle((int)goData.entPosition.X, goData.entPosition.Y, goData.entPosition.Width, goData.entPosition.Height)); + break; + case "EndScroll": + this.mEndScroll.Add(new Rectangle((int)goData.entPosition.X, goData.entPosition.Y, goData.entPosition.Width, goData.entPosition.Height)); + break; + case "End_Area": + this.mEndAreas.Add(new Rectangle((int)goData.entPosition.X, goData.entPosition.Y, goData.entPosition.Width, goData.entPosition.Height)); + break; } } } + // !Load Level Objects + + 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("Core/Shaders/PostProcessing/LightSourceMask"), this._obj_contentmanager.Load("Core/Textures/sun_flare"), this._obj_contentmanager.Load("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); this._obj_camera = new Camera2D(this._obj_viewport); this._obj_camera.Position = new Vector2(this._obj_viewport.Width / 2f, this._obj_viewport.Height / 2f); - this._obj_camera.Zoom = 1.0f; + this._obj_camera.Zoom = 1f; this._obj_camera.Speed = 60f; this._obj_entitymanager.camera = this._obj_camera; + this._obj_gui.Load(this._obj_contentmanager); } public void UnloadLevel() { + this._obj_screenmanager = null; + this._obj_camera = null; this._obj_map = null; + this._obj_entitymanager = null; + this._obj_scene = null; + this._obj_player = null; + this._obj_gui.Unload(); } public void Update(GameTime _gameTime) { float timeDiff = (float)_gameTime.ElapsedGameTime.TotalSeconds; + this._effect_sun.LightSource = this._effect_sun_pos; - foreach (uint goID in this._obj_entitymanager.dynamicObjects) //Checks all the dynamic objects in the level, and loops through updating them. + 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: { - GameObjects go = this._obj_entitymanager.GetObject(goID); //Gets the game object. - this._obj_entitymanager.UpdateGameObject(goID); //Updates the game object. + 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. + for (int i = 0; i < this.mEndScroll.Count; i++) + if (this._obj_player.Bounds.Intersects(this.mEndScroll[i])) + this.isScrolling = false; } - - if ((player.Position.X - (player.Width / 2f)) < (this._obj_camera.Position.X - (this._obj_viewport.Width / 2))) //Check if player is in the camera. + else { - player.Position = new Vector2(((this._obj_camera.Position.X - (this._obj_viewport.Width / 2)) + (player.Width / 2f)), player.Position.Y); //Re-adjust position if player is outside camera. + for (int i = 0; i < this.mStartScroll.Count; i++) //Checks through all the positions to start scrolling, and if the play hits it, the game starts scrolling. + if (this._obj_player.Bounds.Intersects(this.mStartScroll[i])) + this.isScrolling = true; } - if (player.Position.X > (this._obj_camera.Position.X + (this._obj_viewport.Width / 2))) //Check if player is in the camera. + foreach (uint goID in this._obj_entitymanager.dynamicObjects) //Checks all the dynamic objects in the level, and loops through updating them. { - player.Position = new Vector2((this._obj_camera.Position.X + (this._obj_viewport.Width / 2)), player.Position.Y); //Re-adjust position if player is outside camera. + GameObjects go = this._obj_entitymanager.GetObject(goID); //Gets the game object. + this._obj_entitymanager.UpdateGameObject(goID); //Updates the game object. } + if ((this._obj_player.Position.X - (this._obj_player.Width / 2f)) < (this._obj_camera.Position.X - (this._obj_viewport.Width / 2))) //Check if player is in the camera. + this._obj_player.Position = new Vector2(((this._obj_camera.Position.X - (this._obj_viewport.Width / 2)) + (this._obj_player.Width / 2f)), this._obj_player.Position.Y); //Re-adjust position if player is outside camera. + + if (this._obj_player.Position.X > (this._obj_camera.Position.X + (this._obj_viewport.Width / 2))) //Check if player is in the camera. + this._obj_player.Position = new Vector2((this._obj_camera.Position.X + (this._obj_viewport.Width / 2)), this._obj_player.Position.Y); //Re-adjust position if player is outside camera. + Rectangle bounds = new Rectangle((int)(this._obj_camera.Position.X - (this._obj_viewport.Width / 2f)) - 500, 0, this._obj_map.tmWidth * this._obj_map.tmTileWidth, this._obj_map.tmHeight * this._obj_map.tmTileHeight); //Sets bounds for creating objects. foreach (uint goID in this._obj_entitymanager.QueryRegion(bounds)) //Checks if any objects are in the bounds, and loops through updating them. { @@ -131,67 +213,246 @@ public void Update(GameTime _gameTime) if (go.Hidden == false) //Make sure the object isnt hidden. { - if (go.ObjectType == ObjectType.Enemy) + switch (go.ObjectType) { - AI bot = (AI)this._obj_entitymanager.GetObject(goID); //Gets the AI object - - switch (bot.moveDirection) //Switches the bots current direction, and moves that way. - { - case MoveDirection.Left: - bot.moveLeft(); - break; - case MoveDirection.Right: - bot.moveRight(); - break; - } - - foreach (uint goID1 in this._obj_entitymanager.QueryRegion(go.Bounds)) //Collision detection for player, checks the player if its colliding with anything. - { - GameObjects go1 = this._obj_entitymanager.GetObject(goID1); //Gets the + case ObjectType.Enemy: + AI bot = (AI)this._obj_entitymanager.GetObject(goID); //Gets the AI object + switch (bot.moveDirection) //Switches the bots current direction, and moves that way. + { + case MoveDirection.Left: + bot.moveLeft(); + break; + case MoveDirection.Right: + bot.moveRight(); + break; + } - if (go1.ObjectType == ObjectType.LevelObject) + foreach (uint goID1 in this._obj_entitymanager.QueryRegion(go.Bounds)) //Collision detection for player, checks the player if its colliding with anything. { - if (go.Bounds.Intersects(go1.Bounds)) + GameObjects go1 = this._obj_entitymanager.GetObject(goID1); //Gets the + + if (go1.ObjectType == ObjectType.LevelObject) { - switch (bot.moveDirection) //Checks bot direction. + if (go.Bounds.Intersects(go1.Bounds)) { - case MoveDirection.Right: //AI Direction is right so, we change it to left. - bot.moveDirection = MoveDirection.Left; - break; - case MoveDirection.Left: - bot.moveDirection = MoveDirection.Right; - break; + switch (bot.moveDirection) //Checks bot direction. + { + case MoveDirection.Right: //AI Direction is right so, we change it to left. + bot.moveDirection = MoveDirection.Left; + break; + case MoveDirection.Left: + bot.moveDirection = MoveDirection.Right; + break; + } } } } - } + break; + case ObjectType.Bullet: + Blast bullet = (Blast)this._obj_entitymanager.GetObject(goID); + if (bullet.ForDeletion) + { + this._obj_entitymanager.DestroyObject(goID); + break; + } + foreach (uint goID1 in this._obj_entitymanager.QueryRegion(go.Bounds)) + { + GameObjects go1 = this._obj_entitymanager.GetObject(goID1); //Gets the + switch (go1.ObjectType) + { + case ObjectType.LevelObject: + this._obj_entitymanager.DestroyObject(goID); + break; + case ObjectType.Enemy: + this._obj_entitymanager.DestroyObject(goID1); + this._obj_entitymanager.DestroyObject(goID); + break; + } + } + break; } go.Update(_gameTime); //Updates the object. this._obj_entitymanager.UpdateGameObject(goID); //Updates the object within the object manager. } + + if (go.ObjectType == ObjectType.PowerUp) + { + PowerUp tmpPowerUp = (PowerUp)go; //Gets the PowerUp Object + if (tmpPowerUp.Type == PowerUpType.Warp) + { + if (this.isStartWarp) + { + if (tmpPowerUp.Hidden != false || tmpPowerUp.animation.CurrentAnimation != "start") + { + tmpPowerUp.Hidden = false; + tmpPowerUp.animation.Frame = 0; + tmpPowerUp.animation.CurrentAnimation = "start"; + } + this.mWarpTime += (float)_gameTime.ElapsedGameTime.TotalSeconds; + if (this.mWarpTime >= 1.2f) + { + this.isStartWarp = false; + this.mWarpTime = 0f; + tmpPowerUp.animation.CurrentAnimation = "idle"; + } + } + else if (this.isEndWarp) + { + this.mWarpTime += (float)_gameTime.ElapsedGameTime.TotalSeconds; + if (this.mWarpTime >= 1f) + { + this.isEndWarp = false; + this.mWarpTime = 0f; + tmpPowerUp.Hidden = true; + this._obj_screenmanager.addScreen(new ScreenEnding("CONGRATULATIONS, YOU ESCAPED!", EndingType.Win), this.mControllingPlayer); + } + } + } + } } - player.Update(_gameTime); + if (this._obj_player.PlayerHealth <= 0) + { + this._obj_player.Hidden = true; + this._obj_screenmanager.addScreen(new ScreenEnding("YOU DIED!", EndingType.Loss), this.mControllingPlayer); + } + + 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. + + foreach (uint goID in this._obj_entitymanager.QueryRegion(this._obj_player.Bounds)) //Collision detection for player, checks the player if its colliding with anything. + { + GameObjects go = this._obj_entitymanager.GetObject(goID); //Gets the object + if (go.Hidden == false) //Checks its not hidden. + { + if (this._obj_player.Bounds.Intersects(go.Bounds)) + { + switch (go.ObjectType) + { + case ObjectType.Enemy: + this._obj_player.PlayerHealth -= go.Score; //Removes health equal to the damage that the enemy does. + break; + case ObjectType.PowerUp: + PowerUp tmpPowerUp = (PowerUp)this._obj_entitymanager.GetObject(goID); + switch (tmpPowerUp.Type) + { + case PowerUpType.Crystal: + this._obj_player.isGemCollected = true; + this.isStartWarp = true; + this.mWarpTime = 0f; + go.Hidden = true; + break; + case PowerUpType.EnergyBall: + this._obj_player.Score += go.Score; + go.Hidden = true; + break; + case PowerUpType.Warp: + this.isEndWarp = true; + this._obj_player.Hidden = true; + this.mWarpTime = 0f; + tmpPowerUp.animation.Frame = 0; + tmpPowerUp.animation.CurrentAnimation = "end"; + break; + } + break; + case ObjectType.LevelObject: + LevelObject tmpLevelObject = (LevelObject)this._obj_entitymanager.GetObject(goID); + if (this._obj_player.Position.Y <= ((tmpLevelObject.animation.Position.Y - (tmpLevelObject.Bounds.Height / 2f)) + 5)) + { + this._obj_player.Position = new Vector2(this._obj_player.Position.X, ((tmpLevelObject.animation.Position.Y - (tmpLevelObject.Bounds.Height / 2f)))); + this._obj_player.SetFloorHeight(((tmpLevelObject.animation.Position.Y - (tmpLevelObject.Bounds.Height / 2f)))); + } + else + { + if (this._obj_player.Position.X < tmpLevelObject.animation.Position.X) + this._obj_player.Position = new Vector2((tmpLevelObject.animation.Position.X - ((tmpLevelObject.Bounds.Width / 2f) + (this._obj_player.Width / 2f))), this._obj_player.Position.Y); + else if (this._obj_player.Position.X > tmpLevelObject.animation.Position.X) + this._obj_player.Position = new Vector2((tmpLevelObject.animation.Position.X + ((tmpLevelObject.Bounds.Width / 2f) + (this._obj_player.Width / 2f))), this._obj_player.Position.Y); + } + break; + } + } + } + } + + this._obj_entitymanager.Update(_gameTime); + this._obj_player.Update(_gameTime); + this._obj_player.SetFloorHeight(this._obj_player.OriginalJumpHeight); + this._obj_player.isUpdateGravity = true; + + if (this._obj_player.PlayerScore < 2) + this._obj_gui.Ammo = 0; + else + this._obj_gui.Ammo = this._obj_player.PlayerScore / 2; + + this._obj_gui.Crystal = this._obj_player.isGemCollected; + + if (this._obj_player.PlayerHealth >= 0) + this._obj_gui.Health = this._obj_player.PlayerHealth; + else + this._obj_gui.Health = 0; + + this._obj_gui.Points = this._obj_player.PlayerScore; + this._obj_gui.Update(_gameTime, this._obj_camera); } - public void Draw(SpriteBatch spriteBatch) + public void Draw(SpriteBatch _sb) { - spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, this._obj_camera.calculateTransform()); + //Create a mask for the occlusion ray + this._obj_graphics.SetRenderTarget(this._obj_scene); + this._obj_graphics.Clear(Color.White); + _sb.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearClamp, null, null, null, this._obj_camera.calculateTransform()); + this.DrawLevel(_sb); + this._obj_player.Draw(_sb); + _sb.End(); + this._obj_graphics.SetRenderTarget(null); + + //Apply Post Processing Effects + this._obj_ppmanager.Draw(_sb, this._obj_scene); - int minY = (int)(this._obj_camera.Position.Y - (this._obj_viewport.Height / 2f)) / this._obj_map.tmTileHeight; - int minX = (int)(this._obj_camera.Position.X - (this._obj_viewport.Width / 2f)) / this._obj_map.tmTileWidth; - - if (minY < 0) - minY = 0; + Rectangle bounds = new Rectangle((int)(this._obj_camera.Position.X - (this._obj_viewport.Width / 2f)) - 100, 0, (((this._obj_viewport.Width / this._obj_map.tmTileWidth) * this._obj_map.tmTileWidth) + 300), this._obj_map.tmHeight * this._obj_map.tmTileHeight); //Calculates what objects need to be drawn. + //Draw Scene in Colour + this._obj_graphics.SetRenderTarget(this._obj_scene); + this._obj_graphics.Clear(this._effect_sky_color); //Background Colour + _sb.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearClamp, null, null, null, this._obj_camera.calculateTransform()); + this.DrawLevel(_sb); + foreach (uint goID in this._obj_entitymanager.QueryRegion(bounds)) //Checks what objects are in the calculated boundry. + { + GameObjects go = this._obj_entitymanager.GetObject(goID); + if (go.Hidden == false) + { + if (this.mDebugEnabled) //Debug Command + _sb.Draw(this.mDebugRectangle, go.Bounds, Color.Blue * 0.5f); - if (minX < 0) - minX = 0; + go.Draw(_sb); //Draws The Object. + } + } + _sb.End(); + this._obj_graphics.SetRenderTarget(null); + this._obj_graphics.Clear(Color.Black); + + //Draw the post processing effects + _sb.Begin(SpriteSortMode.BackToFront, BlendState.Additive, SamplerState.LinearClamp, null, null, null, this._obj_camera.calculateTransform()); + _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(); + + _sb.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, this._obj_camera.calculateTransform()); + this._obj_player.Draw(_sb); + this._obj_gui.Draw(_sb); + _sb.End(); + } + private void DrawLevel(SpriteBatch _sb) + { + int minY = (int)(this._obj_camera.Position.Y - (this._obj_viewport.Height / 2f)) / this._obj_map.tmTileHeight; + int minX = (int)(this._obj_camera.Position.X - (this._obj_viewport.Width / 2f)) / this._obj_map.tmTileWidth; + if (minY < 0) minY = 0; + if (minX < 0) minX = 0; int maxX = minX + (this._obj_viewport.Width / this._obj_map.tmTileWidth) + 2; int maxY = this._obj_map.tmHeight; - - if (maxX >= this._obj_map.tmWidth) - maxX = this._obj_map.tmWidth; + if (maxX >= this._obj_map.tmWidth) maxX = this._obj_map.tmWidth; for (int i = 0; i < this._obj_map.tmLayerCount; i++) //Draws on layer by layer basis. { @@ -205,24 +466,11 @@ public void Draw(SpriteBatch spriteBatch) { LevelTile tile = this._obj_map.tmTiles[tileData.TileID - 1]; //Gets the tile data. Rectangle onScreen = new Rectangle(x * this._obj_map.tmTileWidth, (y * this._obj_map.tmTileHeight) + (this._obj_map.tmTileHeight / 2), this._obj_map.tmTileWidth, this._obj_map.tmTileHeight); //Calculates where on screen the tile has to be shown. - spriteBatch.Draw(this._obj_map.tmTextures[tile.textureID], onScreen, tile.source, Color.White, 0f, new Vector2(0, this._obj_map.tmTileHeight / 2), tileData.SpriteEffects, this._obj_map.tmLayers[i].LayerDepth); //Draw the tile. + _sb.Draw(this._obj_map.tmTextures[tile.textureID], onScreen, tile.source, Color.White, 0f, new Vector2(0, this._obj_map.tmTileHeight / 2), tileData.SpriteEffects, this._obj_map.tmLayers[i].LayerDepth); //Draw the tile. } } } } - - Rectangle bounds = new Rectangle((int)(this._obj_camera.Position.X - (this._obj_viewport.Width / 2f)) - 100, 0, (((this._obj_viewport.Width / this._obj_map.tmTileWidth) * this._obj_map.tmTileWidth) + 300), this._obj_map.tmHeight * this._obj_map.tmTileHeight); //Calculates what objects need to be drawn. - foreach (uint goID in _obj_entitymanager.QueryRegion(bounds)) //Checks what objects are in the calculated boundry. - { - GameObjects go = _obj_entitymanager.GetObject(goID); - - if (go.Hidden == false) - go.Draw(spriteBatch); //Draws The Object. - } - - player.Draw(spriteBatch); - - spriteBatch.End(); } } } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/BasePostProcess.cs b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/BasePostProcess.cs new file mode 100644 index 0000000..add4a04 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/BasePostProcess.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace SolarFusion.Core.PostProcessing +{ + public class BasePostProcess + { + protected GraphicsDevice _obj_graphics; + protected Effect mEffect; + protected ScreenQuad mScreenQuad; + + public Vector2 mHalfPixel; + public Texture2D mBackBuffer; + public Texture2D mOriginalBuffer; + public RenderTarget2D mSceneTarget; + + public bool Enabled = true; + public bool UsesVertexShader = false; + + public BasePostProcess(GraphicsDevice _graphics) + { + this._obj_graphics = _graphics; + } + + public virtual void Draw() + { + if (Enabled) + { + if (this.mScreenQuad == null) + { + this.mScreenQuad = new ScreenQuad(this._obj_graphics); + this.mScreenQuad.Initialize(); + } + + this.mEffect.CurrentTechnique.Passes[0].Apply(); + this.mScreenQuad.Draw(); + } + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/BasePostProcessEffect.cs b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/BasePostProcessEffect.cs new file mode 100644 index 0000000..d2f697a --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/BasePostProcessEffect.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace SolarFusion.Core.PostProcessing +{ + public class BasePostProcessEffect + { + protected List _obj_postprocesses = new List(); + protected GraphicsDevice _obj_graphics; + + public Vector2 mHalfPixel; + public Texture2D mLastScene; + public Texture2D mOriginalScene; + + public bool Enabled = true; + + public BasePostProcessEffect(GraphicsDevice _graphics) + { + this._obj_graphics = _graphics; + } + + public void AddPostProcess(BasePostProcess _postProcess) + { + this._obj_postprocesses.Add(_postProcess); + } + + public virtual void Draw(Texture2D _scene) + { + if (!Enabled) + return; + + this.mOriginalScene = _scene; + int maxProcess = this._obj_postprocesses.Count; + this.mLastScene = null; + + for (int p = 0; p < maxProcess; p++) + { + if (this._obj_postprocesses[p].Enabled) + { + this._obj_postprocesses[p].mHalfPixel = this.mHalfPixel; + this._obj_postprocesses[p].mOriginalBuffer = this.mOriginalScene; + + if (this._obj_postprocesses[p].mSceneTarget == null) + this._obj_postprocesses[p].mSceneTarget = new RenderTarget2D(this._obj_graphics, this._obj_graphics.Viewport.Width / 2, this._obj_graphics.Viewport.Height / 2, false, SurfaceFormat.Color, DepthFormat.None); + + this._obj_graphics.SetRenderTarget(this._obj_postprocesses[p].mSceneTarget); + + if (this.mLastScene == null) + this.mLastScene = this.mOriginalScene; + + this._obj_postprocesses[p].mBackBuffer = this.mLastScene; + this._obj_graphics.Textures[0] = this._obj_postprocesses[p].mBackBuffer; + this._obj_postprocesses[p].Draw(); + this._obj_graphics.SetRenderTarget(null); + this.mLastScene = this._obj_postprocesses[p].mSceneTarget; + } + } + + if (this.mLastScene == null) + this.mLastScene = _scene; + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/Effects/CrepuscularRays.cs b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/Effects/CrepuscularRays.cs new file mode 100644 index 0000000..d07a677 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/Effects/CrepuscularRays.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace SolarFusion.Core.PostProcessing +{ + public class CrepuscularRays : BasePostProcessEffect + { + public LightSourceMask mLightSourceMask; + public LightRay mLightRays; + + #region "Properties" + public Vector2 LightSource + { + set + { + this.mLightSourceMask.mLighScreenSourcePos = value; + this.mLightRays.mLighScreenSourcePos = value; + } + get + { + return this.mLightRays.mLighScreenSourcePos; + } + } + + public Texture LightTexture + { + get { return this.mLightSourceMask.mLishsourceTexture; } + set { this.mLightSourceMask.mLishsourceTexture = value; } + } + + public float LightSourceSize + { + set { this.mLightSourceMask.LightSize = value; } + get { return this.mLightSourceMask.LightSize; } + } + + public float Density + { + get { return this.mLightRays.Density; } + set { this.mLightRays.Density = value; } + } + + public float Decay + { + get { return this.mLightRays.Decay; } + set { this.mLightRays.Decay = value; } + } + + public float Weight + { + get { return this.mLightRays.Weight; } + set { this.mLightRays.Weight = value; } + } + + public float Exposure + { + get { return this.mLightRays.Exposure; } + set { this.mLightRays.Exposure = value; } + } + #endregion + + public CrepuscularRays(GraphicsDevice _graphics, Vector2 _lightScreenSourcePos, float _lightSourceSize, float _density, float _decay, float _weight, float _exposure, Effect _lightSourceEffect, Texture2D _lightSourceTexture, Effect _lightRayEffect) + : base(_graphics) + { + this.mLightSourceMask = new LightSourceMask(_graphics, _lightScreenSourcePos, _lightSourceSize, _lightSourceEffect, _lightSourceTexture); + this.mLightRays = new LightRay(_graphics, _lightScreenSourcePos, _density, _decay, _weight, _exposure, _lightRayEffect); + AddPostProcess(this.mLightSourceMask); + AddPostProcess(this.mLightRays); + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/Engine/LightRay.cs b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/Engine/LightRay.cs new file mode 100644 index 0000000..ec78289 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/Engine/LightRay.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace SolarFusion.Core.PostProcessing +{ + public class LightRay : BasePostProcess + { + public Vector2 mLighScreenSourcePos; + public float Density = .5f; + public float Decay = .95f; + public float Weight = 1.0f; + public float Exposure = .15f; + + public LightRay(GraphicsDevice _graphics, Vector2 _sourcePos, float _density, float _decay, float _weight, float _exposure, Effect _effect) + : base(_graphics) + { + this.UsesVertexShader = true; + this.mLighScreenSourcePos = _sourcePos; + this.mEffect = _effect; + Density = _density; + Decay = _decay; + Weight = _weight; + Exposure = _exposure; + } + + public override void Draw() + { + this.mEffect.CurrentTechnique = this.mEffect.Techniques["LightRayFX"]; + this.mEffect.Parameters["halfPixel"].SetValue(this.mHalfPixel); + this.mEffect.Parameters["Density"].SetValue(Density); + this.mEffect.Parameters["Decay"].SetValue(Decay); + this.mEffect.Parameters["Weight"].SetValue(Weight); + this.mEffect.Parameters["Exposure"].SetValue(Exposure); + this.mEffect.Parameters["lightScreenPosition"].SetValue(this.mLighScreenSourcePos); + base.Draw(); + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/Engine/LightSourceMask.cs b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/Engine/LightSourceMask.cs new file mode 100644 index 0000000..bfcd86f --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/Engine/LightSourceMask.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace SolarFusion.Core.PostProcessing +{ + public class LightSourceMask : BasePostProcess + { + public Texture mLishsourceTexture; + public Vector2 mLighScreenSourcePos; + public float LightSize = 1500; + + public LightSourceMask(GraphicsDevice _graphics, Vector2 _sourcePos, float _lightSize, Effect _effect, Texture2D _texture) + : base(_graphics) + { + this.UsesVertexShader = true; + this.mLighScreenSourcePos = _sourcePos; + this.mEffect = _effect; + this.mLishsourceTexture = _texture; + this.LightSize = _lightSize; + } + + public override void Draw() + { + this.mEffect.Parameters["screenRes"].SetValue(new Vector2(16, 9)); + this.mEffect.Parameters["halfPixel"].SetValue(this.mHalfPixel); + this.mEffect.CurrentTechnique = this.mEffect.Techniques["LightSourceMask"]; + this.mEffect.Parameters["flare"].SetValue(this.mLishsourceTexture); + this.mEffect.Parameters["SunSize"].SetValue(this.LightSize); + this.mEffect.Parameters["lightScreenPosition"].SetValue(this.mLighScreenSourcePos); + base.Draw(); + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/PostProcessingManager.cs b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/PostProcessingManager.cs new file mode 100644 index 0000000..cffa599 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/PostProcessingManager.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace SolarFusion.Core.PostProcessing +{ + public class PostProcessingManager + { + protected GraphicsDevice _obj_graphics; + protected List _obj_postProcessEffects = new List(); + + public Texture2D mScene; + public Vector2 mHalfPixel; + + public PostProcessingManager(GraphicsDevice _graphics) + { + this._obj_graphics = _graphics; + } + + public void AddEffect(BasePostProcessEffect _ppEffect) + { + this._obj_postProcessEffects.Add(_ppEffect); + } + + public virtual void Draw(SpriteBatch _sb, Texture2D _scene) + { + this.mHalfPixel = -new Vector2(.5f / (float)this._obj_graphics.Viewport.Width, .5f / (float)this._obj_graphics.Viewport.Height); + int maxEffect = this._obj_postProcessEffects.Count; + + this.mScene = _scene; + + for (int e = 0; e < maxEffect; e++) + { + if (this._obj_postProcessEffects[e].Enabled) + { + this._obj_postProcessEffects[e].mHalfPixel = this.mHalfPixel; + + this._obj_postProcessEffects[e].mOriginalScene = _scene; + this._obj_postProcessEffects[e].Draw(this.mScene); + this.mScene = this._obj_postProcessEffects[e].mLastScene; + } + } + + _sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque); + _sb.Draw(this.mScene, new Rectangle(0, 0, this._obj_graphics.Viewport.Width, this._obj_graphics.Viewport.Height), Color.White); + _sb.End(); + } + + protected void SaveTexture(Texture2D texture, string name) + { + FileStream stream = new FileStream(name, FileMode.Create); + texture.SaveAsJpeg(stream, texture.Width, texture.Height); + stream.Close(); + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/ScreenQuad.cs b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/ScreenQuad.cs new file mode 100644 index 0000000..d5156ca --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/PostProcessing/ScreenQuad.cs @@ -0,0 +1,58 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace SolarFusion.Core.PostProcessing +{ + public class ScreenQuad + { + GraphicsDevice _obj_graphics; + VertexBuffer _obj_vb; + short[] _obj_ib; + VertexDeclaration _obj_vertDec; + VertexPositionTexture[] mCorners; + + public ScreenQuad(GraphicsDevice _graphics) + { + this._obj_graphics = _graphics; + this.mCorners = new VertexPositionTexture[4]; + this.mCorners[0].Position = new Vector3(0, 0, 0); + this.mCorners[0].TextureCoordinate = Vector2.Zero; + } + + /// + /// Allows the game component to perform any initialization it needs to before starting + /// to run. This is where it can query for any required services and load content. + /// + public virtual void Initialize() + { + this._obj_vertDec = VertexPositionTexture.VertexDeclaration; + + this.mCorners = new VertexPositionTexture[] + { + new VertexPositionTexture( + new Vector3(1,-1,0), + new Vector2(1,1)), + new VertexPositionTexture( + new Vector3(-1,-1,0), + new Vector2(0,1)), + new VertexPositionTexture( + new Vector3(-1,1,0), + new Vector2(0,0)), + new VertexPositionTexture( + new Vector3(1,1,0), + new Vector2(1,0)) + }; + + this._obj_ib = new short[] { 0, 1, 2, 2, 3, 0 }; + this._obj_vb = new VertexBuffer(this._obj_graphics, typeof(VertexPositionTexture), this.mCorners.Length, BufferUsage.None); + this._obj_vb.SetData(this.mCorners); + } + + public virtual void Draw() + { + this._obj_graphics.SetVertexBuffer(this._obj_vb); + this._obj_graphics.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, this.mCorners, 0, 4, this._obj_ib, 0, 2); + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenEnding.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenEnding.cs new file mode 100644 index 0000000..c948120 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenEnding.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace SolarFusion.Core.Screen +{ + public enum EndingType + { + Win = 0, + Loss + } + + public class ScreenEnding : BaseGUIScreen + { + //----------------CLASS CONSTANTS--------------------------------------------------------- + public const float DEFAULT_ALPHA = 2.0f / 3.0f; + public const int DEFAULT_PADDING_H = 32; + public const int DEFAULT_PADDING_V = 16; + public static readonly Color DEFAULT_COLOUR = Color.White; + + //----------------CLASS MEMBERS----------------------------------------------------------- + protected float _message_alpha; + protected EndingType _end_type; + + //-----------------CONSTRUCTOR---------------------------------------------------------------- + + /// + /// Constructor. + /// + public ScreenEnding(string _message, EndingType _type) + : base(_message, Color.White, false, null, false, 1f) + { + this._is_popup = true; + this._message_alpha = DEFAULT_ALPHA; + this._end_type = _type; + } + + public override void loadContent() + { + switch (this._end_type) + { + case EndingType.Win: + MenuItemBasic winEntryQuit = new MenuItemBasic("MAIN MENU", this.GlobalContentManager); + winEntryQuit.OnSelected += EventTriggerGoToMain; + this._list_menuitems.Add(winEntryQuit); + break; + case EndingType.Loss: + MenuItemBasic lossEntryQuit = new MenuItemBasic("MAIN MENU", this.GlobalContentManager); + lossEntryQuit.OnSelected += EventTriggerGoToMain; + this._list_menuitems.Add(lossEntryQuit); + break; + } + + this.BGColour = Color.Black; + base.loadContent(); + } + + public override void render() + { + this.ScreenManager.fadeBackBuffer(this.CurrentTransitionAlpha * this._message_alpha); + base.render(); + } + + //-----------------EVENT HANDLER DELEGATES--------------------------------------------------- + + /// + /// + /// + /// + /// + void EventTriggerGoToMain(object sender, EventPlayer e) + { + //Trigger the Loading Screen to load our Background Menu and Overlay it with our Menu Screen + ScreenLoading.Load(ScreenManager, this.ControllingPlayer, null, new ScreenBG(), new ScreenMenuRoot()); + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenLoading.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenLoading.cs index 071a902..a38e2d6 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenLoading.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenLoading.cs @@ -126,6 +126,7 @@ public override void update() /// 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; diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenPause.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenPause.cs index 5d9d50f..bbc8bcf 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenPause.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/DefaultScreens/ScreenPause.cs @@ -25,8 +25,9 @@ class ScreenPause : BaseGUIScreen /// Constructor. /// 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; } @@ -63,7 +64,7 @@ public override void render() /// void EventTriggerGoToMain(object sender, EventPlayer e) { - const string tmessage = "Are you sure you want to exit the simulation?"; + const string tmessage = "Are you sure you want to exit the game?"; ScreenMsgBox tmsgboxconfirmquit = new ScreenMsgBox(SysConfig.ASSET_CONFIG_MSGBOX_BG, tmessage); tmsgboxconfirmquit.onAccepted += EventTriggerConfirmGoToMain; ScreenManager.addScreen(tmsgboxconfirmquit, ControllingPlayer); diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenCredits.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenCredits.cs index 879c03c..5e33c22 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenCredits.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenCredits.cs @@ -7,35 +7,88 @@ namespace SolarFusion.Core.Screen { + struct PeopleCredited + { + public string Position; + public string Name; + public string FullString; + public Vector2 TextPosition; + public Vector2 TextOrigin; + } + class ScreenCredits : BaseGUIScreen { + protected List mCreditList; + protected int mMaxTextLength; + protected float mMaxWidth; + protected float mTextScale; + public ScreenCredits() : base("CREDITS", Color.White, true, "System/UI/Logos/static_dimensionalwave", true, 1f) { - + this.mCreditList = new List(); } public override void loadContent() { + Vector2 tmpStartPos = new Vector2(this.ScreenManager.GraphicsDevice.Viewport.Width / 2, (this.ScreenManager.GraphicsDevice.Viewport.Height / 2) - 100); + float tmpOffset = 10f; + this.mMaxTextLength = 60; + this.mMaxWidth = 700f; + this.mTextScale = 0.7f; + + // Add People to Credits + PeopleCredited tmpCredit = new PeopleCredited(); + tmpCredit.Position = "Programmer/Designer"; + tmpCredit.Name = "Daniel McAssey"; + this.mCreditList.Add(tmpCredit); + tmpCredit.Position = "Programmer/Designer"; + tmpCredit.Name = "Jamie Finnegan"; + this.mCreditList.Add(tmpCredit); + tmpCredit.Position = "Programmer/Designer"; + tmpCredit.Name = "James Adams"; + this.mCreditList.Add(tmpCredit); + // !AddPeopleToCredits + + for (int i = 0; i < this.mCreditList.Count; i++) + { + PeopleCredited tmpFixCredit = this.mCreditList[i]; + + if ((tmpFixCredit.Name.Length + tmpFixCredit.Position.Length) < this.mMaxTextLength) + { + while (tmpFixCredit.Position.Length < (this.mMaxTextLength - tmpFixCredit.Name.Length)) + { + tmpFixCredit.Position += "."; + } + } + + tmpFixCredit.FullString = tmpFixCredit.Position + tmpFixCredit.Name; + Vector2 tmpFontSize = this.ScreenManager.DefaultGUIFont.MeasureString(tmpFixCredit.FullString); + tmpFixCredit.TextOrigin = new Vector2(tmpFontSize.X / 2, tmpFontSize.Y / 2); + tmpFixCredit.TextPosition = new Vector2(tmpStartPos.X, (tmpStartPos.Y + (tmpFontSize.Y * (i + 1))) + tmpOffset); //NEED TO FIX + this.mCreditList[i] = tmpFixCredit; + } + base.loadContent(); - //load credits } public override void update() { if(this.GlobalInput.IsPressed("NAV_CANCEL", this.ControllingPlayer)) //If player presses cancel button (Escape/B) - { this.exitScreen(); //Exit the screen. - } base.update(); } public override void render() { + base.render(); + this.ScreenManager.SpriteBatch.Begin(); + for (int i = 0; i < this.mCreditList.Count; i++) + this.ScreenManager.SpriteBatch.DrawString(this.ScreenManager.DefaultGUIFont, this.mCreditList[i].FullString, this.mCreditList[i].TextPosition, Color.White, 0f, this.mCreditList[i].TextOrigin, this.mTextScale, SpriteEffects.None, 0f); - base.render(); + this.ScreenManager.SpriteBatch.End(); } } } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenMenuRoot.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenMenuRoot.cs index dcc610a..1e8659e 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenMenuRoot.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenMenuRoot.cs @@ -7,7 +7,6 @@ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; - namespace SolarFusion.Core.Screen { class ScreenMenuRoot : BaseGUIScreen @@ -20,17 +19,14 @@ public ScreenMenuRoot() public override void loadContent() { MenuItemBasic mi_play = new MenuItemBasic("PLAY", this.GlobalContentManager); - MenuItemBasic mi_options = new MenuItemBasic("OPTIONS", this.GlobalContentManager); MenuItemBasic mi_credits = new MenuItemBasic("CREDITS", this.GlobalContentManager); MenuItemBasic mi_exit = new MenuItemBasic("EXIT", this.GlobalContentManager); mi_play.OnSelected += EventTriggerGoToCharSelect; - mi_options.OnSelected += EventTriggerGoToOptions; mi_credits.OnSelected += EventTriggerGoToCredits; mi_exit.OnSelected += DefaultTriggerMenuBack; this._list_menuitems.Add(mi_play); - this._list_menuitems.Add(mi_options); this._list_menuitems.Add(mi_credits); this._list_menuitems.Add(mi_exit); @@ -57,14 +53,6 @@ void EventTriggerGoToCharSelect(object sender, EventPlayer e) ScreenManager.addScreen(new ScreenCharSelect(), e.PlayerIndex); } - /// - /// Event Handler to Go to the Options Screen. - /// - void EventTriggerGoToOptions(object sender, EventPlayer e) - { - ScreenManager.addScreen(new ScreenOptions(), e.PlayerIndex); - } - /// /// Event Handler to Go to the Credits Screen. /// diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenOptions.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenOptions.cs deleted file mode 100644 index 4976176..0000000 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenOptions.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - -namespace SolarFusion.Core.Screen -{ - class ScreenOptions : BaseGUIScreen - { - public ScreenOptions() - : base("OPTIONS", Color.White, false, null, true, 1f) - { - - } - - public override void update() - { - if (this.GlobalInput.IsPressed("NAV_CANCEL", this.ControllingPlayer)) //If player presses cancel button (Escape/B) - { - this.exitScreen(); //Exit the screen. - } - - base.update(); - } - - public override void render() - { - - - base.render(); - } - } -} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenStart.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenStart.cs new file mode 100644 index 0000000..041445b --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GUIScreens/ScreenStart.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Content; + +namespace SolarFusion.Core.Screen +{ + class ScreenStart : BaseGUIScreen + { + public ScreenStart() + : base("Start_Screen", true, "System/UI/Logos/static_jumpista", true, 0.5f) + { + } + + public override void loadContent() + { + MenuItemBasic mi_start = new MenuItemBasic("PRESS START", this.GlobalContentManager); + this._list_menuitems.Add(mi_start); + base.loadContent(); + } + + public override void update() + { + for (int i = 0; i < 4; i++) + { + if (this.GlobalInput.IsPressed("GLOBAL_START", (PlayerIndex)i)) + { + this.ControllingPlayer = (PlayerIndex)i; + this.EventTriggerGoToMenu(this.ControllingPlayer); + return; + } + } + + base.update(); + } + + public override void render() + { + base.render(); + } + + //---------------EVENT HANDLERS------------------------------------------------------------- + + /// + /// Event Handler to Go to character select screen. + /// + void EventTriggerGoToMenu(PlayerIndex? _player) + { + ScreenManager.addScreen(new ScreenMenuRoot(), _player); + } + + /// + /// When the user cancels the main menu, ask if they want to exit the sample. + /// + protected override void OnCancel(PlayerIndex? pplyrindex) + { + const string tmessage = "Are you sure you want to exit?"; + ScreenMsgBox tmsgbox = new ScreenMsgBox(SysConfig.ASSET_CONFIG_MSGBOX_BG, tmessage); + + tmsgbox.onAccepted += EventTriggerMsgBoxConfirm; + ScreenManager.addScreen(tmsgbox, pplyrindex); + } + + /// + /// Event handler for when the user selects ok on the "are you sure + /// you want to exit" message box. + /// + void EventTriggerMsgBoxConfirm(object sender, EventPlayer e) + { + ScreenManager.Game.Exit(); + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GameScreens/ScreenCharSelect.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GameScreens/ScreenCharSelect.cs index 16b95dd..0a32172 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GameScreens/ScreenCharSelect.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GameScreens/ScreenCharSelect.cs @@ -4,23 +4,37 @@ using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Content; + +using GameData; namespace SolarFusion.Core.Screen { - class ScreenCharSelect : BaseGUIScreen + public class ScreenCharSelect : BaseGUIScreen { + private EntityManager _obj_entitymanager = null; + + int mPlayerSelectIndex; + Vector2 mPlayerSelectPos; MenuItemCharacterSelect _obj_selector; + Player[] _obj_availablePlayers; public ScreenCharSelect() : base("Character Select", Color.White, false, null, false, 1f) { + this.mPlayerSelectPos = Vector2.Zero; } public override void loadContent() { + this.mPlayerSelectIndex = 0; + this.mPlayerSelectPos = new Vector2(this.ScreenManager.GameViewport.Width / 2, this.ScreenManager.GameViewport.Height / 2); + this._obj_entitymanager = new EntityManager(this.GlobalContentManager); + this._obj_availablePlayers = this.LoadPlayersFile(this.GlobalContentManager, this._obj_entitymanager.NextID()); this._obj_selector = new MenuItemCharacterSelect(this.ScreenManager.ContentManager, this.ScreenManager.GameViewport); this._obj_selector.OnIncrement += EventTriggerNextCharacter; this._obj_selector.OnDecrement += EventTriggerPreviousCharacter; + this.LoadPlayer(this.mPlayerSelectIndex); base.loadContent(); } @@ -34,11 +48,17 @@ public override void update() this._obj_selector.OnDecrementEntry(this.ControllingPlayer); if (this.GlobalInput.IsPressed("NAV_SELECT", this.ControllingPlayer)) //If player presses cancel button (Escape/B) - ScreenLoading.Load(this.ScreenManager, "-LOADING-", true, this.ControllingPlayer, new ScreenGame()); //Load Game + { + ScreenLoading.Load(this.ScreenManager, "LOADING", true, this.ControllingPlayer, new ScreenGame(this._obj_availablePlayers[this.mPlayerSelectIndex], this._obj_entitymanager)); //Load Game + this._obj_availablePlayers[this.mPlayerSelectIndex].PlayerAnimation.Scale = this._obj_availablePlayers[this.mPlayerSelectIndex].PlayerAnimation.OriginalScale; + } if (this.GlobalInput.IsPressed("NAV_CANCEL", this.ControllingPlayer)) //If player presses cancel button (Escape/B) this.exitScreen(); //Exit the screen. + if (this.mPlayerSelectIndex < this._obj_availablePlayers.Length && this._obj_availablePlayers[this.mPlayerSelectIndex] != null) + this._obj_availablePlayers[this.mPlayerSelectIndex].Update(this.ScreenManager.Timer); //Update the player + base.update(); } @@ -46,16 +66,36 @@ public override void render() { this._obj_selector.render(this); + if (this.mPlayerSelectIndex < this._obj_availablePlayers.Length && this._obj_availablePlayers[this.mPlayerSelectIndex] != null) + { + this.ScreenManager.SpriteBatch.Begin(); + this._obj_availablePlayers[this.mPlayerSelectIndex].Draw(this.ScreenManager.SpriteBatch); + this.ScreenManager.SpriteBatch.End(); + } + base.render(); } + public void LoadPlayer(int _index) + { + if (this.mPlayerSelectIndex < this._obj_availablePlayers.Length && this._obj_availablePlayers[this.mPlayerSelectIndex] != null && this._obj_selector != null) + { + this._obj_availablePlayers[this.mPlayerSelectIndex].Position = this.mPlayerSelectPos; + this._obj_selector.Text = this._obj_availablePlayers[this.mPlayerSelectIndex].CharacterName; + } + } /// /// Event Handler to show next character. /// void EventTriggerNextCharacter(object sender, EventPlayer e) { + if ((this.mPlayerSelectIndex + 1) < this._obj_availablePlayers.Length) + this.mPlayerSelectIndex += 1; + else + this.mPlayerSelectIndex = 0; + this.LoadPlayer(this.mPlayerSelectIndex); } /// @@ -63,7 +103,68 @@ void EventTriggerNextCharacter(object sender, EventPlayer e) /// void EventTriggerPreviousCharacter(object sender, EventPlayer e) { + if ((this.mPlayerSelectIndex - 1) >= 0) + { + this.mPlayerSelectIndex -= 1; + } + else + { + if (this._obj_availablePlayers.Length != 0) + this.mPlayerSelectIndex = this._obj_availablePlayers.Length - 1; + else + this.mPlayerSelectIndex = 0; + } + + this.LoadPlayer(this.mPlayerSelectIndex); + } + + #region "Load Players" + private Player[] LoadPlayersFile(ContentManager _content, uint _playerID) + { + string[] playerRef = _content.Load("Core/Data/players"); //Load available players. + PlayerData[] players = new PlayerData[playerRef.Length]; //Load the data from the library. + + try + { + for (int i = 0; i < playerRef.Length; i++) + players[i] = _content.Load("Core/Data/Players/" + playerRef[i]); //Load individual player data. + + } + catch (Exception ex) + { + throw new Exception("Error: Cannot Load Player Data, Exception occured. ", ex); + } + + return this.LoadCharacterData(players, _content, _playerID); //Then return the parsed data. + } + + private Player[] LoadCharacterData(PlayerData[] players, ContentManager _content, uint _playerID) //Function to parse the data. + { + Player[] playerObjects = new Player[players.Length]; //Creates an array of player objects. + AnimatedSprite[] characterSprites; //Creates array of animated sprites. + characterSprites = new AnimatedSprite[players.Length]; + + for (int i = 0; i < players.Length; i++) //Loops through loaded players, ready to parse. + { + Texture2D tmpTexture = _content.Load("Sprites/Characters/" + players[i].playerRef + "/spritesheet"); //Loads the texture from the data. + characterSprites[i] = new AnimatedSprite(tmpTexture, players[i].maxFrameCount, players[i].playerAnimations.Length); //And several animations. + + for (int j = 0; j < players[i].playerAnimations.Length; j++) //Loops through each available animation in the data and adds them. + characterSprites[i].AddAnimation(players[i].playerAnimations[j], (j + 1), int.Parse(players[i].playerAnimationFrameCount[j]), players[i].playerAnimationsFPS[players[i].playerAnimations[j]]); + + //Other configuration things for sprite animation. + characterSprites[i].Loop = true; + characterSprites[i].Position = this.mPlayerSelectPos; + characterSprites[i].Origin = new Vector2((tmpTexture.Width / (float)players[i].maxFrameCount) / 2f, (tmpTexture.Height / (float)players[i].playerAnimations.Length) / 2f); + characterSprites[i].Scale = players[i].playerScale * 3f; + characterSprites[i].OriginalScale = players[i].playerScale; + characterSprites[i].CurrentAnimation = players[i].defaultAnimation; + playerObjects[i] = new Player(_playerID, characterSprites[i], characterSprites[i].Position, players[i].moveSpeed, players[i].jumpSpeed, this._obj_entitymanager); + playerObjects[i].CharacterName = players[i].playerName; + } + return playerObjects; } + #endregion } } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GameScreens/ScreenGame.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GameScreens/ScreenGame.cs index 8f59bf2..428351f 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GameScreens/ScreenGame.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/GameScreens/ScreenGame.cs @@ -11,6 +11,7 @@ using SolarFusion.Core; using SolarFusion.Input; using SolarFusion.Level; +using SolarFusion.Core.PostProcessing; namespace SolarFusion.Core.Screen { @@ -20,24 +21,19 @@ public class ScreenGame : AppScreen private LevelManager _obj_levelmanager = null; private Player _obj_activeplayer = null; + public ScreenGame(Player _player, EntityManager _entitym) + { + this._obj_activeplayer = _player; + this._obj_entitymanager = _entitym; + } + public override void loadContent() { base.loadContent(); this.BGColour = Color.Black; - this._obj_levelmanager = new LevelManager(this.GlobalContentManager, this.ScreenManager.GraphicsDevice.Viewport); - this._obj_entitymanager = new EntityManager(this.GlobalContentManager); - - //!Debug! - AnimatedSprite _tmpPlayerAnim = new AnimatedSprite(this._local_content.Load("Sprites/Characters/Jumpista/spritesheet"), 5, 3); - _tmpPlayerAnim.AddAnimation("right", 1, 5, 7); - _tmpPlayerAnim.AddAnimation("left", 2, 5, 7); - _tmpPlayerAnim.AddAnimation("idle", 3, 3, 5); - _tmpPlayerAnim.mCurrentAnimation = "idle"; - _tmpPlayerAnim.Loop = true; - //!Debug! - - this._obj_activeplayer = new Player(this._obj_entitymanager.NextID(), _tmpPlayerAnim, Vector2.Zero, 1.8f, 100, 280, this._obj_entitymanager); - this._obj_levelmanager.LoadLevel(1, this._obj_activeplayer, this._obj_entitymanager); //Load Test Level 0 + this._obj_levelmanager = new LevelManager(this.GlobalContentManager, this.ScreenManager.GraphicsDevice, this.GlobalInput, this.ControllingPlayer, this.ScreenManager, this.ScreenManager.DefaultGUIFont); + this._obj_levelmanager.LoadLevel(1, this._obj_activeplayer, this._obj_entitymanager); //Load Level + this.BGColour = Color.Blue; } public override void unloadContent() @@ -59,27 +55,25 @@ public override void update() //Update per frame this._obj_levelmanager.Update(_gameTimer); - if (this.GlobalInput.IsPressed("PLAY_MOVE_LEFT", this.ControllingPlayer)) //If player presses cancel button (Escape/B) + if (this.GlobalInput.IsPressed("PLAY_MOVE_LEFT", this.ControllingPlayer)) //If player presses left button (Left Arrow/Left DPAD) this._obj_activeplayer.moveLeft(); - else if (this.GlobalInput.IsPressed("PLAY_MOVE_RIGHT", this.ControllingPlayer)) //If player presses cancel button (Escape/B) + else if (this.GlobalInput.IsPressed("PLAY_MOVE_RIGHT", this.ControllingPlayer)) //If player presses left button (Right Arrow/Right DPAD) this._obj_activeplayer.moveRight(); else this._obj_activeplayer.moveIdle(); - if (this.GlobalInput.IsPressed("PLAY_MOVE_JUMP", this.ControllingPlayer)) //If player presses cancel button (Escape/B) + if (this.GlobalInput.IsPressed("PLAY_MOVE_JUMP", this.ControllingPlayer)) //If player presses the jump button (Spacebar/A) this._obj_activeplayer.jump(); + if (this.GlobalInput.IsPressed("PLAY_WEAPON_FIRE", this.ControllingPlayer)) //If player presses the jump button (Spacebar/A) + this._obj_activeplayer.fire(); + base.update(); } public override void appRender() //Render per frame { this.internResetRenderStatesFor2D(); //Reset 2D states - - this.ScreenManager.SpriteBatch.Begin(); - //Render HUD - this.ScreenManager.SpriteBatch.End(); - this._obj_levelmanager.Draw(this.ScreenManager.SpriteBatch); } } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/AppScreen.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/AppScreen.cs index 42b7afc..0273cf1 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/AppScreen.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/AppScreen.cs @@ -66,11 +66,10 @@ public override void update() /// public override void render() { - //Clear the Graphics Device - this.ScreenManager.GraphicsDevice.Clear(this._bgcolour); - + //Clear Screen Black + this.ScreenManager.GraphicsDevice.Clear(Color.Black); + //Render the screen this.appRender(); - //Draw our overlay screen fade. this.renderScreenFade(); } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/BaseGUIScreen.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/BaseGUIScreen.cs index 7638e62..f5d841f 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/BaseGUIScreen.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/BaseGUIScreen.cs @@ -416,6 +416,7 @@ protected virtual void OnCancel(PlayerIndex? pplyrindex) /// protected virtual void DefaultTriggerMenuBack(object psender, EventPlayer pargs) { + this._game_paused = false; this.OnCancel(pargs.PlayerIndex); } diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/BaseScreen.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/BaseScreen.cs index ee1e22d..fb9ed0e 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/BaseScreen.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/BaseScreen.cs @@ -38,6 +38,7 @@ public abstract class BaseScreen protected String _screen_name = String.Empty; protected float _pause_alpha; protected Color _bgcolour = Color.Black; + protected bool _game_paused = false; public BaseScreen() { @@ -143,6 +144,7 @@ public ScreenManager ScreenManager public PlayerIndex? ControllingPlayer { get { return _primary_player; } + set { _primary_player = value; } } /// @@ -350,7 +352,10 @@ protected virtual void updateScreenFade(bool poverlaid) protected virtual void checkForPauseAction() { if (this.GlobalInput.IsPressed("GAME_PAUSE", this.ControllingPlayer)) + { + this._game_paused = true; ScreenManager.addScreen(new ScreenPause(), this.ControllingPlayer); + } } /// diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/Components/GameGUI.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/Components/GameGUI.cs new file mode 100644 index 0000000..c46bb15 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Screen/System/Components/GameGUI.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Content; + +namespace SolarFusion.Core.Screen +{ + public struct GUIElement + { + public Texture2D Texture; + public Vector2 Position; + public Vector2 Origin; + public string Text; + public Vector2 TextOrigin; + public string Value; + public float Scale; + } + + public class GameGUI + { + protected GraphicsDevice _obj_graphics = null; + protected List _obj_elements = null; + protected Dictionary _obj_reference = null; + protected SpriteFont mDefaultFont; + + #region "Properties" + public int Ammo + { + set { this.UpdateElement("Ammo", value.ToString()); } + } + + public float Health + { + set { this.UpdateElement("Health", value.ToString()); } + } + + public float Points + { + set { this.UpdateElement("Points", value.ToString()); } + } + + public bool Crystal + { + set { if (value) { this.UpdateElement("Crystal", "COLLECTED"); } else { this.UpdateElement("Crystal", "MISSING"); } } + } + #endregion + + public GameGUI(GraphicsDevice _graphics, SpriteFont _font) + { + this._obj_graphics = _graphics; + this._obj_elements = new List(); + this._obj_reference = new Dictionary(); + this.mDefaultFont = _font; + } + + public void Load(ContentManager _content) + { + this.AddElement(_content.Load("Sprites/Misc/UI/GUI/life"), new Vector2(30, 30), "Health", 0.7f); + this.AddElement(_content.Load("Sprites/Objects/Static/energy_ball/sprite"), new Vector2(30, 60), "Points", 1f); + this.AddElement(_content.Load("Sprites/Objects/Static/crystal/sprite"), new Vector2(30, 90), "Crystal", 1f); + this.AddElement(_content.Load("Sprites/Objects/Static/blast/sprite"), new Vector2(30, 120), "Ammo", 1f); + } + + public void AddElement(Texture2D _texture, Vector2 _position, string _text, float _scale) + { + GUIElement tmpElement = new GUIElement(); + tmpElement.Texture = _texture; + tmpElement.Position = _position; + tmpElement.Origin = new Vector2(_texture.Width / 2f, _texture.Height / 2f); + tmpElement.Text = _text; + tmpElement.Value = ""; + tmpElement.Scale = _scale; + this._obj_elements.Add(tmpElement); + this._obj_reference.Add(_text, this._obj_elements.Count - 1); + } + + public void UpdateElement(string _reference, string _newValue) + { + if (this._obj_reference.ContainsKey(_reference)) + { + GUIElement tmpElement = this._obj_elements[this._obj_reference[_reference]]; + tmpElement.Value = _newValue; + this._obj_elements[this._obj_reference[_reference]] = tmpElement; + } + } + + public void Unload() + { + this._obj_graphics = null; + } + + public void Update(GameTime _elapsedTime, Camera2D _camera) + { + for (int i = 0; i < this._obj_elements.Count; i++) + { + GUIElement tmpElement = this._obj_elements[i]; + Vector2 tmpMeasure = this.mDefaultFont.MeasureString("- " + tmpElement.Value); + tmpElement.TextOrigin = new Vector2(0, tmpMeasure.Y / 2f); + tmpElement.Position = new Vector2(30 + (_camera.Position.X - (this._obj_graphics.Viewport.Width / 2f)), tmpElement.Position.Y); + this._obj_elements[i] = tmpElement; + } + } + + public void Draw(SpriteBatch _sb) + { + for (int i = 0; i < this._obj_elements.Count; i++) + { + _sb.Draw(this._obj_elements[i].Texture, this._obj_elements[i].Position, null, Color.White, 0f, this._obj_elements[i].Origin, this._obj_elements[i].Scale, SpriteEffects.None, 0f); + _sb.DrawString(this.mDefaultFont, "- " + this._obj_elements[i].Value, new Vector2(this._obj_elements[i].Position.X + 30, this._obj_elements[i].Position.Y), Color.White, 0f, this._obj_elements[i].TextOrigin, 0.5f, SpriteEffects.None, 0f); + } + } + } +} diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/Sprites/Sprite.cs b/SolarFusion/SolarFusion/SolarFusion/Core/Sprites/Sprite.cs index 4e45524..cf8857d 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/Sprites/Sprite.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/Sprites/Sprite.cs @@ -19,6 +19,7 @@ public abstract class Sprite protected Vector2 mSpriteOrigin; protected float mSpriteRotation = 0f; protected float mSpriteScale = 1f; + protected float mSpriteScaleOriginal = 1f; protected SpriteEffects mSpriteEffects; //!Default Variables @@ -43,44 +44,50 @@ public string CurrentAnimation public Texture2D Texture { - get { return mSpriteTexture; } - set { mSpriteTexture = value; } + get { return this.mSpriteTexture; } + set { this.mSpriteTexture = value; } } public Vector2 Position { - get { return mSpritePosition; } - set { mSpritePosition = value; } + get { return this.mSpritePosition; } + set { this.mSpritePosition = value; } } public Color Colour { - get { return mSpriteColor; } - set { mSpriteColor = value; } + get { return this.mSpriteColor; } + set { this.mSpriteColor = value; } } public Vector2 Origin { - get { return mSpriteOrigin; } - set { mSpriteOrigin = value; } + get { return this.mSpriteOrigin; } + set { this.mSpriteOrigin = value; } } public float Rotation { - get { return mSpriteRotation; } - set { mSpriteRotation = value; } + get { return this.mSpriteRotation; } + set { this.mSpriteRotation = value; } } public float Scale { - get { return mSpriteScale; } - set { mSpriteScale = value; } + get { return this.mSpriteScale; } + set { this.mSpriteScale = value; } + } + + public float OriginalScale + { + get { return this.mSpriteScaleOriginal; } + set { this.mSpriteScaleOriginal = value; } } public SpriteEffects Effects { - get { return mSpriteEffects; } - set { mSpriteEffects = value; } + get { return this.mSpriteEffects; } + set { this.mSpriteEffects = value; } } public int Frame @@ -91,23 +98,23 @@ public int Frame public int AnimationHeight { - get { return mAnimationHeight; } + get { return this.mAnimationHeight; } } public int AnimationWidth { - get { return mAnimationWidth; } + get { return this.mAnimationWidth; } } //!PROPERTIES // FUNCTIONS - public Sprite(Texture2D spriteTexture, int maxFrameCount, int animationCount) { mSpriteTexture = spriteTexture; //Assign the appropriate data. mAnimationFrames = maxFrameCount; mAnimationWidth = mSpriteTexture.Width / maxFrameCount; mAnimationHeight = mSpriteTexture.Height / animationCount; + mSpriteOrigin = new Vector2(mAnimationWidth / 2, mAnimationHeight / 2); } public void AddAnimation(string animName, int animRow, int frameCount, int spriteFPS) diff --git a/SolarFusion/SolarFusion/SolarFusion/Core/SysConfig.cs b/SolarFusion/SolarFusion/SolarFusion/Core/SysConfig.cs index 71ea302..73a96fc 100644 --- a/SolarFusion/SolarFusion/SolarFusion/Core/SysConfig.cs +++ b/SolarFusion/SolarFusion/SolarFusion/Core/SysConfig.cs @@ -11,9 +11,9 @@ namespace SolarFusion.Core public class SysConfig { //General Configuration - public const string CONFIG_GAME_BUILD = "0.1dev-branch"; - public const string CONFIG_GAME_BUILD_TYPE = "Development"; - public const string CONFIG_GAME_NAME_CLEAN = "SolarFusion"; + public const string CONFIG_GAME_BUILD = "1.0-beta-branch"; + public const string CONFIG_GAME_BUILD_TYPE = "BETA"; + public const string CONFIG_GAME_NAME_CLEAN = "Jumpista"; public const string CONFIG_GAME_NAME = CONFIG_GAME_NAME_CLEAN + " - " + CONFIG_GAME_BUILD_TYPE + " Build (" + CONFIG_GAME_BUILD + ")"; //Debug Settings @@ -45,8 +45,8 @@ public class SysConfig public const string ASSET_CONFIG_SETTINGS_FILE = "base.config"; //Default Strings - public const string ASSET_CONFIG_MSG_LOADING = "-LOADING-"; - public const string ASSET_CONFIG_MSG_BOX_USAGE = "\n'Enter' - Yes\n'Escape' - No"; + public const string ASSET_CONFIG_MSG_LOADING = "LOADING"; + public const string ASSET_CONFIG_MSG_BOX_USAGE = "\n'OK' - Yes\n'CANCEL' - No"; //Default GamePad Controls public const Buttons INPUT_GAMEPAD_UP_DPAD = Buttons.DPadUp; @@ -63,6 +63,7 @@ public class SysConfig public const Buttons INPUT_GAMEPAD_CANCEL = Buttons.B; public const Buttons INPUT_GAMEPAD_JUMP = Buttons.A; + public const Buttons INPUT_GAMEPAD_FIRE = Buttons.RightShoulder; //Default Keyboard Controls public const Keys INPUT_KEYBOARD_UP = Keys.Up; @@ -70,10 +71,11 @@ public class SysConfig public const Keys INPUT_KEYBOARD_LEFT = Keys.Left; public const Keys INPUT_KEYBOARD_RIGHT = Keys.Right; - public const Keys INPUT_KEYBOARD_START = Keys.Escape; + public const Keys INPUT_KEYBOARD_START = Keys.Enter; public const Keys INPUT_KEYBOARD_SELECT = Keys.Enter; public const Keys INPUT_KEYBOARD_CANCEL = Keys.Escape; public const Keys INPUT_KEYBOARD_JUMP = Keys.Space; + public const Keys INPUT_KEYBOARD_FIRE = Keys.X; } } diff --git a/SolarFusion/SolarFusion/SolarFusion/GameThumbnail.png b/SolarFusion/SolarFusion/SolarFusion/GameThumbnail.png deleted file mode 100644 index 462311a..0000000 Binary files a/SolarFusion/SolarFusion/SolarFusion/GameThumbnail.png and /dev/null differ diff --git a/SolarFusion/SolarFusion/SolarFusion/SolarFusion (Xbox 360).csproj b/SolarFusion/SolarFusion/SolarFusion/SolarFusion (Xbox 360).csproj index 2cb04c4..8869a4b 100644 --- a/SolarFusion/SolarFusion/SolarFusion/SolarFusion (Xbox 360).csproj +++ b/SolarFusion/SolarFusion/SolarFusion/SolarFusion (Xbox 360).csproj @@ -57,11 +57,6 @@ DEBUG;TRACE;XBOX;XBOX360 true - - - true - - @@ -71,33 +66,44 @@ + + + - - + + + + + + + + + - + + @@ -152,12 +158,6 @@ true - - - - - - diff --git a/SolarFusion/SolarFusion/SolarFusion/SolarFusion.csproj b/SolarFusion/SolarFusion/SolarFusion/SolarFusion.csproj index 27e6a28..43be37b 100644 --- a/SolarFusion/SolarFusion/SolarFusion/SolarFusion.csproj +++ b/SolarFusion/SolarFusion/SolarFusion/SolarFusion.csproj @@ -13,7 +13,7 @@ Client v4.0 Windows - Reach + HiDef 23e9d59e-715f-4c16-a7a1-fe6bdd4e1388 Game Core\Game.ico @@ -117,24 +117,35 @@ Code + + + - - + + + + + + + + + - + + @@ -198,7 +209,6 @@ true - + + \ No newline at end of file diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/BrightPass.fx b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/BrightPass.fx new file mode 100644 index 0000000..fa01dfd --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/BrightPass.fx @@ -0,0 +1,24 @@ +uniform extern float BloomThreshold; + +float2 halfPixel; +sampler TextureSampler : register(s0); + +float4 BrightPassPS(float2 texCoord : TEXCOORD0) : COLOR0 +{ + texCoord -= halfPixel; + // Look up the original image color. + float4 c = tex2D(TextureSampler, texCoord); + + // Adjust it to keep only values brighter than the specified threshold. + return saturate((c - BloomThreshold) / (1 - BloomThreshold)); +} + +technique BloomExtract +{ + pass P0 + { + PixelShader = compile ps_2_0 BrightPassPS(); + + //ZWriteEnable = false; + } +} \ No newline at end of file diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/LightSourceMask.fx b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/LightSourceMask.fx new file mode 100644 index 0000000..5bfcf9c --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/LightSourceMask.fx @@ -0,0 +1,41 @@ +#include "PPVertexShader.fxh" + +float2 lightScreenPosition; +float2 screenRes = float2(4,3); +float4x4 matVP; +float2 halfPixel; +float SunSize = 1500; + +sampler2D Scene: register(s0){ + AddressU = Clamp; + AddressV = Clamp; +}; + +texture flare; +sampler Flare = sampler_state +{ + Texture = (flare); + AddressU = CLAMP; + AddressV = CLAMP; +}; + +float4 LightSourceMaskPS(float2 texCoord : TEXCOORD0 ) : COLOR0 +{ + texCoord -= halfPixel; + float4 col = 0; + float2 coord; + float size = SunSize / 1; + float2 center = lightScreenPosition; + coord = .5 - ((texCoord - center) * screenRes) / size * .5f; + col += (pow(tex2D(Flare,coord),2) * 1) * 2; + return col * tex2D(Scene,texCoord); +} + +technique LightSourceMask +{ + pass p0 + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 LightSourceMaskPS(); + } +} \ No newline at end of file diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/LigthRays.fx b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/LigthRays.fx new file mode 100644 index 0000000..aac105f --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/LigthRays.fx @@ -0,0 +1,47 @@ +#include "PPVertexShader.fxh" + +#define NUM_SAMPLES 64 + +float2 lightScreenPosition; +float4x4 matVP; +float2 halfPixel; +float Density = .5f; +float Decay = .95f; +float Weight = 1.0f; +float Exposure = .15f; + +sampler2D Scene: register(s0){ + AddressU = Clamp; + AddressV = Clamp; +}; + +float4 lightRayPS( float2 texCoord : TEXCOORD0 ) : COLOR0 +{ + float2 TexCoord = texCoord - halfPixel; + float2 DeltaTexCoord = (TexCoord - lightScreenPosition); + DeltaTexCoord *= (1.0f / NUM_SAMPLES * Density); + DeltaTexCoord = DeltaTexCoord ; + float3 col = tex2D(Scene,TexCoord); + float IlluminationDecay = 1.0; + float3 Sample; + + for( int i = 0; i < NUM_SAMPLES; ++i ) + { + TexCoord -= DeltaTexCoord; + Sample = tex2D(Scene, TexCoord); + Sample *= IlluminationDecay * Weight; + col += Sample; + IlluminationDecay *= Decay; + } + + return float4(col * Exposure,1); +} + +technique LightRayFX +{ + pass p0 + { + VertexShader = compile vs_3_0 VertexShaderFunction(); + PixelShader = compile ps_3_0 lightRayPS(); + } +} diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/PPVertexShader.fxh b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/PPVertexShader.fxh new file mode 100644 index 0000000..a6c0cf3 --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/PPVertexShader.fxh @@ -0,0 +1,21 @@ +struct VertexShaderOutput +{ + float4 Position : POSITION0; + float2 TexCoord : TexCoord0; +}; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float2 TexCoord : TexCoord0; +}; + +VertexShaderOutput VertexShaderFunction(VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + + output.Position = float4(input.Position.xyz,1); + output.TexCoord = input.TexCoord; + + return output; +} \ No newline at end of file diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/SceneBlend.fx b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/SceneBlend.fx new file mode 100644 index 0000000..8aca21c --- /dev/null +++ b/SolarFusion/SolarFusion/SolarFusionContent/Core/Shaders/PostProcessing/SceneBlend.fx @@ -0,0 +1,50 @@ +#include "PPVertexShader.fxh" + +float2 halfPixel; + +sampler2D Scene: register(s0){ + AddressU = Mirror; + AddressV = Mirror; +}; + +texture OrgScene; +sampler2D orgScene = sampler_state +{ + Texture = ; + AddressU = CLAMP; + AddressV = CLAMP; +}; + +float4 BlendPS(float2 texCoord : TEXCOORD0 ) : COLOR0 +{ + texCoord -= halfPixel; + float4 col = tex2D(orgScene,texCoord) * tex2D(Scene,texCoord); + + return col; +} + +float4 AditivePS(float2 texCoord : TEXCOORD0 ) : COLOR0 +{ + texCoord -= halfPixel; + float4 col = tex2D(orgScene,texCoord) + tex2D(Scene,texCoord); + + return col; +} + +technique Blend +{ + pass p0 + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 BlendPS(); + } +} + +technique Aditive +{ + pass p0 + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 AditivePS(); + } +} \ No newline at end of file diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Core/Textures/sun_flare.png b/SolarFusion/SolarFusion/SolarFusionContent/Core/Textures/sun_flare.png new file mode 100644 index 0000000..9fc5ffb Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Core/Textures/sun_flare.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Levels/level_1/level.tmx b/SolarFusion/SolarFusion/SolarFusionContent/Levels/level_1/level.tmx index 1ac4163..53a2242 100644 --- a/SolarFusion/SolarFusion/SolarFusionContent/Levels/level_1/level.tmx +++ b/SolarFusion/SolarFusion/SolarFusionContent/Levels/level_1/level.tmx @@ -41,49 +41,49 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -109,7 +109,7 @@ - + @@ -126,30 +126,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SolarFusion/SolarFusion/SolarFusionContent/SolarFusionContent.contentproj b/SolarFusion/SolarFusion/SolarFusionContent/SolarFusionContent.contentproj index dd83327..dd3a932 100644 --- a/SolarFusion/SolarFusion/SolarFusionContent/SolarFusionContent.contentproj +++ b/SolarFusion/SolarFusion/SolarFusionContent/SolarFusionContent.contentproj @@ -57,12 +57,11 @@ - - - - - - + + sprite + TextureImporter + TextureProcessor + @@ -86,13 +85,6 @@ true - - - characters - XmlImporter - PassThroughProcessor - - font_DEBUG @@ -437,7 +429,7 @@ - + spritesheet TextureImporter TextureProcessor @@ -1038,6 +1030,133 @@ TextureProcessor + + + sun_flare + TextureImporter + TextureProcessor + + + + + BrightPass + EffectImporter + EffectProcessor + + + LightSourceMask + EffectImporter + EffectProcessor + + + LigthRays + EffectImporter + EffectProcessor + + + SceneBlend + EffectImporter + EffectProcessor + + + + + PPVertexShader + + + + + players + XmlImporter + PassThroughProcessor + Designer + + + + + dr_jumpista + XmlImporter + PassThroughProcessor + Designer + + + + + asterix + XmlImporter + PassThroughProcessor + + + + + anim_loading + TextureImporter + TextureProcessor + + + + + spritesheet + TextureImporter + TextureProcessor + + + + + spritesheet + TextureImporter + TextureProcessor + + + + + spritesheet + TextureImporter + TextureProcessor + + + + + sprite + TextureImporter + TextureProcessor + + + + + sprite + TextureImporter + TextureProcessor + + + + + spritesheet + TextureImporter + TextureProcessor + + + + + sprite + TextureImporter + TextureProcessor + + + + + debug_pixel + TextureImporter + TextureProcessor + + + + + life + TextureImporter + TextureProcessor + + - - diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Characters/Jumpista/spritesheet.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Characters/dr_jumpista/spritesheet.png similarity index 100% rename from SolarFusion/SolarFusion/SolarFusionContent/Sprites/Characters/Jumpista/spritesheet.png rename to SolarFusion/SolarFusion/SolarFusionContent/Sprites/Characters/dr_jumpista/spritesheet.png diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Enemies/mercbot/spritesheet.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Enemies/mercbot/spritesheet.png new file mode 100644 index 0000000..e7c61c1 Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Enemies/mercbot/spritesheet.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Misc/Animated/anim_loading.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Misc/Animated/anim_loading.png new file mode 100644 index 0000000..adb0a4e Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Misc/Animated/anim_loading.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Misc/Static/debug_pixel.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Misc/Static/debug_pixel.png new file mode 100644 index 0000000..dde12bc Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Misc/Static/debug_pixel.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Misc/UI/GUI/life.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Misc/UI/GUI/life.png new file mode 100644 index 0000000..4554291 Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Misc/UI/GUI/life.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Animated/crystal/spritesheet.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Animated/crystal/spritesheet.png new file mode 100644 index 0000000..0a6e683 Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Animated/crystal/spritesheet.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Animated/warp/spritesheet.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Animated/warp/spritesheet.png new file mode 100644 index 0000000..a96d990 Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Animated/warp/spritesheet.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/blast/sprite.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/blast/sprite.png new file mode 100644 index 0000000..bda44fe Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/blast/sprite.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/crate/sprite.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/crate/sprite.png new file mode 100644 index 0000000..c818343 Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/crate/sprite.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/crystal/sprite.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/crystal/sprite.png new file mode 100644 index 0000000..db070dc Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/crystal/sprite.png differ diff --git a/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/energy_ball/sprite.png b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/energy_ball/sprite.png new file mode 100644 index 0000000..45c6a85 Binary files /dev/null and b/SolarFusion/SolarFusion/SolarFusionContent/Sprites/Objects/Static/energy_ball/sprite.png differ