예제 #1
0
        public void calculCliffs(Scene scene)
        {
            if( scene.IsLoadedCore( (int) X, (int) Y - 1 ) ) {
                CliffN = (int) Math.Ceiling( Z - scene.GetCore( (int) X, (int) Y - 1 ).Z );
            } else {
                CliffN = (int) Math.Ceiling( Z - 0 );
            }

            if( scene.IsLoadedCore( (int) X, (int) Y + 1 ) ) {
                CliffS = (int) Math.Ceiling( Z - scene.GetCore( (int) X, (int) Y + 1 ).Z );
            } else {
                CliffS = (int) Math.Ceiling( Z - 0 );
            }

            if( scene.IsLoadedCore( (int) X + 1, (int) Y ) ) {
                CliffE = (int) Math.Ceiling( Z - scene.GetCore( (int) X + 1, (int) Y ).Z );
            } else {
                CliffE = (int) Math.Ceiling( Z - 0 );
            }

            if( scene.IsLoadedCore( (int) X - 1, (int) Y ) ) {
                CliffO = (int) Math.Ceiling( Z - scene.GetCore( (int) X - 1, (int) Y ).Z );
            } else {
                CliffO = (int) Math.Ceiling( Z - 0 );
            }
        }
예제 #2
0
 public void Update(Scene scene)
 {
     if (Keyboard.GetState().IsKeyDown(Keys.A))
     {
         ALight light = scene.GetARadomLight();
         light.Position += new Vector3(-1,-1,0);
         light.RegisterCoreInTheLight(scene);
     }
     if (Keyboard.GetState().IsKeyDown(Keys.D))
     {
         ALight light = scene.GetARadomLight();
         light.Position += new Vector3(1, 1, 0);
         light.RegisterCoreInTheLight(scene);
     }
     if (Keyboard.GetState().IsKeyDown(Keys.W))
     {
         ALight light = scene.GetARadomLight();
         light.Position += new Vector3(1, -1, 0);
         light.RegisterCoreInTheLight(scene);
     }
     if (Keyboard.GetState().IsKeyDown(Keys.S))
     {
         ALight light = scene.GetARadomLight();
         light.Position += new Vector3(-1, 1, 0);
         light.RegisterCoreInTheLight(scene);
     }
 }
예제 #3
0
        /**
         * <summary>
         * Verifie si parmis tout ses tiles, certains sont au centre de la camera
         * Ordre de calcul en fonction de l'orientation de la scene pour que le plus proche element de la camera soit selectionné
         * </summary>
         */
        public void CalculCenterEntity(Scene scene)
        {
            for (int x = 0; x < Chunk.CHUNKS_SIZE; x++)
            {
                for (int y = 0; y < Chunk.CHUNKS_SIZE; y++)
                {
                    switch (scene.Orientation)
                    {
                        case Orientation.SE:
                            cores[x, y].checkCenter(scene);
                            break;
                        case Orientation.SO:
                            cores[(Chunk.CHUNKS_SIZE - 1) - x, y].checkCenter(scene);
                            break;
                        case Orientation.NE:
                            cores[x, (Chunk.CHUNKS_SIZE - 1) - y].checkCenter(scene);
                            break;
                        case Orientation.NO:
                            cores[(Chunk.CHUNKS_SIZE - 1) - x, (Chunk.CHUNKS_SIZE - 1) - y].checkCenter(scene);
                            break;
                    }

                }
            }
        }
예제 #4
0
        //retourne le nombre de sprite affiché
        public override int Draw(SpriteBatch spriteBatch, GameTime gameTime, Scene scene)
        {
            Animation anim_to_draw ;
            //if cannot get the animation for the orientation, get the first one
            if (!anims.TryGetValue(scene.Camera.getLookDirectionFromOrientation(Orientation), out anim_to_draw))
            {
                anim_to_draw = anims.Values.First();
            }

            //affiche l'animation
            return anim_to_draw.Draw(spriteBatch, gameTime, this, scene);
        }
예제 #5
0
        public void Initialize(Scene scene)
        {
            //Test Map creation
            scene.Camera.move(new Vector2(-200, -500));

            BasicGenerator generator = new BasicGenerator();
            Map map = generator.BuildSimpleMap();
            text = GameEngine.Instance.Content.Load<Texture2D>(@"spriteSheets\temp_sprite");
            text2 = GameEngine.Instance.Content.Load<Texture2D>(@"spriteSheets\test_rpg");

            initializeChunks(scene);
            initializeLights(scene);
        }
