コード例 #1
0
        }        //returns the building id

        public int buildFarm(int buildTime)
        {
            int buildingID = -1;

            if (Treasury.haveEnoughToWithdraw(Consts.farm_costtobuild))
            {
                Job   farmerJob;
                int[] farmJobs = new int[Consts.numberOfFarmersPerFarm];

                buildingID = Program._aStronghold._buildingsList.Count + 1;

                for (int i = 0; i < Consts.numberOfFarmersPerFarm; i++)
                {
                    farmerJob   = Job_creater.createFarmerJob(buildingID);
                    farmJobs[i] = farmerJob.JobID;
                    _allJobs.AddLast(farmerJob);
                }                 //creates jobs for the farmer

                BuildingWithJobsAndInventory farm =
                    new BuildingWithJobsAndInventory(buildingID,                          //building ID
                                                     _leader._id,                         //owner ID
                                                     Consts.farm,                         //type
                                                     Consts.farm_name,                    //name
                                                     Consts.farm_hp,                      //hp
                                                     Consts.farm_costtobuild,             //cost to build
                                                     new Status(1, Consts.farm_maxlevel), //level
                                                     Program._gametime,                   //start build time
                                                     buildTime,                           //build time
                                                     farmJobs,                            //jobs
                                                     null,                                //inventory
                                                     BuildingState.Planned,
                                                     new Status(0, 0));

                Program._aStronghold._buildingsList.AddLast(farm);
                Treasury.withdrawGold(Consts.farm_costtobuild);
            }    //have enough money to build farm
            return(buildingID);
        }        //returns building ID