Пример #1
0
        public Level(GameWindow Window, SpriteBatch spriteBatch, Character player)
        {
            obstacles   = new List <Obstacle>();
            spawnPoints = new List <Vector2>();

            lava = new Lava(Game1.graphics.GraphicsDevice, Window);
            lava.DrawRenderTarget(spriteBatch);

            this.player = player;

            this.perlin = new Perlin();
            this.window = Window;

            InitiateLevel();
        }
Пример #2
0
 public void CheckLavaCollision(Lava lava)
 {
     Color[] pixels  = new Color[shadow.texture.Width * shadow.texture.Height];
     Color[] pixels2 = new Color[shadow.texture.Width * shadow.texture.Height];
     //shadow.texture.GetData<Color>(0, new Rectangle(shadow.position.ToPoint(), new Point(shadow.texture.Width, shadow.texture.Height)), pixels2, 0, pixels2.Length);
     shadow.texture.GetData <Color>(pixels2);
     try{
         lava.renderTarget.GetData(0, new Rectangle(shadow.Position.ToPoint(), new Point(shadow.texture.Width, shadow.texture.Height)), pixels, 0, pixels.Length);
     }  catch (ArgumentException e)
     {
         IntersectingLava = true;
         return;
     }
     for (int i = 0; i < pixels.Length; ++i)
     {
         if (pixels[i].A > 0.0f && pixels2[i].A > 0.0f)
         {
             IntersectingLava = true;
             return;
         }
     }
     IntersectingLava = false;
 }