コード例 #1
0
        public static bool switchLayersAction(string action, GameLocation location, Vector2 tile, string layer)
        {
            string[] actions = action.Split(' ');

            foreach (string s in actions)
            {
                string[] layers = s.Split(':');
                if (layers.Length > 1)
                {
                    if (layers.Length < 4)
                    {
                        location.map.switchLayers(layers[0], layers[1]);
                    }
                    else
                    {
                        string[] xStrings = layers[2].Split('-');
                        string[] yStrings = layers[3].Split('-');
                        Range    xRange   = new Range(int.Parse(xStrings[0]), int.Parse(xStrings.Last()) + 1);
                        Range    yRange   = new Range(int.Parse(yStrings[0]), int.Parse(yStrings.Last()) + 1);

                        foreach (int x in xRange.toArray())
                        {
                            foreach (int y in yRange.toArray())
                            {
                                location.map.switchTileBetweenLayers(layers[0], layers[1], x, y);
                            }
                        }
                    }
                }
            }

            return(true);
        }
コード例 #2
0
        public static bool copyLayersAction(string action, GameLocation location, Vector2 tile, string layer)
        {
            string[] actions = action.Split(' ');

            foreach (string s in actions)
            {
                string[] layers = s.Split(':');
                if (layers.Length > 1)
                {
                    if (layers.Length < 4)
                    {
                        Layer l = location.map.GetLayer(layers[0]);
                        if (l != null)
                        {
                            var size = new Microsoft.Xna.Framework.Rectangle(0, 0, l.DisplayWidth / Game1.tileSize, l.DisplayHeight / Game1.tileSize);

                            for (int x = 0; x < size.Width; x++)
                            {
                                for (int y = 0; y < size.Height; y++)
                                {
                                    copyTileBetweenLayers(location.map, layers[0], layers[1], x, y);
                                }
                            }
                        }
                    }
                    else
                    {
                        string[] xStrings = layers[2].Split('-');
                        string[] yStrings = layers[3].Split('-');
                        Range    xRange   = new Range(int.Parse(xStrings[0]), int.Parse(xStrings.Last()) + 1);
                        Range    yRange   = new Range(int.Parse(yStrings[0]), int.Parse(yStrings.Last()) + 1);

                        foreach (int x in xRange.toArray())
                        {
                            foreach (int y in yRange.toArray())
                            {
                                copyTileBetweenLayers(location.map, layers[0], layers[1], x, y);
                            }
                        }
                    }
                }
            }

            return(true);
        }