/// <summary> /// Gather the targeted resource if it is next to it. /// </summary> internal void Gather(Point pos) { if (MoveTarget != null && pos.DistanceFrom(MoveTarget) == 1) { foreach (MapObject mo in Engine.Map.GetCellAt(MoveTarget).MapObjects) { if (mo.GetType().IsSubclassOf(typeof(Resource))) { if (mo.GetType().IsSubclassOf(typeof(Animal))) { Animal animal = (Animal)mo; if (animal.Dead) { if ((CarriedResourceType != ResourceType.Food)) { ResetAmount(); CarriedResourceType = ResourceType.Food; } Resource resource = (Resource)mo; int amount = HowMuchCanILoad(); if (amount > 3) { amount = 3; } amount = resource.gatherAmount(amount); AddAmount(amount); break; } } else { if (mo.GetType() == typeof(Mine) && CarriedResourceType != ResourceType.Gold) { ResetAmount(); CarriedResourceType = ResourceType.Gold; } if (mo.GetType() == typeof(Tree) && CarriedResourceType != ResourceType.Wood) { ResetAmount(); CarriedResourceType = ResourceType.Wood; } if ((mo.GetType() == typeof(Farm)) && (CarriedResourceType != ResourceType.Food)) { ResetAmount(); CarriedResourceType = ResourceType.Food; } Resource resource = (Resource)mo; int amount = HowMuchCanILoad(); if (amount > 3) { amount = 3; } amount = resource.gatherAmount(amount); AddAmount(amount); break; } } } } }