예제 #6
0
 public void ApplyLight(Scene scene)
 {
     if (Active)
     {
         Dictionary<Vector2, SortedList<float, Vector2>> collisionMatrix = LightCache.getCacheForARadius(Radius);
         foreach (DrawableEntity ent in listCoreInTheLight)
         {
             if (ent.Z > Position.Z)
             {
                 //hide below blocks when it is taller
                 switch(scene.Orientation) {
                     case Orientation.SO :
                         if (ent.Y - ent.X > Position.Y - Position.X) continue;
                         break;
                     case Orientation.NE:
                         if (ent.Y - ent.X < Position.Y - Position.X) continue;
                         break;
                     case Orientation.SE:
                         if (ent.Y + ent.X > Position.Y + Position.X) continue;
                         break;
                     case Orientation.NO:
                         if (ent.Y + ent.X < Position.Y + Position.X) continue;
                         break;
                 }
             }
             Vector2 relativePositionTarget = new Vector2(Position.X - ent.X, Position.Y - ent.Y);
             SortedList<float, Vector2> collisionTileMatrix ;
             collisionMatrix.TryGetValue(relativePositionTarget,out collisionTileMatrix) ;
             if (collisionTileMatrix != null)
             {
                 bool show = true;
                 foreach (KeyValuePair<float, Vector2> kvp in collisionTileMatrix)
                 {
                     if (relativePositionTarget.Length() < kvp.Value.Length()) break;
                     if (scene.IsLoadedCore((int)Position.X - (int)kvp.Value.X, (int)Position.Y - (int)kvp.Value.Y))
                     {
                         if (scene.GetCore((int)Position.X - (int)kvp.Value.X, (int)Position.Y - (int)kvp.Value.Y).Z > Position.Z)
                         {
                             show = false;
                         }
                     }
                 }
                 if (show)
                 {
                     addLightToAnEntity(ent);
                 }
             }
         }
     }
 }
예제 #7
0
        public int Draw( SpriteBatch spriteBatch, GameTime gameTime, DrawableEntity ent, Scene scene )
        {
            Frame frame = getCurrentFrame( gameTime );

            spriteBatch.Draw(
                spriteSheet,
                ent.ScreenRect,
                getCurrentFrame( gameTime ).Zone,
                ent.SumColorLight,
                ent.Rotation,
                scene.Camera.Position,
                spriteEffect,
                ent.Layer
                );

            return 1;
        }
예제 #8
0
 public void AddLight(ALight light, Scene scene)
 {
     lights.Add(light);
     light.RegisterCoreInTheLight(scene);
     LightCache.setCache(light.Radius);
 }
예제 #9
0
 public Camera(Scene scene, int coeff = 1)
 {
     cameraFillScreen();
     this.scene = scene ;
     coefficient = coeff;
 }
