示例#1
0
        public static Tile CreateAndParse(XElement element, TileMap tileMap)
        {
            if (element == null)
            {
                return(null);
            }

            int x = 0,
                y = 0;
            XAttribute xAttrib = element.Attribute("x");
            XAttribute yAttrib = element.Attribute("y");

            if (xAttrib != null)
            {
                x = Int32.Parse(xAttrib.Value);
            }
            if (yAttrib != null)
            {
                y = Int32.Parse(yAttrib.Value);
            }

            Tile tile = new Tile(tileMap, x, y);

            XElement installedObjectElement = element.Element("InstalledObject");

            if (installedObjectElement != null)
            {
                tile.InstalledObject = TileObjectBase.CreateAndParse(installedObjectElement, tile);
            }

            return(tile);
        }
示例#2
0
 /// <summary>
 /// Installs the specified object on this tile.
 /// </summary>
 /// <param name="objectToInstall">The object to install</param>
 public void Install(TileObjectBase objectToInstall)
 {
     if (!objectToInstall.Installed)
     {
         objectToInstall.OnInstalledAt(this);
         InstalledObject = objectToInstall;
     }
 }
示例#3
0
        public bool InstallAt(TileObjectBase objectToInstall, TilePosition targetPosition)
        {
            Tile targetTile = TileAt(targetPosition);

            if (targetTile == null)
            {
                return(false);
            }

            targetTile.Install(objectToInstall);
            return(true);
        }
示例#4
0
 public BuildTask(TileObjectBase objectToBuild, int targetX, int targetY)
 {
     ObjectToBuild = objectToBuild;
     TargetX       = targetX;
     TargetY       = targetY;
 }