当前位置: 首页>>代码示例>>C#>>正文


C# MapObject.ScaleObject方法代码示例

本文整理汇总了C#中X_UniTMX.MapObject.ScaleObject方法的典型用法代码示例。如果您正苦于以下问题:C# MapObject.ScaleObject方法的具体用法?C# MapObject.ScaleObject怎么用?C# MapObject.ScaleObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在X_UniTMX.MapObject的用法示例。


在下文中一共展示了MapObject.ScaleObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MapObjectLayer

        /// <summary>
        /// Creates a Map Object Layer from node
        /// </summary>
        /// <param name="node">XML node to parse</param>
        /// <param name="tiledMap">MapObjectLayer parent Map</param>
        /// <param name="layerDepth">This Layer's zDepth</param>
        /// <param name="materials">List of Materials containing the TileSet textures</param>
        public MapObjectLayer(NanoXMLNode node, Map tiledMap, int layerDepth)
            : base(node, tiledMap)
        {
            if (node.GetAttribute("color") != null)
            {
                // get the color string, removing the leading #
                string color = node.GetAttribute("color").Value.Substring(1);

                // get the RGB individually
                string r = color.Substring(0, 2);
                string g = color.Substring(2, 2);
                string b = color.Substring(4, 2);

                // convert to the color
                Color = new Color(
                    (byte)int.Parse(r, NumberStyles.AllowHexSpecifier),
                    (byte)int.Parse(g, NumberStyles.AllowHexSpecifier),
                    (byte)int.Parse(b, NumberStyles.AllowHexSpecifier));
            }

            Objects = new List<MapObject>();

            foreach (NanoXMLNode objectNode in node.SubNodes)
            {
                if (!objectNode.Name.Equals("object"))
                    continue;

                MapObject mapObjectContent = new MapObject(objectNode, this);

                mapObjectContent = mapObjectContent.ScaleObject(tiledMap.MapRenderParameter) as MapObject;

                // Object names need to be unique for our lookup system, but Tiled
                // doesn't require unique names.
                string objectName = mapObjectContent.Name;
                int duplicateCount = 2;

                // if a object already has the same name...
                if (Objects.Find(o => o.Name.Equals(objectName)) != null)
                {
                    // figure out a object name that does work
                    do
                    {
                        objectName = string.Format("{0}{1}", mapObjectContent.Name, duplicateCount);
                        duplicateCount++;
                    } while (Objects.Find(o => o.Name.Equals(objectName)) != null);

                    // log a warning for the user to see
                    //Debug.LogWarning("Renaming object \"" + mapObjectContent.Name + "\" to \"" + objectName + "\" in layer \"" + Name + "\" to make a unique name.");

                    // save that name
                    mapObjectContent.Name = objectName;
                }
                //mapObjectContent.CreateTileObject(tiledMap, Name, layerDepth, materials);

                AddObject(mapObjectContent);
            }
        }
开发者ID:GSP362DeVryNov2014,项目名称:TheTraveler-sr,代码行数:64,代码来源:MapObjectLayer.cs

示例2: MapObjectLayer

        /// <summary>
        /// Creates a map object layer from .tmx
        /// </summary>
        /// <param name="node"></param>
        public MapObjectLayer(XmlNode node, int TileWidth, int TileHeight)
            : base(node)
        {
            if (node.Attributes["color"] != null)
            {
                // get the color string, removing the leading #
                string color = node.Attributes["color"].Value.Substring(1);

                // get the RGB individually
                string r = color.Substring(0, 2);
                string g = color.Substring(2, 2);
                string b = color.Substring(4, 2);

                // convert to the color
                Color = new Color(
                    (byte)int.Parse(r, NumberStyles.AllowHexSpecifier),
                    (byte)int.Parse(g, NumberStyles.AllowHexSpecifier),
                    (byte)int.Parse(b, NumberStyles.AllowHexSpecifier));
            }

            Objects = new List<MapObject>();

            foreach (XmlNode objectNode in node.SelectNodes("object"))
            {
                MapObject mapObjectContent = new MapObject(objectNode);
                mapObjectContent.ScaleObject(TileWidth, TileHeight);
                mapObjectContent.Name = this.Name + "_" + mapObjectContent.Name;
                // Object names need to be unique for our lookup system, but Tiled
                // doesn't require unique names.
                string objectName = mapObjectContent.Name;
                int duplicateCount = 2;

                // if a object already has the same name...
                if (Objects.Find(o => o.Name.Equals(objectName)) != null)
                {
                    // figure out a object name that does work
                    do
                    {
                        objectName = string.Format("{0}{1}", mapObjectContent.Name, duplicateCount);
                        duplicateCount++;
                    } while (Objects.Find(o => o.Name.Equals(objectName)) != null);

                    // log a warning for the user to see
                    Debug.Log("Renaming object \"" + mapObjectContent.Name + "\" to \"" + objectName + "\" in layer \"" + Name + "\" to make a unique name.");

                    // save that name
                    mapObjectContent.Name = objectName;
                }

                //Objects.Add(mapObjectContent);
                AddObject(mapObjectContent);
            }
        }
