コード例 #1
0
ファイル: View.cs プロジェクト: erin100280/Zelda.NET
 /// <summary>
 /// 
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="skin_group"></param>
 public void DisplayUpdate(Scene scene, Skin[] skinGroup)
 {
     if (scene == null)
     {
         throw new ArgumentNullException("scene");
     }
     if (skinGroup == null)
     {
         throw new ArgumentNullException("skinGroup");
     }
     // Updates the isometric display using update rectangles
     // Clear the old sprite positions with the background
     Surface background = (Surface)skinGroup[scene.SceneType].Images[0];
     //Surface subsurface;
     if (oldRect.Length > 0)
     {
         foreach (Rectangle clear_rect in oldRect)
         {
             //subsurface=background.CreateSurfaceFromClipRectangle(clear_rect);
             Surface.Blit(background, clear_rect, clear_rect);
         }
     }
     // Update Isometric view
     // Copy the scene objects Array List KLUDGY!!!
     Object3d[] objectGroup = new Object3d[scene.ObjectGroup.Count];
     //for(int obj=0;obj<=scene.objectGroup.Count;obj++)
     //   objectGroup[obj]=scene.objectGroup[obj];
     scene.ObjectGroup.CopyTo(objectGroup, 0);
     oldRect = Isometric.ViewUpdate(Surface, objectGroup, skinGroup,
         displayOffset, oldRect);
 }
コード例 #2
0
ファイル: View.cs プロジェクト: erin100280/Zelda.NET
 // Initialize
 public View(Surface surface, Scene scene, Skin[] skinGroup, int[] displayOffset)
 {
     //Dimensions of the window for the isotope display
     //view_size=(int[])surface.GetSize();
     //remember the surface
     this.surface = surface;
     //offset from the top left corner of the window for the isotope display
     this.displayOffset = displayOffset;
     RedrawDisplay(scene, skinGroup);
 }
コード例 #3
0
ファイル: Sprites.cs プロジェクト: erin100280/Zelda.NET
        /// <summary>
        /// 
        /// </summary>
        /// <param name="skin_group"></param>
        /// <param name="object_group"></param>
        /// <returns></returns>
        public static Sprite[] UpdateImages(Skin[] skinGroup, Object3d[] objectGroup)
        {
            /* updates all the images for every object

                object_group: the objects whose state will be analysed to find the right image: list of objects_3d or subclass
                skin_group: a list of skins which will be used to find the correct image for the objects sprite: list of skins
                Returns sprite_group : sprite_group: a list of sprites which hold the new images: list of sprites 
            */
            Sprite[] sprite_group = new Sprite[objectGroup.Length];
            int i = 0;
            foreach (Object3d obj in objectGroup)
            {
                Sprite sprite = new Sprite();
                sprite.Surface = skinGroup[obj.ObjectType].GetImage(obj);
                sprite.Rectangle = sprite.Surface.Rectangle;
                sprite.Surface.TransparentColor = System.Drawing.Color.White;
                sprite.Surface.Transparent = true;
                sprite_group[i] = sprite;
                i++;
            }
            return (sprite_group);
        }
