Esempio n. 1
0
 /// <summary>
 /// Inicializa una nueva instancia de la clase AzulEngine.TileEngine.TileLayer que permite
 /// crear una instancia completa con transparencia, visibilidad, posición, escala, velocidad, independencia de cámara y dirección de movimiento
 /// </summary>
 /// <param name="tileCatalog">Catálogo de baldosas</param>
 /// <param name="tileMap">Mapa de baldosas</param>
 /// <param name="transparency">Transparencia de la capa</param>
 /// <param name="visible">Visibilidad de la capa</param>
 /// <param name="position">Posición de la capa</param>
 /// <param name="zoomScale">Escala inicial de la capa</param>
 /// <param name="velocity">Velocidad de desplazamiento de la capa</param>
 /// <param name="cameraIndependent">Indica si la capa es independiente del movimiento de la cámara</param>
 /// <param name="direction">Dirección de desplazamiento de la capa cuando esta es independiente de la cámara</param>
 public TileLayer(TileCatalog tileCatalog, TileMap tileMap, float transparency, Boolean visible, Vector2 position, Vector2 zoomScale, Vector2 velocity, bool cameraIndependent, LayerMovementDirection direction)
     : base(transparency, visible, position, zoomScale, velocity, cameraIndependent, direction)
 {
     this.TileCatalog = tileCatalog;
     this.TileMap = tileMap;
 }
Esempio n. 2
0
 /// <summary>
 /// Inicializa una nueva instancia de la clase AzulEngine.TileEngine.TileLayer que permite
 /// crear una instancia solo con un cátalogo y un mapa de baldosas
 /// </summary>
 /// <param name="tileCatalog">Cátalogo de baldosas</param>
 /// <param name="tileMap">Mapa de baldosas</param>
 public TileLayer(TileCatalog tileCatalog, TileMap tileMap)
     : this(tileCatalog, tileMap, 1.0f, true, Vector2.Zero, Vector2.One, Vector2.One, false, LayerMovementDirection.None)
 {
 }
Esempio n. 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            camera = new Camera2D(new Vector2(0f, 0f), new Vector2(1f), new Vector2(3f));

            this.Services.AddService(typeof(SpriteBatch), spriteBatch);
            this.Services.AddService(typeof(Camera2D), camera);

            texture1 = this.Content.Load<Texture2D>("tex");
            TileCatalog cat1 = new TileCatalog(texture1, 15, 15);

            Random rand = new Random(DateTime.Now.Millisecond);
            TileMap map1 = new TileMap(100, 100);
            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    map1.SetTile(i, j, new Tile(rand.Next(1, cat1.TilePositions.Count)));
                }
            }

            TileLayer layer1 = new TileLayer(cat1, map1, 0.5f, false, new Vector2(0, 0), new Vector2(1f, 1f), new Vector2(3f), false, LayerMovementDirection.None);

            texture2 = this.Content.Load<Texture2D>("tiles2");

            TileCatalog cat2 = new TileCatalog(texture2, 48, 48);
            TileMap map2 = new TileMap(10, 500);
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 500; j++)
                {
                    map2.SetTile(i, j, new Tile(rand.Next(1, cat2.TilePositions.Count)));
                }
            }
            TileLayer layer2 = new TileLayer(cat2, map2, 1.0f, false, new Vector2(0, 0), new Vector2(1f, 1f), new Vector2(3f), true, LayerMovementDirection.Up);

            scene = new TileScene();
            scene.AddLayer(layer2);
            scene.AddLayer(layer1);

            TileComponent component = new TileComponent(this, scene, baseScreenSize, resultionIndependent);
            this.Components.Add(component);

            TextureLayer tLayer1 = new TextureLayer(this.texture1, 1f, false, new Vector2(20f), Vector2.One, new Vector2(1.5f,1.5f), true, Anchor.LowerRight);
            TextureLayer tLayer2 = new TextureLayer(this.texture2, 0.5f, false, new Vector2(10f), Vector2.One, new Vector2(5f), true, Anchor.LowerLeft);

            TextureScene tScene = new TextureScene();
            tScene.AddLayer(tLayer1);
            tScene.AddLayer(tLayer2);
            TextureComponent tComponent = new TextureComponent(this, tScene, baseScreenSize, resultionIndependent);
            this.Components.Add(tComponent);

            texture1 = this.Content.Load<Texture2D>("megax");
            SpriteCatalog scatalog = new SpriteCatalog(texture1, 36, 42);

            SpriteSequence[] spriteSecuences = new SpriteSequence[2];

            SpriteSequence spriteSecuence1 = new SpriteSequence(7, 0);
            spriteSecuence1.StepTime = 400;
            spriteSecuence1.SetFrame(0,new SpriteFrame(1));
            spriteSecuence1.SetFrame(1, new SpriteFrame(1));
            spriteSecuence1.SetFrame(2, new SpriteFrame(1));
            spriteSecuence1.SetFrame(3, new SpriteFrame(1));
            spriteSecuence1.SetFrame(4, new SpriteFrame(2));
            spriteSecuence1.SetFrame(5, new SpriteFrame(3));
            spriteSecuence1.SetFrame(6, new SpriteFrame(1));
            spriteSecuences[0] = spriteSecuence1;

            SpriteSequence spriteSecuence2 = new SpriteSequence(10, 0);
            spriteSecuence2.StepTime = 90;
            spriteSecuence2.SetFrame(0, new SpriteFrame(5));
            spriteSecuence2.SetFrame(1, new SpriteFrame(6));
            spriteSecuence2.SetFrame(2, new SpriteFrame(7));
            spriteSecuence2.SetFrame(3, new SpriteFrame(8));
            spriteSecuence2.SetFrame(4, new SpriteFrame(9));
            spriteSecuence2.SetFrame(5, new SpriteFrame(10));
            spriteSecuence2.SetFrame(6, new SpriteFrame(11));
            spriteSecuence2.SetFrame(7, new SpriteFrame(12));
            spriteSecuence2.SetFrame(8, new SpriteFrame(13));
            spriteSecuence2.SetFrame(9, new SpriteFrame(14));

            spriteSecuences[1] = spriteSecuence2;

            SpriteLayer spLayer = new SpriteLayer(scatalog, spriteSecuences, 1.0f, true, new Vector2(10f), Vector2.One, Vector2.Zero, SpriteEffects.None, true, Anchor.None);
            spLayer.CurrentSequence = 2;
            SpriteScene spScene = new SpriteScene();
            spScene.AddLayer(spLayer);
            SpriteComponent spComponent = new SpriteComponent(this, spScene, baseScreenSize, resultionIndependent);
            this.Components.Add(spComponent);
        }