/////////////////////////////////////////////////////////////////////////////// // Construction and Initializing methods // /////////////////////////////////////////////////////////////////////////////// #region CONSTRUCTION /// <summary> /// Initializes a new instance of the GrabHandle class. /// </summary> /// <param name="newLocation">new grab handle location</param> /// <param name="newCursor">new grab handle mouse over cursor</param> /// <param name="newHandlePosition">Position indicator</param> public GrabHandle(Point newLocation, Cursor newCursor, HandlePosition newHandlePosition) { this.size = new Size(HANDLESIZE, HANDLESIZE); this.location = newLocation; this.cursor = newCursor; this.handlePosition = newHandlePosition; }
/// <summary> /// Initializes a new instance of the GrabHandle class. /// </summary> /// <param name="newLocation">new grab handle location</param> /// <param name="newCursor">new grab handle mouse over cursor</param> /// <param name="newHandlePosition">Position indicator</param> public GrabHandle(PointF newLocation, Cursor newCursor, HandlePosition newHandlePosition) { this.size = new Size(HANDLESIZE, HANDLESIZE); this.location = newLocation; this.cursor = newCursor; this.handlePosition = newHandlePosition; }
/// <summary> /// Updates the Pilot instance. /// </summary> public override void Update() { Update(Cockpit); var oldPosition = Position; Position = Move; if (oldPosition == Position) { return; } //Set PilotHandle to new position. Cockpit.PilotHandle.Position = Position; Cockpit.PilotHandle.Moved(); }
/// <summary> /// Updates the computing model according to the computed values and received inputs. /// </summary> public override void Update() { _oldHandlePosition = HandlePosition.Value; //Compute new values Update(HandlePosition, AnalogicalSwitch, FrontGearExtented, FrontGearRetracted, FrontGearShockAbsorber, LeftGearExtented, LeftGearRetracted, LeftGearShockAbsorber, RightGearExtented, RightGearRetracted, RightGearShockAbsorber, FrontDoorClosed, FrontDoorOpen, LeftDoorClosed, LeftDoorOpen, RightDoorClosed, RightDoorOpen, CircuitPressurized, _actionSequence); //Reset system health monitoring if action sequence has been reversed. if (_actionSequence.Reset) { foreach (var m in _systemHealth) { m.Reset(); } } Update(_systemHealth); //Look for anomaly if (_systemHealth.Any(element => element.AnomalyDetected)) { Anomaly = true; } if (HandlePosition.Valid == false || AnalogicalSwitch.Valid == false || FrontGearExtented.Valid == false || FrontGearRetracted.Valid == false || FrontGearShockAbsorber.Valid == false || LeftGearExtented.Valid == false || LeftGearRetracted.Valid == false || LeftGearShockAbsorber.Valid == false || RightGearExtented.Valid == false || RightGearRetracted.Valid == false || RightGearShockAbsorber.Valid == false || FrontDoorClosed.Valid == false || FrontDoorOpen.Valid == false || LeftDoorClosed.Valid == false || LeftDoorOpen.Valid == false || RightDoorClosed.Valid == false || RightDoorOpen.Valid == false || CircuitPressurized.Valid == false) { Anomaly = true; } //Cockpit Lights //True if and only if all three gears are seen as locked in extended position GearsLockedDown = GearsExtended; //True if and only if at least one door or one gear is maneuvering, i.e. at least on edoor is not locked in closed position or one gear is not locked in retracted or extended position GearsManeuvering = (!FrontDoorClosed.Value || !LeftDoorClosed.Value || !RightDoorClosed.Value) || (!FrontGearExtented.Value && !FrontGearRetracted.Value) || (!LeftGearExtented.Value && !LeftGearRetracted.Value) || (!RightGearExtented.Value && !RightGearRetracted.Value); }
private void resizeHandles(GameObject handle, HandlePosition handlePosition) { BoxCollider colls = handle.GetComponent <BoxCollider>(); switch (handlePosition) { case HandlePosition.NW: handle.transform.localPosition = new Vector3(-radius, radius, 0); break; case HandlePosition.N: handle.transform.localPosition = new Vector3(0, radius, 0); break; case HandlePosition.NE: handle.transform.localPosition = new Vector3(radius, radius, 0); break; case HandlePosition.E: handle.transform.localPosition = new Vector3(radius, midY, 0); break; case HandlePosition.SE: handle.transform.localPosition = new Vector3(radius, minY, 0); break; case HandlePosition.S: handle.transform.localPosition = new Vector3(0, minY, 0); break; case HandlePosition.SW: handle.transform.localPosition = new Vector3(-radius, minY, 0); break; case HandlePosition.W: handle.transform.localPosition = new Vector3(-radius, midY, 0); break; } }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="startPosition">Indicates the initial position of the pilot handle.</param> public Pilot(HandlePosition startPosition) { Position = startPosition; }
private static float Begin(float size, float minSize, float maxSize, bool vertical, HandlePosition handlePosition, params GUILayoutOption[] options) { int controlId = GUIUtility.GetControlID(ControlHint, FocusType.Passive); ResizableContainerState state = (ResizableContainerState)GUIUtility.GetStateObject(typeof(ResizableContainerState), controlId); state.vertical = vertical; state.controlId = controlId; state.handlePosition = handlePosition; if (state.applySize) { size = Mathf.Max(minSize, Mathf.Min(state.size, maxSize)); state.applySize = false; } else { state.size = size; } resizableContainerStates.Push(state); GUILayoutOption[] newOptions; if (options == null || options.Length == 0) { newOptions = new GUILayoutOption[1]; } else { newOptions = new GUILayoutOption[options.Length + 1]; for (int i = 0; i < options.Length; i++) { newOptions[i] = options[i]; } } if (vertical) { newOptions[newOptions.Length - 1] = GUILayout.Height(size); EditorGUILayout.BeginVertical(newOptions); } else { newOptions[newOptions.Length - 1] = GUILayout.Width(size); EditorGUILayout.BeginHorizontal(newOptions); } if (handlePosition == HandlePosition.Before) { DrawHandle(state); } return(size); }
public static float BeginHorizontal(float width, float minWidth, float maxWidth, HandlePosition handlePosition, params GUILayoutOption[] options) { return(Begin(width, minWidth, maxWidth, false, handlePosition, options)); }
public static float BeginHorizontal(float width, HandlePosition handlePosition, params GUILayoutOption[] options) { return(BeginHorizontal(width, 0f, float.MaxValue, handlePosition, options)); }
public static float BeginVertical(float height, float minHeight, float maxHeight, HandlePosition handlePosition, params GUILayoutOption[] options) { return(Begin(height, minHeight, maxHeight, true, handlePosition, options)); }
public static float BeginVertical(float height, HandlePosition handlePosition, params GUILayoutOption[] options) { return(BeginVertical(height, 0f, float.MaxValue, handlePosition, options)); }
private static float Begin(float size, float minSize, float maxSize, bool vertical, HandlePosition handlePosition, params GUILayoutOption[] options) { int controlId = GUIUtility.GetControlID(ControlHint, FocusType.Passive); ResizableContainerState state = (ResizableContainerState) GUIUtility.GetStateObject(typeof(ResizableContainerState), controlId); state.vertical = vertical; state.controlId = controlId; state.handlePosition = handlePosition; if (state.applySize) { size = Mathf.Max(minSize, Mathf.Min(state.size, maxSize)); state.applySize = false; } else { state.size = size; } resizableContainerStates.Push(state); GUILayoutOption[] newOptions; if (options == null || options.Length == 0) { newOptions = new GUILayoutOption[1]; } else { newOptions = new GUILayoutOption[options.Length + 1]; for(int i = 0; i < options.Length; i++) { newOptions[i] = options[i]; } } if (vertical) { newOptions[newOptions.Length - 1] = GUILayout.Height(size); EditorGUILayout.BeginVertical(newOptions); } else { newOptions[newOptions.Length - 1] = GUILayout.Width(size); EditorGUILayout.BeginHorizontal(newOptions); } if (handlePosition == HandlePosition.Before) { DrawHandle(state); } return size; }
public static float BeginVertical(float height, float minHeight, float maxHeight, HandlePosition handlePosition, params GUILayoutOption[] options) { return Begin(height, minHeight, maxHeight, true, handlePosition, options); }
public static float BeginVertical(float height, HandlePosition handlePosition, params GUILayoutOption[] options) { return BeginVertical(height, 0f, float.MaxValue, handlePosition, options); }
public static float BeginHorizontal(float width, float minWidth, float maxWidth, HandlePosition handlePosition, params GUILayoutOption[] options) { return Begin(width, minWidth, maxWidth, false, handlePosition, options); }
public static float BeginHorizontal(float width, HandlePosition handlePosition, params GUILayoutOption[] options) { return BeginHorizontal(width, 0f, float.MaxValue, handlePosition, options); }