예제 #10
0
        private void initializeChunks(Scene scene)
        {
            #region Chunk 0,0
            ChunkProxy testChunk = new ChunkProxy(0, 0);
            int chunk_y = 0;
            Random rand = new Random();
            while (chunk_y < Chunk.CHUNKS_SIZE)
            {
                int chunk_x = 0;
                while (chunk_x < Chunk.CHUNKS_SIZE)
                {
                    int chunk_z = 0;
                    if (rand.Next(100) > 97)
                    {
                        chunk_z = 1;
                    }
                    if (rand.Next(100) > 99)
                    {
                        chunk_z = 4;
                    }
                    CoreProxy core = new CoreProxy(new Vector3(chunk_x, chunk_y, chunk_z), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 32, 32, 16), SpriteEffects.None);
                    core[Orientation.BR] = new SpriteArea(new Rectangle(96, 32, 32, 16), SpriteEffects.FlipHorizontally);
                    core[Orientation.TR] = new SpriteArea(new Rectangle(96, 32, 32, 16), SpriteEffects.None);
                    core[Orientation.TL] = new SpriteArea(new Rectangle(96, 32, 32, 16), SpriteEffects.FlipHorizontally);

                    testChunk[chunk_x, chunk_y] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;

                    //animated sprite
                    if ((chunk_x == Chunk.CHUNKS_SIZE - 1) && (chunk_y == Chunk.CHUNKS_SIZE - 1))
                    {
                        AnimatedEntity animated_entity = new AnimatedEntity(
                            new Vector3(chunk_x, chunk_y, chunk_z),
                            32, 32, new Vector2(16, 27),
                            text, new Color(0, 0, 0, 1), Orientation.S);

                        animated_entity[Orientation.BR] = new Animation(text, SpriteEffects.FlipHorizontally);
                        animated_entity[Orientation.BR].addFrame(new Rectangle(32, 0, 32, 32), 500);
                        animated_entity[Orientation.BR].addFrame(new Rectangle(96, 0, 32, 32), 500);
                        animated_entity[Orientation.BR].addFrame(new Rectangle(32, 0, 32, 32), 500);
                        animated_entity[Orientation.BR].addFrame(new Rectangle(64, 0, 32, 32), 500);

                        animated_entity[Orientation.BL] = new Animation(text);
                        animated_entity[Orientation.BL].addFrame(new Rectangle(32, 0, 32, 32), 500);
                        animated_entity[Orientation.BL].addFrame(new Rectangle(96, 0, 32, 32), 500);
                        animated_entity[Orientation.BL].addFrame(new Rectangle(32, 0, 32, 32), 500);
                        animated_entity[Orientation.BL].addFrame(new Rectangle(64, 0, 32, 32), 500)
                            ;
                        animated_entity[Orientation.TR] = new Animation(text);
                        animated_entity[Orientation.TR].addFrame(new Rectangle(128, 0, 32, 32), 500);
                        animated_entity[Orientation.TR].addFrame(new Rectangle(192, 0, 32, 32), 500);
                        animated_entity[Orientation.TR].addFrame(new Rectangle(128, 0, 32, 32), 500);
                        animated_entity[Orientation.TR].addFrame(new Rectangle(160, 0, 32, 32), 500);

                        animated_entity[Orientation.TL] = new Animation(text, SpriteEffects.FlipHorizontally);
                        animated_entity[Orientation.TL].addFrame(new Rectangle(128, 0, 32, 32), 500);
                        animated_entity[Orientation.TL].addFrame(new Rectangle(192, 0, 32, 32), 500);
                        animated_entity[Orientation.TL].addFrame(new Rectangle(128, 0, 32, 32), 500);
                        animated_entity[Orientation.TL].addFrame(new Rectangle(160, 0, 32, 32), 500);

                        core.addEntity(animated_entity);
                        scene.CalculPositionsEntitiesHandler += animated_entity.calculateScreenRect;
                    }

                    //fontain
                    if ((chunk_x == 0) && (chunk_y == 0))
                    {

                        DrawableEntity testFontain = new DrawableEntity(
                            new Vector3(chunk_x, chunk_y, chunk_z), 27, 34,
                            new Vector2(13, 31), text2,
                            new Color(0, 0, 0, 1), Orientation.S
                        );
                        testFontain[Orientation.BL] = new SpriteArea(new Rectangle(344, 714, 27, 34), SpriteEffects.None);

                        core.addEntity(testFontain);
                        scene.CalculPositionsEntitiesHandler += testFontain.calculateScreenRect;

                        DrawableEntity testContainable = new DrawableEntity(
                            new Vector3(chunk_x, chunk_y, chunk_z + (float)2f), 32, 32,
                            new Vector2(16, 24), text2,
                            new Color(0, 0, 0, 1), Orientation.S
                        );
                        testContainable[Orientation.BL] = new SpriteArea(new Rectangle(205, 136, 32, 32), SpriteEffects.None);
                        core.addEntity(testContainable);
                        scene.CalculPositionsEntitiesHandler += testContainable.calculateScreenRect;
                    }

                    //dwarfs
                    else if (((chunk_x % 4) == 0) && ((chunk_y % 5) == 0))
                    {

                        /***
                            * color is hijack, it contain refill color (magenta and cyan) + light and light intensity
                            * offset colors are listed in shader (0-4 : hair, 5-14 : clothes, 15-255 free)
                            * */
                        Color hijack_color = new Color(
                            0,
                            0,
                            0,
                            (int)rand.Next(5, 13)
                        );

                        //body
                        DrawableEntity testGuysBody = new DrawableEntity(
                            new Vector3(chunk_x, chunk_y, chunk_z), 32, 32,
                            new Vector2(16, 27), text,
                            hijack_color, Orientation.S
                        );

                        testGuysBody[Orientation.BL] = new SpriteArea(new Rectangle(128, 32, 32, 32), SpriteEffects.None);
                        testGuysBody[Orientation.BR] = new SpriteArea(new Rectangle(128, 32, 32, 32), SpriteEffects.FlipHorizontally);
                        core.addEntity(testGuysBody);
                        scene.CalculPositionsEntitiesHandler += testGuysBody.calculateScreenRect;

                        hijack_color = new Color(
                            0,
                            0,
                            0,
                            (int)rand.Next(0, 4)
                        );
                        DrawableEntity testGuysHead = new DrawableEntity(
                            new Vector3(chunk_x, chunk_y, chunk_z), 32, 32,
                            new Vector2(16, (chunk_y % 2 == 0) ? 27 : 30), text,
                            hijack_color, Orientation.S
                        );

                        //head
                        testGuysHead[Orientation.BL] = new SpriteArea(new Rectangle((chunk_y % 2 == 0) ? 128 : 160, 64, 32, 32), SpriteEffects.None);
                        testGuysHead[Orientation.BR] = new SpriteArea(new Rectangle((chunk_y % 2 == 0) ? 128 : 160, 64, 32, 32), SpriteEffects.FlipHorizontally);
                        core.addEntity(testGuysHead);
                        scene.CalculPositionsEntitiesHandler += testGuysHead.calculateScreenRect;

                        chunk_z = 0;
                    }
                    chunk_x++;
                }
                chunk_y++;
            }
            scene.Chunks[0] = new SortedList<int, ChunkProxy>();
            scene.Chunks[0][0] = testChunk;
            #endregion

            //calcul position and center
            scene.CalculPositionsEntitiesHandler(scene);
            scene.CalculCenterEntity();

            //calcul du cliff
            scene.Chunks[0][0].calculCliffs(scene);
        }
