/* * Building.cs * Authors: Bradley Blankenship * Copyright (c) 2007-2008 Cornell University This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework.Content; namespace BuildingSharedContent { /// /// Represents a building in the system. /// public abstract class Building { #region Fields // The name of the building string mName; // The name of the model for the building string mModelName; // The footprint size of the building int mFootPrintSize; // The amount of people it takes to run this int mRequiredUnskilledWorkers; int mRequiredSkilledWorkers; // The number of actual workers in the building int mUnskilledWorkers; int mSkilledWorkers; // The map of resource names and costs Dictionary mResourceCosts; // The map of resources and costs for upkeep Dictionary mUpkeepCosts; // The target building to upgrade to Building mTargetUpgrade; // The upgrade technologies for upgrading List mUpgradeTechnologies; // The upgrade costs for upgrading Dictionary mUpgradeCosts; // The costs string used for initializing the costs of the building string mCostsString; // The costs string used for initializing the upkeep costs of the building string mUpkeepString; // The upgrade string used for initializing the upgrade requirements string mUpgradeString; #endregion #region Properties /// /// Allows access to the name of the building. /// public string Name { get { return mName; } set { mName = value; } } /// /// Allows access to the name of the building's model. /// public string ModelName { get { return mModelName; } set { mModelName = value; } } /// /// Allows access to the footprint size of the building. /// public int FootPrintSize { get { return mFootPrintSize; } set { mFootPrintSize = value; } } /// /// Exposed serialized property used solely for creating the costs for /// the building. /// public string Costs { get { return mCostsString; } set { mCostsString = value; } } /// /// Allows access to the required number of unskilled workers. /// public int RequiredUnskilledWorkers { get { return mRequiredUnskilledWorkers; } set { mRequiredUnskilledWorkers = value; } } /// /// Allows access to the required number of skilled workers. /// public int RequiredSkilledWorkers { get { return mRequiredSkilledWorkers; } set { mRequiredSkilledWorkers = value; } } /// /// Exposed the upkeep string for the value. /// public string Upkeep { get { return mUpkeepString; } set { mUpkeepString = value; } } /// /// Allows access to the upgrade string. /// public string Upgrade { get { return mUpgradeString; } set { mUpgradeString = value; } } /// /// Allows access to the actual numbers of unskilled workers in the /// building. /// [ContentSerializerIgnore] public int UnskilledWorkers { get { return mUnskilledWorkers; } set { mUnskilledWorkers = value; } } /// /// Allows access to the actual numbers of skilled workers in the /// building. /// [ContentSerializerIgnore] public int SkilledWorkers { get { return mSkilledWorkers; } set { mSkilledWorkers = value; } } /// /// Allow viewing and use of the costs for the building. /// [ContentSerializerIgnore] public Dictionary ResourceCosts { get { return mResourceCosts; } } /// /// Allow viewing and use of the costs for upkeeping the building. /// [ContentSerializerIgnore] public Dictionary UpkeepCosts { get { return mUpkeepCosts; } } /// /// Represents the building for the targeted upgrade. /// [ContentSerializerIgnore] public Building TargetUpgrade { get { return mTargetUpgrade; } set { mTargetUpgrade = value; } } /// /// Allows viewing and use of the upgrade technology list. /// [ContentSerializerIgnore] public List UpgradeTechnologies { get { return mUpgradeTechnologies; } } /// /// Allows viewing and use of the upgrade costs /// [ContentSerializerIgnore] public Dictionary UpgradeCosts { get { return mUpgradeCosts; } } #endregion #region Constructs /// /// Base constructor /// public Building() { // Initialize all values needed mResourceCosts = new Dictionary(); mUpkeepCosts = new Dictionary(); mUpgradeTechnologies = new List(); mUpgradeCosts = new Dictionary(); } #endregion #region Initialization /// /// Iinitialize the building, loading the content required if needed. /// public abstract void Initialize(); #endregion /// /// Return the information of the building in string form. /// /// Returns the basic building information. public override string ToString() { // Return the basic information return Name + ", " + ModelName + ", " + FootPrintSize; } } }