public void Add(string doorToken, DoorMode doorMode, Sensor sensor, int timeout) { _settings.Add(new TriggerSettings() { DoorToken = doorToken, DoorMode = doorMode, Sensor = sensor, Timeout = timeout }); }
public SceneOW(OverworldEditor f, Overworld ow, DungeonMain mform) { owForm = f; mainForm = mform; this.ow = ow; //graphics = Graphics.FromImage(scene_bitmap); //this.Image = new Bitmap(4096, 4096); this.MouseUp += new MouseEventHandler(onMouseUp); this.MouseMove += new MouseEventHandler(onMouseMove); this.MouseDoubleClick += new MouseEventHandler(onMouseDoubleClick); this.MouseWheel += SceneOW_MouseWheel; tilesgfxBitmap = new Bitmap(512, 512, 512, PixelFormat.Format8bppIndexed, temptilesgfxPtr); tilemode = new TileMode(this); exitmode = new ExitMode(this); doorMode = new DoorMode(this); entranceMode = new EntranceMode(this); selectedMode = ObjectMode.Tile; itemMode = new ItemMode(this); spriteMode = new SpriteMode(this); transportMode = new TransportMode(this); overlayMode = new OverlayMode(this); gravestoneMode = new GravestoneMode(this); //this.Width = 8192; //this.Height = 8192; //this.Size = new Size(8192, 8192); //this.Refresh(); }
public override void DoubleLockDoor(string Token) { string operationName = "DoubleLock"; Func <DoorCapabilities, bool> capabilitiesCheck = new Func <DoorCapabilities, bool>(DC => DC.DoubleLock && DC.DoubleLockSpecified); Func <DoorMode, bool> operationForbiddenCheck = DM => (DM == DoorMode.LockedDown || DM == DoorMode.LockedOpen); DoorMode target = DoorMode.DoubleLocked; string forbidType = "denied"; DoorOperation(Token, operationName, capabilitiesCheck, operationForbiddenCheck, forbidType, target); }
void DoorOperation(string Token, string operationName, Func <DoorCapabilities, bool> capabilitiesCheck, Func <DoorMode, bool> operationAllowedCheck, string notAllowedSeverity, DoorMode targetState) { Func <DoorMode, DoorMode> transition = new Func <DoorMode, DoorMode>(DM => targetState); DoorOperation(Token, operationName, capabilitiesCheck, operationAllowedCheck, notAllowedSeverity, transition); }
public override void LockDownDoor(string Token) { string operationName = "LockDown"; Func <DoorCapabilities, bool> capabilitiesCheck = new Func <DoorCapabilities, bool>(DC => DC.LockDown && DC.LockDownSpecified); Func <DoorMode, bool> operationForbiddenCheck = DM => (DM == DoorMode.LockedOpen); DoorMode target = DoorMode.LockedDown; string forbidSeverity = "denied"; DoorOperation(Token, operationName, capabilitiesCheck, operationForbiddenCheck, forbidSeverity, target); }
public override void LockOpenReleaseDoor(string Token) { string operationName = "LockedOpen"; Func <DoorCapabilities, bool> capabilitiesCheck = new Func <DoorCapabilities, bool>(DC => DC.LockOpen && DC.LockOpenSpecified); Func <DoorMode, bool> operationForbiddenCheck = DM => (DM != DoorMode.LockedOpen); DoorMode target = DoorMode.Unlocked; string forbidSeverity = "not applicable"; DoorOperation(Token, operationName, capabilitiesCheck, operationForbiddenCheck, forbidSeverity, target); }
/***************************************************************************************/ #region Utils void DoorOperation(string Token, string operationName, Func <DoorCapabilities, bool> capabilitiesCheck, Func <DoorMode, bool> operationForbiddenCheck, string notAllowedSeverity, Func <DoorMode, DoorMode> transition) { LoggingService.LogMessage(string.Format("{0} operation requested for {1}", operationName, Token), ExternalLogging.MessageType.Details); ConfStorageLoad(); EventServerLoad(); if (ConfStorage.DoorStateList.ContainsKey(Token)) { if (capabilitiesCheck(ConfStorage.DoorInfoList[Token].Capabilities)) { DoorState doorState = ConfStorage.DoorStateList[Token]; if (operationForbiddenCheck(doorState.DoorMode)) { string message = String.Format("Door {0} is {1}. Operation {2}", Token, doorState.DoorMode.ToString(), notAllowedSeverity); LoggingService.LogMessage(message, ExternalLogging.MessageType.Error); FaultLib.ReturnFault(message, new string[] { "Sender", "ActionNotSupported" }); //throw FaultLib.GetSoapException(FaultType.General, message); } else { DoorMode targetState = transition(doorState.DoorMode); doorState.DoorMode = targetState; DoorSensorService.ProcessModeChanging(Token, targetState, ConfStorage, EventServer, StateReporter); StateReporter.ReportStateUpdate(Token, doorState); EventServer.DoorModeEvent(this, "Changed", Token, doorState.DoorMode); } } else { string message = string.Format("{0} is not supported for {1}.", operationName, Token); LoggingService.LogMessage(message, ExternalLogging.MessageType.Error); FaultLib.ReturnFault(message, new string[] { "Sender", "ActionNotSupported" }); //throw FaultLib.GetSoapException(FaultType.General, message); } } else { string message = string.Format("Token {0} does not exist", Token); LoggingService.LogMessage(message, ExternalLogging.MessageType.Error); FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" }); //throw FaultLib.GetSoapException(FaultType.General, message); } EventServerSave(); ConfStorageSave(); }
public void GoAtTarget(int targetIndexInList) { if (currTargetGO != null && currTargetGO == targets[targetIndexInList]) { Debug.Log("already On that Floor"); return; } liftAnimator.SetBool("IsMoving", true); currTargetGO = targets[targetIndexInList]; IsGoing = true; openingDoorsMode = currTargetGO.GetComponent <FloorTargetInfo>().DoorModeOnThisFloor; }
public void Open(DoorMode dm, float t) { if (status != DoorPanelStatus.OPEN && pending != DoorPanelStatus.OPEN) { startPos = transform.localPosition; startRot = transform.root.localRotation; switch (dm) { case DoorMode.SLIDE_UP: targetPos = homePos + Vector3.up; targetRot = homeRot; break; case DoorMode.SLIDE_DOWN: targetPos = homePos + Vector3.down; targetRot = homeRot; break; case DoorMode.SLIDE_RIGHT: targetPos = homePos + Vector3.right; targetRot = homeRot; break; case DoorMode.SLIDE_LEFT: targetPos = homePos + Vector3.left; targetRot = homeRot; break; case DoorMode.SWING_RIGHT: targetPos = homePos + transform.InverseTransformPoint(transform.position + (Vector3.forward + Vector3.left) * transform.root.localScale.x / 2f); targetRot = Quaternion.Euler(new Vector3(0f, 90f, 0f)) * homeRot; break; case DoorMode.SWING_LEFT: targetPos = homePos + transform.InverseTransformPoint(transform.position + (Vector3.forward + Vector3.right) * transform.root.localScale.x / 2f); targetRot = Quaternion.Euler(new Vector3(0f, -90f, 0f)) * homeRot; break; default: return; } baseTime = Time.time; movementTime = t; status = DoorPanelStatus.MOVING; pending = DoorPanelStatus.OPEN; } }
public override void UnlockDoor(string Token) { string operationName = "Unlock"; Func <DoorCapabilities, bool> capabilitiesCheck = new Func <DoorCapabilities, bool>(DC => DC.Unlock && DC.UnlockSpecified); Func <DoorMode, bool> operationForbiddenCheck = DM => (DM == DoorMode.LockedDown || DM == DoorMode.LockedOpen); DoorMode target = DoorMode.Locked; string forbidSeverity = "denied"; Func <DoorMode, DoorMode> transition = new Func <DoorMode, DoorMode>( (initial) => { return(initial == DoorMode.DoubleLocked ? DoorMode.Locked : DoorMode.Unlocked); } ); DoorOperation(Token, operationName, capabilitiesCheck, operationForbiddenCheck, forbidSeverity, transition); }
DoorMode?GetDoorStateFromNotification(NotificationMessageHolderType notification) { XmlElement dataElement = notification.Message.GetMessageData(); Dictionary <string, string> dataSimpleItems = dataElement.GetMessageElementSimpleItems(); if (dataSimpleItems.ContainsKey("State")) { DoorMode state; if (DoorMode.TryParse(dataSimpleItems["State"], out state)) { return(state); } return(null); } return(null); }
private void Start() { if (heroTF == null) { heroTF = GameObject.FindGameObjectWithTag("Player").transform; } _currElevatorSpeed = startElevatorSpeed; //liftAnimator = GetComponent<Animator>(); currTargetGO = targets[0]; //openTheDoors(); if (firstGoesFloor != null) { liftAnimator.SetBool("IsMoving", true); currTargetGO = firstGoesFloor; IsGoing = true; openingDoorsMode = currTargetGO.GetComponent <FloorTargetInfo>().DoorModeOnThisFloor; } }
//int selectedMode = 0; public SceneOW(Form1 f) { //graphics = Graphics.FromImage(scene_bitmap); //this.Image = new Bitmap(4096, 4096); this.MouseUp += new MouseEventHandler(onMouseUp); this.MouseMove += new MouseEventHandler(onMouseMove); this.MouseDoubleClick += new MouseEventHandler(onMouseDoubleClick); this.MouseWheel += SceneOW_MouseWheel; mainForm = f; tilesgfxBitmap = new Bitmap(512, 512, 512, PixelFormat.Format8bppIndexed, temptilesgfxPtr); tilemode = new TileMode(this); exitmode = new ExitMode(this); doorMode = new DoorMode(this); entranceMode = new EntranceMode(this); selectedMode = ObjectMode.Tile; itemMode = new ItemMode(this); spriteMode = new SpriteMode(this); transportMode = new TransportMode(this); //this.Refresh(); }
void ValidateDoorModeSimpleItem(NotificationMessageHolderType notification, DoorMode expectedMode) { ValidateDoorModeSimpleItem(notification, expectedMode.ToString()); }
/// <summary> /// Constructor for DoorModePropertyEventArgs /// </summary> /// <param name="doorControlService">Door Control Service object</param> /// <param name="utcTime">UTC time of event</param> /// <param name="propertyOperation">Property operation</param> /// <param name="doorToken">Door Token</param> /// <param name="currentState">Current Door Mode state</param> public DoorModePropertyEventArgs(DoorControlService doorControlService, DateTime utcTime, string propertyOperation, string doorToken, DoorMode currentState) : base(doorControlService, utcTime, propertyOperation, doorToken) { m_currentState = currentState; }
void ValidateDoorIsNotInMode(NotificationMessageHolderType notification, DoorMode notExpectedMode) { ValidateDoorModeSimpleItem(notification, (s) => s != notExpectedMode.ToString(), (s) => string.Format("Expected: not '{0}', actual: '{1}'", notExpectedMode, s)); }
public void ProcessModeChanging(string doorToken, DoorMode mode, ConfStorage storage, EventServer eventServer, ExternalLogging.StateReportingService stateReporter) { if (_eventServer != eventServer || _stateReporter != stateReporter) { _eventServer = eventServer; _stateReporter = stateReporter; InitUpdateActions(); } TriggerSettings[] settings = storage.TriggerConfiguration.Settings.Where(S => S.DoorToken == doorToken).ToArray(); DoorState state = storage.DoorStateList[doorToken]; if (settings != null) { List <TriggerSettings> triggers = new List <TriggerSettings>(); TriggerSettings doorMonitorSettings = settings.Where(S => S.Sensor == Sensor.DoorMonitor && S.DoorMode == mode).FirstOrDefault(); if (doorMonitorSettings != null) { triggers.Add(doorMonitorSettings); } TriggerSettings doorLockMonitorSettings = settings.Where(S => S.Sensor == Sensor.DoorLockMonitor && S.DoorMode == mode).FirstOrDefault(); if (doorLockMonitorSettings != null) { triggers.Add(doorLockMonitorSettings); } TriggerSettings doorDoubleLockMonitorSettings = settings.Where(S => S.Sensor == Sensor.DoorDoubleLockMonitor && S.DoorMode == mode).FirstOrDefault(); if (doorDoubleLockMonitorSettings != null) { triggers.Add(doorDoubleLockMonitorSettings); } List <TriggerSettings> orderedTriggers = triggers.OrderBy(TS => TS.Timeout).ToList(); if (orderedTriggers.Count > 0) { Dictionary <Sensor, object> values = new Dictionary <Sensor, object>(); values.Add(Sensor.DoorMonitor, _doorMonitorValues[mode]); values.Add(Sensor.DoorLockMonitor, _doorLockMonitorValues[mode]); values.Add(Sensor.DoorDoubleLockMonitor, _doorDoubleLockMonitorValues[mode]); int timeout = 0; List <Action> update = new List <Action>(); for (int i = 0; i < orderedTriggers.Count; i++) { TriggerSettings ts = orderedTriggers[i]; int delay = ts.Timeout - timeout; if (delay > 0) { Action del = () => { Thread.Sleep(delay); }; update.Add(del); } Action nextAction = () => _updates[ts.Sensor](state, doorToken, values[ts.Sensor]); System.Diagnostics.Debug.WriteLine(string.Format("{0}: {1} => {2}", ts.Timeout, ts.Sensor, values[ts.Sensor])); update.Add(nextAction); timeout = ts.Timeout; } Action updateAll = new Action( () => { foreach (Action del in update) { del.Invoke(); } }); updateAll.BeginInvoke(null, null); } } }
public static ObstacleData Prototype(string instructionSetID, GameObject prefab, int width, int length, LightMode lightMode, DoorMode doorMode, bool isInteractable, bool useVFX) { ObstacleData prototype = new ObstacleData(); prototype.instructionSetID = instructionSetID; prototype.prefab = prefab; prototype.width = width; prototype.length = length; prototype.lightMode = lightMode; prototype.doorMode = doorMode; prototype.isInteractable = isInteractable; prototype.useVFX = useVFX; return(prototype); }
void ValidateDoorIsInMode(NotificationMessageHolderType notification, DoorMode expectedMode) { ValidateDoorIsInMode(notification, expectedMode.ToString()); }
private static void BuildObstaclePrototype(string instructionSetID, int width, int length, LightMode lightMode, DoorMode doorMode, bool isInteractable, bool useVFX) { obstaclePrototypes.Add(instructionSetID, ObstacleData.Prototype(instructionSetID, GetModelPrototype(instructionSetID), width, length, lightMode, doorMode, isInteractable, useVFX)); }