internal bool Buy(ObjectType type) { Util.Resources res = PriceDictionary.GetPrice(type); if ((Wood < res.Wood) || (Food < res.Food) || (Gold < res.Gold)) { return(false); } Wood -= res.Wood; Food -= res.Food; Gold -= res.Gold; return(true); }
internal void ClickMenuItem(GameObject sender) { ObjectType type = sender.GetComponent <Objects.Object>().Type; Debug.Log(type + " was clicked"); if (!HumanPlayer.Buy(type)) { HudManager.Debug("Not enough resources! Requires: " + PriceDictionary.GetPrice(type)); return; } // add building Building building = ObjectFactory.CreateBuilding(type); Tile tile = SelectionManager.SelectedUnit <Tile>(); tile.SetBuilding(building); HumanPlayer.AddObject(building); // clear build menu SelectionManager.Deselect(); HudManager.UpdateBuildMenu(); }