public SmallBlock01(Game game, Vector2 position) : base(game) { _position = position; _spritebatch = Game.Services.GetService<SpriteBatch>(); krypton = Game.Services.GetService<KryptonEngine>(); }
public Freeblock(Game game, Vector2 position) { Game = game; krypton = Game.Services.GetService<KryptonEngine>(); _world = Game.Services.GetService<World>(); _position = position; }
public virtual void LoadContent(World world, Game game, Vector2 position,float scale, KryptonEngine krypton) { base.LoadContent(world, "Ground", position, scale); body.IsStatic = true; var hull = ShadowHull.CreateRectangle(ConvertUnits.ToSimUnits(new Vector2(mSpriteTexture.Width, mSpriteTexture.Height))); hull.Position = GamePosition; krypton.Hulls.Add(hull); }
public CaveBlock(Game game, Vector2 position, Color color,AMaterialStats stats,bool gtbS,Tileset tset,Color glowcolour) : base(game, position, color, stats,tset,glowcolour) { NeighbourList = new List<CaveBlock>(); GoingtobeSolid = gtbS; krypton = Game.Services.GetService<KryptonEngine>(); _world = Game.Services.GetService<World>(); }
public PlayerShip(Game game, Vector2 position) { Game = game; _soundBank = Game.Services.GetService<SoundBank[]>(); _world = Game.Services.GetService<World>(); krypton = Game.Services.GetService<KryptonEngine>(); thrustLR = _soundBank[0].GetCue("thrust01"); thrustLR.Play(); thrustLR.Pause(); thrustUD = _soundBank[0].GetCue("thrust01"); thrustUD.Play(); thrustUD.Pause(); Position = position; _particleRenderer = Game.Services.GetService<SpriteBatchRenderer>(); //_textures = Game.Services.GetService<Textures>(); //Loadcontentstuff _shiptxture = Game.Content.Load<Texture2D>("player_ship"); _turretTxture = Game.Content.Load<Texture2D>(".\\guns\\turret01"); _centreVect = new Vector2(_shiptxture.Width / 2, _shiptxture.Height / 2); ProximityBox = new Rectangle(0, 0, _shiptxture.Width+Globals.PhysBuffer, _shiptxture.Height + Globals.PhysBuffer); //make ship fixture in for farseer box = BodyFactory.CreateCircle(_world, ConvertUnits.ToSimUnits(_shiptxture.Width / 2), 7.0f); box.BodyType = BodyType.Dynamic; box.Restitution = 0.5f; box.Friction = 0.2f; box.FixedRotation = true; box.LinearDamping = 0.4f; box.Position = ConvertUnits.ToSimUnits(Position.X + _centreVect.X, Position.Y + _centreVect.Y); box.UserData = "player"; //box.OnCollision += Collide; box.OnSeparation += Collide; //make light in krypton var mLightTexture = LightTextureBuilder.CreateConicLight(Game.GraphicsDevice, 256, 2.0f); light = CreateLights(mLightTexture,400); var mLightTexture2 = LightTextureBuilder.CreatePointLight(Game.GraphicsDevice, 64); light2 = CreateLights(mLightTexture2,200); //set up thruster particle _thrustparticle = Game.Content.Load<ParticleEffect>(".\\mercury\\thruster"); _thrustparticle.LoadContent(Game.Content); _thrusterEmitter = (ConeEmitter)_thrustparticle[0]; //_thrusterEmitter.Initialise(); _thrusterEmitter.ParticleTexture = Game.Content.Load<Texture2D>(".\\mercury\\Particle004"); _thrustparticle.Initialise(); _particleRenderer.LoadContent(Game.Content); //_centerVect = new Vector2(_shiptxture.Width / 2,_shiptxture.Width / 2); currentWeapon = new Gun(Game, true, BulletsStats.Plasma01); }
public LightingEngine() { PresentationParameters pp = Renderer.GD.PresentationParameters; SurfaceFormat format = pp.BackBufferFormat; Krypton = new KryptonEngine(GeneralManager.Game, "Effects/KryptonEffect"); Krypton.Initialize(); Krypton.AmbientColor = Color.Black; Vertices = new VertexPositionColorTexture[4]; Vertices[0] = new VertexPositionColorTexture(new Vector3(-1, 1, 0), Color.White, new Vector2(0, 0)); Vertices[1] = new VertexPositionColorTexture(new Vector3(1, 1, 0), Color.White, new Vector2(1, 0)); Vertices[2] = new VertexPositionColorTexture(new Vector3(-1, -1, 0), Color.White, new Vector2(0, 1)); Vertices[3] = new VertexPositionColorTexture(new Vector3(1, -1, 0), Color.White, new Vector2(1, 1)); VertexBuffer = new VertexBuffer(Renderer.GD, typeof(VertexPositionColorTexture), Vertices.Length, BufferUsage.None); VertexBuffer.SetData(Vertices); _colorMapRenderTarget = new RenderTarget2D(Renderer.GD, GeneralManager.ScreenX, GeneralManager.ScreenY); _normalMapRenderTarget = new RenderTarget2D(Renderer.GD, GeneralManager.ScreenX, GeneralManager.ScreenY); _shadowMapRenderTarget = new RenderTarget2D(Renderer.GD, GeneralManager.ScreenX, GeneralManager.ScreenY, false, format, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); _lightEffect = GeneralManager.Content.Load <Effect>("Effects/MultiTarget"); _lightCombinedEffect = GeneralManager.Content.Load <Effect>("Effects/DeferredCombined"); // Point light technique _lightEffectTechniquePointLight = _lightEffect.Techniques["DeferredPointLight"]; // Spot light technique _lightEffectTechniqueSpotLight = _lightEffect.Techniques["DeferredSpotLight"]; // Shared light properties _lightEffectParameterLightColor = _lightEffect.Parameters["lightColor"]; _lightEffectParameterLightDecay = _lightEffect.Parameters["lightDecay"]; _lightEffectParameterNormapMap = _lightEffect.Parameters["NormalMap"]; _lightEffectParameterPosition = _lightEffect.Parameters["lightPosition"]; _lightEffectParameterScreenHeight = _lightEffect.Parameters["screenHeight"]; _lightEffectParameterScreenWidth = _lightEffect.Parameters["screenWidth"]; _lightEffectParameterStrength = _lightEffect.Parameters["lightStrength"]; // Spot light parameters _lightEffectParameterConeDirection = _lightEffect.Parameters["coneDirection"]; _lightEffectParameterConeAngle = _lightEffect.Parameters["coneAngle"]; _lightEffectParameterConeDecay = _lightEffect.Parameters["coneDecay"]; _lightCombinedEffectTechnique = _lightCombinedEffect.Techniques["DeferredCombined2"]; _lightCombinedEffectParamAmbient = _lightCombinedEffect.Parameters["ambient"]; _lightCombinedEffectParamLightAmbient = _lightCombinedEffect.Parameters["lightAmbient"]; _lightCombinedEffectParamAmbientColor = _lightCombinedEffect.Parameters["ambientColor"]; _lightCombinedEffectParamColorMap = _lightCombinedEffect.Parameters["ColorMap"]; _lightCombinedEffectParamShadowMap = _lightCombinedEffect.Parameters["ShadingMap"]; _lightCombinedEffectParamNormalMap = _lightCombinedEffect.Parameters["NormalMap"]; SB = new SpriteBatch(Renderer.GD); Normals = new Dictionary <float, List <NormalMap> >(); }
/* public Sprite(SpriteAnimation animation, Vector2 position) { Initialize(); // Load the Sprite texture Animation = animation; Active = true; // Set the position of the enemy Position = position; } */ public Sprite(Texture2D texture, Vector2 position, KryptonEngine krypton) { Initialize(); Active = true; Position = position; Texture = texture; this.krypton = krypton; findShadowHull(Texture); }
public Game1() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferHeight = Settings.Screensize.Y; graphics.PreferredBackBufferWidth = Settings.Screensize.X; //graphics.IsFullScreen = true; Content.RootDirectory = "Content"; this.krypton = new KryptonEngine(this, "KryptonEffect"); }
public Game1() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferHeight = (int)Globals.Screensize.Y; graphics.PreferredBackBufferWidth = (int)Globals.Screensize.X; //graphics.IsFullScreen = true; Content.RootDirectory = "Content"; krypton = new KryptonEngine(this, ".\\krypton stuff\\KryptonEffect"); TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 16); IsFixedTimeStep = true; }
/// <summary> /// Prepares the light map to be drawn (pre-render) /// </summary> public void LightMapPrepare() { // Prepare and set the matrix var viewWidth = this.GraphicsDevice.ScissorRectangle.Width; var viewHeight = this.GraphicsDevice.ScissorRectangle.Height; // Prepare the matrix with optional settings and assign it to an effect parameter Matrix lightMapMatrix = this.LightmapMatrixGet(); this.mEffect.Parameters["Matrix"].SetValue(lightMapMatrix); // Obtain the original rendering states var originalRenderTargets = this.GraphicsDevice.GetRenderTargets(); // Set and clear the target this.GraphicsDevice.SetRenderTarget(this.mMap); this.GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.Stencil, this.mAmbientColor, 0, 1); // Make sure we're culling the right way! this.GraphicsDevice.RasterizerState = KryptonEngine.RasterizerStateGetFromCullMode(this.mCullMode); // put the render target's size into a more friendly format var targetSize = new Vector2(this.mMap.Width, this.mMap.Height); // Render Light Maps foreach (var light in this.mLights) { // Loop through each light within the view frustum if (light.Bounds.Intersects(this.mBounds)) { // Clear the stencil and set the scissor rect (because we're stretching geometry past the light's reach) this.GraphicsDevice.Clear(ClearOptions.Stencil, Color.Black, 0, 1); this.GraphicsDevice.ScissorRectangle = KryptonEngine.ScissorRectCreateForLight(light, lightMapMatrix, targetSize); // Draw the light! light.Draw(this.RenderHelper, this.mHulls); } } if (this.mBluriness > 0) { // Blur the shadow map horizontally to the blur target this.GraphicsDevice.SetRenderTarget(this.mMapBlur); this.RenderHelper.BlurTextureToTarget(this.mMap, LightMapSize.Full, BlurTechnique.Horizontal, this.mBluriness); // Blur the shadow map vertically back to the final map this.GraphicsDevice.SetRenderTarget(this.mMap); this.RenderHelper.BlurTextureToTarget(this.mMapBlur, LightMapSize.Full, BlurTechnique.Vertical, this.mBluriness); } // Reset to the original rendering states this.GraphicsDevice.SetRenderTargets(originalRenderTargets); }
public LightingComponent(LightingMode lightingMode = LightingMode.Knockout, LightMapSize mLightMapSize = LightMapSize.Full, int mBluriness = 0) { mLight = new KryptonEngine(MilkShake.Game, "KryptonEffect"); mLight.Initialize(); // [Settings] mLight.LightMapSize = mLightMapSize; mLight.Bluriness = mBluriness; mLightingMode = lightingMode; mRenderTarget = new RenderTarget2D(MilkShake.Graphics, Globals.ScreenWidth, Globals.ScreenHeight); }
public virtual void LoadContent(World world, string AssetName, Vector2 position, float Scale, KryptonEngine krypton) { base.LoadContent(world, AssetName, position, Scale); light = new Krypton.Lights.Light2D() { Texture = Krypton.LightTextureBuilder.CreatePointLight(Game.GraphicsDevice, 512), Range = ConvertUnits.ToSimUnits(500), Intensity = float.MaxValue, Position = Vector2.Zero, }; krypton.Lights.Add(light); }
public Platform(Rectangle platformBounds,TileCollision collision, Boolean isShadowCaster, KryptonEngine krypton) { this.krypton = krypton; Collision = collision; IsShadowCaster = isShadowCaster; Bounds = platformBounds; if (isShadowCaster) { ShadowHull shadowHull = ShadowHull.CreateRectangle(new Vector2(platformBounds.Width, platformBounds.Height)); shadowHull.Position.X = platformBounds.X + platformBounds.Width/2; shadowHull.Position.Y = platformBounds.Y + platformBounds.Height/2; krypton.Hulls.Add(shadowHull); } }
public KryptonDemoGame() { // Setup the graphics device manager with some default settings Graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = 1280, PreferredBackBufferHeight = 720 }; // Allow the window to be resized (to demonstrate render target recreation) Window.AllowUserResizing = true; // Setup the content manager with some default settings Content.RootDirectory = "Content"; // Create Krypton krypton = new KryptonEngine(this, "KryptonEffect"); }
public GameWorld(Game game, string name) { world = new World(9.8f * Vector2.UnitY); lighting = new KryptonEngine(game, "KryptonEffect"); lighting.Initialize(); tiles = new List<Tile>(); collisionMap = new List<StaticBody>(); objects = new List<PhysicsObject>(); Load(game, name); camera = new Camera(Vector2.Zero, size); player = new MrGuy(world, 100, 200, MainGame.texPlayer); }
public LightingComponent(Scene mScene, LightMapSize mLightMapSize = LightMapSize.Full, int mBluriness = 0) : base(mScene) { mLight = new KryptonEngine(MilkShake.Game, "KryptonEffect"); mLight.Initialize(); // [Settings] mLight.LightMapSize = mLightMapSize; mLight.Bluriness = mBluriness; // [Events] Scene.Listener.PreDraw[DrawLayer.First] += new DrawEvent(PreDraw); Scene.Listener.PostDraw[DrawLayer.Fourth] += new DrawEvent(PostDraw); }
public LightRenderer( ) { _game = ObjectFactory.GetInstance<IGame>( ) ; var content = new ResourceContentManager( ( (Game) _game ).Services, Resource1.ResourceManager ) ; var effect = content.Load<Effect>( @"KryptonEffect" ) ; _krypton=new KryptonEngine( (Game) _game, effect ); _krypton.Initialize( ); IoC.Model.ItemsAddedOrRemoved += ( s, e ) => rebuild( ) ; IoC.Model.ItemChanged += ( s, e ) => rebuild( ) ; IoC.Model.NewModelLoaded += ( s, e ) => rebuild( ) ; }
public Lighting(Engine engine) : base(engine) { Krypton = new KryptonEngine(engine, @"Krypton\KryptonEffect"); Krypton.Bluriness = 3; Krypton.CullMode = CullMode.None; Krypton.Matrix = Engine.Camera.CameraMatrix; Krypton.SpriteBatchCompatablityEnabled = true; PointLightTexture = LightTextureBuilder.CreatePointLight(Engine.Video.GraphicsDevice, 512); this.DrawOrder = (int)Global.Layers.Lighting; engine.AddComponent(this); }
/// <summary> /// Gets a pixel-space rectangle which contains the light passed in /// </summary> /// <param name="light">The light used to create the rectangle</param> /// <param name="matrix">the WorldViewProjection matrix being used to render</param> /// <param name="targetSize">The rendertarget's size</param> /// <returns></returns> private static Rectangle ScissorRectCreateForLight(ILight2D light, Microsoft.Xna.Framework.Matrix matrix, Vector2 targetSize) { // This needs refining, but it works as is (I believe) var lightBounds = light.Bounds; var min = KryptonEngine.VectorToPixel(lightBounds.Min, matrix, targetSize); var max = KryptonEngine.VectorToPixel(lightBounds.Max, matrix, targetSize); var min2 = Vector2.Min(min, max); var max2 = Vector2.Max(min, max); min = Vector2.Clamp(min2, Vector2.Zero, targetSize); max = Vector2.Clamp(max2, Vector2.Zero, targetSize); return(new Rectangle((int)(min.X), (int)(min.Y), (int)(max.X - min.X), (int)(max.Y - min.Y))); }
public HauntedHouse() { // Setup the graphics device manager with some default settings this.graphics = new GraphicsDeviceManager(this); this.graphics.PreferredBackBufferWidth = 1280; this.graphics.PreferredBackBufferHeight = 720; // Allow the window to be resized (to demonstrate render target recreation) this.Window.AllowUserResizing = true; // Setup the content manager with some default settings this.Content.RootDirectory = "Content"; // Create Krypton this.krypton = new KryptonEngine(this, "KryptonEffect"); map = new Map(); }
public Game1() { graphics = new GraphicsDeviceManager(this); //Sets the programs screen size this.graphics.PreferredBackBufferWidth = 1660; this.graphics.PreferredBackBufferHeight = 940; this.Window.AllowUserResizing = true; //Create Krypton this.krypton = new KryptonEngine(this, "KryptonEffect"); krypton.AmbientColor = Color.Black; this.krypton.CullMode = CullMode.None; this.krypton.Bluriness = 6f; //This will set the program to full screen mode //this.graphics.IsFullScreen = true; Content.RootDirectory = "Content"; }
public GameWorld(Vector2 playerPos, Game game, string name) { world = new World(9.8f * Vector2.UnitY); globalLighting = new KryptonEngine(game, "KryptonEffect"); globalLighting.Initialize(); tiles = new List<Tile>(); collisionMap = new List<StaticBody>(); objects = new List<GameObject>(); triggers = new List<Trigger>(); toAdd = new List<GameObject>(); Load(game, name); player = new PlayerGuy(world, playerPos.X, playerPos.Y, MainGame.texPlayer); objects.Add(player); // Player will have an index of -1 camera = new Camera(player.Position, size, 15f, this.player); }
public KryptonDemoGame() { // Setup the graphics device manager with some default settings this.graphics = new GraphicsDeviceManager(this); this.graphics.PreferredBackBufferWidth = 1280; this.graphics.PreferredBackBufferHeight = 720; // Allow the window to be resized (to demonstrate render target recreation) this.Window.AllowUserResizing = true; // Setup the content manager with some default settings this.Content.RootDirectory = "Content"; // Create Krypton this.krypton = new KryptonEngine(this, "KryptonEffect"); // As a side note, you may want Krypton to be used as a GameComponent. // To do this, you would simply add the following line of code and remove the Initialize and Draw function of krypton below: // this.Components.Add(this.krypton); }
// Make sure this is called for each StaticBody after loading level data public void CreateBody(World w, KryptonEngine lightEngine) { Vertices vs = new Vertices(); Vector2[] points = new Vector2[this.vertices.Count]; for (int i = 0; i < vertices.Count; i++) { vs.Add(vertices[i] * MainGame.PIXEL_TO_METER); points[i] = vertices[i]; } List<Vertices> list = FarseerPhysics.Common.Decomposition.EarclipDecomposer.ConvexPartition(vs); poly = BodyFactory.CreateCompoundPolygon(w, list, 1.0f); poly.BodyType = BodyType.Static; foreach (Vertices v in list) { Vector2[] p = new Vector2[v.Count]; for (int i = 0; i < p.Length; i++) p[i] = v[p.Length - i - 1] * MainGame.METER_TO_PIXEL; lightEngine.Hulls.Add(ShadowHull.CreateConvex(ref p)); } }
public Player(Game game, Character character, Camera2D cam, KryptonEngine krypton) { this.game = game; this.krypton = krypton; this.character = character; this.creature = new WheeledCreature(game); userInterface = new UserInterface(game); this.cam = cam; userInput = new UserInput(this); wards = new List<Ward>(); light = new Krypton.Lights.Light2D() { Texture = Krypton.LightTextureBuilder.CreatePointLight(this.game.GraphicsDevice, 512), Range = ConvertUnits.ToSimUnits(1200), Intensity = float.MaxValue, Position = Vector2.Zero, }; krypton.Lights.Add(light); }
int Time = 21000; // Hour * 1000 #endregion Fields #region Constructors //==================================== //========== INITALIZING ============= //==================================== public GameWorld(WorldScreen WorldScreen) { LightSystem = new KryptonEngine(GeneralManager.Game, "Effects/KryptonEffect"); LightSystem.Initialize(); SetLightColorPath(); Chunks = new Dictionary<Vector2, Chunk>(); Entities = new List<Entity>(); Generator = new WorldGenerator(this); ParentScreen = WorldScreen; PhysicalWorld = new World(new Vector2(0, 16 * 9.81f)); InitLightSystem(); TestPlayer = new Player(this, true); SetBlock(new Vector2(4, 4), new TileEntities.TorchTE(this, new Vector2(128, 128))); SetBlock(new Vector2(4, 3), new TileEntities.TreeTE(this, new Vector2(128, 96))); Entities.Add(new DynamicBody(this, new CircleShape(10.5f, 0.5f), new Vector2(95, 100), "Textures/DynamicBodies/Barrel1")); Debug.WriteLine("World Initialized"); }
public virtual void LoadContent(World world, KryptonEngine krypton) { Ward ward = new Ward(game); ward.LoadContent(world, "Cursor", new Vector2(20,0), 2, krypton); ward.Initialize(); ward.team = creature.team; wards.Add(ward); creature.LoadContent(world, character.name, new Vector2(500, 0), 0.5f); creature.isPlayer = true; character.LoadContent(world, game); userInterface.LoadContent(world, game); userInput.LoadContent(world); }
/// <summary> /// Prepares the light map to be drawn (pre-render) /// </summary> public void LightMapPrepare() { // Prepare the matrix with optional settings and assign it to an effect parameter Matrix lightMapMatrix = LightmapMatrixGet(); _effect.Parameters["Matrix"].SetValue(lightMapMatrix); // Obtain the original rendering states var originalRenderTargets = GraphicsDevice.GetRenderTargets(); // Set and clear the target GraphicsDevice.SetRenderTarget(_map); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.Stencil, AmbientColor, 0, 1); // Make sure we're culling the right way! GraphicsDevice.RasterizerState = KryptonEngine.RasterizerStateGetFromCullMode(CullMode); // put the render target's size into a more friendly format var targetSize = new Vector2(_map.Width, _map.Height); // Render Light Maps foreach (var light in Lights) { // Loop through each light within the view frustum if (!light.Bounds.Intersects(_bounds)) { continue; } // Clear the stencil and set the scissor rect (because we're stretching geometry past the light's reach) GraphicsDevice.Clear( options: ClearOptions.Stencil, color: Color.Black, depth: 0, stencil: 0); GraphicsDevice.ScissorRectangle = ScissorRectCreateForLight( light: light, matrix: lightMapMatrix, targetSize: targetSize); // Draw the light! light.Draw(RenderHelper, Hulls); } if (_bluriness > 0) { // Blur the shadow map horizontally to the blur target GraphicsDevice.SetRenderTarget(_mapBlur); RenderHelper.BlurTextureToTarget( _map, LightMapSize.Full, BlurTechnique.Horizontal, _bluriness); // Blur the shadow map vertically back to the final map GraphicsDevice.SetRenderTarget(_map); RenderHelper.BlurTextureToTarget( _mapBlur, LightMapSize.Full, BlurTechnique.Vertical, _bluriness); } // Reset to the original rendering states GraphicsDevice.SetRenderTargets(originalRenderTargets); }
/// <summary> /// Disposes of render targets /// </summary> private void DisposeRenderTargets() { KryptonEngine.TryDispose(this.mMap); KryptonEngine.TryDispose(this.mMapBlur); }
public override void ReloadServices(Game game) { base.ReloadServices(game); krypton = Game.Services.GetService<KryptonEngine>(); _world = Game.Services.GetService<World>(); }
public static bool IsLit(World world, Vector2 targetPosition, KryptonEngine krypton) { foreach (Krypton.Lights.Light2D light in krypton.Lights) if (WithinRange(targetPosition, light.Position, light.Range) && WithinLineOfSight(world, light.Position, targetPosition)) return true; return false; }
public static bool IsLit(World world, Rectangle targetBox, KryptonEngine krypton) { Vector2 targetPosition; foreach (Krypton.Lights.Light2D light in krypton.Lights) { targetPosition = new Vector2(targetBox.Left, targetBox.Top); if (WithinRange(targetPosition, light.Position, light.Range) && WithinLineOfSight(world, light.Position, targetPosition)) return true; targetPosition = new Vector2(targetBox.Right, targetBox.Top); if (WithinRange(targetPosition, light.Position, light.Range) && WithinLineOfSight(world, light.Position, targetPosition)) return true; targetPosition = new Vector2(targetBox.Left, targetBox.Bottom); if (WithinRange(targetPosition, light.Position, light.Range) && WithinLineOfSight(world, light.Position, targetPosition)) return true; targetPosition = new Vector2(targetBox.Right, targetBox.Bottom); if (WithinRange(targetPosition, light.Position, light.Range) && WithinLineOfSight(world, light.Position, targetPosition)) return true; } return false; }
public LightingEngine() { PresentationParameters pp = Renderer.GD.PresentationParameters; SurfaceFormat format = pp.BackBufferFormat; Krypton = new KryptonEngine(GeneralManager.Game, "Effects/KryptonEffect"); Krypton.Initialize(); Krypton.AmbientColor = Color.Black; Vertices = new VertexPositionColorTexture[4]; Vertices[0] = new VertexPositionColorTexture(new Vector3(-1, 1, 0), Color.White, new Vector2(0, 0)); Vertices[1] = new VertexPositionColorTexture(new Vector3(1, 1, 0), Color.White, new Vector2(1, 0)); Vertices[2] = new VertexPositionColorTexture(new Vector3(-1, -1, 0), Color.White, new Vector2(0, 1)); Vertices[3] = new VertexPositionColorTexture(new Vector3(1, -1, 0), Color.White, new Vector2(1, 1)); VertexBuffer = new VertexBuffer(Renderer.GD, typeof(VertexPositionColorTexture), Vertices.Length, BufferUsage.None); VertexBuffer.SetData(Vertices); _colorMapRenderTarget = new RenderTarget2D(Renderer.GD, GeneralManager.ScreenX, GeneralManager.ScreenY); _normalMapRenderTarget = new RenderTarget2D(Renderer.GD, GeneralManager.ScreenX, GeneralManager.ScreenY); _shadowMapRenderTarget = new RenderTarget2D(Renderer.GD, GeneralManager.ScreenX, GeneralManager.ScreenY, false, format, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); _lightEffect = GeneralManager.Content.Load<Effect>("Effects/MultiTarget"); _lightCombinedEffect = GeneralManager.Content.Load<Effect>("Effects/DeferredCombined"); // Point light technique _lightEffectTechniquePointLight = _lightEffect.Techniques["DeferredPointLight"]; // Spot light technique _lightEffectTechniqueSpotLight = _lightEffect.Techniques["DeferredSpotLight"]; // Shared light properties _lightEffectParameterLightColor = _lightEffect.Parameters["lightColor"]; _lightEffectParameterLightDecay = _lightEffect.Parameters["lightDecay"]; _lightEffectParameterNormapMap = _lightEffect.Parameters["NormalMap"]; _lightEffectParameterPosition = _lightEffect.Parameters["lightPosition"]; _lightEffectParameterScreenHeight = _lightEffect.Parameters["screenHeight"]; _lightEffectParameterScreenWidth = _lightEffect.Parameters["screenWidth"]; _lightEffectParameterStrength = _lightEffect.Parameters["lightStrength"]; // Spot light parameters _lightEffectParameterConeDirection = _lightEffect.Parameters["coneDirection"]; _lightEffectParameterConeAngle = _lightEffect.Parameters["coneAngle"]; _lightEffectParameterConeDecay = _lightEffect.Parameters["coneDecay"]; _lightCombinedEffectTechnique = _lightCombinedEffect.Techniques["DeferredCombined2"]; _lightCombinedEffectParamAmbient = _lightCombinedEffect.Parameters["ambient"]; _lightCombinedEffectParamLightAmbient = _lightCombinedEffect.Parameters["lightAmbient"]; _lightCombinedEffectParamAmbientColor = _lightCombinedEffect.Parameters["ambientColor"]; _lightCombinedEffectParamColorMap = _lightCombinedEffect.Parameters["ColorMap"]; _lightCombinedEffectParamShadowMap = _lightCombinedEffect.Parameters["ShadingMap"]; _lightCombinedEffectParamNormalMap = _lightCombinedEffect.Parameters["NormalMap"]; SB = new SpriteBatch(Renderer.GD); Normals = new Dictionary<float, List<NormalMap>>(); }
public Projectile(Game game, Vector2 spawnpoint ,bool friendly) : base(game,spawnpoint) { Friendly = friendly; Alive = true; krypton = Game.Services.GetService<KryptonEngine>(); _world = Game.Services.GetService<World>(); _soundBank = Game.Services.GetService<SoundBank[]>(); PlayShootSound(); }
public void Intialise(List<Platform> platforms,List<Sprite> sprites,KryptonEngine krypton,ContentManager content,GraphicsDevice graphicsDevice, ScreenDebuger screenDebuger, Level level) { if (EntityType == "Player") { Texture2D playerImage = content.Load<Texture2D>("player"); Sprite testSprite = new Sprite(playerImage, new Vector2(0,0), false, krypton); Player aPlayer = new Player(new Vector2(EntityBounds.X, EntityBounds.Y), testSprite,screenDebuger,content,graphicsDevice,level); level.setPlayer(aPlayer); } if (EntityType == "Hazard") { } if (EntityType == "Platform") { TileCollision tileCollision = TileCollision.Platform; if (Properties["CollisionType"] == "Platform") {tileCollision = TileCollision.Platform;} if (Properties["CollisionType"] == "Passable") { tileCollision = TileCollision.Passable; } if (Properties["CollisionType"] == "Impassable") { tileCollision = TileCollision.Impassable; } Platform platform = new Platform(EntityBounds, tileCollision, Convert.ToBoolean(Properties["IsShadowCaster"]), krypton); platforms.Add(platform); } if (EntityType == "Light") { Color color = new Color(); color.R = (byte)Convert.ToInt32(Properties["R"]); color.G = (byte)Convert.ToInt32(Properties["G"]); color.B = (byte)Convert.ToInt32(Properties["B"]); color.A = 255; /* X = EntityBounds.X, Y = EntityBounds.Y, Range = (float)Convert.ToInt32(Properties["Range"]), Intensity = (float)Convert.ToDouble(Properties["Intensity"]), Color = color, ShadowType = ShadowType.Illuminated, Fov = MathHelper.PiOver2 * (float) (0.5) * */ Light2D light = new Light2D { Texture = LightTextureBuilder.CreatePointLight(graphicsDevice, 1024), X = EntityBounds.X, Y = EntityBounds.Y, Range = (float)Convert.ToInt32(Properties["Range"]), Intensity = (float)Convert.ToDouble(Properties["Intensity"]), Color = color, ShadowType = ShadowType.Illuminated, Fov = MathHelper.PiOver2 * (float)Convert.ToDouble(Properties["Fov"]) }; //Optional Properties if(Properties.ContainsKey("Flicker")){ light.Flicker = (bool)Convert.ToBoolean(Properties["Flicker"]);} krypton.Lights.Add(light); } }