GetBlock() public method

public GetBlock ( int dir ) : bool
dir int
return bool
コード例 #1
0
ファイル: Map.cs プロジェクト: 2cwldys/fodev-tools
        private bool clickBlocks(int x, int y)
        {
            if (!((x % bsize(1) >= Config.LineSize) ^ (y % bsize(1) >= Config.LineSize)))
            {
                return(true);
            }

            int  dir  = 0;
            Tile tile = null;
            int  tx   = 0;
            int  ty   = 0;

            if ((x % bsize(1) < Config.LineSize))
            {
                tx  = x / bsize(1);
                ty  = y / bsize(1);
                dir = Directions.West;
                if (tx == Width)
                {
                    dir = Directions.East;
                    tx--;
                }
                if (ty == Height)
                {
                    ty--;
                }
            }
            else
            {
                tx  = x / bsize(1);
                ty  = y / bsize(1);
                dir = Directions.North;
                if (ty == Height)
                {
                    dir = Directions.South;
                    ty--;
                }
            }
            tile = tiles[tx, ty];
            if (lastToggle == -1)
            {
                if (tile.GetBlock(dir))
                {
                    lastToggle = 0;
                }
                else
                {
                    lastToggle = 1;
                }
            }
            if (lastToggle == 1 && !tile.GetBlock(dir) || lastToggle == 0 && tile.GetBlock(dir))
            {
                ChangeToggleBlock change = new ChangeToggleBlock(tx, ty, dir);
                apply(change);
            }

            return(true);
        }
コード例 #2
0
ファイル: Map.File.cs プロジェクト: Venseer/tools
        /// <summary>
        /// Save the map instance.
        /// </summary>
        /// <param name="fileName">File name for the saved map</param>
        public void Save(string fileName)
        {
            XmlDocument d    = new XmlDocument();
            XmlElement  root = d.CreateElement("tilemap");

            root.SetAttribute("version", Config.MapVersion);
            d.AppendChild(root);

            XmlElement el = d.CreateElement("header");

            el.SetAttribute("width", Width.ToString());
            el.SetAttribute("height", Height.ToString());
            el.SetAttribute("details", post.ToString().ToLower());

            d.DocumentElement.AppendChild(el);

            XmlElement blocks = d.CreateElement("scrollblockers");

            for (int i = 1; i < scrollBlockers.Count; i++)
            {
                XmlElement bl = d.CreateElement("scrollblocker");
                bl.SetAttribute("x", scrollBlockers[i].First.ToString());
                bl.SetAttribute("y", scrollBlockers[i].Second.ToString());
                blocks.AppendChild(bl);
            }
            d.DocumentElement.AppendChild(blocks);

            XmlElement allTiles = d.CreateElement("tiles");

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Tile       tile = tiles[x, y];
                    XmlElement t    = d.CreateElement("tile");
                    t.SetAttribute("x", x.ToString());
                    t.SetAttribute("y", y.ToString());
                    t.SetAttribute("variant", tile.Variant.ToString());
                    t.SetAttribute("wide", tile.Wide.ToString().ToLower());
                    t.SetAttribute("walls",
                                   tile.GetBlock(Directions.North).ToString().ToLower() + "," +
                                   tile.GetBlock(Directions.East).ToString().ToLower() + "," +
                                   tile.GetBlock(Directions.South).ToString().ToLower() + "," +
                                   tile.GetBlock(Directions.West).ToString().ToLower()
                                   );
                    if (tile.Filled)
                    {
                        t.SetAttribute("filled", true.ToString().ToLower());
                    }
                    allTiles.AppendChild(t);
                }
            }
            d.DocumentElement.AppendChild(allTiles);

            d.Save(fileName);
        }
コード例 #3
0
ファイル: Tile.cs プロジェクト: 2cwldys/fodev-tools
 public Tile AttachToTile(Tile tile, int fromDir)
 {
     tile.attachTile(this, fromDir);
     neighbours[(fromDir + 2) % 4] = tile;
     blocks[(fromDir + 2) % 4]     = tile.GetBlock(fromDir);
     return(this);
 }
コード例 #4
0
ファイル: Tile.cs プロジェクト: SnakeSolidNL/tools
 public Tile AttachToTile(Tile tile, int fromDir)
 {
     tile.attachTile(this, fromDir);
     neighbours[(fromDir + 2) % 4] = tile;
     blocks[(fromDir + 2) % 4] = tile.GetBlock(fromDir);
     return this;
 }