private void OnTouch(object sender, PointerEventArgs e) { // Only when selling if (!building) { return; } for (int i = 0; i < e.Pointers.Count; i++) { // Tell if we touched a card if (e.Pointers[i].GetPressData().Target != null && e.Pointers[i].GetPressData().Target.tag == "Card") { // Store in var for easier handling Transform lastTouchedCard = e.Pointers[i].GetPressData().Target; int lastTouchedCardIndex = int.Parse(lastTouchedCard.name); // Check if we have money to buy a house if (Game.Instance.CurrentPlayer.playerCurrency >= Game.Instance.board.cardsPrice[lastTouchedCardIndex].price) { // Check if we own this card if (Game.Instance.CurrentPlayer.propertiesOwned.Contains(lastTouchedCardIndex)) { // Get the manager for this property HouseManager manager = Game.Instance.board.boardCardHouses[lastTouchedCardIndex]; // Build Houses for the prop if (manager != null && manager.currHouses < 5 && !manager.cantClickBuy) { // Buy house manager.BuyHouses(); // Get paid Game.Instance.CurrentPlayer.SubstractCurrency(manager.housePrice); // Refresh Info Game.Instance.CurrentPlayer.RefreshPlayerInfo(); } } } } } }