コード例 #4
0
ファイル: IsotopeMain.cs プロジェクト: erin100280/Zelda.NET
        public static void Run()
        {
            filePath = Path.Combine("..", "..");
            string fileDirectory = "Data";
            string fileName = "amp.png";
            if (File.Exists(fileName))
            {
                filePath = "";
                fileDirectory = "";
            }
            else if (File.Exists(Path.Combine(fileDirectory, fileName)))
            {
                filePath = "";
            }

            filePath = Path.Combine(filePath, fileDirectory);

            // Setup the pygame display, the window caption and its icon

            Video.WindowIcon();
            Video.WindowCaption = "SDL.NET - Isotope";
            Surface surface = Video.SetVideoMode(400, 360);

            // Setup the two scenes of a bedroom and a lounge with Ian Curtis as the lead actor  

            ArrayList joyWorld = new ArrayList();

            Scene bedroom = new Scene(0, new ArrayList());
            Scene lounge = new Scene(1, new ArrayList());
            joyWorld.Add(bedroom);
            joyWorld.Add(lounge);

            // Scene 0

            ObjectPortable guitar = new ObjectPortable(new int[] { 60, 0, 40 }, new int[] { 20, 12, 20 }, 3, false);
            bedroom.AppendObject(guitar);

            Object3d bed = new Object3d(new int[] { 10, 100, 0 }, new int[] { 70, 52, 28 }, 6, false);
            bedroom.AppendObject(bed);

            LeadActor ianCurtis = new LeadActor(new int[] { 90, 90, 0 }, new int[] { 14, 14, 50 }, 4, bedroom, false);
            bedroom.AppendObject(ianCurtis);

            Portal door = new Portal(new int[] { 180, 105, 0 }, new int[] { 10, 30, 56 }, 5, lounge, new int[] { 10, 115, 0 });
            bedroom.AppendObject(door);

            DissolverRandomCreator ampFactory = new DissolverRandomCreator(new int[] { 180, 105, 60 }, new int[] { 10, 10, 10 }, 4000, bedroom, true);
            bedroom.AppendObject(ampFactory);

            // walls and floor
            Object3d ground = new Object3d(new int[] { -1000, -1000, -100 }, new int[] { 2000, 2000, 100 }, 4000, true);
            bedroom.AppendObject(ground);

            Object3d wall0 = new Object3d(new int[] { 180, 0, -20 }, new int[] { 20, 180, 120 }, 4000, true);
            bedroom.AppendObject(wall0);

            Object3d wall1 = new Object3d(new int[] { 0, 180, -20 }, new int[] { 180, 20, 120 }, 4000, true);
            bedroom.AppendObject(wall1);

            Object3d wall2 = new Object3d(new int[] { 0, -20, -20 }, new int[] { 180, 20, 120 }, 4000, true);
            bedroom.AppendObject(wall2);

            Object3d wall3 = new Object3d(new int[] { -20, 0, -20 }, new int[] { 20, 180, 120 }, 4000, true);
            bedroom.AppendObject(wall3);

            // Scene 1
            Object3d sofa = new Object3d(new int[] { 0, 0, 0 }, new int[] { 39, 66, 37 }, 7, false);
            lounge.AppendObject(sofa);

            ObjectPortable amp = new ObjectPortable(new int[] { 60, 0, 25 }, new int[] { 16, 10, 18 }, 2, false);
            lounge.AppendObject(amp);

            Portal door2 = new Portal(new int[] { 0, 105, 0 }, new int[] { 10, 30, 56 }, 5, bedroom, new int[] { 160, 115, 0 });
            lounge.AppendObject(door2);

            // walls and floor
            Object3d ground2 = new Object3d(new int[] { -1000, -1000, -100 }, new int[] { 2000, 2000, 100 }, 4000, true);
            lounge.AppendObject(ground2);

            Object3d wall4 = new Object3d(new int[] { 180, 0, -20 }, new int[] { 20, 180, 120 }, 4000, true);
            lounge.AppendObject(wall4);

            Object3d wall5 = new Object3d(new int[] { 0, 180, -20 }, new int[] { 180, 20, 120 }, 4000, true);
            lounge.AppendObject(wall5);

            Object3d wall6 = new Object3d(new int[] { 0, -20, -20 }, new int[] { 180, 20, 120 }, 4000, true);
            lounge.AppendObject(wall6);

            Object3d wall7 = new Object3d(new int[] { -20, 0, -20 }, new int[] { 20, 180, 120 }, 4000, true);
            lounge.AppendObject(wall7);

            // Images for the Backgrounds and the objects

            Skin[] skinGroup = new Skin[8];

            ArrayList bedroomImage = SkinsLib.LoadImages(new string[] { Path.Combine(filePath, "bedroom.png") });
            skinGroup[0] = (new Skin(bedroomImage, "Bedroom"));

            ArrayList loungeImage = SkinsLib.LoadImages(new string[] { Path.Combine(filePath, "lounge.png") });
            skinGroup[1] = (new Skin(loungeImage, "Lounge"));

            ArrayList ampImage = SkinsLib.LoadImages(new string[] { Path.Combine(filePath, "amp.png") });
            skinGroup[2] = (new Skin(ampImage, "Amp"));

            ArrayList guitarImage = SkinsLib.LoadImages(new string[] { Path.Combine(filePath, "guitar.png") });
            skinGroup[3] = (new Skin(guitarImage, "Guitar"));

            ArrayList ianCurtisImages = SkinsLib.LoadImages(new string[] {Path.Combine(filePath, "ian_curtis0.png"),Path.Combine(filePath, "ian_curtis5.png"),Path.Combine(filePath, "ian_curtis3.png"),Path.Combine(filePath, "ian_curtisF4.png"),
																			  Path.Combine(filePath, "ian_curtisF6.png"),Path.Combine(filePath, "ian_curtisF7.png"),Path.Combine(filePath, "ian_curtisF0.png"),Path.Combine(filePath, "ian_curtisF5.png"),Path.Combine(filePath, "ian_curtisF3.png"),Path.Combine(filePath, "ian_curtis4.png"),Path.Combine(filePath, "ian_curtis6.png"),Path.Combine(filePath, "ian_curtis7.png")});
            skinGroup[4] = (Skin)new Pointing(ianCurtisImages, "Ian Curtis");

            // Mirror the images to complete the animation
            //for(int i=3;i<9;i++)
            //   ((Surface)ian_curtis_images[i]).FlipHorizontal();

            ArrayList doorImage = SkinsLib.LoadImages(new string[] { Path.Combine(filePath, "door.png") });
            skinGroup[5] = (new Skin(doorImage, "Door"));

            ArrayList bedImage = SkinsLib.LoadImages(new string[] { Path.Combine(filePath, "bed.png") });
            skinGroup[6] = (new Skin(bedImage, "Bed"));

            ArrayList sofaImage = SkinsLib.LoadImages(new string[] { Path.Combine(filePath, "sofa.png") });
            skinGroup[7] = (new Skin(sofaImage, "Sofa"));

            Keys joyKeys = new Keys(Key.O, Key.P, Key.A, Key.Z,
                Key.M, Key.G, Key.H, Key.B, Key.U);

            // Create an isotope engine using the skin_group and the scene_group
            Engine joyEngine = new Engine(ianCurtis, skinGroup, surface, joyKeys, Path.Combine(filePath, "titlebar.png"));

            // Start the isotope engine
            joyEngine.Start();
        }
