public bool RoomDeletion(Graphics _g, Point _p) { Room selectedRoom = null; foreach (Room roomInList in roomList) { if (roomInList.IsWall(_p)) { selectedRoom = roomInList; break; } else { Interior selectedItem = null; foreach (Interior item in roomInList.Interior) { if (item.BoundingBox.Contains(_p)) { selectedItem = item; } } if (selectedItem != null) { if (!selectedItem.IsDoor) { loadingScreen = new HouseBuilderLoading("Verbindungen werden getrennt", 100000); loadingScreen.ShowDialog(); } roomInList.Interior.Remove(selectedItem); return(true); } } } if (selectedRoom != null) { if (selectedRoom.Interior.Count > 0) { loadingScreen = new HouseBuilderLoading("Verbindungen werden getrennt", 100000); loadingScreen.ShowDialog(); } roomList.Remove(selectedRoom); RemoveRoom(selectedRoom, _g); return(true); } return(false); }
private string PlaceInterior(Graphics _g, Interior _i, Point _p, bool _connectionError) { foreach (Room roomInList in roomList) { if (roomInList.BoundingBox.Contains(_i.Position)) { if (CheckInteriorWallCollision(roomInList, _i)) { return("Fehler: Objekte dürfen die Wände nicht schneiden!"); } foreach (Interior item in roomInList.Interior) { if (CheckInteriorCollision(roomInList, item, _i, _p)) { return("Fehler: Objekte dürfen sich nicht überschneiden!"); } } loadingScreen = new HouseBuilderLoading("Es wird nach Geräten gesucht", 125000); loadingScreen.ShowDialog(); loadingScreen = new HouseBuilderLoading("Gerät wird verbunden"); loadingScreen.ShowDialog(); _g.DrawImage(_i.Image, _p); #if DEBUG _g.DrawRectangle(new Pen(Color.Red), _i.BoundingBox); #endif roomInList.AddInterior(_i); if (_connectionError) { return("Fehler: Verbindung des Gerätes ist fehlgeschlagen! Benutzen sie das Stromkabel um das Gerät zu verbinden!"); } else { return(""); } } } return("Fehler: Geräte müssen innerhalb von Räumen platziert werden"); }
public void AddInterior(Interior _i) { interior.AddLast(_i); }
public string DetermineInteriorGraphic(Graphics _g, Point _p, bool _connectionError) { Interior newItem = null; switch (current_state) { case (int)DESIGN_STATE.FRIDGE: if (!_connectionError) { newItem = new Interior(Properties.Resources.fridgebig, _p, false); } else { newItem = new Interior(Properties.Resources.fridgeerror, Properties.Resources.fridgebig, _p); } break; case (int)DESIGN_STATE.HEATER: if (!_connectionError) { newItem = new Interior(Properties.Resources.icon_heizung, _p, false); } else { newItem = new Interior(Properties.Resources.heizungerror, Properties.Resources.icon_heizung, _p); } break; case (int)DESIGN_STATE.LIGHT: if (!_connectionError) { newItem = new Interior(Properties.Resources.lightbulbbig, _p, false); } else { newItem = new Interior(Properties.Resources.lightbulberror, Properties.Resources.lightbulbbig, _p); } break; case (int)DESIGN_STATE.MICROWAVE: if (!_connectionError) { newItem = new Interior(Properties.Resources.herd128, _p, false); } else { newItem = new Interior(Properties.Resources.herd128error, Properties.Resources.herd128, _p); } break; case (int)DESIGN_STATE.PC: if (!_connectionError) { newItem = new Interior(Properties.Resources.PCbig, _p, false); } else { newItem = new Interior(Properties.Resources.pcerror, Properties.Resources.PCbig, _p); } break; case (int)DESIGN_STATE.TV: if (!_connectionError) { newItem = new Interior(Properties.Resources.TVbig, _p, false); } else { newItem = new Interior(Properties.Resources.TVerror, Properties.Resources.TVbig, _p); } break; case (int)DESIGN_STATE.WASHING: if (!_connectionError) { newItem = new Interior(Properties.Resources.washing_machine_icon, _p, false); } else { newItem = new Interior(Properties.Resources.washingError, Properties.Resources.washing_machine_icon, _p); } break; default: break; } newItem.Resize(3); _p = new Point(_p.X - newItem.BoundingBox.Width / 2, _p.Y - newItem.BoundingBox.Height / 2); newItem.BoundingBox = new Rectangle(_p.X, _p.Y, newItem.BoundingBox.Width, newItem.BoundingBox.Height); return(PlaceInterior(_g, newItem, _p, _connectionError)); }
public bool CheckInteriorWallCollision(Room _r, Interior _i) { return(!_r.BoundingBox.Contains(_i.BoundingBox)); }
public bool CheckInteriorCollision(Room _r, Interior _onField, Interior _newInterior, Point _p) { bool interiorCollision = _onField.BoundingBox.IntersectsWith(_newInterior.BoundingBox) || _newInterior.BoundingBox.IntersectsWith(_onField.BoundingBox); return(interiorCollision); }