WarTornLands.World.TileSetBox.DimensionsOf C# (CSharp) Method

DimensionsOf() public method

public DimensionsOf ( int gid ) : Point
gid int
return Point
        public Point DimensionsOf(int gid)
        {
            List<TileSet> setsReversed = new List<TileSet>(_sets);
            setsReversed.Reverse();

            foreach (TileSet set in setsReversed)
            {
                if (set.FirstID <= gid)
                    return set.TileDimensions;
            }

            throw new Exception();
        }

Usage Example

Exemplo n.º 1
0
        public Entity CreateEntity(TileSetBox tilesetBox, DataRow data)
        {
            Entity entity = CreateEntity(
                    tilesetBox.TypeOf(
                        int.Parse(
                            data["gid"].ToString()
                               )));

            entity.Position = new Vector2(
                int.Parse(data["x"].ToString()) + tilesetBox.DimensionsOf(int.Parse(data["gid"].ToString())).X * .5f,
                int.Parse(data["y"].ToString()));

            // Handle special types
            #region Chest
            //Creates a standard Dialog providing the item specified in the Tiled editor

            if (entity.Categorie.Equals("Chest"))
            {
                Conversation con = new Conversation("default");

                //try
                //{
                    con.Add(new ItemContainer(
                        SwitchItemType(data.GetChildRows("object_properties")[0])));
                //}
                //catch { throw new Exception("A Chest is missing an Item."); }
                con.Add(new KillSpeaker());

                List<Conversation> cons = new List<Conversation>();
                cons.Add(con);

                entity.AddModule(new Dialog(cons));
            }
            #endregion
            #region Door
            if (entity.Categorie.Equals("Door"))
            {
                entity.AddModule(new OpenDoorOnCollide(data));
            }
            #endregion
            #region JumpPoint
            if (entity.Categorie.Equals("JumpPoint"))
            {
                DataRow jumpProps = data.GetChildRows("object_properties")[0];

                entity.AddModule(new JumpPoint(
                    XMLParser.ValueOfProperty(jumpProps, "ID"),
                    XMLParser.ValueOfProperty(jumpProps, "Target")));

                _jumpPoints.Add(entity);
            }
            #endregion
            #region Check for demanded zone
            try
            {
                string zoneID = XMLParser.ValueOfProperty(data.GetChildRows("object_properties")[0], "ZoneID");
                // Check if the entity relates to a Zone
                if (zoneID != null)
                {
                    entity.SetZone(FindMatch(int.Parse(zoneID)));
                }
            }
            catch { }
            #endregion

            return entity;
        }