public ActionButtonTrain(RegisteredObject obj) : base(string.Empty)
        {
            this.entityData = obj.getPrefab().GetComponent <UnitBase>().getData();
            this.buttonText = this.entityData.getUnitTypeName() + " (" + this.entityData.cost + ")";

            this.setMainActionFunction((unit) => {
                BuildingTrainingHouse trainingHouse = (BuildingTrainingHouse)unit;
                if (trainingHouse.tryAddToQueue(obj))
                {
                    // Remove resources
                    trainingHouse.getTeam().reduceResources(this.entityData.cost);
                }
            });

            this.setShouldDisableFunction((entity) => {
                return(this.entityData.cost > entity.getTeam().getResources());
            });
        }
Exemple #2
0
    public ActionButtonTrain(RegisteredObject obj) : base(string.Empty)
    {
        this.unitData   = obj.getPrefab().GetComponent <UnitBase>().unitData;
        this.buttonText = this.unitData.unitName + " (" + 0 + ")";

        this.setMainActionFunction((unit) => {
            BuildingTrainingHouse trainingHouse = (BuildingTrainingHouse)unit;
            if (trainingHouse.tryAddToQueue(obj))
            {
                // Remove resources
                trainingHouse.map.reduceResources(trainingHouse.getTeam(), 0);
            }
        });

        this.setShouldDisableFunction((entity) => {
            BuildingTrainingHouse trainingHouse = ((BuildingTrainingHouse)entity);
            return(0 > Player.localPlayer.currentTeamResources || trainingHouse.isQueueFull());
        });
    }