示例#1
0
        public AbstractGameAsset CreateGameAsset(Field f, AbstractGameAsset template, Vector3 pos, int level)
        {
            UUID uuid = UUID.Random();

            AbstractGameAsset asset = null;
            string            name  = string.Format("{0} ({1})", template.InitialNames[level], f.Name);

            if (template is Factory)
            {
                asset = new Factory(name, uuid, pos, level);
            }
            else if (template is Houses)
            {
                asset = new Houses(name, uuid, pos, level);
            }
            else if (template is Crops)
            {
                asset = new Crops(name, uuid, pos, level);
            }
            else
            {
                throw new Exception(string.Format("Unrecognized asset type {0}", template));
            }

            asset.InitialNames = template.InitialNames;
            asset.ConstructionCostsPerBuildStep = template.ConstructionCostsPerBuildStep;
            asset.StepsToBuilds      = template.StepsToBuilds;
            asset.NormalRevenues     = template.NormalRevenues;
            asset.WaterUsages        = template.WaterUsages;
            asset.MaintenanceCosts   = template.MaintenanceCosts;
            asset.InitialTimesToLive = template.InitialTimesToLive;
            asset.TimeToLive         = asset.InitialTimesToLive[level];
            asset.Field = f;
            asset.Game  = m_controller.Game;

            int revenue = m_controller.EconomicDistributor.Allocate(asset.Game.EconomicActivity, asset);

            if (template is Houses)
            {
                asset.MarketPrice = revenue;
            }
            else
            {
                asset.RevenueThisTurn = revenue;
            }

            return(asset);
        }
示例#2
0
        public AbstractGameAsset CreateGameAsset(Field f, AbstractGameAsset template, Vector3 pos, int level)
        {
            UUID uuid = UUID.Random();

            AbstractGameAsset asset = null;
            string name = string.Format("{0} ({1})", template.InitialNames[level], f.Name);

            if (template is Factory)
                asset = new Factory(name, uuid, pos, level);
            else if (template is Houses)
                asset = new Houses(name, uuid, pos, level);
            else if (template is Crops)
                asset = new Crops(name, uuid, pos, level);
            else
                throw new Exception(string.Format("Unrecognized asset type {0}", template));

            asset.InitialNames = template.InitialNames;
            asset.ConstructionCostsPerBuildStep = template.ConstructionCostsPerBuildStep;
            asset.StepsToBuilds = template.StepsToBuilds;
            asset.NormalRevenues = template.NormalRevenues;
            asset.WaterUsages = template.WaterUsages;
            asset.MaintenanceCosts = template.MaintenanceCosts;
            asset.InitialTimesToLive = template.InitialTimesToLive;
            asset.TimeToLive = asset.InitialTimesToLive[level];
            asset.Field = f;
            asset.Game = m_controller.Game;

            int revenue = m_controller.EconomicDistributor.Allocate(asset.Game.EconomicActivity, asset);
            if (template is Houses)
                asset.MarketPrice = revenue;
            else
                asset.RevenueThisTurn = revenue;

            return asset;
        }