예제 #11
0
        /**
         * <summary>Ordre d'affichage en fonction de l'orientation de la scene</summary>
         */
        public int Draw(SpriteBatch sb, GameTime gameTime, Scene scene)
        {
            int count_sprite = 0;
            for (int x = 0; x < Chunk.CHUNKS_SIZE; x++)
            {
                for (int y = 0; y < Chunk.CHUNKS_SIZE; y++)
                {
                    switch (scene.Orientation)
                    {
                        case Orientation.SE:
                            count_sprite += cores[x, y].Draw(sb, gameTime, scene);
                            break;
                        case Orientation.SO:
                            count_sprite += cores[(Chunk.CHUNKS_SIZE - 1) - x, y].Draw(sb, gameTime, scene);
                            break;
                        case Orientation.NE:
                            count_sprite += cores[x, (Chunk.CHUNKS_SIZE - 1) - y].Draw(sb, gameTime, scene);
                            break;
                        case Orientation.NO:
                            count_sprite += cores[(Chunk.CHUNKS_SIZE - 1) - x, (Chunk.CHUNKS_SIZE - 1) - y].Draw(sb, gameTime, scene);
                            break;
                    }
                }
            }

            return count_sprite;
        }
예제 #12
0
 /**
  * <summary>
  * Calcul le cliff a afficher pour tous les tiles
  * </summary>
  */
 public void calculCliffs(Scene scene)
 {
     for (int x = 0; x < Chunk.CHUNKS_SIZE; x++)
     {
         for (int y = 0; y < Chunk.CHUNKS_SIZE; y++)
         {
             cores[x, y].calculCliffs(scene);
         }
     }
 }
예제 #13
0
        public override int Draw( SpriteBatch spriteBatch, GameTime gameTime, Scene scene )
        {
            int count_sprite = 0;
            //TODO ? : Do not show hidden part
            int cliffToDraw = Math.Max( Math.Max( CliffS, CliffO ), Math.Max( CliffE, CliffN ) );
            for( int i = cliffToDraw ; i > 0 ; i-- ) {
                spriteBatch.Draw(
                    SpriteSheet,
                    new Rectangle(
                        ScreenRect.X,
                        ScreenRect.Y + (int) ( ( i - 1 ) * 16 * scene.Camera.Coefficient ),
                        (int) ( 32 * scene.Camera.Coefficient ),
                        (int) ( 32 * scene.Camera.Coefficient )
                    ),
                    new Rectangle( 192, 64, 32, 32 ),
                    SumColorLight,
                    0f,
                    scene.Camera.Position,
                    SpriteEffects.None,
                    0.000001f
                );
                count_sprite++;
            }

            count_sprite += base.Draw( spriteBatch, gameTime, scene );

            //draw owned entities
            foreach( DrawableEntity ent in entities ) {
                ent.Color = new Color(SumColorLight.R, SumColorLight.G, SumColorLight.B, ent.SumColorLight.A);
                count_sprite += ent.Draw( spriteBatch, gameTime, scene );
                ent.SumColorLight = ent.Color;
            }

            //return sprite number
            return count_sprite;
        }
예제 #14
0
 public override void checkCenter(Scene scene)
 {
     base.checkCenter(scene);
     foreach( DrawableEntity ent in entities ) {
         ent.checkCenter(scene);
     }
 }
예제 #15
0
 public Camera(float X, float Y, Scene scene, int coeff = 1)
     : this(scene, coeff)
 {
     Position = new Vector2(X, Y);
 }
예제 #16
0
 public void ApplyLights(Scene scene)
 {
     foreach(ALight light in lights) {
         light.ApplyLight(scene);
     }
 }
예제 #17
0
 public List<DrawableEntity> RegisterCoreInTheLight(Scene scene)
 {
     listCoreInTheLight.Clear();
     for (float i = Position.X - Radius; i < Position.X + Radius;i++ )
     {
         for (float j = Position.Y - Radius; j < Position.Y + Radius; j++)
         {
             if (scene.IsLoadedCore((int)Math.Ceiling(i), (int)Math.Ceiling(j)))
             {
                 CoreProxy core = scene.GetCore((int)Math.Ceiling(i), (int)Math.Ceiling(j));
                 float distance_to_core = Vector2.Subtract(new Vector2(core.X, core.Y), new Vector2(Position.X, Position.Y)).Length();
                 if (distance_to_core <= Radius)
                 {
                     listCoreInTheLight.Add(core);
                 }
             }
         }
     }
     return listCoreInTheLight;
 }
