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); }
/// <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; } }
public bool InstallAt(TileObjectBase objectToInstall, TilePosition targetPosition) { Tile targetTile = TileAt(targetPosition); if (targetTile == null) { return(false); } targetTile.Install(objectToInstall); return(true); }
public BuildTask(TileObjectBase objectToBuild, int targetX, int targetY) { ObjectToBuild = objectToBuild; TargetX = targetX; TargetY = targetY; }