Exemplo n.º 1
0
 /// <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);
 }
Exemplo n.º 2
0
        // simulates a 3 dimensional scene

        /// <summary>
        /// 
        /// </summary>
        /// <param name="scene"></param>
        public static void Update(Scene scene)
        {
            /*Updates the physics simulation of the objects

               scene: scene to update: scene class
            */
            // Object tick: let each object run its tick() action.
            // make a copy of the object pointers in case the objects remove themselves from the master list
            if (scene == null)
            {
                throw new ArgumentNullException("scene");
            }
            Object3d[] update_group = new Object3d[scene.ObjectGroup.Count];
            scene.ObjectGroup.CopyTo(update_group, 0);
            foreach (Object3d obj in update_group)
            {
                obj.Tick();
            }
            // Note: the objects must not modify the object lists or positions in their event functions called by the
            // Collision and Touch processors.
            // Detect collisons
            update_group = new Object3d[scene.ObjectGroup.Count];
            scene.ObjectGroup.CopyTo(update_group, 0);
            //Console.WriteLine("Simulator Update.Collision_Processor");
            Physics.CollisionProcessor(update_group);
            // Detect touches
            //Console.WriteLine("Simulator Update.Physics.touch_processor");
            Physics.TouchProcessor(update_group);
        }
Exemplo n.º 3
0
 // 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);
 }
Exemplo 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();
        }
Exemplo n.º 5
0
 /* An object which can signal to lead actors for a scene change if they touch the portal */
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="size"></param>
 /// <param name="objtype"></param>
 /// <param name="dest_scene"></param>
 /// <param name="dest_pos"></param>
 public Portal(int[] position, int[] size, int objectType, Scene destinationScene, int[] destinationPosition)
     : base(position, size, objectType, true)
 {
     this.destScene = destinationScene;
     Vector.CopyVector(destinationPosition, this.destPos);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="pos"></param>
        public void EventChangeScene(Scene scene, int[] pos)
        {
            /* Event handler for a requested change scene, usually asked by doors who touched this lead actor
	          
                scene: the new scene to change the lead actor to: scene class
                pos: the new position vector in the new scene: list of 3 integers [x,y,z]
            */
            newScene = scene;
            Vector.CopyVector(pos, newPosition);
        }
Exemplo n.º 7
0
 /// <summary>
 /// 
 /// </summary>
 public override void Tick()
 {
     //System.Console.WriteLine("Lead Actor Tick entry");
     /*/Redefined tick function to allow movement between scenes /*/
     if (scene != newScene)
     {
         Vector.CopyVector(newPosition, GetPosition());
         newScene.ObjectGroup.Add(this);
         scene.ObjectGroup.Remove(this);
         scene = newScene;
     }
     if (pickupCommand == true)
     {
         Pickup();
         pickupCommand = false;
     }
     if (dropCommand == true)
     {
         Drop();
         dropCommand = false;
     }
     base.Tick();
 }
Exemplo n.º 8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="size"></param>
 /// <param name="objtype"></param>
 /// <param name="scene"></param>
 /// <param name="fixedob"></param>
 public LeadActor(int[] pos, int[] size, int objectType, Scene scene, bool fixedObject)
     : base(pos, size, objectType, fixedObject)
 {
     newScene = scene;
     newPosition = pos;
     this.scene = scene;
     //Flags for pick up and drop messages from external control: perhaps this means we really need a player object
 }
Exemplo n.º 9
0
 /// <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);
 }