Ignore:
Timestamp:
2012-07-03 15:01:44 (8 years ago)
Author:
dezhidki
Message:

Talletus.

File:
1 edited

Legend:

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

    r3477 r3489  
    2020        protected int bWidth, bHeight; 
    2121        public Game Game { get; set; } 
     22        public Vector RoomsPosOnGrid { get; set; } 
    2223 
    2324        public Room(Game game, Vector pos, Vector size, double thickness) 
    2425        { 
    2526            Game = game; 
    26             Position = pos; 
     27            Position = VecMath.sub(pos, new Vector(Game.Level.Width / 2, -(Game.Level.Height / 2))); 
    2728            width = size.X; 
    2829            height = size.Y; 
     
    5354            foreach (IPhysicsObject obj in insideObjects) 
    5455            { 
    55                 if(obj != null) 
    56                 Game.Add(obj); 
     56                if (obj != null) 
     57                    Game.Add(obj); 
    5758            } 
    58              
     59 
    5960 
    6061            isBuilt = true; 
     
    7475        public void addBlock(IPhysicsObject obj, int bx, int by) 
    7576        { 
    76             if (bx > bWidth || bx < 0 || by > bHeight || by < 0 || insideObjects[bx,by] != null) throw new Exception("Can't put block to " + bx + " , " + by); 
     77            if (bx > bWidth || bx < 0 || by > bHeight || by < 0 || insideObjects[bx, by] != null) throw new Exception("Can't put block to " + bx + " , " + by); 
    7778            obj.Left = insidePos.X + (bx * blockWidth); 
    7879            obj.Top = insidePos.Y + (by * blockHeight); 
     
    8586            PhysicsObject wallLeft = createWall(VecMath.sub(Position, new Vector(0, thickness)), thickness, height); 
    8687            PhysicsObject wallDown = createWall(VecMath.sub(Position, new Vector(0, height)), width + thickness, thickness); 
    87             PhysicsObject wallRight = createWall(VecMath.add(Position, new Vector(width, -thickness)), thickness, height-thickness); 
     88            wallDown.Color = Color.Black; 
     89            PhysicsObject wallRight = createWall(VecMath.add(Position, new Vector(width, -thickness)), thickness, height - thickness); 
    8890            roomObjects.Add(wallTop); 
    8991            roomObjects.Add(wallLeft); 
     
    107109            bg.Top = Position.Y - thickness; 
    108110            bg.IgnoresCollisionResponse = true; 
    109             bg.Color = Color.Black; 
     111            bg.Color = Color.Green; 
    110112            bg.IgnoresExplosions = true; 
    111113            return bg; 
     
    114116    } 
    115117 
    116     class RoomTemplates 
     118    class RoomDirection 
    117119    { 
     120        public const int North = 0; 
     121        public const int East = 1; 
     122        public const int South = 2; 
     123        public const int West = 3; 
    118124 
     125        public static Vector getOffsetFromDir(int dir) 
     126        { 
     127            if (dir == North) 
     128                return new Vector(0, -1); 
     129            if (dir == East) 
     130                return new Vector(1, 0); 
     131            if (dir == South) 
     132                return new Vector(0, 1); 
     133            if (dir == West) 
     134                return new Vector(-1, 0); 
     135 
     136            return Vector.Zero; 
     137        } 
    119138    } 
    120139} 
Note: See TracChangeset for help on using the changeset viewer.