コード例 #5
0
ファイル: Engine.cs プロジェクト: erin100280/Zelda.NET
        public void DrawInfoPanel(Surface surface, LeadActor player, Skin[] skinGroup)
        {
            /* Draws the information panel on the surface.

                surface: The area of the surface to draw into from the pygame window: surface class
                player: The lead actor being used for the player: lead_actor class
                skin_group: The group of skins to be used in the engines isometric view: skin class
            */
            if (surface == null)
            {
                throw new ArgumentNullException("surface");
            }
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            //draw titlebar
            Rectangle rect = surface.Blit(this.titleSprite.Surface, this.titleSprite.Rectangle);
            int[] draw_order;
            //draw inventory
            Object3d[] inventory_array = new Object3d[player.Inventory.Count];
            for (int i = 0; i < player.Inventory.Count; i++)
            {
                inventory_array[i] = (Object3d)player.Inventory[i];
            }
            if (player.Inventory.Count > 0)
            {
                Sprite[] sprite_group = Sprites.UpdateImages(skinGroup, inventory_array);
                int p = 155;
                draw_order = new int[player.Inventory.Count];
                int q = 0;
                for (int i = player.UsingObject; i < player.Inventory.Count; i++)
                {
                    draw_order[q] = i;
                    q++;
                }
                for (int i = 0; i < player.UsingObject; i++)
                {
                    draw_order[q] = i;
                    q++;
                }

                foreach (int i in draw_order)
                {
                    sprite_group[i].X = p;
                    sprite_group[i].Y = 38 - sprite_group[i].Height;
                    surface.Blit(sprite_group[i].Surface, sprite_group[i].Rectangle);
                    Surface text = this.font.Render(skinGroup[inventory_array[i].ObjectType].Name, Color.FromArgb(255, 255, 255));
                    Point textpos = new Point(0, 0);
                    textpos.X = p - skinGroup[inventory_array[i].ObjectType].Name.Length * 3 + sprite_group[i].Width / 2;
                    textpos.Y = 35;
                    surface.Blit(text, textpos);
                    p = p + sprite_group[i].Width + 20;
                }
            }
            //Update the display with the panel changes
            surface.Update(rect);
        }
コード例 #6
0
ファイル: Engine.cs プロジェクト: erin100280/Zelda.NET
        /// <summary>
        /// 
        /// </summary>
        /// <param name="player"></param>
        /// <param name="skin_group"></param>
        /// <param name="surface"></param>
        /// <param name="keys"></param>
        /// <param name="titlefile"></param>
        public Engine(LeadActor player, Skin[] skinGroup, Surface surface, Keys keys, string titleFile)
        {
            /* Initialise the Isotope Engine */
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            //Game Control
            //the lower limit of msec per frame
            this.timeLimit = 100;
            //define the keys using default values, users can redefine the keys by changing the key codes
            this.keys = keys;

            //Physical simulation elements
            //this.simulator = new Simulator();
            //Pick the players actor object and remember it
            this.player = player;

            //Graphical display elements
            //load the titlebar graphic as a sprite for drawing later. Users can reload their own image.
            this.titleSprite = new Sprite();
            this.titleSprite.Surface = new Surface(titleFile);

            int[] offset ={ 200, 170 };
            this.display = new View(surface, this.player.Scene, skinGroup, offset);
            //Isometric display elements
            this.skinGroup = skinGroup;
            //remember the surface
            this.surface = surface;

            //Load the default font: Do we need some tester here to ensure we find a font?
            //if (font==None)
            this.font = new SdlDotNet.Graphics.Font(Path.Combine(IsotopeMain.FilePath, "FreeSans.ttf"), 10);
            Events.Quit += new EventHandler<QuitEventArgs>(Events_Quit);
        }
