Beispiel #1
0
        /// <summary>
        /// Libera el contenido del cuarto
        /// </summary>
        public virtual void UnloadContent()
        {
            // Luego se manda a liberar toda referencia que exista a dichos objetos
            for (int i = 0; i < areaItems.Count; i++)
            {
                EntityManager.Instance.removeEntity(areaItems[i]);
            }

            areaItems.Clear();
            EventManager.Instance.removeEntityFromListeners(this);
            Program.GAME.ComponentManager.removeComponentsFromEntity(this);
            collisionComponent = null;
        }
Beispiel #2
0
        /// <summary>
        /// Carga el contenido del cuarto
        /// </summary>
        public virtual void LoadContent()
        {
            collisionComponent = new AreaCollisionComponent(this);

            int blockSize = GameConstants.BLOCK_SIZE;
            int roomOuterBorder = GameConstants.ROOM_OUTER_BORDER;

            IEntity areaLimits = new Entity("roomLimits");
            List<CollisionBody> limits = new List<CollisionBody>();
            Rectangle limitsRectangle = new Rectangle();
            this.areaItems.Add(areaLimits);

            // upper play borders
            limitsRectangle.X = -roomOuterBorder;
            limitsRectangle.Y = -roomOuterBorder;
            limitsRectangle.Width = (this.WidthBlocks * blockSize) + roomOuterBorder;
            limitsRectangle.Height = roomOuterBorder;
            limits.Add(ShapeFactory.CreateRectangle("upperLimitBack", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.BACK_PLAY_AREA));
            limits.Add(ShapeFactory.CreateRectangle("upperLimitMiddle", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.MIDDLE_PLAY_AREA));
            limits.Add(ShapeFactory.CreateRectangle("upperLimitFront", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.FRONT_PLAY_AREA));

            // right play borders
            limitsRectangle.X = this.WidthBlocks * blockSize;
            limitsRectangle.Y = -roomOuterBorder;
            limitsRectangle.Width = roomOuterBorder;
            limitsRectangle.Height = (this.heightBlocks * blockSize) + roomOuterBorder;
            limits.Add(ShapeFactory.CreateRectangle("rightLimitBack", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.BACK_PLAY_AREA));
            limits.Add(ShapeFactory.CreateRectangle("rightLimitMiddle", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.MIDDLE_PLAY_AREA));
            limits.Add(ShapeFactory.CreateRectangle("rightLimitFront", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.FRONT_PLAY_AREA));

            // lower play borders
            limitsRectangle.X = 0;
            limitsRectangle.Y = this.HeightBlocks * blockSize;
            limitsRectangle.Width = (this.WidthBlocks * blockSize) + roomOuterBorder;
            limitsRectangle.Height = roomOuterBorder;
            limits.Add(ShapeFactory.CreateRectangle("lowerLimitBack", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.BACK_PLAY_AREA));
            limits.Add(ShapeFactory.CreateRectangle("lowerLimitMiddle", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.MIDDLE_PLAY_AREA));
            limits.Add(ShapeFactory.CreateRectangle("lowerLimitFront", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.FRONT_PLAY_AREA));

            // left play borders
            limitsRectangle.X = -roomOuterBorder;
            limitsRectangle.Y = 0;
            limitsRectangle.Width = roomOuterBorder;
            limitsRectangle.Height = (this.heightBlocks * blockSize) + roomOuterBorder;
            limits.Add(ShapeFactory.CreateRectangle("leftLimitBack", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.BACK_PLAY_AREA));
            limits.Add(ShapeFactory.CreateRectangle("leftLimitMiddle", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.MIDDLE_PLAY_AREA));
            limits.Add(ShapeFactory.CreateRectangle("leftLimitFront", areaLimits, true, false,
                limitsRectangle.Width, limitsRectangle.Height, new Vector2(limitsRectangle.X, limitsRectangle.Y), false, GameLayers.FRONT_PLAY_AREA));

            areaLimits.addComponent(new StaticCollisionComponent(areaLimits, limits));
            EventManager.Instance.addListener(EventType.DEAD_EVENT, this);
            // Aquí código para cargar los objetos del cuarto
        }