public CustomPropertiesDialog(string dialogTitle, xTile.ObjectModel.Component component)
        {
            InitializeComponent();

            this.Text = dialogTitle;
            m_component = component;
        }
Beispiel #2
0
        public MapStatisticsDialog(Map map, xTile.Dimensions.Rectangle viewport)
        {
            InitializeComponent();

            m_map = map;
            m_viewport = viewport;
        }
Beispiel #3
0
        private void DisplayCustomProperties(xTile.ObjectModel.Component component)
        {
            int oldIndent = m_textBoxStatistics.SelectionIndent;

            m_textBoxStatistics.SelectionFont = m_propertyNameFont;
            m_textBoxStatistics.AppendText("Custom Properties\t");

            m_textBoxStatistics.SelectionFont = m_propertyValueFont;
            m_textBoxStatistics.AppendLine(component.Properties.Count.ToString());

            m_textBoxStatistics.SelectionIndent += 25;
            foreach (KeyValuePair<string, PropertyValue> keyValuePair in component.Properties)
            {
                m_textBoxStatistics.SelectionBullet = true;

                m_textBoxStatistics.SelectionFont = m_propertyNameFont;
                m_textBoxStatistics.AppendText(keyValuePair.Key);
                m_textBoxStatistics.AppendText(" = ");

                m_textBoxStatistics.SelectionFont = m_propertyValueFont;
                m_textBoxStatistics.AppendLine(keyValuePair.Value);
            }
            m_textBoxStatistics.SelectionBullet = false;
            m_textBoxStatistics.SelectionIndent = oldIndent;
        }
Beispiel #4
0
        public void LoadProperties(xTile.ObjectModel.Component component)
        {
            m_dataGridView.Rows.Clear();

            m_newProperties.Clear();
            foreach (KeyValuePair<string, PropertyValue> keyValuePair
                in component.Properties)
            {
                m_newProperties.Add(keyValuePair.Key, keyValuePair.Value);

                DataGridViewRow row = new DataGridViewRow();
                DataGridViewTextBoxCell nameCell = new DataGridViewTextBoxCell();
                nameCell.Value = keyValuePair.Key;
                DataGridViewTextBoxCell valueCell = new DataGridViewTextBoxCell();
                valueCell.Value = keyValuePair.Value.ToString();

                if (keyValuePair.Value.Type == typeof(float)
                    || keyValuePair.Value.Type == typeof(int))
                    valueCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;

                row.Cells.Add(nameCell);
                row.Cells.Add(valueCell);
                m_dataGridView.Rows.Add(row);
            }
        }
Beispiel #5
0
 public PizzaGuy(
     Vector2 location,
     Texture2D texture,
     Rectangle initialFrame,
     Vector2 velocity,
     xTile.Layers.Layer map)
     : base(location, texture, initialFrame, velocity, map)
 {
 }
Beispiel #6
0
 public Ghost(
     Vector2 location,
     Texture2D texture,
     Rectangle initialFrame,
     Vector2 velocity,
     xTile.Layers.Layer map,
     PizzaGuy pacman)
     : base(location, texture, initialFrame, velocity, map)
 {
     this.pacman = pacman;
 }
