コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected virtual void loadSprites(XmlElement e)
        {
            IEnumerator ie          = e.ChildNodes.GetEnumerator();
            ArrayList   colors      = new ArrayList();
            ArrayList   spriteNodes = new ArrayList();

            while (ie.MoveNext())
            {
                XmlNode child = (XmlNode)ie.Current;
                if (child.Name.Equals("spriteType"))
                {
                    colors.Add(child);
                }
                else if (child.Name.Equals("colorVariation"))
                {
                    colors.Add(child);
                    //throw new NotSupportedException("prease use <spriteType> tag.");
                }
                else if (child.Name.Equals("picture") || child.Name.Equals("sprite"))
                {
                    switch (stType)
                    {
                    case SpriteTableType.Unknown:
                        stType = SpriteTableType.Basic;
                        break;

                    case SpriteTableType.Basic:
                        break;

                    default:
                        throw new FormatException("<sprite> tag is not available together with <pictures> or <sprites> tags.");
                    }
                    spriteNodes.Add(child);
                }
                else if (child.Name.Equals("pictures") || child.Name.Equals("sprites"))
                {
                    switch (stType)
                    {
                    case SpriteTableType.Unknown:
                        stType = SpriteTableType.VarHeight;
                        break;

                    case SpriteTableType.VarHeight:
                        break;

                    default:
                        throw new FormatException("<" + child.Name + "> tag is not available together with <sprite> tag.");
                    }
                    spriteNodes.Add(child);
                }
            }
            if (colors.Count == 0)
            {
                colors.Add(e.FirstChild.Clone());
            }
            _colorMax = colors.Count;
            _dirMax   = spriteNodes.Count;
            contribs  = new Contribution[_dirMax, _colorMax];
            int defaultDir = _dirMax;

            for (int i = 0; i < _colorMax; i++)
            {
                for (int j = 0; j < _dirMax; j++)
                {
                    e.Attributes["id"].Value = this.Id + "-" + i + ":" + j;
                    XmlNode temp = ((XmlNode)spriteNodes[j]).Clone();
                    if (parseDirection(temp, j) == 0 && defaultDir > j)
                    {
                        defaultDir = j;
                    }
                    Contribution newContrib
                        = CreatePrimitiveContrib((XmlElement)temp, (XmlNode)colors[i], e);
                    PluginManager.AddContribution(newContrib);
                    contribs[j, i] = newContrib;
                }
            }

            // set unassigned direction table
            for (int j = 0; j < dirTable.Length; j++)
            {
                if (dirTable[j] == -1)
                {
                    dirTable[j] = defaultDir;
                }
            }
        }