Changeset 3572 for 2012/27


Ignore:
Timestamp:
2012-07-05 11:22:43 (11 years ago)
Author:
dezhidki
Message:

Levels are now dissapearing, if not on the screen
Possible to spawn random levels

Location:
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Room.cs

    r3570 r3572  
    1616        protected List<IPhysicsObject> roomDecorations = new List<IPhysicsObject>(); 
    1717        protected List<IPhysicsObject> roomObjects = new List<IPhysicsObject>(); 
    18         private bool isBuilt = false; 
     18        public bool isBuilt = false; 
    1919        protected IPhysicsObject[,] insideObjects; 
    2020        protected PhysicsObject[] doors = new PhysicsObject[4]; 
     
    9898                if (obj != null) 
    9999                    obj.Destroy(); 
     100            } 
     101        } 
     102 
     103        public void hideLevel() 
     104        { 
     105            if (roomDecorations.Count == 0) throw new Exception("Cannot hide empty room!"); 
     106            if (!isBuilt) return; 
     107 
     108            foreach (IPhysicsObject obj in roomDecorations) 
     109            { 
     110                obj.IsVisible = false; 
     111            } 
     112            foreach (IPhysicsObject obj in roomObjects) 
     113            { 
     114                obj.IsVisible = false; 
     115            } 
     116            foreach (IPhysicsObject obj in insideObjects) 
     117            { 
     118                if (obj != null) 
     119                    obj.IsVisible = false; 
     120            } 
     121        } 
     122 
     123        public void restoreLevel() 
     124        { 
     125            if (roomDecorations.Count == 0) throw new Exception("Cannot hide empty room!"); 
     126            if (!isBuilt) return; 
     127 
     128            foreach (IPhysicsObject obj in roomDecorations) 
     129            { 
     130                obj.IsVisible = true; 
     131            } 
     132            foreach (IPhysicsObject obj in roomObjects) 
     133            { 
     134                obj.IsVisible = true; 
     135            } 
     136            foreach (IPhysicsObject obj in insideObjects) 
     137            { 
     138                if (obj != null) 
     139                    obj.IsVisible = true; 
    100140            } 
    101141        } 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.cs

    r3570 r3572  
    4646        generator.generateRandomLevel(5, 10); 
    4747        generator.initDungeon(); 
    48       //  generator.buildDungeon(); 
    4948        Room centerRoom = generator.getRoomAt((int)(generator.CenterRoom.X), (int)(generator.CenterRoom.Y)); 
    5049        Camera.Position = centerRoom.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 
    51         //Camera.ZoomToLevel(); 
    52         //Camera.Zoom(0.5); 
    5350 
    5451        player = new Player(this, Vector.Zero, playerPic); 
     
    10198        newPos = room.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 
    10299        oldRoom = player.currentRoom; 
    103         room.buildLevel(); 
     100        if (room.isBuilt) room.restoreLevel(); 
     101        else room.buildLevel(); 
    104102        moveCameraTo(newPos - oldPos); 
    105103        player.Position = player.currentRoom.getDoor(dir).Position + RoomDirection.getOffsetFromWorldDir(dir) * 130; 
     
    124122            Camera.Position = newPos; 
    125123            moveCamera = false; 
    126             oldRoom.destroyLevel(); 
     124            oldRoom.hideLevel(); 
    127125        } 
    128126    } 
Note: See TracChangeset for help on using the changeset viewer.