Beispiel #7
0
        public CompatibilityReport DetermineCompatibility(xTile.Map map)
        {
            List<CompatibilityNote> compatibilityNotes = new List<CompatibilityNote>();

            if (map.TileSheets.Count != 1)
                compatibilityNotes.Add(
                    new CompatibilityNote(CompatibilityLevel.None, "Map must use exactly one tile sheet"));

            if (map.Layers.Count == 0)
                compatibilityNotes.Add(
                    new CompatibilityNote(CompatibilityLevel.None, "Map must have at least one layer"));

            if (map.Layers.Count > 8)
                compatibilityNotes.Add(
                    new CompatibilityNote(CompatibilityLevel.None, "Map must have no more than 8 layers"));

            xTile.Dimensions.Size layerSize = map.Layers[0].LayerSize;

            foreach (Layer layer in map.Layers)
                if (layer.LayerSize != layerSize)
                {
                    compatibilityNotes.Add(
                        new CompatibilityNote(CompatibilityLevel.None, "All layers must be of the same size"));
                    break;
                }

            xTile.Dimensions.Size tileSize = map.Layers[0].TileSize;
            foreach (Layer layer in map.Layers)
                if (layer.TileSize != tileSize)
                {
                    compatibilityNotes.Add
                        (new CompatibilityNote(CompatibilityLevel.None,
                            "All layers must share a common tile size dictated by the tile sheet"));
                    break;
                }

            string[] descriptionParagraphs = map.Description.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            if (descriptionParagraphs.Length > 4)
                compatibilityNotes.Add(new CompatibilityNote(CompatibilityLevel.None, "Map description should not exceed 4 paragraphs"));

            compatibilityNotes.Add(
                new CompatibilityNote(CompatibilityLevel.Partial, "Tile, layer and map attributes will not be stored"));

            compatibilityNotes.Add(
                new CompatibilityNote(CompatibilityLevel.Partial, "Auto-tiling definitions will not be stored"));

            compatibilityNotes.Add(
                new CompatibilityNote(CompatibilityLevel.Partial, "Brush definitions will not be stored"));

            CompatibilityReport compatibilityReport = new CompatibilityReport(compatibilityNotes);
            return compatibilityReport;
        }
Beispiel #8
0
        public MazeActor(
            Vector2 location,
            Texture2D texture,
            Rectangle initialFrame,
            Vector2 velocity,
            xTile.Layers.Layer map)
            : base(location, texture, initialFrame, velocity)
        {
            direction = Direction.RIGHT;
            target = location;
            this.map = map;

            UpdateDirection();
        }
Beispiel #9
0
        public Pacman(
            Vector2 location,
            Texture2D texture,
            Rectangle initialFrame,
            Vector2 velocity,
            xTile.Map map)
            : base(location, texture, initialFrame, velocity)
        {
            direction = Direction.RIGHT;
            target = location + new Vector2(32, 0);
            this.map = map;

            UpdateDirection();
        }
        public List<GameObject> GetGameObjects(Game game, xTile.Map map, Camera cam)
        {
            List<GameObject> returnObjects = new List<GameObject>();

            Layer triggerLayer = map.GetLayer("detonators");
            Layer destroyableTiles50X50 = map.GetLayer("destroyableTiles50x50");
            Layer destroyableTile100X100 = map.GetLayer("destroyableTiles100x100");

            List<DestroyableTileInfo> destroyables = new List<DestroyableTileInfo>();
            List<DestroyableTileInfo> triggers = new List<DestroyableTileInfo>();
            if(triggerLayer != null)
            {
                triggers.AddRange(ExtractGameObjectPositions(triggerLayer, "detonator"));

                if(destroyableTiles50X50 != null)
                {
                    destroyables.AddRange(ExtractGameObjectPositions(destroyableTiles50X50, "destroyable_tile_small"));
                }
                if(destroyableTile100X100 != null)
                {
                    destroyables.AddRange(ExtractGameObjectPositions(destroyableTile100X100, "destroyable_tile"));
                }

                if(triggers.Count == destroyables.Count)
                {
                    for (int i = 0; i < triggers.Count; i++)
                    {
                        for(int y = 0; y < destroyables.Count; y++)
                        {
                            if(triggers[i].ID == destroyables[y].ID)
                            {
                                returnObjects.Add(CreateGameObject(triggers[i], destroyables[y], game, cam));
                                continue;
                            }
                        }
                    }
                }
                else
                {
                    Debug.WriteLine("Amount of triggers does not match the amount of destroyables");
                }
            }

            return returnObjects;
        }
Beispiel #11
0
        public BomberMan(Keys UpKey, Keys DownKey, Keys LeftKey, Keys RightKey, 
                         Vector2 location,
                         Texture2D texture,
                         Rectangle initialFrame,
                         Vector2 velocity,
                         xTile.Layers.Layer map)
            : base(location, texture, initialFrame, velocity, map)
        {
            this.UpKey = UpKey;
            this.DownKey = DownKey;
            this.LeftKey = LeftKey;
            this.RightKey = RightKey;

            Tile tile = map.Tiles[0, 0];

            if (tile != null && tile.TileIndex == 28)
                map.Tiles[0, 0] = null;

            this.Tagged = false;
        }
