Exemplo n.º 1
0
        public async Task <IActionResult> Edit(List <PgreDB.Models.AllInfoPvPlantV> Model)
        {
            if (ModelState.IsValid)
            {
                if (Model.Count != 0)
                {
                    foreach (AllInfoPvPlantV item in Model)
                    {
                        PowerPlant tmpPP = _context.PowerPlants.Find(item.PowerPlantId);
                        tmpPP.Name         = item.EromuNeve;
                        tmpPP.LocationCity = item.LocationCity;
                        if (item.LocationParcelNumber != null)
                        {
                            tmpPP.LocationParcelNumber = item.LocationParcelNumber;
                        }
                        else
                        {
                            tmpPP.LocationParcelNumber = "";
                        }

                        tmpPP.LocationParcelNumber = item.LocationParcelNumber;
                        PvPlantPhysical tmpPPP = _context.PvPlantPhysicals
                                                 .Where(b => b.PowerPlantId == item.PowerPlantId)
                                                 .FirstOrDefault();
                        _context.Update(tmpPP);
                        _context.Update(tmpPPP);
                    }

                    await _context.SaveChangesAsync();
                }
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public Vessel(PowerPlant plant, Weapon weapon, String name)
 {
     _weapon = weapon;
     _plant  = plant;
     _name   = name;
     Console.WriteLine("The vessel " + _name + " created!");
 }
    public void ButtonClicked()
    {
        if (GameBoardViewModel.Instance.IsProductSelected())
        {
            GameBoardViewModel.Instance.DeselectProduct();
        }

        var        buttonName     = gameObject.name;
        GameObject createdProduct = null;
        IProduct   product;

        if (buttonName.Contains("Barrack"))
        {
            product             = new Barrack("Barrack", ProductType.Building, true, 0.5f);
            createdProduct      = ViewFactory.Create <IProduct, BuildingViewModel>(product, Resources.Load <GameObject>("Prefabs/Barrack"), null);
            createdProduct.name = "Barrack_Template";
        }

        if (buttonName.Contains("PowerPlant"))
        {
            product             = new PowerPlant("Power Plant", ProductType.Building, true, 0.5f);
            createdProduct      = ViewFactory.Create <IProduct, BuildingViewModel>(product, Resources.Load <GameObject>("Prefabs/PowerPlant"), null);
            createdProduct.name = "PowerPlant_Template";
        }
        GameBoardViewModel.Instance.SelectProduct(createdProduct);
    }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("PowerPlantId,Sitename,Contactname,ContactPhone,ContactEmail,Capacity,UsefulLife,ProjectCost,Loan")] PowerPlant powerPlant)
        {
            if (id != powerPlant.PowerPlantId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(powerPlant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PowerPlantExists(powerPlant.PowerPlantId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(powerPlant));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a structure
        /// </summary>
        /// <param name="type"></param>
        /// <param name="health"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="owner"></param>
        /// <param name="commandCenter"></param>
        /// <returns></returns>
        public static IStructure CreateStructure(StructureTypes type, float xPos, float yPos, Player owner, CommandCenter commandCenter, int currentAreaID, IPlayerLocator pl)
        {
            IStructure s;

            switch (type)
            {
            case (StructureTypes.LaserTurret):
                s = new Turret(_localIDManager.PopFreeID(), xPos, yPos, owner, commandCenter, currentAreaID, pl);
                break;

            case (StructureTypes.Biodome):
                s = new Biodome(xPos, yPos, _localIDManager.PopFreeID(), owner, currentAreaID);
                break;

            case (StructureTypes.PowerPlant):
                s = new PowerPlant(xPos, yPos, _localIDManager.PopFreeID(), owner, currentAreaID);
                break;

            case (StructureTypes.Silo):
                s = new Silo(xPos, yPos, _localIDManager.PopFreeID(), owner, currentAreaID);
                break;


            default:
                throw new Exception("CreateStructure not implemented for structure type " + type.ToString());
            }
            _galaxyRegistrationManager.RegisterObject(s);

            return(s);
        }
    // Update is called once per frame
    void Update()
    {
        UISelectedUpdate();

        if (GetSelected().Tag == "Beacon")
        {
            Beacon b = GetSelected().GetComponent <Beacon>();
            //radius
            resourceProduction.text = /* "-" + */ b.PowerRate.ToString();
            //power consumed per second
            resourceConsumption.text = b.Radius.ToString();
        }

        else if (GetSelected().Tag == "Factory")
        {
            Factory f = GetSelected().GetComponent <Factory>();
            //factory does not currently have/say anything about itself.
            resourceProduction.text  = "";
            resourceConsumption.text = "";
        }
        else if (GetSelected().Tag == "Farm")
        {
            Farm f = GetSelected().GetComponent <Farm>();
            //consuming mass
            resourceConsumption.text = /* "-" + */ f.MassRate.ToString();
            //producing food
            resourceProduction.text = "+" + f.FoodRate.ToString();
        }
        else if (GetSelected().Tag == "PowerPlant")
        {
            PowerPlant p = GetSelected().GetComponent <PowerPlant>();
            //consume mass
            resourceConsumption.text = /* "-" + */ p.MassRate.ToString();
            //produce power
            resourceProduction.text = "+" + p.PowerRate.ToString();
        }
        else if (GetSelected().Tag == "Base")
        {
            Base b = GetSelected().GetComponent <Base>();
            //consuming food
            resourceConsumption.text = b.FoodRate.ToString();
            //consuming power
            resourceProduction.text = b.PowerRate.ToString();
        }
        else if (GetSelected().Tag == "Victory")
        {
            //do nothing.
        }

        Debug.Log("The object is active and enabled: " + GetSelected().isActiveAndEnabled);
        if (GetSelected().On)
        {
            status.text = "Active";
        }
        else
        {
            status.text = "Inactive";
        }
    }
Exemplo n.º 7
0
 private static decimal GetCost(PowerPlant powerPlant, Fuel fuel)
 {
     return(powerPlant.Type switch
     {
         PowerPlantType.WindTurbine => 0.0M + GetCo2Cost(powerPlant, fuel),
         PowerPlantType.GasFired => (fuel.Gas / powerPlant.Efficiency) + GetCo2Cost(powerPlant, fuel),
         _ => (fuel.Kerosine / powerPlant.Efficiency) + GetCo2Cost(powerPlant, fuel)
     });
Exemplo n.º 8
0
        public bool AddPowerPlant(PowerPlant powerPlant)
        {
            var result = _simulationContext.AddPowerPlant(powerPlant);

            _backgroundTaskQueue.QueueBackgroundWorkItem(BackGroundTaskType.Simulation);

            return(result);
        }
Exemplo n.º 9
0
    public void CreateFactory()
    {
        Vector2    createPos  = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        PowerPlant powerplant = Instantiate(powerplantPrefab, createPos, Quaternion.identity);

        powerplant.gameObject.transform.parent = gameObject.transform;
        InfoController.m.scrollBar.SetActive(true);
    }
Exemplo n.º 10
0
        private double GetPowerGeneration(PowerPlant plant, Double normalValue)
        {
            double powerGeneration = plant.Capacity * normalValue;

            powerGeneration = (powerGeneration / plant.InclinationAngleEfficiency) * 100;
            powerGeneration = (powerGeneration / plant.DirectionAngleEfficiency) * 100;

            return(powerGeneration);
        }
Exemplo n.º 11
0
 public bool SpawnPowerPlant(int gridX, int gridY, int faction)
 {
     if (grid.GetTile(gridX, gridY) is ResourceTile)
     {
         PowerPlant pp = new PowerPlant(this, gridX, gridY, faction, world, grid);
         attackables.Add(pp);
         return(true);
     }
     return(false);
 }
Exemplo n.º 12
0
    void handleTileClick(MapCoords coords, TiledMap map)
    {
        Structure s = map.mapData.getStructure(coords);

        if (!(s is EmptyTile))
        {
            selector.Select(coords);
        }

        if (s is PowerPlant)
        {
            PowerPlant p = s as PowerPlant;
            //show current power grid
            int newPollution = powerHandler.StartSurge(coords, p.powerRange);
            pollutionHandler.pollute(newPollution);
        }
        else if (s is EmptyTile && structureToPlace != null)
        {
            if (moneyHandler.buyStructure(structureToPlace, coords))
            {
                selector.Select(coords);
            }
        }


        if (Input.GetKey(KeyCode.LeftShift))
        {
            if (structureToPlace is Conduit)
            {
                structureToPlace = new Conduit();
            }
            else if (structureToPlace is Miner)
            {
                structureToPlace = new Miner();
            }
            else if (structureToPlace is HeatLaser)
            {
                structureToPlace = new HeatLaser();
            }
            else if (structureToPlace is Surger)
            {
                structureToPlace = new Surger();
            }
            else
            {
                Debug.LogWarning("COULD NOT RECOGNIZE TYPE " + structureToPlace);
                structureToPlace = null;
            }
        }
        else
        {
            structureToPlace = null;
        }
    }
Exemplo n.º 13
0
        public async Task <IActionResult> Create([Bind("PowerPlantId,Sitename,Contactname,ContactPhone,ContactEmail,Capacity,UsefulLife,ProjectCost,Loan")] PowerPlant powerPlant)
        {
            if (ModelState.IsValid)
            {
                _context.Add(powerPlant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(powerPlant));
        }
        public void supply_1_gigawatt_of_power_to_the_electric_network()
        {
            var aPowerPlant        = new PowerPlant();
            var powerPlantConsumer = Substitute.For <Area>(new object[] { null });

            aPowerPlant.AddPowerReceiver(powerPlantConsumer);

            aPowerPlant.SupplyPower();

            powerPlantConsumer.Received(1).ReceiveFrom(aPowerPlant, OneGigawatt);
        }
Exemplo n.º 15
0
 public Resources()
 {
     MetalMine     = new MetalMine();
     CrystalMine   = new CrystalMine();
     DeuteriumMine = new DeuteriumMine();
     PowerPlant    = new PowerPlant();
     FusionPlant   = new FusionPlant();
     SolarSatelite = new SolarSatelite();
     MetalSilo     = new MetalSilo();
     CrystalSilo   = new CrystalSilo();
     DeuteriumSilo = new DeuteriumSilo();
 }
Exemplo n.º 16
0
 public OracleContext(IALogger logger = null)
     : base(new OraclePowerPlant(), logger)
 {
     DbType = DbTypeName.Oracle; var currDir =
         Path.GetDirectoryName(
             System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\";
     PowerPlant.DbContext        = this;
     ColumnTypeConverterForWrite =
         PowerPlant.CreateColumnTypeConverter(currDir + ConversionFileForWrite);
     ColumnTypeConverterForRead =
         PowerPlant.CreateColumnTypeConverter(currDir + ConversionFileForRead);
 }
        public void PowerPlantValidator_NameIsEmpty_ReturnsValidationError()
        {
            // Arrange
            var powerPlant = new PowerPlant(string.Empty, PowerPlantType.WindTurbine, 0.5m, 0, 100);

            // Act
            var result = _validator.TestValidate(powerPlant);

            // Assert
            result.IsValid.Should().BeFalse();
            result.ShouldHaveValidationErrorFor(p => p.Name);
        }
        public void PowerPlantValidator_PMaxIsSmallerThanPMin_ReturnsValidationError()
        {
            // Arrange
            var powerPlant = new PowerPlant("Test", PowerPlantType.WindTurbine, 0.8m, 20, 10);

            // Act
            var result = _validator.TestValidate(powerPlant);

            // Assert
            result.IsValid.Should().BeFalse();
            result.ShouldHaveValidationErrorFor(p => p.PMax);
        }
        public void PowerPlantValidator_TypeIsNotInEnum_ReturnsValidationError()
        {
            // Arrange
            var powerPlant = new PowerPlant("Test", (PowerPlantType)4, 1.2m, 0, 100);

            // Act
            var result = _validator.TestValidate(powerPlant);

            // Assert
            result.IsValid.Should().BeFalse();
            result.ShouldHaveValidationErrorFor(p => p.Type);
        }
        public void PowerPlantValidator_EfficiencyIsGreaterThan1_ReturnsValidationError()
        {
            // Arrange
            var powerPlant = new PowerPlant("Test", PowerPlantType.WindTurbine, 1.2m, 0, 100);

            // Act
            var result = _validator.TestValidate(powerPlant);

            // Assert
            result.IsValid.Should().BeFalse();
            result.ShouldHaveValidationErrorFor(p => p.Efficiency);
        }
        public void PowerPlantValidator_ValidPowerPlant_ReturnsNoValidationErrors()
        {
            // Arrange
            var powerPlant = new PowerPlant("Test", PowerPlantType.WindTurbine, 0.5m, 0, 100);

            // Act
            var result = _validator.TestValidate(powerPlant);

            // Assert
            result.IsValid.Should().BeTrue();
            result.ShouldNotHaveAnyValidationErrors();
        }
        public void supply_power_to_multiple_areas()
        {
            var aPowerPlant         = new PowerPlant();
            var anAreaConsumer      = Substitute.For <AreaPowerReceiver>();
            var anotherAreaConsumer = Substitute.For <AreaPowerReceiver>();

            aPowerPlant.AddPowerReceiver(anAreaConsumer);
            aPowerPlant.AddPowerReceiver(anotherAreaConsumer);

            aPowerPlant.SupplyPower();

            anAreaConsumer.Received(1).ReceiveFrom(aPowerPlant, Power.CreateMegawatts(500));
            anotherAreaConsumer.Received(1).ReceiveFrom(aPowerPlant, Power.CreateMegawatts(500));
        }
Exemplo n.º 23
0
        public async Task <IActionResult> Edit(PowerPlant input)
        {
            var entity = await _dbContext.PowerPlants.FirstOrDefaultAsync(e => e.Id == input.Id);

            if (entity == null)
            {
                entity = new PowerPlant();
                await _dbContext.PowerPlants.AddAsync(entity);
            }
            entity.Name = input.Name;
            await _dbContext.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public void PowerPlantValidator_MultipleInvalidProps_ReturnsMultipleValidationErrors()
        {
            // Arrange
            var powerPlant = new PowerPlant(null, PowerPlantType.Turbojet, 12, -4, 4);

            // Act
            var result = _validator.TestValidate(powerPlant);

            // Assert
            result.IsValid.Should().BeFalse();
            result.ShouldHaveValidationErrorFor(f => f.Name);
            result.ShouldHaveValidationErrorFor(f => f.Efficiency);
            result.ShouldHaveValidationErrorFor(f => f.PMin);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Creates a structure
        /// </summary>
        /// <param name="type"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="owner"></param>
        /// <param name="commandCenter"></param>
        /// <param name="currentAreaID"></param>
        /// <param name="pl"></param>
        /// <param name="writeToDB">If true, must specify dbm</param>
        /// <param name="dbm">must be specified if writeToDB is true</param>
        /// <returns></returns>
        public static IStructure CreateStructure(StructureTypes type, float xPos, float yPos, Player owner, CommandCenter commandCenter, int currentAreaID, IPlayerLocator pl, bool writeToDB = false, IDatabaseManager dbm = null)
        {
            IStructure s;

            switch (type)
            {
            case (StructureTypes.LaserTurret):
                TurretTypes t = owner.GetArea().AreaType == AreaTypes.Planet ? TurretTypes.Planet : TurretTypes.Space;
                s = new Turret(_localIDManager.PopFreeID(), xPos, yPos, owner.Id, currentAreaID, t, pl);

                break;

            case (StructureTypes.Biodome):
                return(CreateBiodome(xPos, yPos, owner, currentAreaID));

            case (StructureTypes.PowerPlant):
                s = new PowerPlant(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID);
                break;

            case (StructureTypes.Silo):
                s = new Silo(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID);
                break;

            case (StructureTypes.CommandCenter):
                return(CreateCommandCenter(xPos, yPos, owner, currentAreaID));

            case (StructureTypes.Factory):
                s = new Factory(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID);
                break;

            default:
                throw new Exception("CreateStructure not implemented for structure type " + type.ToString());
            }
            _galaxyRegistrationManager.RegisterObject(s);

            if (writeToDB)
            {
                if (dbm == null)
                {
                    throw new Exception("Error: must specify IDatabaseManager dbm if writeToDB is true.");
                }
                else
                {
                    dbm.SaveAsync(s);
                }
            }

            return(s);
        }
        /// <summary>
        /// Calculate price per MWh of a specific powerplant based on its efficiency, fuel price and Co2 for gas-fired
        /// </summary>
        private static decimal CalculatePricePerMWh(PowerPlant powerPlant, Fuels fuels)
        {
            // Produce electricity from wind is free
            // Only Gas-fired powerplant can generate Co2
            var pricePerMWh = powerPlant.Type switch
            {
                PowerPlantType.WindTurbine => 0,
                PowerPlantType.GasFired => fuels.GasPricePerMWh + Co2GeneratedPerMWh * fuels.Co2PricePerTon,
                PowerPlantType.Turbojet => fuels.KerosenePricePerMWh,
                _ => throw new ArgumentOutOfRangeException(nameof(powerPlant),
                                                           $"{powerPlant.Type} is an unknown powerplant type")
            };

            return(pricePerMWh / powerPlant.Efficiency);
        }
        public void get_monthly_report()
        {
            var aPowerPlant         = new PowerPlant();
            var aBuildingReport     = new BuildingConsumptionReport(Guid.NewGuid(), Power.CreateKilowatts(5));
            var someBuildingsReport = new List <BuildingConsumptionReport> {
                aBuildingReport, aBuildingReport
            };
            var someCitiesReport = new List <CityConsumptionReport> {
                new CityConsumptionReport(Guid.NewGuid(), someBuildingsReport),
                new CityConsumptionReport(Guid.NewGuid(), someBuildingsReport)
            };

            aPowerPlant.GetNotifiedOfElectricConsumeOff(new AreaConsumptionReport(Guid.NewGuid(), someCitiesReport));
            aPowerPlant.GetNotifiedOfElectricConsumeOff(new AreaConsumptionReport(Guid.NewGuid(), someCitiesReport));

            var monthlyReport = aPowerPlant.GetMonthlyReport();

            monthlyReport.TotalGeneratedPower.Should().BeEquivalentTo(OneGigawatt);
            monthlyReport.TotalConsumedPower().Should().BeEquivalentTo(Power.CreateKilowatts(40));
        }
    public Structure FactoryMethod(Structures structureType)
    {
        Structure  structure = null;
        Barracks   b         = new Barracks();
        PowerPlant p         = new PowerPlant();

        switch (structureType)
        {
        case Structures.Barracks:
            structure = b.createBarracks();
            break;

        case Structures.PowerPlant:
            structure = p.createPowerplant();
            break;

        default:
            return(null);
        }
        return(structure);
    }
Exemplo n.º 29
0
    public void SetSelectedPlant(PowerPlant p)
    {
        bool isBiddable = true;

        for (int i = biddableCount; i < inMarketPowerPlants.Count; i++)
        {
            if (((PowerPlant)inMarketPowerPlants[i]) == p)
            {
                isBiddable = false;
                break;
            }
        }

        if (!isBiddable)
        {
            return;
        }

        selectedPlant = p;
        currentBid    = p.baseCost;
        LayoutPowerPlantCards();
        LayoutPlayerMiniViews();
    }
Exemplo n.º 30
0
    public void ReadReciprocatingEngine(PowerPlant pp, bool flagMessage)
    {
        ReciprocatingEngine rp = new ReciprocatingEngine();

        pp.engine = rp;
        rp.pp     = pp;

        rp.engineName = ReadString("engine_name", flagMessage);
        rp.p_r        = ReadDblValue("p_takeoff", flagMessage);
        rp.p_ck       = ReadDblValue("p_max_0", flagMessage);
        rp.p_k        = ReadDblValue("p_max", flagMessage);
        rp.h_k        = ReadDblValue("rated_altitude", flagMessage);
        rp.h_k2_shift = ReadDblValue("blower_shift_altitude", flagMessage);
        rp.p_k2       = ReadDblValue("p_max_2", flagMessage);
        rp.h_k2       = ReadDblValue("rated_altitude_2", flagMessage);

        rp.propellerName = ReadString("propepper_name", flagMessage);
        rp.diameter      = ReadDblValue("diameter", flagMessage);
        rp.fm            = ReadDblValue("fm", flagMessage);
        rp.epsilon       = ReadDblValue("epsilon", flagMessage);

        rp.Init();
    }
Exemplo n.º 31
0
 public void Setup(PowerPlant p)
 {
     plant = p;
 }
Exemplo n.º 32
0
    public void SetSelectedPlant(PowerPlant p)
    {
        bool isBiddable = true;
        for (int i = biddableCount; i < inMarketPowerPlants.Count; i++) {
            if(((PowerPlant)inMarketPowerPlants[i])==p){
                isBiddable = false;
                break;
            }
        }

        if (!isBiddable)
            return;

        selectedPlant = p;
        currentBid = p.baseCost;
        LayoutPowerPlantCards ();
        LayoutPlayerMiniViews ();
    }
Exemplo n.º 33
0
 public void DeselectAll()
 {
     selectedPlant = null;
 }
Exemplo n.º 34
0
 public void SetPowerPlant(PowerPlant plant)
 {
     _powerPlant = plant;
 }
Exemplo n.º 35
0
        public Boolean LoadFromDB(VehicleData data, Int64 vehCoid = 0)
        {
            if (data == null)
                data = DataAccess.Vehicle.GetVehicle(vehCoid);

            if (data == null)
                return false;

            if (data.Ornament != -1L)
            {
                _ornament = new SimpleObject();
                _ornament.LoadFromDB(data.Ornament);
            }

            if (data.RaceItem != -1L)
            {
                _raceItem = new SimpleObject();
                _raceItem.LoadFromDB(data.RaceItem);
            }

            if (data.PowerPlant != -1L)
            {
                _powerPlant = new PowerPlant();
                _powerPlant.LoadFromDB(data.PowerPlant);
            }

            if (data.Wheelset != -1L)
            {
                _wheelSet = new WheelSet();
                _wheelSet.LoadFromDB(data.Wheelset);
            }

            if (data.Armor != -1L)
            {
                _armor = new Armor();
                _armor.LoadFromDB(data.Armor);
            }

            if (data.MeleeWeapon != -1L)
            {
                _meleeWeapon = new Weapon();
                _meleeWeapon.LoadFromDB(data.MeleeWeapon);
            }

            if (data.Front != -1L)
            {
                _weapons[0] = new Weapon();
                _weapons[0].LoadFromDB(data.Front);
            }

            if (data.Turret != -1L)
            {
                _weapons[1] = new Weapon();
                _weapons[1].LoadFromDB(data.Turret);
            }

            if (data.Rear != -1L)
            {
                _weapons[2] = new Weapon();
                _weapons[2].LoadFromDB(data.Rear);
            }

            InitializeFromCBID(data.Cbid, null);
            SetCOID(data.Coid);
            CoidCurrentOwner = data.OwnerCoid;
            TeamFaction = data.TeamFaction;
            Position = new Vector3(data.X, data.Y, data.Z);
            Rotation = new Vector4(data.Q1, data.Q2, data.Q3, data.Q4);
            Velocity = new Vector3();
            AngularVelocity = new Vector3();
            Trim = data.Trim;
            PrimaryColor = data.PrimaryColor;
            SecondaryColor = data.SecondaryColor;
            VehicleName = data.Name;

            IsInDB = true;

            return true;
        }