protected override void Start() { consumerableEnergyType = EnType.Electric; Electricity electricity = new Electricity(data.gridPos); producedEnergies.Add(electricity); }
public void SupplyPower(Electricity electricity) { FlatPin flatPin1 = new FlatPin(); FlatPin flatPin2 = new FlatPin(); _americanPowerPlug.SupplyPower(electricity, flatPin1, flatPin2); }
public void GenerateTestElectricity() { connected = true; Electricity newElec = new Electricity(); ElectricityOutput(currentTick + 1, newElec); }
public void InitEnd(Electricity end) { IsEnd = false; End = end; End.Hp = 100; End.Dead += End_Dead; }
//電力塔 public void AddMy_Electricity(Electricity _obj) { myTowerObjs.Add(_obj); myTowerAmount = myTowerObjs.Count; myElectricityObjs.Add(_obj); // GetIcon(GameManager.whichObject.EIcon, minmap.myTowerIcons); }
public IHttpActionResult PutElectricity(int id, Electricity electricity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != electricity.Electricities_id) { return(BadRequest()); } db.Entry(electricity).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ElectricityExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IActionResult GenerateElectricityUtility(Electricity electricity) { using (var trasnaction = _context.Database.BeginTransaction()) { var currentDate = DateTime.Now; var utilities = this._context.Utilities .Where(m => m.UtilityType == UtilityType.Electricity && (m.Date.Day == currentDate.Day && m.Date.Month == currentDate.Month && m.Date.Year == currentDate.Year)).FirstOrDefault(); if (utilities == null) { var utility = new Utility { ElectricityId = electricity.Id, Date = DateTime.Now, Amount = this._amountCalculator.getElectricityTariff(electricity.TarriffId, electricity.Amount), UtilityType = UtilityType.Electricity, SmartHouseCityRegion = SmartHouseCityRegion.Lapad }; this._context.Utilities.Add(utility); this._context.SaveChanges(); trasnaction.Commit(); return(new OkObjectResult(utility)); } else { utilities.Amount += this._amountCalculator.getElectricityTariff(electricity.TarriffId, electricity.Amount); utilities.Date = currentDate; } this._context.SaveChanges(); trasnaction.Commit(); return(new OkObjectResult(utilities)); } }
void FindTower(List <Turret_Manager> TurretList, Electricity _electricity) { for (int i = 0; i < TurretList.Count; i++) { if (_electricity.firstE.connectTowers.Contains(TurretList[i])) { continue; } if (Vector3.SqrMagnitude(TurretList[i].transform.position - _electricity.transform.position) <= range * range) { if (TurretList[i].GridNumber <= 1) { _electricity.firstE.connectTowers.Add(TurretList[i]); _electricity.firstE.Use_Electricit(-(TurretList[i].GetMyElectricity())); TurretList[i].power = _electricity; continue; } tmpCollider = Physics.OverlapBox(TurretList[i].transform.position, tmpV3, TurretList[i].transform.localRotation, TowerMask); if (tmpCollider.Length >= TurretList[i].GridNumber) { _electricity.firstE.connectTowers.Add(TurretList[i]); _electricity.firstE.Use_Electricit(-(TurretList[i].GetMyElectricity())); TurretList[i].power = _electricity; } else { TurretList[i].power = null; } } } }
public static Car creator(int numberOfWheels, String carBrand, String fuelType, int maxSpeed) { Car car; switch (fuelType) { case "diesel": car = new Diesel(numberOfWheels, maxSpeed); break; case "petrol": car = new Petrol(numberOfWheels, maxSpeed); break; case "electricity": car = new Electricity(numberOfWheels, maxSpeed); break; default: car = new Car(numberOfWheels, carBrand, fuelType, maxSpeed); return(car); } switch (carBrand) { case "peel": car = new PeelP50(car); break; case "audi": car = new Audi(car); break; case "nissan": car = new Nissan(car); break; case "tesla": car = new Tesla(car); break; default: return(car); } return(car); }
public static double GetWattHour(Electricity res) { if (res.Consumptions.Length > 1) { long epochmin = res.Consumptions[0].epoch; long epochmax = epochmin; double wattshour = 0; foreach (var elec in res.Consumptions) { wattshour += elec.watts * (elec.epoch - epochmin); epochmin = elec.epoch; } wattshour = wattshour / 3600; return(wattshour); } else { if (res.Consumptions[0] != null) { return(res.Consumptions[0].watts); } else { return(0); } } }
public static Electricity WorkOutActualNumbers(IElectricityIO ElectricItem) //add Resistance to SMso they get properly worked out { float Current = 0; float Voltage = 0; Dictionary <IElectricityIO, float> AnInterestingDictionary = new Dictionary <IElectricityIO, float> (); foreach (KeyValuePair <int, float> CurrentIDItem in ElectricItem.SourceVoltages) { Voltage += CurrentIDItem.Value; //Logger.Log ("yeah no" + Voltage.ToString ()); } //Logger.Log("yeah no Number > " + ElectricItem.SourceVoltages.Count.ToString ()); foreach (KeyValuePair <int, Dictionary <IElectricityIO, float> > CurrentIDItem in ElectricItem.CurrentComingFrom) { foreach (KeyValuePair <IElectricityIO, float> CurrentItem in CurrentIDItem.Value) { if (AnInterestingDictionary.ContainsKey(CurrentItem.Key)) { AnInterestingDictionary [CurrentItem.Key] += CurrentItem.Value; } else { AnInterestingDictionary [CurrentItem.Key] = CurrentItem.Value; } } if (ElectricItem.CurrentGoingTo.ContainsKey(CurrentIDItem.Key)) { foreach (KeyValuePair <IElectricityIO, float> CurrentItem in ElectricItem.CurrentGoingTo[CurrentIDItem.Key]) { if (AnInterestingDictionary.ContainsKey(CurrentItem.Key)) { AnInterestingDictionary [CurrentItem.Key] += -CurrentItem.Value; } else { AnInterestingDictionary [CurrentItem.Key] = -CurrentItem.Value; } } } } // foreach (KeyValuePair<IElectricityIO,float> CurrentItem in AnInterestingDictionary) { // Logger.Log (CurrentItem.Key.ToString () + " <key yeah Value> " + CurrentItem.Value.ToString () + " THSo> " + ElectricItem.GameObject().name.ToString(), Category.Electrical ); // } foreach (KeyValuePair <IElectricityIO, float> CurrentItem in AnInterestingDictionary) //!! It's not working somewhere at 17 and 9? { if (CurrentItem.Value > 0) { Current += CurrentItem.Value; } } //Logger.Log (Voltage.ToString () + " < yeah Those voltage " + Current.ToString() + " < yeah Those Current " + (Voltage/Current).ToString() + " < yeah Those Resistance" + ElectricItem.GameObject().name.ToString() + " < at", Category.Electrical); Electricity Cabledata = new Electricity(); Cabledata.Current = Current; Cabledata.Voltage = Voltage; Cabledata.EstimatedResistant = Voltage / Current; return(Cabledata); }
//ElectricityInsert public static int ElectricityInsert(Electricity elect) { int recordsAffected = 0; try { SqlCommand cmd = DataConnection.GenerateCommand(); cmd.CommandText = "SP_InsertRecords_EBC"; cmd.Parameters.AddWithValue("@auserId", elect.customerId); cmd.Parameters.AddWithValue("@auserName", elect.customerName); cmd.Parameters.AddWithValue("@alastReading", elect.lastReading); cmd.Parameters.AddWithValue("@acurrentReading", elect.currentReading); cmd.Parameters.AddWithValue("@aunits", elect.units); cmd.Parameters.AddWithValue("@aprice", elect.price); cmd.Connection.Open(); recordsAffected = cmd.ExecuteNonQuery(); cmd.Connection.Close(); } catch (SqlException ex) { throw ex; } catch (SystemException ex) { throw ex; } return(recordsAffected); }
public void TurnOffSupply() { supplyElectricity = false; Electricity supply = new Electricity(); RemoveSupply(this.GameObject()); //OnCircuitChange.Invoke(); }
public void SupplyPower(Electricity electricity) { RectangularPin rectangularPin1 = new RectangularPin(); RectangularPin rectangularPin2 = new RectangularPin(); RectangularPin rectangularPin3 = new RectangularPin(); _ukPowerPlug.SupplyPower(electricity, rectangularPin1, rectangularPin2, rectangularPin3); }
public void ElectricityOutput(int tick, Electricity electricity) { //Feed electrcity supply into the connected wire if (connectedWire != null) { connectedWire.ElectricityInput(tick, electricity); } }
public override void ComponentAction(Electricity electricty) { currentTime = 0; StartCoroutine(Timer()); ele = electricty; electricty.stop = true; base.ComponentAction(electricty); }
public Colossus() : base(20) { Name = "Colossus"; RequiredTech = new BronzeWorking(); ObsoleteTech = new Electricity(); SetSmallIcon(4, 3); Type = Wonder.Colossus; }
public override void ComponentAction(Electricity electricty) { GameObject ele = Instantiate(electricty.gameObject, transform.parent); ele.GetComponent <Electricity>().power = newPower; ele.GetComponent <Electricity>().UpdateTarget(ButtonNextPoint); base.ComponentAction(electricty); }
public ActionResult DeleteConfirmed(int id) { Electricity electricity = db.electricity.Find(id); db.electricity.Remove(electricity); db.SaveChanges(); return(RedirectToAction("Index")); }
IEnumerator Bomb() { int counter = 1; int reduction; int blocksToHitModulus = 2; // half the blocks float minHitsDivider = 2; //3 float maxHitsDivider = 0.55f; // 0.75 GameObject[] block = GameObject.FindGameObjectsWithTag("block"); // Not including super blocks...should I? foreach (GameObject b in block) { //should I do this block? if ((b != null) && (counter % blocksToHitModulus == 0)) { //remove points depending on min and max hit dividers reduction = (int)Mathf.Round(Random.Range(b.GetComponentInParent <Block>().hitsRemaining / minHitsDivider, b.GetComponentInParent <Block>().hitsRemaining / maxHitsDivider)); //update score if (reduction > b.GetComponentInParent <Block>().hitsRemaining) { GameManager.manager.level[GameManager.manager.currentLevel].shotPoints += b.GetComponentInParent <Block>().hitsRemaining; } else { GameManager.manager.level[GameManager.manager.currentLevel].shotPoints += reduction; } //reduce block hits remaining b.GetComponentInParent <Block>().hitsRemaining -= reduction; //Adjust hitsRemainingText if (b.GetComponentInParent <Block>().hitsRemaining > 0) { //StartCoroutine(FlashBlock(b)); //flash the blocks hitsRemainingText = b.GetComponentInChildren <TextMeshProUGUI>(); hitsRemainingText.text = b.GetComponentInParent <Block>().hitsRemaining.ToString(); //message showing number of hits needed reduced StartCoroutine(GameManager.manager.Message("-" + reduction, b.transform.position, 4, 2, Color.white)); if (b != null) { BlockColour(b); } } else { hitsRemainingText = b.GetComponentInChildren <TextMeshProUGUI>(); hitsRemainingText.text = "0"; StartCoroutine(GameManager.manager.Message("X", b.transform.position, 4, 2, Color.white)); StartCoroutine(BlockDeath(b)); } //Create new electricity line GameObject currentBomb = Instantiate(bombEmpty, transform.localPosition, Quaternion.identity); Electricity electricity = currentBomb.GetComponentInChildren <Electricity>(); electricity.lines(b.transform.localPosition); Destroy(currentBomb, deathDelay); } counter++; } yield return(null); }
public IActionResult Add([FromBody] ElectricityDTO command) { var item = new Electricity();; mapper.MapToModel(command, item); _repository.Insert(item); return(Created(String.Empty, item)); }
//電力塔 public void RemoveEnemy_Electricity(Electricity _obj) { if (enemyTowerObjs.Contains(_obj)) { // ReIcon(GameManager.whichObject.TowerIcon, minmap.enemyTowerIcons, enemyTowerObjs.IndexOf(_obj)); enemyTowerObjs.Remove(_obj); towerAmount = enemyTowerObjs.Count; } }
public override void ComponentAction(Electricity electricty) { Destroy(electricty.gameObject); GameController.instance.ChangeCanvas(false); Destroy(GameController.instance.CurrentPuzzle); GameController.instance.messageTxt.text = "Puzzle Finished"; Invoke("off", 1); GameController.instance.puzzleController.puzzleStartedBy.ActiveComponents(); }
protected void btnInsert_Click(object sender, EventArgs e) { try { Electricity elect = new Electricity(); elect.customerId = Convert.ToInt32(txtuserid.Text); elect.customerName = txtUserName.Text; elect.lastReading = Convert.ToInt32(txtlast.Text); elect.currentReading = Convert.ToInt32(txtcurrent.Text); txtunits.Text = (Convert.ToInt32(txtcurrent.Text) - Convert.ToInt32(txtlast.Text)).ToString(); int unit = int.Parse(txtunits.Text); float cost = 0; if (0 < unit && unit <= 100) { cost = 1; } else if (100 < unit && unit <= 250) { cost = 3; } else if (250 < unit && unit <= 600) { cost = 5; } else { cost = 10; } txtprice.Text = (unit * cost).ToString(); elect.units = Convert.ToInt32(txtunits.Text); elect.price = Convert.ToInt32(txtprice.Text); int recordsAffected = UserBLL.ElectricityInsert(elect); if (recordsAffected > 0) { Response.Write("<script type='text/javascript'>alert('Details Inserted Successfully');</script>"); } else { throw new UserException("Details not inserted"); } } catch (UserException ex) { Response.Write("<script type='text/javascript'>alert('" + ex.Message + "');</script>"); } catch (SystemException ex) { Response.Write("<script type='text/javascript'>alert('" + ex.Message + "');</script>"); } }
public ActionResult Edit(Electricity electricity) { if (ModelState.IsValid) { db.Entry(electricity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(electricity)); }
// // GET: /Electricity/Details/5 public ActionResult Details(int id = 0) { Electricity electricity = db.ElectricityНабор.Find(id); if (electricity == null) { return(HttpNotFound()); } return(View(electricity)); }
//電力塔 public void RemoveMy_Electricity(Electricity _obj) { if (myTowerObjs.Contains(_obj)) { // ReIcon(GameManager.whichObject.EIcon, minmap.myTowerIcons, myTowerObjs.IndexOf(_obj)); myElectricityObjs.Remove(_obj); myTowerObjs.Remove(_obj); myTowerAmount = myTowerObjs.Count; } }
public DAL.Electricity Post(Electricity electricity) { using (var trasnaction = _context.Database.BeginTransaction()) { var newElectricity = this._mapper.Map <DAL.Electricity>(electricity); this._context.Electricity.Add(newElectricity); this._context.SaveChanges(); trasnaction.Commit(); return(newElectricity); } }
public void ElectricityInput(int tick, Electricity electricity) { if (tick > currentTick) { currentTick = tick; suppliedElectricity = electricity; //Send event that the supply has updated OnSupplyChange.Invoke(); } //Do not pass on electricty }
public ActionResult Create(Electricity electricity) { if (ModelState.IsValid) { db.electricity.Add(electricity); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(electricity)); }
public void SupplyPower(Electricity electricity, RectangularPin rectangularPin1, RectangularPin rectangularPin2, RectangularPin rectangularPin3) { Console.WriteLine("{0} being supplied to UK Power Plug via {1}, {2} and {3}", electricity, rectangularPin1, rectangularPin2, rectangularPin3); }
public void SupplyPower(Electricity electricity, FlatPin flatPin1, FlatPin flatPin2) { Console.WriteLine("{0} being supplied to American Power Plug via {1} and {2}", electricity, flatPin1, flatPin2); }