コード例 #1
0
        private void CreateAsset(ChromaAsset chromaAsset, XmlNode node, bool createFiles)
        {
            if (!chromaAsset.Parse())
            {
                return;
            }

            if (Assets.Count(x => x.imageName == chromaAsset.imageName) == 0)
            {
                chromaAsset.flipH = (node.Attributes.GetNamedItem("flipH") != null && node.Attributes.GetNamedItem("flipH").InnerText == "1");
                Assets.Add(chromaAsset);

                if (chromaAsset.sourceImage != null && createFiles)
                {
                    chromaAsset.GenerateImage();
                }

                chromaAsset.ImageX = chromaAsset.ImageX + (CANVAS_WIDTH / 2);  // 32;
                chromaAsset.ImageY = chromaAsset.ImageY + (CANVAS_HEIGHT / 2); // 25;
            }

            if (chromaAsset.imageName.Contains("_sd_"))
            {
                chromaAsset.Shadow = true;
                chromaAsset.Z      = int.MinValue;
            }
            else
            {
                chromaAsset.Z += chromaAsset.Layer;
            }
        }
コード例 #2
0
        private void GenerateAssets(bool createFiles = true)
        {
            var xmlData = FileUtil.SolveXmlFile(XmlDirectory, "assets");

            if (xmlData == null)
            {
                return;
            }

            XmlNodeList assets = xmlData.SelectNodes("//assets/asset");

            for (int i = 0; i < assets.Count; i++)
            {
                var asset = assets.Item(i);

                var X = int.Parse(asset.Attributes.GetNamedItem("x").InnerText);
                var Y = int.Parse(asset.Attributes.GetNamedItem("y").InnerText);

                string imageName = asset.Attributes.GetNamedItem("name").InnerText;

                if (imageName.Contains(".props") || imageName.StartsWith("s_" + this.Sprite))
                {
                    continue;
                }

                if (!IsIcon)
                {
                    if (imageName.Contains("_icon_"))
                    {
                        continue;
                    }
                }
                else
                {
                    if (!imageName.Contains("_icon_"))
                    {
                        continue;
                    }
                }

                if (asset.Attributes.GetNamedItem("source") != null)
                {
                    var newChromaAsset = new ChromaAsset(this, X, Y, asset.Attributes.GetNamedItem("source").InnerText, imageName);
                    CreateAsset(newChromaAsset, asset, createFiles);
                }
                else
                {
                    var chromaAsset = new ChromaAsset(this, X, Y, null, imageName);
                    CreateAsset(chromaAsset, asset, createFiles);
                }
            }

            this.MaxStates = 0;

            var visualization = FileUtil.SolveXmlFile(XmlDirectory, "visualization");

            if (visualization == null)
            {
                return;
            }

            XmlNodeList animations = visualization.SelectNodes("//visualizationData/visualization[@size='" + (IsSmallFurni ? "32" : "64") + "']/animations/animation");

            if (animations == null || animations.Count == 0)
            {
                animations = visualization.SelectNodes("//visualizationData/visualization[@size='" + (IsSmallFurni ? "32" : "64") + "']/directions/direction[@id='" + RenderDirection + "']/animations/animation");
            }

            for (int i = 0; i < animations.Count; i++)
            {
                var animation = animations.Item(i);

                if (animation.Name != "animation" && animation.Attributes.GetNamedItem("id") == null)
                {
                    continue;
                }

                int state = int.Parse(animation.Attributes.GetNamedItem("id").InnerText);

                if (state > MaxStates)
                {
                    MaxStates = state;
                }
            }

            this.MaxStates             = MaxStates;
            this.HighestAnimationLayer = this.Assets.Where(x => !x.Shadow).ToList().Max(x => x.Layer) + 1;

            for (int i = 0; i < HighestAnimationLayer; i++)
            {
                //var letter = alphabet[i];
                //string letter = Convert.ToString(alphabet[i]);

                if (!this.Animations.ContainsKey(i))
                {
                    var animation = new ChromaAnimation();
                    this.Animations.Add(i, animation);

                    for (int j = 0; j < this.AnimationCount; j++)
                    {
                        if (!animation.States.ContainsKey(j))
                        {
                            var frame = new ChromaFrame();
                            frame.Frames.Add("0");

                            animation.States.Add(j, frame);
                        }
                    }
                }
            }
        }