开发者ID:networkpadawan,项目名称:X-uniTMX2D,代码行数:57,代码来源:MapObjectLayer.cs

示例3: MapObjectLayer

        /// <summary>
        /// Creates a map object layer from .tmx
        /// </summary>
        /// <param name="node"></param>
        public MapObjectLayer(XElement node, Map tiledMap, int layerDepth, List<Material> materials)
            : base(node)
        {
            if (node.Attribute("color") != null)
            {
                // get the color string, removing the leading #
                string color = node.Attribute("color").Value.Substring(1);

                // get the RGB individually
                string r = color.Substring(0, 2);
                string g = color.Substring(2, 2);
                string b = color.Substring(4, 2);

                // convert to the color
                Color = new Color(
                    (byte)int.Parse(r, NumberStyles.AllowHexSpecifier),
                    (byte)int.Parse(g, NumberStyles.AllowHexSpecifier),
                    (byte)int.Parse(b, NumberStyles.AllowHexSpecifier));
            }

            Objects = new List<MapObject>();

            foreach (XElement objectNode in node.Descendants("object"))
            {
                MapObject mapObjectContent = new MapObject(objectNode);
                //if (tiledMap.Orientation == Orientation.Orthogonal)
                //{
                //	mapObjectContent.ScaleObject(tiledMap.TileWidth, tiledMap.TileHeight);
                //}
                //// In Isometric maps, we must consider tile width == height for objects so their size can be correctly calculated
                //else if (tiledMap.Orientation == Orientation.Isometric)
                //{
                //	mapObjectContent.ScaleObject(tiledMap.TileHeight, tiledMap.TileHeight);
                //}
                //// In Staggered maps, we must pre-alter object position, as it comes mixed between staggered and orthogonal properties
                //else if (tiledMap.Orientation == Orientation.Staggered)
                //{
                //	float x = mapObjectContent.Bounds.x / (float)tiledMap.TileWidth;
                //	float y = mapObjectContent.Bounds.y / (float)tiledMap.TileHeight * 2.0f;
                //	float width = mapObjectContent.Bounds.width / (float)tiledMap.TileWidth;
                //	float height = mapObjectContent.Bounds.height / (float)tiledMap.TileWidth;

                //	if (Mathf.FloorToInt(Mathf.Abs(y)) % 2 > 0)
                //		x -= 0.5f;

                //	mapObjectContent.Bounds = new Rect(x, y, width, height);

                //	if (mapObjectContent.Points != null)
                //	{
                //		for (int i = 0; i < mapObjectContent.Points.Count; i++)
                //		{
                //			mapObjectContent.Points[i] = new Vector2(mapObjectContent.Points[i].x / (float)tiledMap.TileWidth, mapObjectContent.Points[i].y / (float)tiledMap.TileHeight * 2.0f);
                //		}
                //	}
                //}
                mapObjectContent.ScaleObject(tiledMap.TileWidth, tiledMap.TileHeight, tiledMap.Orientation);
                mapObjectContent.Name = this.Name + "_" + mapObjectContent.Name;
                // Object names need to be unique for our lookup system, but Tiled
                // doesn't require unique names.
                string objectName = mapObjectContent.Name;
                int duplicateCount = 2;

                // if a object already has the same name...
                if (Objects.Find(o => o.Name.Equals(objectName)) != null)
                {
                    // figure out a object name that does work
                    do
                    {
                        objectName = string.Format("{0}{1}", mapObjectContent.Name, duplicateCount);
                        duplicateCount++;
                    } while (Objects.Find(o => o.Name.Equals(objectName)) != null);

                    // log a warning for the user to see
                    Debug.Log("Renaming object \"" + mapObjectContent.Name + "\" to \"" + objectName + "\" in layer \"" + Name + "\" to make a unique name.");

                    // save that name
                    mapObjectContent.Name = objectName;
                }
                mapObjectContent.CreateTileObject(tiledMap, Name, layerDepth, materials);

                AddObject(mapObjectContent);
            }
        }
开发者ID:Teclys23,项目名称:stormsword,代码行数:87,代码来源:MapObjectLayer.cs


注:本文中的X_UniTMX.MapObject.ScaleObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。