public FarmObject(Cabin cabin)
 {
     Type    = GameObjectTypes.Building;
     Element = cabin.Element;
     TileX   = cabin.TileX;
     TileY   = cabin.TileY;
     Width   = cabin.Width + 1;
     Height  = cabin.Height + 1;
     SetTileXYRange();
 }
        public bool MoveToValidLocation(Cabin cabin)
        {
            var objects = new GameObjects(this);
            var moved   = objects.MoveToValidLocation(cabin);

            if (!moved)
            {
                Console.WriteLine("There were no valid locations found for the new cabin on your farm.");
            }
            return(moved);
        }
        public void SwitchCabin(Cabin cabin)
        {
            var element = new XElement(cabin.Element);
            var x       = TileX;
            var y       = TileY;

            TileX = x;
            TileY = y;
            cabin.UpdateFarmhand(Farmhand);
            Element.ReplaceAll(cabin.Element.Nodes());
        }
        public Cabin CreateNewCabin(Cabin cabin)
        {
            cabin.UpdateFarmhand(Host);
            UpdateHost();
            var moved = MoveToValidLocation(cabin);

            if (moved)
            {
                Farm.Element("buildings").Add(cabin.Element);
                return(cabin);
            }
            return(null);
        }
Exemple #5
0
        public bool MoveToValidLocation(Cabin originalCabin)
        {
            var cabin = new FarmObject(originalCabin);
            Tuple <int, int, bool> location;

            location = FindValidLocation(cabin);
            if (location == null)
            {
                return(false);
            }
            if (location.Item3)
            {
                ClearLocationForCabin(location.Item1, location.Item2, cabin);
            }
            originalCabin.TileX = location.Item1;
            originalCabin.TileY = location.Item2;
            return(true);
        }
Exemple #6
0
 public Farmhand(XElement element, bool inGame, bool isCabin = false)
 {
     InGame    = inGame;
     InStorage = !InGame;
     Cabin     = new Cabin(element);
 }
 public XElement SwitchHost(Cabin cabin)
 {
     return(SwitchHost(cabin.Farmhand, cabin.Element));
 }