當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。