Exemplo n.º 1
0
        /*
         * 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);
        }
Exemplo n.º 2
0
 public Map(Game game, string lightShaderPath)
 {
     if (lightShaderPath != null)
     {
         //create krypton, link to this game, use shaders
         Krypton = new KryptonEngine(game, lightShaderPath);
         this.InitializeMapLight();
     }
 }
Exemplo n.º 3
0
        public PlatformerGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Create Krypton
            this.krypton         = new KryptonEngine(this, "KryptonEffect");
            krypton.AmbientColor = new Color(130, 130, 150);

            Accelerometer.Initialize();
        }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
        protected override void Initialize()
        {
            try
            {
                _spriteBatch = new SpriteBatch(GraphicsDevice);

                Camera          = new Camera2D();
                Camera.Position = new Vector3(500, 500, 0);

                /*   Camera.Initialize();
                 * Camera.FocusPosition = new Vector2(0, 0); ;
                 */
                _pixel = new Texture2D(GraphicsDevice, 1, 1);
                _pixel.SetData <Color>(new Color[] { Color.White });

                _cache = new Dictionary <string, Texture2D>();

                GraphicsDevice.RasterizerState = RasterizerState.CullNone;

                _krypton = new KryptonEngine();
                _krypton.GraphicsDevice = GraphicsDevice;
                _krypton.mEffect        = contentManager.Load <Effect>("KryptonEffect");
                _krypton.Initialize();

                _krypton.LoadContent();

                LightTexture = LightTextureBuilder.CreatePointLight(GraphicsDevice, 1024);
                //_krypton.
                // _krypton.AmbientColor = Color.DarkGreen;
                _krypton.CullMode = CullMode.None;
                _krypton.SpriteBatchCompatablityEnabled = true;

                _lightSymbolTexture   = contentManager.Load <Texture2D>("light_bulb");
                _lightSymbolPixelData = GetPixelData(_lightSymbolTexture);

                _selectionTexture = contentManager.Load <Texture2D>("selection");

                System.Windows.Forms.Application.Idle += delegate { Invalidate(); };

                this.MouseMove  += new System.Windows.Forms.MouseEventHandler(OnMouseMove);
                this.MouseDown  += new System.Windows.Forms.MouseEventHandler(OnMouseDown);
                this.MouseUp    += new System.Windows.Forms.MouseEventHandler(OnMouseUp);
                this.MouseClick += new System.Windows.Forms.MouseEventHandler(MapPanel_MouseClick);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public Game1()
        {
            GraphicsDeviceManager = new GraphicsDeviceManager(this);
            GraphicsDeviceManager.PreferredBackBufferWidth  = PreferredWidth;
            GraphicsDeviceManager.PreferredBackBufferHeight = PreferredHeight;
            GraphicsDeviceManager.IsFullScreen = FullScreen;

            Content.RootDirectory = "Content";

            GameEnvironment.StartServices(this, new ScreenManager(this), null, GraphicsDeviceManager);
            GameEnvironment.ScreenRectangle = new Rectangle(0, 0, PreferredWidth, PreferredHeight);

            KryptonEngine = new KryptonEngine(this, "KryptonEffect");

            Components.Add(new MousePointer(this));
        }
Exemplo n.º 8
0
        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( );
        }