コード例 #7
0
ファイル: View.cs プロジェクト: erin100280/Zelda.NET
 /// <summary>
 /// 
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="skin_group"></param>
 public void RedrawDisplay(Scene scene, Skin[] skinGroup)
 {
     if (scene == null)
     {
         throw new ArgumentNullException("scene");
     }
     if (skinGroup == null)
     {
         throw new ArgumentNullException("skinGroup");
     }
     // Redraws the entire display, including background
     //Display the background
     //Console.WriteLine(scene);
     Surface.Blit((Surface)skinGroup[scene.SceneType].Images[0], ((Surface)skinGroup[scene.SceneType].Images[0]).Rectangle);
     Surface.Update();
     DisplayUpdate(scene, skinGroup);
 }
コード例 #8
0
ファイル: Isometric.cs プロジェクト: erin100280/Zelda.NET
        /// <summary>
        /// 
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="objectGroup"></param>
        /// <param name="skin_group"></param>
        /// <param name="offset"></param>
        /// <param name="old_rect"></param>
        /// <returns></returns>
        public static Rectangle[] ViewUpdate(Surface surface, Object3d[] objectGroup, Skin[] skinGroup, int[] offset, Rectangle[] oldRect)
        {
            /* Update the isometric view based only on the changes in the screen

                surface: The pygame display area to be drawn into: surface
                object_group: a list of objects to be displayed: list of objects_3d or subclass
                skin_group: a list of skins which will be used to find the correct image for the objects sprite: list of skins
                offset: 2d vector to add to the isometric coordinates: list of 2 integers [x,y]
                old_rect: A list of pygame rectangles where the old sprites were drawn for updating: list of rect
                Returns old_rect: see above
            */
            if (skinGroup == null)
            {
                throw new ArgumentNullException("skinGroup");
            }
            if (objectGroup == null)
            {
                throw new ArgumentNullException("objectGroup");
            }
            if (surface == null)
            {
                throw new ArgumentNullException("surface");
            }

            // Find out what objects are visable
            int visable_limit = skinGroup.Length;
            //Object3d[] visable_object_group;
            ArrayList visable_object_list = new ArrayList();
            foreach (Object3d obj in objectGroup)
            {
                if (obj.ObjectType < visable_limit)
                {
                    visable_object_list.Add(obj);
                }
            }
            Object3d[] visable_object_group = new Object3d[visable_object_list.Count];
            visable_object_list.CopyTo(visable_object_group);

            // Draw the isometric view in the display surface
            Rectangle[] sprite_rect = ViewDraw(surface, (Object3d[])visable_object_group, skinGroup, offset);

            // Combines the rectangles that need updating: the new sprites and the old background rectangles   
            Rectangle[] update_rect = Sprites.CombineRectangles(sprite_rect, oldRect);

            // Update the display
            surface.Update(update_rect);

            // Remember the sprite rectangles
            oldRect = new Rectangle[sprite_rect.Length];
            for (int rect = 0; rect < sprite_rect.Length; rect++)
            {
                oldRect[rect] = sprite_rect[rect];
            }
            return (oldRect);
        }
コード例 #9
0
ファイル: Isometric.cs プロジェクト: erin100280/Zelda.NET
        // NOTE: The below routines have dependencies on the graphics subsystem and should be
        // Moved into a separate file so that this file can be system independent.

        /// <summary>
        /// 
        /// </summary>
        /// <param name="view"></param>
        /// <param name="objectGroup"></param>
        /// <param name="skin_group"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        public static Rectangle[] ViewDraw(Surface view, Object3d[] objectGroup, Skin[] skinGroup, int[] offset)
        {
            /* Draw the sprites to the screen based on isometric ordered sorting

                objectGroup: a list of objects to be displayed: list of objects_3d or subclass
                skin_group: a list of skins which will be used to find the correct image for the objects sprite: list of skins
                offset: 2d vector to add to the isometric coordinates: list of 2 integers [x,y]
                Returns rect: A list of pygame rectangles where the sprites were drawn : list of rect
            */
            //Calculate the isometric order of drawing the sprites from object information
            int[] draw_order = Order(objectGroup);
            //Put the correct images for all the skins into a sprite group
            Sprite[] sprite_group = Sprites.UpdateImages(skinGroup, objectGroup);
            //Calculate the screen coordinates of the sprites from the object data
            GroupTransform(objectGroup, sprite_group, offset);
            //Draw sprites in isometric order to the screen
            Rectangle[] rect;
            rect = (Rectangle[])Sprites.OrderedDraw(sprite_group, draw_order, view);
            return (rect);
        }