void OnMouseDown() { Debug.Log("Lever was Clicked"); float distToPlayer = Vector3.Distance(Player.position, transform.position); if (distToPlayer <= 1.5f) { Debug.Log("Lever was Clicked AND PLAYER WAS CLOSE ENOUGH"); if (someObject.tag == "doorHorizontal" || someObject.tag == "doorVertical") { Debug.Log("door tag worked"); door someObjectsDoor = someObject.GetComponent <door>(); someObjectsDoor.moveDoor(); Debug.Log("Door was Opened"); } if (someObject.tag == "bridge") { bridge someObjectsBridge = someObject.GetComponent <bridge>(); someObjectsBridge.moveBridge(); Debug.Log("Bridge was Extended"); } if (someObject.tag == "fireTrapHorizontal" || someObject.tag == "fireTrapVertical") { Debug.Log("FireTrap was Successfully Detected by Lever"); fireTrap someObjectsFireTrap = someObject.GetComponent <fireTrap>(); someObjectsFireTrap.doFireTrap(); Debug.Log("Fire Trap was Enabled/Disabled"); } } }
public ViewResult AddBridge(bridge bridge) { ViewBag.message = "添加信息成功!"; var result = repository.AddBridge(bridge); if (result == false) { ViewBag.message = "添加信息失败!"; } return(View(new AddBridgeViewModel())); }
public bool AddBridge(bridge bridge) { bridge.id = Guid.NewGuid(); //去掉短横杠 try { context.bridge.Add(bridge); context.SaveChanges(); return(true); } catch (Exception ex) //catch (DbEntityValidationException dbEx) { throw new Exception("数据库添加信息出现异常。"); } }