Exemplo n.º 9
0
        public static void CreateLights(Texture2D texture, KryptonEngine krypton, CollisionLayer map)
        {
            //make random lights
            for (int i = 0; i < lightCount; i++)
            {
                if (RandomLightColorOn)
                {
                    byte r = (byte)(rand.Next(randomLightColorRedScale - 64) + 64);
                    byte g = (byte)(rand.Next(randomLightColorGreenScale - 64) + 64);
                    byte b = (byte)(rand.Next(randomLightColorBlueScale - 64) + 64);
                    lightColor = new Color(r, g, b);
                }
                if (RandomLightIntensityOn)
                {
                    lightIntensity = (float)(rand.NextDouble() * randomLightIntensityMin + randomLightIntensityMax);
                }
                Light2D light = new Light2D()
                {
                    Texture   = texture,
                    Range     = (float)(rand.NextDouble() * (randomLightRangeMax - randomLightRangeMin) + randomLightRangeMin),
                    Color     = lightColor,
                    Intensity = lightIntensity,
                    Angle     = MathHelper.TwoPi * (float)rand.NextDouble(),
                    X         = (float)(rand.NextDouble() * map.WidthInPixels),
                    Y         = (float)(rand.NextDouble() * map.HeightInPixels)
                };

                //here we set the light's field of view
                if (i % 2 == 0)
                {
                    if (RandomLightFovOn)
                    {
                        light.Fov = MathHelper.PiOver2 * (float)(rand.NextDouble() * 0.75 + 0.25);
                    }
                    else
                    {
                        light.Fov = lightFov;
                    }
                }

                krypton.Lights.Add(light);
            }
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        public HauntedHouse()
        {
            // Setup the graphics device manager with some default settings
            this.graphics = new GraphicsDeviceManager(this);
            this.graphics.PreferredBackBufferWidth  = 1280;
            this.graphics.PreferredBackBufferHeight = 720;
            //this.graphics.ToggleFullScreen();

            screenDebuger = new ScreenDebuger();

            // 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");
            this.ambiantLight = new KryptonEngine(this, "KryptonEffect");
        }
Exemplo n.º 12
0
        /*
         * 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, bool isShadowCaster, KryptonEngine krypton)
        {
            Active        = true;
            this.position = position;

            Texture = texture;
            Width   = texture.Width;
            Height  = texture.Height;
            Bounds  = texture.Bounds;

            this.krypton = krypton;

            this.isShadowCaster = isShadowCaster;
            if (isShadowCaster)
            {
                hulls = new List <ShadowHull>();
                findShadowHull(Texture);
            }

            sourceRectangle = new Rectangle(0, 0, Width, Height);
        }
Exemplo n.º 13
0
 public Core(int width, int height, bool fullScreen, bool isBorder)
 {
     Settings.LoadSettings(this);
     graphics = new GraphicsDeviceManager(this);
     graphics.SynchronizeWithVerticalRetrace = false;
     IsFixedTimeStep       = true;
     Content.RootDirectory = "Content";
     if (width == 0 || height == 0)
     {
         graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
         graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
         if (graphics.PreferredBackBufferWidth > 1920)
         {
             graphics.PreferredBackBufferWidth = 1920;
         }
         if (graphics.PreferredBackBufferHeight > 1080)
         {
             graphics.PreferredBackBufferHeight = 1080;
         }
     }
     else
     {
         graphics.PreferredBackBufferWidth  = width;
         graphics.PreferredBackBufferHeight = height;
     }
     screenWidth           = graphics.PreferredBackBufferWidth;
     screenHeight          = graphics.PreferredBackBufferHeight;
     graphics.IsFullScreen = fullScreen;
     if (!fullScreen && !isBorder)
     {
         System.Windows.Forms.Form gameForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(Window.Handle);
         gameForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
     }
     Window.Title = "BFSR Client";
     krypton      = new KryptonEngine(this, "shader\\KryptonEffect");
     instance     = this;
 }
Exemplo n.º 14
0
        public void Intialise(KryptonEngine krypton, ContentManager content, GraphicsDevice graphicsDevice, ScreenDebuger screenDebuger, List <Sprite> sprites)
        {
            this.content       = content;
            this.krypton       = krypton;
            this.sprites       = sprites;
            this.screenDebuger = screenDebuger;
            placeHolder        = content.Load <Texture2D>("PlaceHolder");
            interestingLight   = content.Load <Texture2D>("player");
            platforms          = new List <Platform>();

            //Texture2D playerImage = content.Load<Texture2D>("playerDraft");
            //Sprite testSprite = new Sprite(playerImage, new Vector2(0,0), false, krypton);
            //player = new Player(new Vector2(100, 100), testSprite);

            foreach (var layer in TileLayers)
            {
                for (int y = 0; y < layer.Height; y++)
                {
                    for (int x = 0; x < layer.Width; x++)
                    {
                        Tile tile = layer.Tiles[y * layer.Width + x];
                        if (tile.Exists)
                        {
                            tile.Intialise(new Vector2(x, y), content);
                        }
                    }
                }
            }

            foreach (var layer in EntityLayers)
            {
                foreach (Entity entity in layer.Entities)
                {
                    entity.Intialise(platforms, sprites, krypton, content, graphicsDevice, screenDebuger, this);
                }
            }

            // Create a light we can control
            torch = new Light2D()
            {
                Texture    = LightTextureBuilder.CreatePointLight(graphicsDevice, 1024),
                X          = 0,
                Y          = 0,
                Range      = 800,
                Intensity  = 0.6f,
                Color      = Color.White,
                ShadowType = ShadowType.Illuminated,
                Fov        = MathHelper.PiOver2 * (float)(0.3)
            };
            krypton.Lights.Add(torch);

            torchGlow = new Light2D()
            {
                Texture    = LightTextureBuilder.CreatePointLight(graphicsDevice, 1024),
                X          = 0,
                Y          = 0,
                Range      = 700,
                Intensity  = 0.25f,
                Color      = Color.White,
                ShadowType = ShadowType.Solid,
                //Fov = MathHelper.PiOver2 * (float)(0.5)
            };
            krypton.Lights.Add(torchGlow);
        }
Exemplo n.º 15
0
        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);
            }
        }