private static void openDoor(Door door, Player player) { int sx = door.Range.Xmin; int ex = door.Range.Xmax; int sy = door.Range.Ymin; int ey = door.Range.Ymax; int sz = door.Range.Zmin; int ez = door.Range.Zmax; Block[] buffer = new Block[(ex - sx + 1) * (ey - sy + 1) * (ez - sz + 1)]; int counter = 0; for (int x = sx; x <= ex; x++) { for (int y = sy; y <= ey; y++) { for (int z = sz; z <= ez; z++) { buffer[counter] = player.WorldMap.GetBlock(x, y, z); player.WorldMap.QueueUpdate(new BlockUpdate(null, new Vector3I(x, y, z), Block.Air)); counter++; } } } DoorInfo info = new DoorInfo(door, buffer, player.WorldMap); //reclose door Scheduler.NewTask(doorTimer_Elapsed).RunOnce(info, DoorCloseTimer); }
private static DoorInstance TransformDoorInfo(DoorInfo <RoomBase> doorInfo, RoomInstance connectedRoomInstance) { var doorLine = doorInfo.DoorLine; switch (doorLine.GetDirection()) { case OrthogonalLine.Direction.Right: return(new DoorInstance(new Unity.Utils.OrthogonalLine(doorLine.From.ToUnityIntVector3(), doorLine.To.ToUnityIntVector3()), Vector2Int.up, connectedRoomInstance.Room, connectedRoomInstance)); case OrthogonalLine.Direction.Left: return(new DoorInstance(new Unity.Utils.OrthogonalLine(doorLine.To.ToUnityIntVector3(), doorLine.From.ToUnityIntVector3()), Vector2Int.down, connectedRoomInstance.Room, connectedRoomInstance)); case OrthogonalLine.Direction.Top: return(new DoorInstance(new Unity.Utils.OrthogonalLine(doorLine.From.ToUnityIntVector3(), doorLine.To.ToUnityIntVector3()), Vector2Int.left, connectedRoomInstance.Room, connectedRoomInstance)); case OrthogonalLine.Direction.Bottom: return(new DoorInstance(new Unity.Utils.OrthogonalLine(doorLine.To.ToUnityIntVector3(), doorLine.From.ToUnityIntVector3()), Vector2Int.right, connectedRoomInstance.Room, connectedRoomInstance)); default: throw new ArgumentOutOfRangeException(); } }
public void GetDoorInfoListInvalidTokenTest() { RunTest(() => { List <DoorInfo> fullList = GetFullDoorInfoList(); if (fullList == null || fullList.Count == 0) { return; } string token = Guid.NewGuid().ToString().Substring(0, 8); DoorInfo[] infos = null; RunStep(() => { infos = Client.GetDoorInfo(new string[] { token }); }, "Get DoorInfo with invalid token"); Assert(infos == null || infos.Length == 0, "List of DoorInfo is not empty", "Check that the DUT returned no DoorInfos"); int maxLimit = GetMaxLimit(); if (maxLimit >= 2) { infos = GetDoorInfo(new string[] { fullList[0].token, token }); DoorInfo expected = fullList[0]; this.CheckRequestedInfo(infos, expected.token, D => D.token, "DoorInfo", Assert); } else { LogTestEvent(string.Format("MaxLimit={0}, skip part with sending request with one correct and one incorrect tokens.", maxLimit) + Environment.NewLine); } }); }
public static void SetDoorState(int doorId, bool locked, float heading) { DoorInfo door = DoorList.FirstOrDefault(x => x.Id == doorId); if (door != null) { door.Locked = locked; door.State = heading; door.ColShape.setData("DOOR_INFO", door); door.ShortRangeColShape.setData("DOOR_INFO", door); foreach (var entity in door.ColShape.getAllEntities()) { var player = API.shared.getPlayerFromHandle(entity); if (player == null) { continue; } float cH = door.State; API.shared.sendNativeToPlayer(player, SET_STATE_OF_CLOSEST_DOOR_OF_TYPE, door.Hash, door.Position.X, door.Position.Y, door.Position.Z, door.Locked, cH, false); } } }
static void openDoor(Zone zone, Player player) { int sx = zone.Bounds.XMin; int ex = zone.Bounds.XMax; int sy = zone.Bounds.YMin; int ey = zone.Bounds.YMax; int sz = zone.Bounds.ZMin; int ez = zone.Bounds.ZMax; Block[] buffer = new Block[zone.Bounds.Volume]; int counter = 0; for (int x = sx; x <= ex; x++) { for (int y = sy; y <= ey; y++) { for (int z = sz; z <= ez; z++) { buffer[counter] = player.WorldMap.GetBlock(x, y, z); player.WorldMap.QueueUpdate(new BlockUpdate(null, new Vector3I(x, y, z), Block.Air)); counter++; } } } DoorInfo info = new DoorInfo(zone, buffer, player.WorldMap); //reclose door Scheduler.NewTask(doorTimer_Elapsed).RunOnce(info, DoorCloseTimer); }
static Door() { id2info = new Dictionary <int, DoorInfo>(); id2info[27] = new DoorInfo("RedDoor", YKnyttLib.JuniValues.PowerNames.RedKey); id2info[28] = new DoorInfo("YellowDoor", YKnyttLib.JuniValues.PowerNames.YellowKey); id2info[29] = new DoorInfo("BlueDoor", YKnyttLib.JuniValues.PowerNames.BlueKey); id2info[30] = new DoorInfo("PurpleDoor", YKnyttLib.JuniValues.PowerNames.PurpleKey); }
protected void AddVerticalDoors(DoorInfo <int> doorInfo) { Payload.CollideableTilemap.SetTile(doorInfo.DoorLine.GetNthPoint(0), Config.VerticalBottom); if (doorInfo.DoorLine.Length > 1) { Payload.CollideableTilemap.SetTile(doorInfo.DoorLine.GetNthPoint(1), Config.VerticalTop); } }
protected void AddHorizontalDoors(DoorInfo <int> doorInfo) { Payload.CollideableTilemap.SetTile(doorInfo.DoorLine.GetNthPoint(0), Config.HorizontalLeft); if (doorInfo.DoorLine.Length > 1) { Payload.CollideableTilemap.SetTile(doorInfo.DoorLine.GetNthPoint(1), Config.HorizontalRight); } }
public void AccessPointAndDoorInfoConsistencyTest() { RunTest( () => { List <DoorInfo> doors = GetFullDoorInfoList(); // initialize PACSPortClient Proxies.Onvif.PACSPortClient client = PACSPortClient; List <AccessPointInfo> accessPoints = GetAccessPointInfoList(); BeginStep("Validate response received"); List <string> doorTokens = new List <string>(); foreach (AccessPointInfo info in accessPoints) { bool door; // empty type is OK if (info.EntityType == null) { door = true; } else { XmlQualifiedName type = info.EntityType; door = (type.Namespace == OnvifService.DOORCONTROL && type.Name == "Door"); } // it's Door if (door) { if (!doorTokens.Contains(info.Entity)) { doorTokens.Add(info.Entity); } } } StepPassed(); bool ok = true; StringBuilder logger = new StringBuilder(); foreach (string token in doorTokens) { DoorInfo door = doors.Where(D => D.token == token).FirstOrDefault(); if (door == null) { ok = false; logger.AppendFormat("Door with token '{0}' not found{1}", token, Environment.NewLine); } } Assert(ok, logger.ToStringTrimNewLine(), "Check that information is consistent"); }); }
public DoorInfo GetDoor(string token) { DoorInfo info = _doorInfos.FirstOrDefault(D => D.token == token); if (info == null) { CommonUtils.ReturnFault(new string[] { "Sender", "InvalidArgVal", "InvalidToken" }); } return(info); }
public override void _Ready() { open_area = GetNode <Area2D>("OpenArea"); door_info = id2info[ObjectID.y]; GetNode <AnimatedSprite>("AnimatedSprite").Animation = door_info.Anim; if (Juni.Powers.getPower(door_info.Power)) { GetNode <CollisionShape2D>("StaticBody2D/CollisionShape2D").Disabled = true; } }
public static bool ToggleDoorState(int doorId) { DoorInfo door = DoorList.FirstOrDefault(x => x.Id == doorId); if (door == null) { return(false); } SetDoorState(door.Id, !door.Locked, 0); return(door.Locked); }
public virtual void UnconvertDoors() { if (m_House == null) { return; } BaseDoor newdoor = null; foreach (BaseDoor door in new ArrayList(m_House.Doors)) { door.Open = false; Type type = typeof(StrongWoodDoor); for (int i = 0; i < AddDoorGump.m_Types.Length; i++) { DoorInfo di = AddDoorGump.m_Types[i]; if (di.BaseID == door.ClosedID || di.BaseID + 2 == door.ClosedID || di.BaseID + 8 == door.ClosedID || di.BaseID + 10 == door.ClosedID) { type = di.Type; } } newdoor = Activator.CreateInstance(type, new object[] { DoorFacing.WestCW }) as BaseDoor; //newdoor = new StrongWoodDoor( (DoorFacing)0 ); newdoor.ItemID = door.ItemID; newdoor.ClosedID = door.ClosedID; newdoor.OpenedID = door.OpenedID; newdoor.OpenedSound = door.OpenedSound; newdoor.ClosedSound = door.ClosedSound; newdoor.Offset = door.Offset; newdoor.Location = door.Location; newdoor.Map = door.Map; door.Delete(); if (m_Relock) { newdoor.Locked = true; } foreach (Item inneritem in newdoor.GetItemsInRange(1)) { if (inneritem is BaseDoor && inneritem != newdoor && inneritem.Z == newdoor.Z) { ((BaseDoor)inneritem).Link = newdoor; newdoor.Link = (BaseDoor)inneritem; } } m_House.Doors.Remove(door); } }
/* EXPORTED METHODS */ public int registerDoor(int modelHash, Vector3 position) { var colShapeId = ++_doorCounter; var info = new DoorInfo(); info.Hash = modelHash; info.Position = position; info.Locked = false; // Open by default; info.Id = colShapeId; } info.State = 0;
/* * Get first door, move it to last listDoor; * */ public DoorInfo PopDoorInfo() { DoorInfo doorInfo = listDoor[0]; for (int i = 0; i < listDoor.Count - 1; i++) { listDoor[i] = listDoor[i + 1]; } listDoor[7] = doorInfo; return(doorInfo); }
public void Setup(DoorInfo info, Color colorBg, Color colorItem, float posX, float posY) { sprite.color = colorBg; txt.color = colorItem; Vector3 tmpPos = transform.position; tmpPos.x = posX; tmpPos.y = posY; transform.position = tmpPos; this.info = info; txt.text = info.ToName(); }
public bool PairDoors(DoorInfo other) { if (this.pair == null && other.pair == null && Vector2.Distance(this.loc, other.loc) == 1 && Vector2.Distance(this.loc + other.face, other.loc + this.face) == 1 && this.face + other.face == Vector2.zero && ((other.loc - this.loc).normalized.x == (this.face - other.face).normalized.x || (other.loc - this.loc).normalized.y == (this.face - other.face).normalized.y)) { this.pair = other; other.pair = this; return(true); } else { return(false); } }
public bool PairDoors(DoorInfo other, Material mat) { if (this.pair == null && other.pair == null && Vector2.Distance(this.loc, other.loc) == 1 && Vector2.Distance(this.loc + other.face, other.loc + this.face) == 1 && this.face + other.face == Vector2.zero && ((other.loc - this.loc).normalized.x == (this.face - other.face).normalized.x || (other.loc - this.loc).normalized.y == (this.face - other.face).normalized.y)) { this.pair = other; other.pair = this; other.gameObject.GetComponent <MeshRenderer> ().material = mat; gameObject.GetComponent <MeshRenderer> ().material = mat; return(true); } else { return(false); } }
private static void Export() { SceneInfoForServer export_info = new SceneInfoForServer(); export_info.scene_id = 1001; export_info.scene_name = "scene_name"; export_info.door_list = new List <DoorInfo>(); DoorInfo door = new DoorInfo(); door.door_id = 1; door.pos_x = 1.1f; door.pos_y = 2.2f; door.pos_z = 3.123456f; door.target_scene_id = 1002; door.target_x = 11.1f; door.target_y = 22.2f; door.target_z = 33.123456f; export_info.door_list.Add(door); export_info.door_list.Add(door); export_info.npc_list = new List <NPCInfo>(); NPCInfo npc = new NPCInfo(); npc.npc_id = 1; npc.pos_x = 1.1f; npc.pos_y = 2.2f; npc.pos_z = 3.123456f; export_info.npc_list.Add(npc); export_info.monster_list = new List <MonsterInfo>(); MonsterInfo monster = new MonsterInfo(); monster.monster_id = 1; monster.pos_x = 1.1f; monster.pos_y = 2.2f; monster.pos_z = 3.123456f; export_info.monster_list.Add(monster); export_info.test_dic = new Dictionary <int, string>(); export_info.test_dic.Add(1, "one"); export_info.test_dic.Add(3, "three"); export_info.test_dic.Add(6, "haha"); string content = LuaUtility.ToLua(export_info); Debug.Log("SceneInfoExporterForServer:Export content : " + content); }
void stateMonitor_StateUpdated(string token, DoorState state) { Invoke(new Action( () => { foreach (TreeNode item in tvDoors.Nodes) { DoorInfo info = (DoorInfo)item.Tag; if (info.token == token) { UpdateDoorState(item, state); break; } } } )); }
public void ParseDoorInfos() { JsonData controlData = JsonMapper.ToObject(Resources.Load <TextAsset>("DoorData/doors").text); foreach (JsonData item in controlData) { DoorInfo doorInfo = new DoorInfo(); doorInfo.id = (int)item["id"]; doorInfo.switchId = (int)item["switchId"]; doorInfo.colorType = (ColorType)(int)item["type"]; JsonData dt = item["rooms"]; for (int i = 0; i < dt.Count; i++) { doorInfo.roomList.Add((int)dt[i]); } doorInfoDict[doorInfo.id] = doorInfo; } JsonData normalData = JsonMapper.ToObject(Resources.Load <TextAsset>("DoorData/switches").text); foreach (JsonData item in normalData) { SwitchInfo switchInfo = new SwitchInfo(); switchInfo.id = (int)item["id"]; switchInfo.colorType = (ColorType)(int)item["type"]; switchInfoDict[switchInfo.id] = switchInfo; } JsonData enterData = JsonMapper.ToObject(Resources.Load <TextAsset>("DoorData/enters").text); foreach (JsonData item in enterData) { EnterInfo enterInfo = new EnterInfo(); enterInfo.id = (int)item["id"]; JsonData dt = item["rooms"]; for (int i = 0; i < dt.Count; i++) { enterInfo.roomList.Add((int)dt[i]); } enterInfoDict[enterInfo.id] = enterInfo; } initFinish = true; }
void tvDoors_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode node = e.Node; if (node != null) { while (node.Parent != null) { node = node.Parent; } DoorInfo info = node.Tag as DoorInfo; DisplayDoorInfo(info); } else { DisplayDoorInfo(null); } }
static void doorTimer_Elapsed(SchedulerTask task) { DoorInfo info = (DoorInfo)task.UserState; int counter = 0; for (int x = info.Zone.Bounds.XMin; x <= info.Zone.Bounds.XMax; x++) { for (int y = info.Zone.Bounds.YMin; y <= info.Zone.Bounds.YMax; y++) { for (int z = info.Zone.Bounds.ZMin; z <= info.Zone.Bounds.ZMax; z++) { info.WorldMap.QueueUpdate(new BlockUpdate(null, new Vector3I(x, y, z), info.Buffer[counter])); counter++; } } } lock (openDoorsLock) { openDoors.Remove(info.Zone); } }
private void Start() { if (sr != null) { StartCoroutine(Util.DelayExecute(() => { return(GameController.manager.doorMan.initFinish); }, () => { DoorInfo info = GameController.manager.doorMan.GetDoorInfoById(id); Debug.Log(info); if (info == null) { return; } Debug.Log(info.colorType); sr.sprite = spList[(int)info.colorType]; sr.transform.localPosition = new Vector3(sr.transform.localPosition.x, sr.transform.localPosition.y, -0.1f); })); } }
private static void doorTimer_Elapsed(SchedulerTask task) { DoorInfo info = ( DoorInfo )task.UserState; int counter = 0; for (int x = info.Door.Range.Xmin; x <= info.Door.Range.Xmax; x++) { for (int y = info.Door.Range.Ymin; y <= info.Door.Range.Ymax; y++) { for (int z = info.Door.Range.Zmin; z <= info.Door.Range.Zmax; z++) { info.WorldMap.QueueUpdate(new BlockUpdate(null, new Vector3I(x, y, z), info.Buffer[counter])); counter++; } } } lock ( openDoorsLock ) { openDoors.Remove(info.Door); } }
public static DoorInfo GetDoorInfoFromName(string doorcode) { DoorInfo dinfo = new DoorInfo(); dinfo.levelWorld = int.Parse(doorcode[0].ToString()); if (doorcode[1].Equals('A')) { dinfo.typeWorld = TYPE_WORLD.GV; } else if (doorcode[1].Equals('B')) { dinfo.typeWorld = TYPE_WORLD.AR; } else { dinfo.typeWorld = TYPE_WORLD.SIK; } return(dinfo); }
public static DoorInfo GetDoorInfoFromValue(int doorvalue) { DoorInfo dinfo = new DoorInfo(); dinfo.levelWorld = doorvalue % 10; if (doorvalue / 10 == 0) { dinfo.typeWorld = TYPE_WORLD.GV; } else if (doorvalue / 10 == 1) { dinfo.typeWorld = TYPE_WORLD.AR; } else { dinfo.typeWorld = TYPE_WORLD.SIK; } return(dinfo); }
public void SetupMap(DoorInfo doorInfo) { if (doorInfo.TypeWorld == TYPE_WORLD.AR) { currMap = arMap; } else if (doorInfo.TypeWorld == TYPE_WORLD.GV) { currMap = gvMap; } else { currMap = sikMap; } currMap.gameObject.SetActive(true); currMap.SetColor(GameScreenManager.Instance.color1, GameScreenManager.Instance.color2); currMap.SetupMap(); currMap.player.Init(); }
public static List <DoorInfo> BuildService(byte[] deviceData) { var doors = new List <DoorInfo>(); var masterDoor = new DoorInfo(); masterDoor.Name = "门一"; masterDoor.DoorIndex = 1; masterDoor.DoorType = DoorType.Master; //masterDoor.ElectricalAppliances = 0; //masterDoor.CheckOutAction = CheckOutOptions.Button; //masterDoor.AlertType = 0; //masterDoor.Remark = ""; masterDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildDelayOpenService(deviceData[16])); masterDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildOverTimeOpenService(deviceData[18])); masterDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildIllegalOpenService(deviceData[19])); masterDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildUnlockOpenService(deviceData[27])); masterDoor.Services.Add(DuressServiceMapper.BuildService(deviceData)); doors.Add(masterDoor); var slaveDoor = new DoorInfo(); slaveDoor.Name = "门二"; slaveDoor.DoorIndex = 2; slaveDoor.DoorType = DoorType.Slave; //slaveDoor.ElectricalAppliances = 0; //slaveDoor.CheckOutAction = CheckOutOptions.Button; //slaveDoor.AlertType = 0; //slaveDoor.Remark = ""; slaveDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildDelayOpenService(deviceData[20])); slaveDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildOverTimeOpenService(deviceData[22])); slaveDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildIllegalOpenService(deviceData[23])); slaveDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildUnlockOpenService(deviceData[28])); slaveDoor.Services.Add(DuressServiceMapper.BuildService(deviceData)); doors.Add(slaveDoor); return(doors); }
/* Create list door in currword by info door of previous door * */ public void CreateListDoor(DoorInfo info) { listDoor.Clear(); if (info.LevelWorld == 8) { for (int i = 1; i < 9; i++) { listDoor.Add(new DoorInfo(info.TypeWorld, i)); } } else { for (int i = info.LevelWorld + 1; i < 9; i++) { listDoor.Add(new DoorInfo(info.TypeWorld, i)); } for (int i = 1; i < info.LevelWorld + 1; i++) { listDoor.Add(new DoorInfo(info.TypeWorld, i)); } } }
private static void openDoor( Door door, Player player ) { int sx = door.Range.Xmin; int ex = door.Range.Xmax; int sy = door.Range.Ymin; int ey = door.Range.Ymax; int sz = door.Range.Zmin; int ez = door.Range.Zmax; Block[] buffer = new Block[( ex - sx + 1 ) * ( ey - sy + 1 ) * ( ez - sz + 1 )]; int counter = 0; for ( int x = sx; x <= ex; x++ ) { for ( int y = sy; y <= ey; y++ ) { for ( int z = sz; z <= ez; z++ ) { buffer[counter] = player.WorldMap.GetBlock( x, y, z ); player.WorldMap.QueueUpdate( new BlockUpdate( null, new Vector3I( x, y, z ), Block.Air ) ); counter++; } } } DoorInfo info = new DoorInfo( door, buffer, player.WorldMap ); //reclose door Scheduler.NewTask( doorTimer_Elapsed ).RunOnce( info, DoorCloseTimer ); }