Beispiel #12
0
 public MapTreeViewEventArgs(TreeNode treeNode, xTile.ObjectModel.Component component)
 {
     m_treeNode = treeNode;
     m_component = component;
 }
Beispiel #13
0
        private void updatePlayer(GameTime gameTime, Map map, xTile.Dimensions.Rectangle viewport)
        {
            player.update(gameTime, map);

            for(int i = 0; i < puncheeList.Count; i++)
            {
                if(player.mCurrentRect.Intersects(puncheeList[i].mCurrentRect))
                {
                    player.killSelf();
                    explosion.mOrigin = player.mPosition;
                    explosion.init();
                    mManager.deathSound.Play();
                }
            }

            for (int i = 0; i < scoreAreaList.Count; i++)
            {
                if (player.mCurrentRect.Intersects(scoreAreaList[i].mRectangle))
                {
                    player.killSelf();
                    explosion.mOrigin = player.mPosition;
                    explosion.init();
                    mManager.deathSound.Play();
                }
            }
        }
Beispiel #14
0
        private void ParseTiles(xTile.Layers.Layer platformLayer, AggregateTileHandler func)
        {
            List<TileAggregate> aggregates = new List<TileAggregate>();
            Dictionary<Point, TileAggregate> pointToAggregate = new Dictionary<Point, TileAggregate>();

            var width = platformLayer.LayerWidth;
            var height = platformLayer.LayerHeight;
            var tiles = platformLayer.Tiles;
            for(int y = 0; y < height; y++)
            {
                for(int x = 0; x < width; x++)
                {
                    if(tiles[x, y] != null)
                    {
                        string type = "";
                        string color = "";
                        Dictionary<string, string> properties = new Dictionary<string, string>();
                        foreach(var property in tiles[x, y].TileSheet.Properties)
                        {
                            switch(property.Key)
                            {
                                case "Type":
                                    type = property.Value;
                                    break;
                                case "Color":
                                    color = property.Value;
                                    break;
                                default:
                                    properties[property.Key] = property.Value;
                                    break;
                            }
                        }

                        TileAggregate aggregate;
                        if(x > 0
                           && pointToAggregate.TryGetValue(new Point(x-1, y), out aggregate)
                           && aggregate.type == type
                           && (aggregate.dir == TileDirection.HORIZONTAL || aggregate.dir == TileDirection.UNDEFINED)
                           && aggregate.color == color)
                        {
                            aggregate.dir = TileDirection.HORIZONTAL;
                            aggregate.rect.Width++;
                            pointToAggregate[new Point(x, y)] = aggregate;
                        }
                        else if(y > 0
                                && pointToAggregate.TryGetValue(new Point(x, y-1), out aggregate)
                                && aggregate.type == type
                                && (aggregate.dir == TileDirection.VERTICAL || aggregate.dir == TileDirection.UNDEFINED)
                                && aggregate.color == color)
                        {
                            aggregate.dir = TileDirection.VERTICAL;
                            aggregate.rect.Height++;
                            pointToAggregate[new Point(x, y)] = aggregate;
                        }
                        else
                        {
                            aggregate = new TileAggregate();
                            aggregate.type = type;
                            aggregate.color = color;
                            aggregate.dir = TileDirection.UNDEFINED;
                            aggregate.rect = new Rectangle(x, y, 1, 1);
                            pointToAggregate[new Point(x, y)] = aggregate;
                            aggregates.Add(aggregate);
                        }

                        foreach(var keyPair in properties)
                        {
                            aggregate.properties[keyPair.Key] = keyPair.Value;
                        }
                    }
                }
            }

            //Combine
            List<TileAggregate> combinedStripsToRemove = new List<TileAggregate>();
            foreach(var aggregate in aggregates)
            {
                TileAggregate aboveAggregate;
                if(aggregate.rect.Y > 0
                   && pointToAggregate.TryGetValue(new Point(aggregate.rect.X, aggregate.rect.Y-1), out aboveAggregate)
                   && aboveAggregate.type == aggregate.type
                   && (aboveAggregate.dir == TileDirection.HORIZONTAL || aboveAggregate.dir == TileDirection.COMBINED)
                   && aboveAggregate.color == aggregate.color
                   && aboveAggregate.rect.X == aggregate.rect.X
                   && aboveAggregate.rect.Width == aggregate.rect.Width)
                {
                    combinedStripsToRemove.Add(aggregate);
                    aboveAggregate.dir = TileDirection.COMBINED;
                    aboveAggregate.rect.Height++;
                    pointToAggregate[new Point(aggregate.rect.X, aggregate.rect.Y)] = aboveAggregate;
                    foreach(var keyPair in aggregate.properties)
                    {
                        aboveAggregate.properties[keyPair.Key] = keyPair.Value;
                    }
                }
            }
            foreach(var aggregate in combinedStripsToRemove)
            {
                aggregates.Remove(aggregate);
            }

            func(aggregates, pointToAggregate);
        }