예제 #18
0
 public void AddScene( SceneList sceneIdentifier, Scene scene )
 {
     scenes.Add(sceneIdentifier, scene);
 }
예제 #19
0
 private void initializeLights(Scene scene)
 {
     //light
     FixedLight test_light4 = new FixedLight(14, new Vector3(14, 14, 0), new Color(200,122,50));
     FixedLight test_light5 = new FixedLight(10, new Vector3(10, 21, 0), Color.Yellow);
     FixedLight test_light6 = new FixedLight(10, new Vector3(21, 10, 0), Color.Blue);
     scene.AddLight(test_light4);
     //scene.AddLight(test_light5);
     //scene.AddLight(test_light6);
 }
예제 #20
0
 /**
  * <summary>
  * Calcul la position du Tile a l'écran en fonction de l'orientation.
  * Note : la camera s'applique lors du rendu
  * </summary>
  */
 public void calculateScreenRect(Scene scene)
 {
     switch (scene.Orientation)
     {
         //Calcul pour SE
         case Orientation.SE :
             screenRect.X = (int)((X * 16 - Y * 16 - centerSprite.X) * scene.Camera.Coefficient);
             screenRect.Y = (int)((X * 8 + Y * 8 - Z * 16 - centerSprite.Y) * scene.Camera.Coefficient);
             screenRect.Width = (int)(Width * scene.Camera.Coefficient);
             screenRect.Height = (int)(Height * scene.Camera.Coefficient);
             break;
         //Calcul pour SO
         case Orientation.SO:
             screenRect.X = (int)((X * 16 + Y * 16 - centerSprite.X) * scene.Camera.Coefficient);
             screenRect.Y = (int)((Y * 8 - X * 8 - Z * 16 - centerSprite.Y) * scene.Camera.Coefficient);
             screenRect.Width = (int)(Width * scene.Camera.Coefficient);
             screenRect.Height = (int)(Height * scene.Camera.Coefficient);
             break;
         //Calcul pour NO
         case Orientation.NO:
             screenRect.X = (int)((Y * 16 - X * 16 - centerSprite.X) * scene.Camera.Coefficient);
             screenRect.Y = (int)((-1 * Y * 8 - X * 8 - Z * 16 - centerSprite.Y) * scene.Camera.Coefficient);
             screenRect.Width = (int)(Width * scene.Camera.Coefficient);
             screenRect.Height = (int)(Height * scene.Camera.Coefficient);
             break;
         //Calcul pour NE
         case Orientation.NE:
             screenRect.X = (int)((-1 * X * 16 - Y * 16 - centerSprite.X) * scene.Camera.Coefficient);
             screenRect.Y = (int)((X * 8 - Y * 8 - Z * 16 - centerSprite.Y) * scene.Camera.Coefficient);
             screenRect.Width = (int)(Width * scene.Camera.Coefficient);
             screenRect.Height = (int)(Height * scene.Camera.Coefficient);
             break;
     }
 }
예제 #21
0
 public void Draw(Scene scene)
 {
 }
예제 #22
0
 /**
  * <summary>
  * Verifie si le DrawEntity est au centre de l'écran, si oui le stock dans Scene.getInstance().CenterEntity
  * </summary>
  */
 public virtual void checkCenter(Scene scene)
 {
     if (ScreenRect.X > (scene.Camera.Width / 2 + scene.Camera.Position.X - Width / 2) * scene.Camera.Coefficient)
     {
         if (ScreenRect.X < (scene.Camera.Width / 2 + scene.Camera.Position.X + Width / 2) * scene.Camera.Coefficient)
         {
             if (ScreenRect.Y > (scene.Camera.Height / 2 + scene.Camera.Position.Y - Height / 2) * scene.Camera.Coefficient)
             {
                 if (ScreenRect.Y < (scene.Camera.Height / 2 + scene.Camera.Position.Y + Height / 2) * scene.Camera.Coefficient)
                 {
                     scene.CenterEntity = this;
                 }
             }
         }
     }
 }
예제 #23
0
 private void initializeLights(Scene scene)
 {
     //light
     FixedLight test_light4 = new FixedLight(8, new Vector3(20, 20, 30), Color.Red);
     scene.AddLight(test_light4);
     FixedLight test_light2 = new FixedLight(14, new Vector3(20, 10, 30), Color.Blue);
     scene.AddLight(test_light2);
     FixedLight test_light3 = new FixedLight(14, new Vector3(10, 20, 30), Color.Green);
     scene.AddLight(test_light3);
 }
