Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="impact"></param>
        /// <param name="other_obj"></param>
        /// <param name="impact_face"></param>
        public override void EventTouch(bool impact, Object3d otherObject, int impactFace)
        {
            if (otherObject == null)
            {
                throw new ArgumentNullException("otherObject");
            }
            LeadActor aOtherObject = otherObject as LeadActor;

            if (aOtherObject != null)
            {
                (aOtherObject).EventChangeScene(destScene, destPos);
            }
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        //end of game_loop function


        //public int PlayerControl(ArrayList objectGroup, Skin[] skinGroup, Surface surface, LeadActor player)
        public int PlayerControl(LeadActor player)
        {
            /* Checks for key presses and quit events from the player
             *
             *  objectGroup: The group of objects in the players scene: list of Object3d class or subclass
             *  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
             *  surface: The area of the surface to draw into from the pygame window: surface class
             *
             *  kquit: returns 1 if quit event occurs: integer */
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            //Check movement keys based on direct access to the keyboard state
            //keys=pygame.key.get_pressed();
            //Checks for the direction keys: up down left right
            int[] W = { -2, 0, 0 };
            int[] E = { 2, 0, 0 };
            int[] N = { 0, 2, 0 };
            int[] S = { 0, -2, 0 };
            Events.Poll();
            if (Keyboard.IsKeyPressed(this.keys.Up) == true || Keyboard.IsKeyPressed(this.keys.Down) == true ||
                Keyboard.IsKeyPressed(this.keys.Left) == true || Keyboard.IsKeyPressed(keys.Right) == true)
            {
                if (Keyboard.IsKeyPressed(this.keys.Up) == true)
                {
                    player.Move(W);
                }
                if (Keyboard.IsKeyPressed(this.keys.Down) == true)
                {
                    player.Move(E);
                }
                if (Keyboard.IsKeyPressed(this.keys.Left) == true)
                {
                    player.Move(N);
                }
                if (Keyboard.IsKeyPressed(this.keys.Right) == true)
                {
                    player.Move(S);
                }
            }
            //if no direction key is pressed then stop the player
            else
            {
                player.Stop();
            }
            //Check for the Jump key
            if (Keyboard.IsKeyPressed(this.keys.Jump) == true)
            {
                player.Jump();
            }
            if (Keyboard.IsKeyPressed(this.keys.Pickup) == true)
            {
                player.EventPickup();
            }
            if (Keyboard.IsKeyPressed(this.keys.Drop) == true)
            {
                player.EventDrop();
            }
            if (Keyboard.IsKeyPressed(this.keys.UsingKey) == true)
            {
                player.EventUsingObject();
            }
            int kquit = 0;

            if (Keyboard.IsKeyPressed(Key.Q) == true)
            {
                kquit = 1;
            }
            if (Keyboard.IsKeyPressed(Key.Escape) == true)
            {
                kquit = 1;
            }
            return(kquit);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        //end of game_loop function


        //public int PlayerControl(ArrayList objectGroup, Skin[] skinGroup, Surface surface, LeadActor player)
        public int PlayerControl(LeadActor player)
        {
            /* Checks for key presses and quit events from the player

                objectGroup: The group of objects in the players scene: list of Object3d class or subclass
                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
                surface: The area of the surface to draw into from the pygame window: surface class

                kquit: returns 1 if quit event occurs: integer */
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            //Check movement keys based on direct access to the keyboard state
            //keys=pygame.key.get_pressed();
            //Checks for the direction keys: up down left right
            int[] W ={ -2, 0, 0 };
            int[] E ={ 2, 0, 0 };
            int[] N ={ 0, 2, 0 };
            int[] S ={ 0, -2, 0 };
            Events.Poll();
            if (Keyboard.IsKeyPressed(this.keys.Up) == true || Keyboard.IsKeyPressed(this.keys.Down) == true ||
                Keyboard.IsKeyPressed(this.keys.Left) == true || Keyboard.IsKeyPressed(keys.Right) == true)
            {
                if (Keyboard.IsKeyPressed(this.keys.Up) == true)
                {
                    player.Move(W);
                }
                if (Keyboard.IsKeyPressed(this.keys.Down) == true)
                {
                    player.Move(E);
                }
                if (Keyboard.IsKeyPressed(this.keys.Left) == true)
                {
                    player.Move(N);
                }
                if (Keyboard.IsKeyPressed(this.keys.Right) == true)
                {
                    player.Move(S);
                }
            }
            //if no direction key is pressed then stop the player
            else
            {
                player.Stop();
            }
            //Check for the Jump key
            if (Keyboard.IsKeyPressed(this.keys.Jump) == true)
            {
                player.Jump();
            }
            if (Keyboard.IsKeyPressed(this.keys.Pickup) == true)
            {
                player.EventPickup();
            }
            if (Keyboard.IsKeyPressed(this.keys.Drop) == true)
            {
                player.EventDrop();
            }
            if (Keyboard.IsKeyPressed(this.keys.UsingKey) == true)
            {
                player.EventUsingObject();
            }
            int kquit = 0;
            if (Keyboard.IsKeyPressed(Key.Q) == true)
            {
                kquit = 1;
            }
            if (Keyboard.IsKeyPressed(Key.Escape) == true)
            {
                kquit = 1;
            }
            return kquit;
        }
Ejemplo n.º 8
0
        /// <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);
        }