/* * Check if the tile is a valid tile to be picked and if so, pick it * and handle inventory changes. */ void TryPicking() { bool isAction = RBInput.GetButtonDownForPlayer(InputStrings.ACTION, PlayerIndex, playerDevice); if (isAction) { //.TODO This violates MVC, fix it if (actionTile != null) { GroundTile tile = (GroundTile)actionTile.GetComponent <GroundTile> (); Plant plant = tile.getPlant(); if (plant != null && plant.isRipe()) { Inventory inventory = (Inventory)GetComponent <Inventory> (); int pickedItemID = tile.Pick(); inventory.AddItem(pickedItemID, 1); AudioSource.PlayClipAtPoint(backpackSound, transform.position); } } } }