public long AddStructure(StructureObject structure) { try { if (structure == null) { return(-2); } var structureEntity = ModelMapper.Map <StructureObject, Structure>(structure); if (structureEntity == null || string.IsNullOrEmpty(structureEntity.Name)) { return(-2); } using (var db = new ImportPermitEntities()) { var returnStatus = db.Structures.Add(structureEntity); db.SaveChanges(); return(returnStatus.StructureId); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public PropertyDisplayPanel(StructureObject columnTieback) { Size = new Size(270, 60); IsSelected = false; InternalName = columnTieback.InternalName; check = new CheckBox { Name = $"{columnTieback.InternalName}Check", Text = columnTieback.FriendlyName, AutoSize = true, Location = new Point(5, 5) }; check.CheckedChanged += new EventHandler(PropertyPanelCheck_CheckChanged); Controls.Add(check); text = new TextBox { Name = $"{columnTieback.InternalName}Textbox", Size = new Size(255, 25), Location = new Point(5, 30) }; text.GotFocus += new EventHandler(PropertyPanelText_Focused); Controls.Add(text); }
public long UpdateStructure(StructureObject structure) { try { if (structure == null) { return(-2); } var structureEntity = ModelMapper.Map <StructureObject, Structure>(structure); if (structureEntity == null || structureEntity.StructureId < 1) { return(-2); } using (var db = new ImportPermitEntities()) { db.Structures.Attach(structureEntity); db.Entry(structureEntity).State = EntityState.Modified; db.SaveChanges(); return(structure.StructureId); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public void VarPrimitiveRejectsStructure() { StructureObject so = new StructureObject("var", new StructureObject("foo", "bar")); PrologMachine pm = new PrologMachine(); Assert.IsFalse(pm.Resolve(so)); }
public void VarPrimitiveRejectsInteger() { StructureObject so = new StructureObject("var", 1); PrologMachine pm = new PrologMachine(); Assert.IsFalse(pm.Resolve(so)); }
public void IntegerPrimitiveAcceptsInteger() { StructureObject so = new StructureObject("integer", 1); PrologMachine pm = new PrologMachine(); Assert.IsTrue(pm.Resolve(so)); }
public void AtomicPrimitiveAcceptsAtom() { StructureObject so = new StructureObject("atomic", "a"); PrologMachine pm = new PrologMachine(); Assert.IsTrue(pm.Resolve(so)); }
public void IntegerPrimitiveRejectsAtom() { StructureObject so = new StructureObject("integer", "a"); PrologMachine pm = new PrologMachine(); Assert.IsFalse(pm.Resolve(so)); }
public void EqualPrimitiveDontUnifyDifferentAtoms() { StructureObject so = new StructureObject("=", "a", "b"); PrologMachine pm = new PrologMachine(); Assert.IsFalse(pm.Resolve(so)); }
public void EqualPrimitiveUnifyVariables() { StructureObject so = new StructureObject("=", "Y", "X"); PrologMachine pm = new PrologMachine(); Assert.IsTrue(pm.Resolve(so)); }
public void VarPrimitiveAcceptsVariable() { StructureObject so = new StructureObject("var", "X"); PrologMachine pm = new PrologMachine(); Assert.IsTrue(pm.Resolve(so)); }
public void NonVarPrimitiveRejectsVariable() { StructureObject so = new StructureObject("nonvar", "X"); PrologMachine pm = new PrologMachine(); Assert.IsFalse(pm.Resolve(so)); }
public void NonVarPrimitiveAcceptsStructure() { StructureObject so = new StructureObject("nonvar", new StructureObject("foo", "bar")); PrologMachine pm = new PrologMachine(); Assert.IsTrue(pm.Resolve(so)); }
public void EqualPrimitiveUnifyAtomWithVariable() { StructureObject so = new StructureObject("=", "a", "X"); PrologMachine pm = new PrologMachine(); Assert.IsTrue(pm.Resolve(so)); Assert.AreEqual(so.Parameters[0], pm.GetVariable(0).Dereference()); }
public void EqualPrimitiveUnifyInternalAtomVariable() { StructureObject so = new StructureObject("=", new StructureObject("f", "a"), new StructureObject("f", "X")); PrologMachine pm = new PrologMachine(); Assert.IsTrue(pm.Resolve(so)); Assert.AreEqual("a", pm.GetVariable(0).Dereference().ToString()); }
public void removeStructure(StructureObject obj) { if (obj == null) { return; } removeStructure(obj.coords); }
public ActionResult EditStructure(StructureObject structure) { var gVal = new GenericValidator(); try { if (!ModelState.IsValid) { gVal.Code = -1; gVal.Error = "Plese provide all required fields and try again."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var stat = ValidateStructure(structure); if (stat.Code < 1) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_structure"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldstructure = Session["_structure"] as StructureObject; if (oldstructure == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldstructure.Name = structure.Name.Trim(); oldstructure.Description = structure.Description; var docStatus = new StructureServices().UpdateStructure(oldstructure); if (docStatus < 1) { gVal.Code = -1; gVal.Error = docStatus == -3 ? "Structure already exists." : "Structure information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldstructure.StructureId; gVal.Error = "Structure information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "Structure information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public long UpdateStructure(StructureObject structure) { try { return(_structureManager.UpdateStructure(structure)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public ActionResult AddStructure(StructureObject structure) { var gVal = new GenericValidator(); try { if (!ModelState.IsValid) { gVal.Code = -1; gVal.Error = "Plese provide all required fields and try again."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateStructure(structure); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new StructureServices().AddStructure(structure); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "Structure upload failed. Please try again." : "The Structure Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "Structure was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "Structure processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
private AnimDrawable LoadUpgrade(StructureObject structObj, int upgradeSlot, DrawProperties inheritProps) { string upgradeName = ""; if (upgradeSlot == 0) { upgradeName = structObj.Upgrade1; } else if (upgradeSlot == 1) { upgradeName = structObj.Upgrade2; } else if (upgradeSlot == 2) { upgradeName = structObj.Upgrade3; } IniFile.IniSection upgradeRules = OwnerCollection.Rules.GetOrCreateSection(upgradeName); if (upgradeRules != null && upgradeRules.HasKey("Image")) { upgradeName = upgradeRules.ReadString("Image"); } IniFile.IniSection upgradeArt = OwnerCollection.Art.GetOrCreateSection(upgradeName); if (upgradeArt != null && upgradeArt.HasKey("Image")) { upgradeName = upgradeArt.ReadString("Image"); } IniFile.IniSection upgRules = OwnerCollection.Rules.GetOrCreateSection(upgradeName); IniFile.IniSection upgArt = OwnerCollection.Art.GetOrCreateSection(upgradeName); AnimDrawable upgrade = new AnimDrawable(_config, _vfs, upgRules, upgArt); upgrade.OwnerCollection = OwnerCollection; upgrade.Props = inheritProps; upgrade.LoadFromRules(); upgrade.NewTheater = this.NewTheater; upgrade.IsBuildingPart = true; string shpfilename = NewTheater ? OwnerCollection.ApplyNewTheaterIfNeeded(upgradeName, upgradeName + ".shp") : upgradeName + ".shp"; upgrade.Shp = _vfs.Open <ShpFile>(shpfilename); Point powerupOffset = new Point(_powerupSlots[upgradeSlot].X, _powerupSlots[upgradeSlot].Y); upgrade.Props.Offset.Offset(powerupOffset); return(upgrade); }
public StructureInspectorForm(StructureObject _structureObject, ConnectionProfile _profile) { InitializeComponent(); profile = _profile; structureObject = _structureObject; if (structureObject.ObjectType == StructureObjectType.Table) { txtName.Enabled = true; } else { txtName.Enabled = false; } txtName.Text = structureObject.InternalName; txtFriendlyName.Text = structureObject.FriendlyName; lblObjectTypeOutput.Text = structureObject.ObjectType.ToString(); lblChildTypeOutput.Text = (structureObject.ObjectType + 1).ToString(); }
private GenericValidator ValidateStructure(StructureObject structure) { var gVal = new GenericValidator(); try { if (string.IsNullOrEmpty(structure.Name)) { gVal.Code = -1; gVal.Error = "Please provide Structure."; return(gVal); } gVal.Code = 5; return(gVal); } catch (Exception) { gVal.Code = -1; gVal.Error = "Structure Validation failed. Please provide all required fields and try again."; return(gVal); } }
private void edit_Complete(object sender, EventArgs e) { Control ctlSender = sender as Control; StructureObjectType objectType = (StructureObjectType)Enum.Parse(typeof(StructureObjectType), ctlSender.Tag.ToString()); StructureObject structureObject; if (string.IsNullOrWhiteSpace(ctlSender.Text)) { structureObject = null; } else { structureObject = new StructureObject(objectType) { InternalName = ctlSender.Text, FriendlyName = ctlSender.Text }; } profile.GetType().GetProperty(ctlSender.Tag.ToString()).SetValue(profile, structureObject); }
public SpawnSwitchInfo(string _stype, StructureObject ob) { sType = _stype; switchModel = ob; }
public SpawnBoxInfo(string _btype, StructureObject ob) { bType = _btype; structureModel = ob; }
public SpawnBoxInfo(string _btype) { bType = _btype; structureModel = null; }
public void OnSceneChange() { sentColorCorrespondence = false; var renderers = UnityEngine.Object.FindObjectsOfType <Renderer>(); colorIds = new Dictionary <Color, string> (); var mpb = new MaterialPropertyBlock(); foreach (var r in renderers) { // var layer = r.gameObject.layer; // var tag = r.gameObject.tag; string classTag = r.name; string objTag = getUniqueId(r.gameObject); StructureObject so = r.gameObject.GetComponent <StructureObject> (); if (so == null) { so = r.gameObject.GetComponentInParent <StructureObject> (); } SimObjPhysics sop = r.gameObject.GetComponent <SimObjPhysics> (); if (sop == null) { sop = r.gameObject.GetComponentInParent <SimObjPhysics> (); } if (so != null) { classTag = "" + so.WhatIsMyStructureObjectTag; //objTag = so.gameObject.name; } if (sop != null) { classTag = "" + sop.Type; objTag = sop.UniqueID; } Color classColor; Color objColor; classColor = ColorEncoding.EncodeTagAsColor(classTag); objColor = ColorEncoding.EncodeTagAsColor(objTag); capturePasses [0].camera.WorldToScreenPoint(r.bounds.center); if (so != null || sop != null) { colorIds [objColor] = objTag; colorIds [classColor] = classTag; } else { colorIds [objColor] = r.gameObject.name; } // if (r.material.name.ToLower().Contains ("lightray")) { // objColor.a = 0; // classColor.a = 0; // mpb.SetFloat ("_Opacity", 0); // // } else { // objColor.a = 1; // classColor.a = 1; // mpb.SetFloat ("_Opacity", 1); // } // // updated per @danielg - replaces commented out code if (r.material.name.ToLower().Contains("lightray")) { r.enabled = false; continue; } objColor.a = 1; classColor.a = 1; mpb.SetFloat("_Opacity", 1); mpb.SetColor("_CategoryColor", classColor); mpb.SetColor("_ObjectColor", objColor); r.SetPropertyBlock(mpb); } }
/// <summary>Reads all objects. </summary> private void LoadAllObjects(MapFile mf) { // import tiles foreach (var iso in mf.Tiles) { _tiles[iso.Dx, iso.Dy / 2] = new MapTile(iso.Dx, iso.Dy, iso.Rx, iso.Ry, iso.Z, iso.TileNum, iso.SubTile, _tiles); } // import terrain foreach (var terr in mf.Terrains) { var t = new TerrainObject(terr.Name); _terrainObjects.Add(t); _tiles.GetTile(terr.Tile).AddObject(t); } // import smudges foreach (var sm in mf.Smudges) { var s = new SmudgeObject(sm.Name); _tiles.GetTile(sm.Tile).AddObject(s); _smudgeObjects.Add(s); } // import overlays foreach (var o in mf.Overlays) { var ovl = new OverlayObject(o.OverlayID, o.OverlayValue); _tiles.GetTile(o.Tile).AddObject(ovl); _overlayObjects.Add(ovl); } // import infantry foreach (var i in mf.Infantries) { var inf = new InfantryObject(i.Owner, i.Name, i.Health, i.Direction, i.OnBridge); _tiles.GetTile(i.Tile).AddObject(inf); _infantryObjects.Add(inf); } foreach (var u in mf.Units) { var un = new UnitObject(u.Owner, u.Name, u.Health, u.Direction, u.OnBridge); _tiles.GetTile(u.Tile).AddObject(un); _unitObjects.Add(un); } foreach (var a in mf.Aircrafts) { var ac = new AircraftObject(a.Owner, a.Name, a.Health, a.Direction, a.OnBridge); _tiles.GetTile(a.Tile).AddObject(ac); _aircraftObjects.Add(ac); } foreach (var s in mf.Structures) { var str = new StructureObject(s.Owner, s.Name, s.Health, s.Direction); str.Upgrade1 = s.Upgrade1; str.Upgrade2 = s.Upgrade2; str.Upgrade3 = s.Upgrade3; _tiles.GetTile(s.Tile).AddObject(str); _structureObjects.Add(str); } }
/// <summary> /// NOTE : Tileinfo를 통하여 Draw /// </summary> /// <param name="_rooms"></param> public GameObject DrawTilemap(DungeonRoom room, bool ingame) { //Tilemap 생성 및 초기화 var tmpob = new GameObject("Room" + room.roomNumberOfList, typeof(Tilemap), typeof(CompositeCollider2D)); tmpob.AddComponent <TilemapCollider2D>().usedByComposite = true; tmpob.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Static; tmpob.AddComponent <TilemapRenderer>().sortingLayerName = "Ground"; tmpob.tag = "Ground"; tmpob.layer = 8; Tilemap tmptilemap = tmpob.GetComponent <Tilemap>(); //내부 생성 for (int x = 0; x < room.roomRect.xMax; x++) { for (int y = 0; y < room.roomRect.yMax; y++) { if (room.roomTileArray[x, y] != null) { TileInfo tmpdata = room.roomTileArray[x, y]; switch (tmpdata.tileType) { case TileType.Terrain: tmptilemap.SetTile(new Vector3Int(x, y, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); break; case TileType.Structure: StructureObject tmpen = Instantiate(loadData.structurePrefabDic[tmpdata.tileName], new Vector3(x + 0.5f, y + 0.5f, 0), Quaternion.identity, tmptilemap.transform); tmpen.ownRoom = room; if (tmpdata.tileName == STRUCTURE_TYPE.Entrance.ToString()) { tmpen.transform.localPosition += new Vector3(0, 0.5f, 0); //Maptool에서 사용할경우 대비 if (room.entranceInfoList.Count == 0) { room.entranceInfoList.Add(new EntranceConnectRoom(null, tmpen.GetComponent <EntranceSc>())); } if (room.roomClearType == Room_ClearType.Boss) { tmpen.sR.sprite = loadData.tileDataArray[room.roomSpriteType].entranceSprite[0]; } tmpen.sR.sprite = loadData.tileDataArray[room.roomSpriteType].entranceSprite[0]; tmpen.sR.sortingLayerName = "Entrance"; tmpen.GetComponent <EntranceSc>().spriteArray[0] = loadData.tileDataArray[room.roomSpriteType].entranceSprite[0]; tmpen.GetComponent <EntranceSc>().spriteArray[1] = loadData.tileDataArray[room.roomSpriteType].entranceSprite[1]; tmpen.transform.SetParent(tmpob.transform); //이미 출입문이 생성되어있는방 예외 처리 foreach (EntranceConnectRoom nroom in room.entranceInfoList) { if (nroom.entrance == null) { tmpen.GetComponent <EntranceSc>().ownRoom = room; nroom.entrance = tmpen.GetComponent <EntranceSc>(); break; } } } else if (tmpdata.tileName == STRUCTURE_TYPE.Box.ToString()) { room.boxInfoList.Add(new SpawnBoxInfo(tmpdata.tileNamesType.ToString(), tmpen)); } else if (tmpdata.tileName == STRUCTURE_TYPE.Switch.ToString()) { room.switchInfoList.Add(new SpawnSwitchInfo(tmpdata.tileNamesType, tmpen)); } break; case TileType.Monster: Monster tmpmonster = Instantiate(loadData.monsterPrefabDic[room.roomTileArray[x, y].tileName], new Vector3Int(x, y, 0), loadData.monsterPrefabDic[room.roomTileArray[x, y].tileName].transform.rotation, tmptilemap.transform); tmpmonster.ownRoom = room; room.monsterInfoList.Add(new SpawnMonsterInfo(tmpmonster.mType, new Vector2(x, y), tmpmonster)); break; case TileType.Item: ItemSc tmpitem = Instantiate(loadData.itemPrefabDic[room.roomTileArray[x, y].tileName], new Vector3Int(x, y, 0), Quaternion.identity, tmptilemap.transform); break; case TileType.Boss: BossMonsterController tmpboss = Instantiate(loadData.bossPrefabDic[room.roomTileArray[x, y].tileName], new Vector3Int(x, y, 0), loadData.bossPrefabDic[room.roomTileArray[x, y].tileName].transform.rotation, tmptilemap.transform); tmpboss.ownRoom = room; room.bossInfoList.Add(new SpawnBossInfo(tmpboss.bType, new Vector2(x, y), tmpboss)); break; default: Debug.Log(room.roomTileArray[x, y].tileType.ToString()); break; } } } } //인게임일 경우에만 생성 (맵툴의 경우에는 배경을 남겨두므로 제외) if (ingame) { //Edge생성 for (int i = 0; i < room.roomRect.xMax; i++) { tmptilemap.SetTile(new Vector3Int(i, -1, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int(i, -2, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int(i, (int)room.roomRect.yMax, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int(i, (int)room.roomRect.yMax + 1, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); } //left, right for (int j = -2; j < room.roomRect.yMax + 2; j++) { tmptilemap.SetTile(new Vector3Int(-1, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int(-2, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int((int)room.roomRect.xMax, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int((int)room.roomRect.xMax + 1, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); } //배경 생성 GameObject tmpParent = new GameObject("BackGroundParent"); int count = 0; foreach (var tmptile in loadData.tileDataArray[room.roomSpriteType].backGroundTile) { GameObject backgroundob = new GameObject("BackGround", typeof(SpriteRenderer)); backgroundob.transform.localPosition = Vector3.zero; backgroundob.transform.localRotation = Quaternion.identity; backgroundob.GetComponent <SpriteRenderer>().sortingLayerName = "BackGround"; backgroundob.GetComponent <SpriteRenderer>().drawMode = SpriteDrawMode.Sliced; backgroundob.GetComponent <SpriteRenderer>().sprite = tmptile.sprite; backgroundob.GetComponent <SpriteRenderer>().size = room.roomRect.size; backgroundob.GetComponent <SpriteRenderer>().sortingOrder = count; count++; backgroundob.transform.SetParent(tmpParent.transform); } tmpParent.transform.SetParent(tmpob.transform); } room.roomModel = tmpob; tmpob.SetActive(false); return(tmpob); }
public bool GetPlaceAccess(StructureObject structure, Vector3 position) { return(true); }