public virtual void Act(ContentObject actingObject, Character actingCharacter, Vector2 location) { }
public override void Act(ContentObject actingObject, Character actingCharacter, Vector2 location) { base.Act(actingObject, actingCharacter, location); Crop crop = GetCrop(Map.Name, location); int tileIndex = GetTileIndexAtLocation(0, location); int tileIndexValue = GetTileValueAtLocation(0, location); #region CONTAINERS /// open the container and then return ItemContainer container = GetCollidingContainer(); if (container != null && OnContainerOpened != null) { OnContainerOpened(container); return; } #endregion /// IF THERE IS A CROP THERE if (crop != null) { if (crop.IsGrown) { Session.AddInventory(crop); RemoveCrop(_map.Name, crop.GetHashCode()); actingCharacter.State = Character.CharacterState.Idle; } else if (actingObject is Tool) { Tool tool = (actingObject as Tool); switch (tool.Type) { case "WateringCan": crop.IsWatered = true; Map.BaseLayer[tileIndex] = (int)TILES.DARKDIRT; /// remove the current handler because we want to have more /// time for the watering :P crop.OnNoLongerWatered -= new Crop.OnNoLongerWateredHandler(crop_OnNoLongerWatered); crop.OnNoLongerWatered += new Crop.OnNoLongerWateredHandler(crop_OnNoLongerWatered); break; } } } /// THERE IS NO CROP else { if (actingObject is Tool) { Tool tool = (actingObject as Tool); switch (tool.Type) { case "Hoe": if (tileIndexValue == (int)TILES.LIGHTGRASS || tileIndexValue == (int)TILES.MEDIUMGRASS || tileIndexValue == (int)TILES.DARKGRASS) Map.BaseLayer[tileIndex] = (int)TILES.LIGHTDIRT; break; } } else if (actingObject is Crop) { if (tileIndexValue == (int)TILES.LIGHTDIRT || tileIndexValue == (int)TILES.DARKDIRT) { Crop c = actingObject as Crop; c.Coordinates = GetCollidingTileVector2(location); AddCrop(Map.Name, c); Session.RemoveInventory(c); Session.SelectedInventoryItem = null; } } } }