예제 #1
0
        /// <summary>
        /// Constructs a Building instance.
        /// </summary>
        /// <param name="buildingTypeName">The name of the type of this building.</param>
        /// <param name="behaviors">The list of behaviors of this building.</param>
        protected Building(string buildingTypeName, params EntityBehavior[] behaviors)
            : base(buildingTypeName, false, behaviors)
        {
            this.buildingType = new IBuildingType(this.ElementType.ElementTypeImpl as IBuildingTypeInternal);

            // Create and register the basic production lines of this building based on the metadata.
            List <IUnitType>    unitTypes    = new List <IUnitType>(this.buildingType.UnitTypes);
            List <IAddonType>   addonTypes   = new List <IAddonType>(this.buildingType.AddonTypes);
            List <IUpgradeType> upgradeTypes = new List <IUpgradeType>(this.buildingType.UpgradeTypes);

            if (unitTypes.Count > 0)
            {
                ProductionLine unitProductionLine = new UnitProductionLine(this, unitTypes);
                this.RegisterProductionLine(unitProductionLine);
            }
            if (addonTypes.Count > 0)
            {
                ProductionLine addonProductionLine = new AddonProductionLine(this, addonTypes);
                this.RegisterProductionLine(addonProductionLine);
            }
            if (upgradeTypes.Count > 0)
            {
                ProductionLine upgradeProductionLine = new UpgradeProductionLine(this, upgradeTypes);
                this.RegisterProductionLine(upgradeProductionLine);
            }
        }
예제 #2
0
        /// <summary>
        /// Constructs an Addon instance.
        /// </summary>
        /// <param name="addonTypeName">The name of the type of this addon.</param>
        /// <param name="behaviors">The list of behaviors of this addon.</param>
        protected Addon(string addonTypeName, params EntityBehavior[] behaviors)
            : base(addonTypeName, false, behaviors)
        {
            this.addonType = new IAddonType(this.ElementType.ElementTypeImpl as IAddonTypeInternal);

            // Create and register the basic production lines of this addon based on the metadata.
            List <IUpgradeType> upgradeTypes = new List <IUpgradeType>(this.addonType.UpgradeTypes);

            if (upgradeTypes.Count > 0)
            {
                ProductionLine upgradeProductionLine = new UpgradeProductionLine(this, upgradeTypes);
                this.RegisterProductionLine(upgradeProductionLine);
            }
        }