Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UnitBase"/> class.
        /// </summary>
        /// <param name="row"></param>
        public UnitBase(DataRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            this.unitId           = Convert.ToInt32(row["UnitID"], CultureInfo.InvariantCulture);
            this.Name             = Convert.ToString(row["Name"], CultureInfo.InvariantCulture);
            this.bombardmentRange = Convert.ToInt32(row["BombardmentRange"], CultureInfo.InvariantCulture);
            this.bombardmentPower = Convert.ToInt32(row["Bombardment"], CultureInfo.InvariantCulture);
            this.canMergeWithCity = Convert.ToBoolean(row["CanMergeWithCity"], CultureInfo.InvariantCulture);
            this.canSettle        = Convert.ToBoolean(row["CanSettle"], CultureInfo.InvariantCulture);
            this.canWork          = Convert.ToBoolean(row["CanWork"], CultureInfo.InvariantCulture);
            this.Cost             = Convert.ToInt32(row["Cost"], CultureInfo.InvariantCulture);
            this.defense          = Convert.ToInt32(row["Defense"], CultureInfo.InvariantCulture);
            this.rank             = UnitRank.Conscript;
            this.type             = (UnitType)Enum.Parse(typeof(UnitType), row["Type"].ToString(), true);
            this.hitPoints        = this.MaxHitPoints;
            this.movesPerTurn     = Convert.ToInt32(row["Movement"], CultureInfo.InvariantCulture);
            this.movesLeft        = this.movesPerTurn;
            this.offensivePower   = Convert.ToInt32(row["Attack"], CultureInfo.InvariantCulture);
            this.populationPoints = Convert.ToInt32(row["PopulationPoints"], CultureInfo.InvariantCulture);
            this.rateOfFire       = Convert.ToInt32(row["RateOfFire"], CultureInfo.InvariantCulture);
            this.neededResources  = new NamedObjectCollection <Resource>();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CountryBase"/> class.
 /// </summary>
 public CountryBase()
 {
     this.availableGovernments = new NamedObjectCollection <Government>();
     this.availableResources   = new NamedObjectCollection <Resource>();
     this.units = new NamedObjectCollection <UnitBase>();
     this.acquiredTechnologies     = new NamedObjectCollection <Technology>();
     this.researchableTechnologies = new NamedObjectCollection <Technology>();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CityBase"/> class.
 /// </summary>
 public CityBase()
 {
     this.population         = 1;
     this.happyPeople        = 1;
     this.sizeClass          = CitySizeClass.Town;
     this.buildableItems     = new NamedObjectCollection <BuildableItem>();
     this.availableResources = new NamedObjectCollection <Resource>();
     this.improvements       = new NamedObjectCollection <Improvement>();
     this.usedCells          = new Collection <Point>();
 }
Exemplo n.º 4
0
        private void LoadTerrains(DataTable terrainTable)
        {
            this.terrains = new NamedObjectCollection <Terrain>();

            Terrain terrain;

            foreach (DataRow row in terrainTable.Rows)
            {
                terrain = new Terrain(row);
                this.terrains.Add(terrain);
            }
        }
Exemplo n.º 5
0
        private void LoadResources(DataTable resourcesTable)
        {
            this.resources = new NamedObjectCollection <Resource>();

            Resource resource;

            foreach (DataRow row in resourcesTable.Rows)
            {
                resource = new Resource(row);
                this.resources.Add(resource);
            }
        }
Exemplo n.º 6
0
        private void LoadUnits(DataTable unitsTable)
        {
            this.units = new NamedObjectCollection <UnitBase>();

            UnitBase unit;

            foreach (DataRow row in unitsTable.Rows)
            {
                unit = new UnitBase(row);
                this.units.Add(unit);
            }
        }
Exemplo n.º 7
0
        private void LoadImprovements(DataTable improvementTable)
        {
            this.improvements = new NamedObjectCollection <Improvement>();

            Improvement improvement;

            foreach (DataRow row in improvementTable.Rows)
            {
                improvement = new Improvement(row);
                this.improvements.Add(improvement);
            }
        }
Exemplo n.º 8
0
        private void LoadGovernments(DataTable governmentTable)
        {
            this.governments = new NamedObjectCollection <Government>();

            Government government;

            foreach (DataRow row in governmentTable.Rows)
            {
                government = new Government(row);
                this.governments.Add(government);
            }
        }
Exemplo n.º 9
0
        private void LoadCivilizations(DataTable civilizationTable)
        {
            this.civilizations = new NamedObjectCollection <Civilization>();

            Civilization civilization;

            foreach (DataRow row in civilizationTable.Rows)
            {
                civilization = new Civilization(row);
                this.civilizations.Add(civilization);
            }
        }
Exemplo n.º 10
0
        private void LoadEras(DataTable eraTable)
        {
            this.eras = new NamedObjectCollection <Era>();

            Era era;

            foreach (DataRow row in eraTable.Rows)
            {
                era = new Era(row);
                this.eras.Add(era);
            }
        }
Exemplo n.º 11
0
        private void LoadTechnologies(DataTable technologyTable)
        {
            this.technologies = new NamedObjectCollection <Technology>();

            Technology technology;

            foreach (DataRow row in technologyTable.Rows)
            {
                technology     = new Technology(row);
                technology.Era = GetEra(technology.EraId);
                this.technologies.Add(technology);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Resource"/> class.
        /// </summary>
        /// <param name="row">A <c>System.Data.DataRow</c> with the
        /// information about the Resource.</param>
        public Resource(DataRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            this.commerceEffect       = Convert.ToInt32(row["Commerce"], CultureInfo.InvariantCulture);
            this.foodEffect           = Convert.ToInt32(row["Food"], CultureInfo.InvariantCulture);
            this.Name                 = Convert.ToString(row["Name"], CultureInfo.InvariantCulture);
            this.railroadPrerequisite = Convert.ToBoolean(row["IsRailroadPrerequisite"], CultureInfo.InvariantCulture);
            this.shieldEffect         = Convert.ToInt32(row["Shields"], CultureInfo.InvariantCulture);
            this.terrains             = new NamedObjectCollection <Terrain>();
            this.requiredTechnologies = new NamedObjectCollection <Technology>();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Government"/> class.
        /// </summary>
        /// <param name="row">A <c>System.Data.DataRow</c> containing the information
        /// about the Government.</param>
        public Government(DataRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            this.Name                 = Convert.ToString(row["Name"], CultureInfo.InvariantCulture);
            this.fallback             = Convert.ToBoolean(row["IsFallback"], CultureInfo.InvariantCulture);
            this.freeCityUnits        = Convert.ToInt32(row["FreeCityUnits"], CultureInfo.InvariantCulture);
            this.freeMetropolisUnits  = Convert.ToInt32(row["FreeMetropolisUnits"], CultureInfo.InvariantCulture);
            this.freeTownUnits        = Convert.ToInt32(row["FreeTownUnits"], CultureInfo.InvariantCulture);
            this.leaderTitle          = Convert.ToString(row["LeaderTitle"], CultureInfo.InvariantCulture);
            this.primary              = Convert.ToBoolean(row["IsPrimary"], CultureInfo.InvariantCulture);
            this.requiredTechnologies = new NamedObjectCollection <Technology>();

            int efficiency = Convert.ToInt32(row["WorkerEfficiencyFactor"], CultureInfo.InvariantCulture);

            switch (efficiency)
            {
            case 1:
                this.workerEfficiency = WorkerEfficiency.Normal;
                break;

            case 2:
                this.workerEfficiency = WorkerEfficiency.PlusTwentyFivePercent;
                break;

            case 3:
                this.workerEfficiency = WorkerEfficiency.PlusFiftyPercent;
                break;

            case -2:
                this.workerEfficiency = WorkerEfficiency.MinusTwentyFivePercent;
                break;

            case -3:
                this.workerEfficiency = WorkerEfficiency.MinusFiftyPercent;
                break;

            default:
                throw new InvalidOperationException(McKnight_Similization_Core.UnknownWorkerEfficiency);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Technology"/> class.
        /// </summary>
        /// <param name="row">A <c>System.Data.DataRow</c> object containing the
        /// information about the technology.</param>
        public Technology(DataRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            this.technologyID = Convert.ToInt32(row["TechnologyID"], CultureInfo.InvariantCulture);
            this.eraId        = Convert.ToInt32(row["EraID"], CultureInfo.InvariantCulture);
            this.Name         = Convert.ToString(row["Name"], CultureInfo.InvariantCulture);
            if (!row.IsNull("RequiredForNextEra"))
            {
                this.requiredForEraAdvance = Convert.ToBoolean(row["RequiredForNextEra"], CultureInfo.InvariantCulture);
            }
            if (!row.IsNull("RequiredForEspionage"))
            {
                this.requiredForEspionage = Convert.ToBoolean(row["RequiredForEspionage"], CultureInfo.InvariantCulture);
            }
            this.requiredResearchUnits = Convert.ToInt32(row["ResearchUnits"], CultureInfo.InvariantCulture);
            this.requiredTechnologies  = new NamedObjectCollection <Technology>();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Civilization"/> class.
        /// </summary>
        /// <param name="row">A <see cref="System.Data.DataRow"/> containing the
        /// record of the Civilization information.</param>
        public Civilization(DataRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            this.civilizationId       = Convert.ToInt32(row["CivilizationID"], CultureInfo.InvariantCulture);
            this.adjective            = (string)row["Adjective"];
            this.noun                 = (string)row["Noun"];
            this.expansionist         = Convert.ToBoolean(row["Expansionist"], CultureInfo.InvariantCulture);
            this.commercial           = Convert.ToBoolean(row["Commercial"], CultureInfo.InvariantCulture);
            this.industrious          = Convert.ToBoolean(row["Industrious"], CultureInfo.InvariantCulture);
            this.leaderName           = (string)row["LeaderName"];
            this.militaristic         = Convert.ToBoolean(row["Militaristic"], CultureInfo.InvariantCulture);
            this.Name                 = (string)row["Name"];
            this.religious            = Convert.ToBoolean(row["Religious"], CultureInfo.InvariantCulture);
            this.scientific           = Convert.ToBoolean(row["Scientific"], CultureInfo.InvariantCulture);
            this.startingTechnologies = new NamedObjectCollection <Technology>();
            this.cityNames            = new Collection <string>();
        }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Improvement"/> class.
 /// </summary>
 public Improvement()
 {
     this.requiredImprovements = new NamedObjectCollection <Improvement>();
     this.requiredResources    = new NamedObjectCollection <Resource>();
     this.requiredTechnologies = new NamedObjectCollection <Technology>();
 }
Exemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnitBase"/> class.
 /// </summary>
 public UnitBase()
 {
     this.neededResources = new NamedObjectCollection <Resource>();
 }