Beispiel #15
0
        protected List<DoorInfo> ExtractGameObjectPositions(xTile.Layers.Layer layer)
        {
            TileArray tileArray = layer.Tiles;
            Size tileSize = layer.TileSize;
            Size amntOfTiles = layer.LayerSize;
            List<DoorInfo> doorInfos = new List<DoorInfo>();

            for (int x = 0; x < amntOfTiles.Width; x++)
            {
                for (int y = 0; y < amntOfTiles.Height; y++)
                {
                    Location tileLocation = new Location(x, y);
                    Tile thisTile = tileArray[tileLocation];

                    if (thisTile != null)
                    {
                        DoorInfo info = new DoorInfo();
                        info.position = new Point(x * tileSize.Width, y * tileSize.Height);
                        info.player = thisTile.Properties["color"];
                        doorInfos.Add(info);
                    }
                }
            }

            return doorInfos;
        }
Beispiel #16
0
        private TreeNode SearchComponent(TreeNode rootNode, xTile.ObjectModel.Component component)
        {
            if (rootNode.Tag == component)
                return rootNode;

            foreach (TreeNode childNode in rootNode.Nodes)
            {
                TreeNode resultNode = SearchComponent(childNode, component);
                if (resultNode != null)
                    return resultNode;
            }

            return null;
        }
Beispiel #17
0
        /// <summary>
        /// Sets the viewport.
        /// 
        /// NOTE: This function is not supported on the Zune platform.
        /// </summary>
        /// <param name="viewport">Viewport to apply</param>
        public void SetViewport(xTile.Dimensions.Rectangle viewport)
        {
            // further clip region within display device's dimensions
            int nMaxWidth = m_graphicsDevice.PresentationParameters.BackBufferWidth;
            int nMaxHeight = m_graphicsDevice.PresentationParameters.BackBufferHeight;

            int viewportLeft = Clamp(viewport.X, 0, nMaxWidth);
            int viewportTop = Clamp(viewport.Y, 0, nMaxHeight);
            int viewportRight = Clamp(viewport.X + viewport.Width, 0, nMaxWidth);
            int viewportBottom = Clamp(viewport.Y + viewport.Height, 0, nMaxHeight);
            int viewportWidth = viewportRight - viewportLeft;
            int viewportHeight = viewportBottom - viewportTop;

            m_graphicsDevice.Viewport = new Viewport(
                viewportLeft, viewportTop, viewportWidth, viewportHeight);
        }
Beispiel #18
0
        public void SetViewport(xTile.Dimensions.Rectangle viewport)
        {
            if (m_graphics == null)
                return;

            m_graphics.SetClip(new RectangleF(
                viewport.Location.X, viewport.Location.Y,
                viewport.Size.Width, viewport.Size.Height));
        }
Beispiel #19
0
 public void StoreProperties(xTile.ObjectModel.Component component)
 {
     component.Properties.Clear();
     component.Properties.CopyFrom(m_newProperties);
 }