void CreateNewWagon(Rail rail) { const float wagonCost = 10f; if (Player.score < wagonCost) // check if enough money { ScoreText.color = Color.red; UserInformationText.text = "You do not have enough money to place a train wagon."; return; } if (rail.CurrentNumberOfWagons() >= rail.MaxNrOfWagons()) // also check if rail still has room for more trains // Debug.Log("Too many wagons already on this track, I'm not gonna put any more"); { UserInformationText.text = "Reached the maximum number of wagons on this track."; // have some player information here that its not possible return; } Player.score -= wagonCost; updateScore(); UserInformationText.text = "You placed a train wagon. This cost you " + (int)wagonCost + ".- CHF."; rail.AddWagon(); }