Exemple #1
0
        public object Clone()
        {
            AngleRange clone = this.MemberwiseClone() as AngleRange;

            clone.sprites = new List <Sprite>(clone.sprites);

            return(clone);
        }
Exemple #2
0
        void UpdateSpriteArrays()
        {
            List <Sprite>         edgeSpriteList     = new List <Sprite>();
            List <Sprite>         cornerSpriteList   = new List <Sprite>();
            List <AngleRangeInfo> angleRangeInfoList = new List <AngleRangeInfo>();

            m_CurrentAngleRanges.Clear();
            m_CurrentCornerSprites.Clear();

            if (spriteShape)
            {
                List <AngleRange> sortedAngleRanges = new List <AngleRange>(spriteShape.angleRanges);
                sortedAngleRanges.Sort((a, b) => a.order.CompareTo(b.order));

                for (int i = 0; i < sortedAngleRanges.Count; i++)
                {
                    AngleRange     angleRange     = sortedAngleRanges[i];
                    AngleRangeInfo angleRangeInfo = new AngleRangeInfo();
                    angleRangeInfo.start = angleRange.start;
                    angleRangeInfo.end   = angleRange.end;
                    angleRangeInfo.order = (uint)angleRange.order;
                    List <int> spriteIndices     = new List <int>();
                    bool       validSpritesFound = false;
                    foreach (Sprite edgeSprite in angleRange.sprites)
                    {
                        edgeSpriteList.Add(edgeSprite);
                        spriteIndices.Add(edgeSpriteList.Count - 1);
                        if (edgeSprite != null)
                        {
                            validSpritesFound = true;
                        }
                    }
                    if (validSpritesFound)
                    {
                        angleRangeInfo.sprites = spriteIndices.ToArray();
                        angleRangeInfoList.Add(angleRangeInfo);
                    }
                }

                for (int i = 0; i < spriteShape.cornerSprites.Count; i++)
                {
                    CornerSprite cornerSprite = spriteShape.cornerSprites[i];
                    cornerSpriteList.Add(cornerSprite.sprites[0]);
                    m_CurrentCornerSprites.Add(cornerSprite.Clone() as CornerSprite);
                }

                for (int i = 0; i < spriteShape.angleRanges.Count; i++)
                {
                    AngleRange angleRange = spriteShape.angleRanges[i];
                    m_CurrentAngleRanges.Add(angleRange.Clone() as AngleRange);
                }
            }

            m_EdgeSpriteArray     = edgeSpriteList.ToArray();
            m_CornerSpriteArray   = cornerSpriteList.ToArray();
            m_AngleRangeInfoArray = angleRangeInfoList.ToArray();
        }
        void UpdateSpriteData()
        {
            if (spriteShape)
            {
                List <Sprite>         edgeSpriteList     = new List <Sprite>();
                List <Sprite>         cornerSpriteList   = new List <Sprite>();
                List <AngleRangeInfo> angleRangeInfoList = new List <AngleRangeInfo>();

                List <AngleRange> sortedAngleRanges = new List <AngleRange>(spriteShape.angleRanges);
                sortedAngleRanges.Sort((a, b) => a.order.CompareTo(b.order));

                for (int i = 0; i < sortedAngleRanges.Count; i++)
                {
                    bool       validSpritesFound = false;
                    AngleRange angleRange        = sortedAngleRanges[i];
                    foreach (Sprite edgeSprite in angleRange.sprites)
                    {
                        if (edgeSprite != null)
                        {
                            validSpritesFound = true;
                            break;
                        }
                    }

                    if (validSpritesFound)
                    {
                        AngleRangeInfo angleRangeInfo = new AngleRangeInfo();
                        angleRangeInfo.start = angleRange.start;
                        angleRangeInfo.end   = angleRange.end;
                        angleRangeInfo.order = (uint)angleRange.order;
                        List <int> spriteIndices = new List <int>();
                        foreach (Sprite edgeSprite in angleRange.sprites)
                        {
                            edgeSpriteList.Add(edgeSprite);
                            spriteIndices.Add(edgeSpriteList.Count - 1);
                        }
                        angleRangeInfo.sprites = spriteIndices.ToArray();
                        angleRangeInfoList.Add(angleRangeInfo);
                    }
                }

                bool validCornerSpritesFound = false;
                foreach (CornerSprite cornerSprite in spriteShape.cornerSprites)
                {
                    if (cornerSprite.sprites[0] != null)
                    {
                        validCornerSpritesFound = true;
                        break;
                    }
                }

                if (validCornerSpritesFound)
                {
                    for (int i = 0; i < spriteShape.cornerSprites.Count; i++)
                    {
                        CornerSprite cornerSprite = spriteShape.cornerSprites[i];
                        cornerSpriteList.Add(cornerSprite.sprites[0]);
                    }
                }

                m_EdgeSpriteArray     = edgeSpriteList.ToArray();
                m_CornerSpriteArray   = cornerSpriteList.ToArray();
                m_AngleRangeInfoArray = angleRangeInfoList.ToArray();

                List <Sprite> spriteList = new List <Sprite>();
                spriteList.AddRange(m_EdgeSpriteArray);
                spriteList.AddRange(m_CornerSpriteArray);
                m_SpriteArray = spriteList.ToArray();
            }
            else
            {
                m_SpriteArray         = new Sprite[0];
                m_EdgeSpriteArray     = new Sprite[0];
                m_CornerSpriteArray   = new Sprite[0];
                m_AngleRangeInfoArray = new AngleRangeInfo[0];
            }
        }