예제 #24
0
        /*
         * Retourne le nombre de sprite dessiné
         *
         */
        public virtual int Draw(SpriteBatch spriteBatch, GameTime gameTime, Scene scene)
        {
            //si aucun sprite set, on n'affiche 0 sprite, obvious !
            if (sprites.Count == 0) return 0;

            SpriteArea sprite_to_draw;
            //if cannot get the animation for the orientation, get the first one
            if (!sprites.TryGetValue(scene.Camera.getLookDirectionFromOrientation(Orientation), out sprite_to_draw))
            {
                sprite_to_draw = sprites.Values.First();
            }

            spriteBatch.Draw(
                SpriteSheet,
                ScreenRect,
                sprite_to_draw.Rectangle,
                SumColorLight,
                rotation,
                scene.Camera.Position,
                sprite_to_draw.SpriteEffect,
                layer
                );

            //RAZ Color
            SumColorLight = Color;

            return 1;
        }
예제 #25
0
        private void initializeChunks(Scene scene)
        {
            #region Chunk 0,0
            ChunkProxy testChunk = new ChunkProxy(0, 0);
            int chunk_y = 0;
            Random rand = new Random();
            while (chunk_y < Chunk.CHUNKS_SIZE)
            {
                int chunk_x = 0;
                while (chunk_x < Chunk.CHUNKS_SIZE)
                {

                    CoreProxy core = new CoreProxy(new Vector3(chunk_x, chunk_y, 7), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 32, 32, 16), SpriteEffects.None);
                    core[Orientation.BR] = new SpriteArea(new Rectangle(96, 32, 32, 16), SpriteEffects.FlipHorizontally);
                    core[Orientation.TR] = new SpriteArea(new Rectangle(96, 32, 32, 16), SpriteEffects.None);
                    core[Orientation.TL] = new SpriteArea(new Rectangle(96, 32, 32, 16), SpriteEffects.FlipHorizontally);

                    testChunk[chunk_x, chunk_y] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;

                    //animated sprite
                    if ((chunk_x == Chunk.CHUNKS_SIZE - 1) && (chunk_y == Chunk.CHUNKS_SIZE - 1))
                    {
                        AnimatedEntity animated_entity = new AnimatedEntity(
                            new Vector3(chunk_x, chunk_y, 7),
                            32, 32, new Vector2(16, 27),
                            text, new Color(0, 0, 0, 1), Orientation.S);

                        animated_entity[Orientation.BR] = new Animation(text, SpriteEffects.FlipHorizontally);
                        animated_entity[Orientation.BR].addFrame(new Rectangle(32, 0, 32, 32), 500);
                        animated_entity[Orientation.BR].addFrame(new Rectangle(96, 0, 32, 32), 500);
                        animated_entity[Orientation.BR].addFrame(new Rectangle(32, 0, 32, 32), 500);
                        animated_entity[Orientation.BR].addFrame(new Rectangle(64, 0, 32, 32), 500);

                        animated_entity[Orientation.BL] = new Animation(text);
                        animated_entity[Orientation.BL].addFrame(new Rectangle(32, 0, 32, 32), 500);
                        animated_entity[Orientation.BL].addFrame(new Rectangle(96, 0, 32, 32), 500);
                        animated_entity[Orientation.BL].addFrame(new Rectangle(32, 0, 32, 32), 500);
                        animated_entity[Orientation.BL].addFrame(new Rectangle(64, 0, 32, 32), 500)
                            ;
                        animated_entity[Orientation.TR] = new Animation(text);
                        animated_entity[Orientation.TR].addFrame(new Rectangle(128, 0, 32, 32), 500);
                        animated_entity[Orientation.TR].addFrame(new Rectangle(192, 0, 32, 32), 500);
                        animated_entity[Orientation.TR].addFrame(new Rectangle(128, 0, 32, 32), 500);
                        animated_entity[Orientation.TR].addFrame(new Rectangle(160, 0, 32, 32), 500);

                        animated_entity[Orientation.TL] = new Animation(text, SpriteEffects.FlipHorizontally);
                        animated_entity[Orientation.TL].addFrame(new Rectangle(128, 0, 32, 32), 500);
                        animated_entity[Orientation.TL].addFrame(new Rectangle(192, 0, 32, 32), 500);
                        animated_entity[Orientation.TL].addFrame(new Rectangle(128, 0, 32, 32), 500);
                        animated_entity[Orientation.TL].addFrame(new Rectangle(160, 0, 32, 32), 500);

                        core.addEntity(animated_entity);
                        scene.CalculPositionsEntitiesHandler += animated_entity.calculateScreenRect;
                    }

                    //fontain
                    if ((chunk_x == 0) && (chunk_y == 0))
                    {

                        DrawableEntity testFontain = new DrawableEntity(
                            new Vector3(chunk_x, chunk_y, 7), 27, 34,
                            new Vector2(13, 31), text2,
                            new Color(0, 0, 0, 1), Orientation.S
                        );
                        testFontain[Orientation.BL] = new SpriteArea(new Rectangle(344, 714, 27, 34), SpriteEffects.None);

                        core.addEntity(testFontain);
                        scene.CalculPositionsEntitiesHandler += testFontain.calculateScreenRect;

                        DrawableEntity testContainable = new DrawableEntity(
                            new Vector3(chunk_x, chunk_y, (float)9f), 32, 32,
                            new Vector2(16, 24), text2,
                            new Color(0, 0, 0, 1), Orientation.S
                        );
                        testContainable[Orientation.BL] = new SpriteArea(new Rectangle(205, 136, 32, 32), SpriteEffects.None);
                        core.addEntity(testContainable);
                        scene.CalculPositionsEntitiesHandler += testContainable.calculateScreenRect;
                    }

                    //dwarfs
                    else if (((chunk_x % 4) == 0) && ((chunk_y % 5) == 0))
                    {

                        /***
                            * color is hijack, it contain refill color (magenta and cyan) + light and light intensity
                            * offset colors are listed in shader (0-4 : hair, 5-14 : clothes, 15-255 free)
                            * */
                        Color hijack_color = new Color(
                            0,
                            0,
                            0,
                            (int)rand.Next(5, 13)
                        );

                        //body
                        DrawableEntity testGuysBody = new DrawableEntity(
                            new Vector3(chunk_x, chunk_y, 7), 32, 32,
                            new Vector2(16, 27), text,
                            hijack_color, Orientation.S
                        );

                        testGuysBody[Orientation.BL] = new SpriteArea(new Rectangle(128, 32, 32, 32), SpriteEffects.None);
                        testGuysBody[Orientation.BR] = new SpriteArea(new Rectangle(128, 32, 32, 32), SpriteEffects.FlipHorizontally);
                        core.addEntity(testGuysBody);
                        scene.CalculPositionsEntitiesHandler += testGuysBody.calculateScreenRect;

                        hijack_color = new Color(
                            0,
                            0,
                            0,
                            (int)rand.Next(0, 4)
                        );
                        DrawableEntity testGuysHead = new DrawableEntity(
                            new Vector3(chunk_x, chunk_y, 7), 32, 32,
                            new Vector2(16, (chunk_y % 2 == 0) ? 27 : 30), text,
                            hijack_color, Orientation.S
                        );

                        //head
                        testGuysHead[Orientation.BL] = new SpriteArea(new Rectangle((chunk_y % 2 == 0) ? 128 : 160, 64, 32, 32), SpriteEffects.None);
                        testGuysHead[Orientation.BR] = new SpriteArea(new Rectangle((chunk_y % 2 == 0) ? 128 : 160, 64, 32, 32), SpriteEffects.FlipHorizontally);
                        core.addEntity(testGuysHead);
                        scene.CalculPositionsEntitiesHandler += testGuysHead.calculateScreenRect;
                    }
                    chunk_x++;
                }
                chunk_y++;
            }
            scene.Chunks[0] = new SortedList<int, ChunkProxy>();
            scene.Chunks[0][0] = testChunk;
            #endregion
            #region Chunk 0,1

            int j;
            //eau 0,1
            j = 0;
            ChunkProxy testChunk2 = new ChunkProxy(0, 1);
            while (j < Chunk.CHUNKS_SIZE)
            {
                int i = 0;
                while (i < Chunk.CHUNKS_SIZE)
                {
                    CoreProxy core = new CoreProxy(new Vector3(i, j + Chunk.CHUNKS_SIZE, 0), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 64, 32, 16), SpriteEffects.None);
                    testChunk2[i, j] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;
                    i++;
                }
                j++;
            }
            scene.Chunks[0][1] = testChunk2;
            #endregion
            #region Chunk 1,0
            //eau 1,0
            j = 0;
            ChunkProxy testChunk3 = new ChunkProxy(1, 0);
            while (j < Chunk.CHUNKS_SIZE)
            {
                int i = 0;
                while (i < Chunk.CHUNKS_SIZE)
                {
                    CoreProxy core = new CoreProxy(new Vector3(i + Chunk.CHUNKS_SIZE, j, 0), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 64, 32, 16), SpriteEffects.None);
                    testChunk3[i, j] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;
                    i++;
                }
                j++;
            }
            scene.Chunks[1] = new SortedList<int, ChunkProxy>();
            scene.Chunks[1][0] = testChunk3;

            #endregion
            #region Chunk 0,-1
            //eau 0,-1
            j = 0;
            ChunkProxy testChunk4 = new ChunkProxy(0, -1);
            while (j < Chunk.CHUNKS_SIZE)
            {
                int i = 0;
                while (i < Chunk.CHUNKS_SIZE)
                {
                    CoreProxy core = new CoreProxy(new Vector3(i, j - Chunk.CHUNKS_SIZE, 0), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 64, 32, 16), SpriteEffects.None);
                    testChunk4[i, j] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;
                    i++;
                }
                j++;
            }
            scene.Chunks[0][-1] = testChunk4;
            #endregion
            #region Chunk -1,0

            //eau -1, 0
            j = 0;
            ChunkProxy testChunk5 = new ChunkProxy(-1, 0);
            while (j < Chunk.CHUNKS_SIZE)
            {
                int i = 0;
                while (i < Chunk.CHUNKS_SIZE)
                {
                    CoreProxy core = new CoreProxy(new Vector3(i - Chunk.CHUNKS_SIZE, j, 0), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 64, 32, 16), SpriteEffects.None);
                    testChunk5[i, j] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;
                    i++;
                }
                j++;
            }
            scene.Chunks[-1] = new SortedList<int, ChunkProxy>();
            scene.Chunks[-1][0] = testChunk5;

            #endregion
            #region Chunk -1,-1
            //eau -1, -1
            j = 0;
            ChunkProxy testChunk6 = new ChunkProxy(-1, -1);
            while (j < Chunk.CHUNKS_SIZE)
            {
                int i = 0;
                while (i < Chunk.CHUNKS_SIZE)
                {
                    CoreProxy core = new CoreProxy(new Vector3(i - Chunk.CHUNKS_SIZE, j - Chunk.CHUNKS_SIZE, 0), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    if (((i % 2) == 0) && ((j % 2) == 0))
                    {

                        DrawableEntity water = new DrawableEntity(
                            new Vector3(i - Chunk.CHUNKS_SIZE, j - Chunk.CHUNKS_SIZE, 0), 34, 21,
                            new Vector2(17, 20), text2,
                            new Color(0, 0, 0, 1), Orientation.S
                        );
                        water[Orientation.BL] = new SpriteArea(new Rectangle(307, 726, 34, 21), SpriteEffects.None);
                        water[Orientation.BR] = new SpriteArea(new Rectangle(307, 726, 34, 21), SpriteEffects.FlipHorizontally);
                        water[Orientation.TL] = new SpriteArea(new Rectangle(307, 726, 34, 21), SpriteEffects.None);
                        water[Orientation.TR] = new SpriteArea(new Rectangle(307, 726, 34, 21), SpriteEffects.FlipHorizontally);
                        core.addEntity(water);
                        scene.CalculPositionsEntitiesHandler += water.calculateScreenRect;
                    }
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 64, 32, 16), SpriteEffects.None);
                    testChunk6[i, j] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;
                    i++;
                }
                j++;
            }
            scene.Chunks[-1][-1] = testChunk6;

            #endregion
            #region Chunk 1,-1

            //eau 1,-1
            j = 0;
            ChunkProxy testChunk7 = new ChunkProxy(1, -1);
            while (j < Chunk.CHUNKS_SIZE)
            {
                int i = 0;
                while (i < Chunk.CHUNKS_SIZE)
                {
                    CoreProxy core = new CoreProxy(new Vector3(i + Chunk.CHUNKS_SIZE, j - Chunk.CHUNKS_SIZE, 0), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 64, 32, 16), SpriteEffects.None);
                    testChunk7[i, j] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;
                    i++;
                }
                j++;
            }
            scene.Chunks[1][-1] = testChunk7;

            #endregion
            #region Chunk -1,1
            //eau -1, 1
            j = 0;
            ChunkProxy testChunk8 = new ChunkProxy(-1, 1);
            while (j < Chunk.CHUNKS_SIZE)
            {
                int i = 0;
                while (i < Chunk.CHUNKS_SIZE)
                {
                    CoreProxy core = new CoreProxy(new Vector3(i - Chunk.CHUNKS_SIZE, j + Chunk.CHUNKS_SIZE, 0), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 64, 32, 16), SpriteEffects.None);
                    testChunk8[i, j] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;
                    i++;
                }
                j++;
            }
            scene.Chunks[-1][1] = testChunk8;

            #endregion
            #region Chunk 1,1
            //eau 1, 1
            j = 0;
            ChunkProxy testChunk9 = new ChunkProxy(1, 0);
            while (j < Chunk.CHUNKS_SIZE)
            {
                int i = 0;
                while (i < Chunk.CHUNKS_SIZE)
                {
                    CoreProxy core = new CoreProxy(new Vector3(i + Chunk.CHUNKS_SIZE, j + Chunk.CHUNKS_SIZE, 0), 32, 16,
                                new Vector2(16, 8), text,
                                new Color(0, 0, 0, 1)
                    );
                    core[Orientation.BL] = new SpriteArea(new Rectangle(96, 64, 32, 16), SpriteEffects.None);
                    testChunk9[i, j] = core;
                    scene.CalculPositionsEntitiesHandler += core.calculateScreenRect;
                    i++;
                }
                j++;
            }
            scene.Chunks[1][1] = testChunk9;

            #endregion

            //calcul position and center
            scene.CalculPositionsEntitiesHandler(scene);
            scene.CalculCenterEntity();

            //calcul du cliff
            scene.Chunks[0][0].calculCliffs(scene);
        }
예제 #26
0
 public override void Initialize()
 {
     base.Initialize();
     scene = new Scene();
     scene.Initialize();
 }