示例#1
0
        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);
        }
示例#2
0
        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();
        }