public Mobile GetMobile(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType, TargetInfliction inflictionType) { Notoriety[] noto = NotoFlagsToArray(notoFlags); Mobile m; switch (targetDistance) { case TargetDistance.Next: m = GetNextMobile(noto, bodyType, MAX_DISTANCE, friendType, inflictionType); break; case TargetDistance.Nearest: m = GetNextMobile(noto, bodyType, 3, friendType, inflictionType); break; case TargetDistance.Closest: m = GetClosestMobile(noto, bodyType, friendType, inflictionType); break; default: throw new ArgumentOutOfRangeException(nameof(targetDistance), targetDistance, null); } return(m); }
public void Update(int ms) { DurationLeft -= ms; if (!TargetDistance.Equals(Vector2.Zero)) { _tom.CharFix.Body.Position += ((Step * ms) / Level.PixelPerMeter); } }
public DistanceViewModel( TargetDistance config, TargetInfoModel model) { this.config = config ?? Settings.Instance.TargetDistance; this.model = model ?? TargetInfoModel.Instance; this.Initialize(); }
public DistanceViewModel( TargetDistance config, TargetInfoModel model) { this.config = config ?? Settings.Instance.TargetDistance; this.model = model ?? TargetInfoModel.Instance; this.RaisePropertyChanged(nameof(Config)); this.RaisePropertyChanged(nameof(Model)); this.Initialize(); }
public bool GetFriend(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType = TargetFriendType.Include) { Mobile m = GetMobile(notoFlags, bodyType, targetDistance, friendType); if (m == null) { return(false); } SetFriend(m); return(true); }
public bool GetEnemy(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType = TargetFriendType.None, TargetInfliction inflictionType = TargetInfliction.Any) { Mobile m = GetMobile(notoFlags, bodyType, targetDistance, friendType, inflictionType); if (m == null) { return(false); } SetEnemy(m); return(true); }
public Mobile GetMobile(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType, TargetInfliction inflictionType, int previousSerial = 0) { Notoriety[] noto = NotoFlagsToArray(notoFlags); Mobile m; switch (targetDistance) { case TargetDistance.Next: m = GetNextMobile(noto, bodyType, MAX_DISTANCE, friendType, inflictionType); break; case TargetDistance.Nearest: Mobile previousMobile = Engine.Mobiles.GetMobile(previousSerial); if (previousMobile == null || previousMobile.Distance > MAX_DISTANCE) { m = GetClosestMobile(noto, bodyType, friendType, inflictionType); } else { m = GetNextMobile(noto, bodyType, MAX_DISTANCE, friendType, inflictionType, false, previousMobile); } break; case TargetDistance.Closest: m = GetClosestMobile(noto, bodyType, friendType, inflictionType); break; case TargetDistance.Previous: m = GetNextMobile(noto, bodyType, MAX_DISTANCE, friendType, inflictionType, true); break; default: throw new ArgumentOutOfRangeException(nameof(targetDistance), targetDistance, null); } return(m); }
public bool GetFriend(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType = TargetFriendType.Include, TargetInfliction inflictionType = TargetInfliction.Any) { Mobile m = GetMobile(notoFlags, bodyType, targetDistance, friendType, inflictionType, targetDistance == TargetDistance.Nearest ? AliasCommands.GetAlias("friend") : 0); if (m == null) { return(false); } SetFriend(m); return(true); }
/* * Returns false if camera didn't move */ private bool ComputeCameraMovement() { var frameDurationFactor = (float)(App.Current.TimeSinceLastFrame) / FRAME_DURATION_AT_60_FPS; if (PositionDistance.Length() > STOP_DISTANCE_THRESHOLD || TargetDistance.Length() > STOP_DISTANCE_THRESHOLD || MoveVelocity.Length() > STOP_DISTANCE_THRESHOLD || _lookingAroundDelta.Length() > STOP_DISTANCE_THRESHOLD || _manipulatedByMouseWheel || _orbitDelta.Length() > 0.001f || _manipulatedByKeyboard) { if (_orbitDelta.Length() > 0.001f) { OrbitByAngle(_orbitDelta); _orbitDelta *= new Vector2(ORBIT_HORIZONTAL_FRICTION, ORBIT_VERTICAL_FRICTION) / frameDurationFactor; } if (MoveVelocity.Length() > MaxMoveVelocity) { MoveVelocity *= MaxMoveVelocity / MoveVelocity.Length(); } else if (!_manipulatedByKeyboard) { MoveVelocity *= (1 - _frictionKeyboardManipulation) / frameDurationFactor; } _cameraPositionGoal += MoveVelocity; _cameraTargetGoal += MoveVelocity + _lookingAroundDelta; _lookingAroundDelta = Vector3.Zero; PositionDistance *= CAMERA_MOVE_FRICTION / frameDurationFactor; TargetDistance *= CAMERA_MOVE_FRICTION / frameDurationFactor; _isTransitionActive = true; _manipulatedByMouseWheel = false; return(true); } else { StopTransitionOfPositionTarget(); _isTransitionActive = false; return(false); } }
private void server_CreateNewTarget() { lastTarget = targets[currentTarget].gameObject; int nextTarget = currentTarget + 8; if (experiment.Trial.TrialNro % 2 == 1) { nextTarget++; } nextTarget = nextTarget % targets.Count; bool doneAllDists = true; bool doneAllWidths = true; foreach (bool done in doneDistances) { if (!done) { doneAllDists = false; } } foreach (bool done in doneWidths) { if (!done) { doneAllWidths = false; } } experiment.Trial.TrialNro++; if (experiment.Trial.TrialNro == NumberOfTrials) { if (doneAllWidths && doneAllDists)//&& doneZones[1] && doneZones[2]) //all zones are done, experiment finishes { nextTarget = -1; all_SetTargetAndTrial(-1, -1); if (Network.isServer) { //if (Network.isClient || Network.isServer) networkView.RPC("all_SetTargetAndTrial", RPCMode.Others, -1, -1); } GameObject osStart1 = TargetSet; GameObject osEnd1 = TargetSet; all_SynchOffScreenTargets(osStart1.name, osEnd1.name); if (Network.isServer) { //if (Network.isClient || Network.isServer) networkView.RPC("all_SynchOffScreenTargets", RPCMode.Others, osStart1.name, osEnd1.name); } Screen.lockCursor = false; return; } else { // Change width, reset distances if (doneAllDists && !doneAllWidths) { TargetWidths newWidth = (TargetWidths)UnityEngine.Random.Range(0, doneWidths.Length); while (doneWidths[(int)newWidth]) { newWidth = (TargetWidths)UnityEngine.Random.Range(0, doneWidths.Length); } all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), newWidth.ToString(), TargetDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), newWidth.ToString(), TargetDistance.ToString()); } doneWidths[(int)newWidth] = true; for (int dist = 0; dist < doneDistances.Length; dist++) { doneDistances[dist] = false; // Do not do distances that will put targets out of view in view based. if (RefFrame == ReferenceFrame.View && dist > 1) { doneDistances[dist] = true; } // Do not do distances that are all in view else if (RefFrame == ReferenceFrame.Body && dist < 2) { doneDistances[dist] = true; } } } // Change distance keep width else { TargetDistances newDistance = (TargetDistances)UnityEngine.Random.Range(0, doneDistances.Length); while (doneDistances[(int)newDistance]) { newDistance = (TargetDistances)UnityEngine.Random.Range(0, doneDistances.Length); } all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), newDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), newDistance.ToString()); } doneDistances[(int)newDistance] = true; } } nextTarget = UnityEngine.Random.Range(0, targets.Count); experiment.Trial.TrialNro = 0; } all_SetTargetAndTrial(nextTarget, experiment.Trial.TrialNro); if (Network.isServer) { //if (Network.isClient || Network.isServer) networkView.RPC("all_SetTargetAndTrial", RPCMode.Others, nextTarget, experiment.Trial.TrialNro); } //creates the offscreen targeting objects GameObject osStart2 = lastTarget; GameObject osEnd2 = targets[currentTarget].gameObject; all_SynchOffScreenTargets(osStart2.name, osEnd2.name); if (Network.isServer) { //if (Network.isClient || Network.isServer) networkView.RPC("all_SynchOffScreenTargets", RPCMode.Others, osStart2.name, osEnd2.name); } }
new void Start() { base.Start(); PrepareOffScreenRay(); experiment = new ExperimentControl("RingSelection"); experiment.DepthPlane = TargetSet; experiment.Camera = EPSONcamera.GetComponent <Camera>(); experiment.LeftEyeCamera = LeftEyeCamera; experiment.Settings = cSettings; experiment.BaseFolder = BaseFolder; experiment.ParticipantNro = ParticipantNro; all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), TargetDistance.ToString()); IndexInitialTargets(); CreateInitialLayout(); }
void OnGUI() { if (!ShowGUI && GUILayout.Button("Show Controls", GUILayout.Width(100), GUILayout.Height(30))) { ShowGUI = true; } else if (ShowGUI && GUILayout.Button("Hide Controls", GUILayout.Width(100), GUILayout.Height(30))) { ShowGUI = false; } CommToAndroid.Instance.ShowGUI = ShowGUI; NetworkProvider.Instance.ShowGUI = ShowGUI; RotationProvider.Instance.ShowGUI = ShowGUI; cSettings.RaycastController.ShowGUI = ShowGUI; if (ShowGUI) { if (GUILayout.Button("Start", GUILayout.Width(100), GUILayout.Height(30))) { //starts the experiment on the desktop (server) or when it's standalone if (!NetworkProvider.Instance.isConnected || Network.isServer) { server_StartExperiment(); Screen.lockCursor = true; } else { networkView.RPC("server_StartExperiment", RPCMode.Server); } } // GUI for changing reference frames(view/body/world) GUILayout.BeginArea(new Rect(0, 65, 50, 150)); System.Array refFrames = System.Enum.GetValues(typeof(ReferenceFrame)); GUILayout.Label("RefFrame:", GUILayout.Width(100), GUILayout.Height(20)); foreach (ReferenceFrame refFrame in refFrames) { bool isCurrent = refFrame == RefFrame; if (GUILayout.Toggle(isCurrent, refFrame.ToString(), GUILayout.Width(100), GUILayout.Height(25)) && !isCurrent) //-- this last piece is VERY important { //calls both the remote and the local method all_UpdateReferenceFrame(Zone.ToString(), refFrame.ToString(), TargetWidth.ToString(), TargetDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), refFrame.ToString(), TargetWidth.ToString(), TargetDistance.ToString()); } } } GUILayout.EndArea(); // GUI for changing parameters(width/amplitude) GUILayout.BeginArea(new Rect(60, 65, 50, 200)); System.Array targetWidths = System.Enum.GetValues(typeof(TargetWidths)); GUILayout.Label("TargetWidth:", GUILayout.Width(100), GUILayout.Height(20)); foreach (TargetWidths targetWidth in targetWidths) { bool isCurrent = targetWidth == TargetWidth; if (GUILayout.Toggle(isCurrent, targetWidth.ToString(), GUILayout.Width(100), GUILayout.Height(25)) && !isCurrent) //-- this last piece is VERY important { //calls both the remote and the local method all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), targetWidth.ToString(), TargetDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), targetWidth.ToString(), TargetDistance.ToString()); } } } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(120, 65, 50, 200)); System.Array targetDistances = System.Enum.GetValues(typeof(TargetDistances)); GUILayout.Label("TargetDistance:", GUILayout.Width(100), GUILayout.Height(20)); foreach (TargetDistances targetDistance in targetDistances) { bool isCurrent = targetDistance == TargetDistance; if (GUILayout.Toggle(isCurrent, targetDistance.ToString(), GUILayout.Width(100), GUILayout.Height(25)) && !isCurrent) //-- this last piece is VERY important { //calls both the remote and the local method all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), targetDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), targetDistance.ToString()); } } } GUILayout.EndArea(); } GUILayout.BeginArea(new Rect(Screen.width - 100, Screen.height - 100, 100, 100)); GUILayout.Label("Trial " + (experiment.Trial.TrialNro + 1) + "/" + NumberOfTrials, GUILayout.Width(100), GUILayout.Height(20)); GUILayout.EndArea(); }
public bool UpdateAndCheckIfRedrawRequired() { if (_showSceneControl.RenderSetup == null) { return(false); } // Stop all transitions when switching between camera-ops if (_showSceneControl.RenderSetup.CurrentCameraOp != _cameraOperator) { _cameraOperator = _showSceneControl.RenderSetup.CurrentCameraOp; _cameraPositionGoal = _showSceneControl.RenderSetup.CameraPosition; _cameraTargetGoal = _showSceneControl.RenderSetup.CameraTarget; MoveVelocity = Vector3.Zero; _isTransitionActive = false; } // This is an extremely unfortunate solution to check if the camera has been manipulated from the // outside (e.g. by another view, parameters or animation) if (!_isTransitionActive && (PositionDistance.Length() > STOP_DISTANCE_THRESHOLD || TargetDistance.Length() > STOP_DISTANCE_THRESHOLD)) { _cameraPositionGoal = _showSceneControl.RenderSetup.CameraPosition; _cameraTargetGoal = _showSceneControl.RenderSetup.CameraTarget; return(true); } var redrawRequired = false; UpdateRawMouseData(); if (_lockInteraction) { return(false); } _lockInteraction = true; // Manipulation... redrawRequired |= ManipulateGizmos(); if (_showSceneControl.RenderSetup.TransformGizmo.State != TransformGizmo.TransformGizmo.GizmoStates.Dragged) { ManipulateCameraByMouse(); } _manipulatedByKeyboard = ManipulateCameraByKeyboard(); _spaceMouse.ManipulateCamera(); // Transition... redrawRequired |= ComputeCameraMovement(); _lockInteraction = false; return(redrawRequired); }
/** * WPF will discard some mouse-wheel events on slow framerates which leads to a laggy * interaction in complex scenes. For that reason, we include the framerate into the zoom-speed * and -- sadly -- avoid transitions for for zooming. */ public void HandleMouseWheel(float delta) { var transitionActive = PositionDistance.Length() > STOP_DISTANCE_THRESHOLD || TargetDistance.Length() > STOP_DISTANCE_THRESHOLD; var viewDirection = transitionActive ? _cameraPositionGoal - _cameraTargetGoal : _showSceneControl.RenderSetup.CameraPosition - _showSceneControl.RenderSetup.CameraTarget; var frameDurationFactor = (float)(App.Current.TimeSinceLastFrame) / FRAME_DURATION_AT_60_FPS; var zoomFactorForCurrentFramerate = 1 + (ZOOM_SPEED * frameDurationFactor); if (delta < 0) { viewDirection *= zoomFactorForCurrentFramerate; } else { viewDirection /= zoomFactorForCurrentFramerate; } _showSceneControl.RenderSetup.CameraPosition = _cameraPositionGoal = _cameraTargetGoal + viewDirection; _manipulatedByMouseWheel = true; }