/// <summary> /// Freeze action. /// </summary> public void Freeze(float freezeTime) { if (!CanDamage) { return; } // cannot be freeze. if (!mCanFreeze) { return; } // freeze x velocity. if (VelocityInfo != null) { VelocityInfo.Freeze(); } LiveObjectAnimator.StopAnimationInFrame(); spriteRenderer.color = BF_GameSettings.instance.FREEZE_COLOR; mFreezeTime = freezeTime; mIsFreeze = true; }
protected override Vector3 CalculateVelocity(VelocityInfo velocityInfo) { Vector3 currentVelocity = velocityInfo.currentVelocity; Vector3 impulseVelocity = velocityInfo.impulseVelocity; Vector3 impulseVelocityRedirectble = velocityInfo.impulseVelocityRedirectble; //Kill Y velocity if just get grounded so not to slide if (characterMotor.GroundingStatus.IsStableOnGround && !characterMotor.LastGroundingStatus.IsStableOnGround) { currentVelocity = Vector3.ProjectOnPlane(currentVelocity, characterMotor.CharacterUp); currentVelocity = characterMotor.GetDirectionTangentToSurface(currentVelocity, characterMotor.GroundingStatus.GroundNormal) * currentVelocity.magnitude; } Vector3 totalImpulse = impulseVelocity; Vector3 resultingVelocity; Vector3 horizontalVelocity = CalculateHorizontalVelocity(currentVelocity); Vector3 verticalVelocity = CalculateVerticalVelocity(currentVelocity); //Redirect impulseVelocityRedirectble if conditions met if (EnableRedirect && CheckRedirectConditions(impulseVelocityRedirectble)) { totalImpulse += CalculateRedirectedImpulse(impulseVelocityRedirectble); } else { totalImpulse += impulseVelocityRedirectble; } resultingVelocity = horizontalVelocity + verticalVelocity; resultingVelocity += totalImpulse; return(resultingVelocity); }
private void UpdateVelocity(VelocityInfo velocityInfo) { SetMoveDirection(); Vector3 newVelocity; CharacterGroundingReport GroundingStatus = playerController.GroundingStatus; CharacterTransientGroundingReport LastGroundingStatus = playerController.LastGroundingStatus; //Take move input direction directly and flatten (Dont do turn smoothing for now) float slopeMoveSpeed = 10f; newVelocity = moveDirection.xoz() * slopeMoveSpeed; //Project velocity sideways along slope Vector3 slopeRight = Vector3.Cross(Vector3.up, GroundingStatus.GroundNormal); Vector3 slopeOut = Vector3.Cross(slopeRight, Vector3.up); newVelocity = Vector3.ProjectOnPlane(newVelocity, slopeOut).xoz(); //Add velocity down slope float slopeFallSpeed = 20f; Vector3 fallVelocity = slopeFallSpeed * Vector3.down; newVelocity += Vector3.ProjectOnPlane(fallVelocity, GroundingStatus.GroundNormal); NewVelocityOut.Value = newVelocity; UpdateSlopeSlidePivot(); }
/// <summary> /// Gets the velocity data for the session's username and password. /// </summary> /// <param name="sessionId">The Session ID returned from the JavaScript data collector.</param> /// <param name="username">The username of the user.</param> /// <param name="password">The password of the user.</param> /// <returns>Velocity data</returns> public VelocityInfo GetVelocity(string sessionId, string username, string password) { ValidateSession(sessionId); using (IWebClient client = this._webClientFactory.Create()) { PrepareWebClient((WebClient)client, true); NameValueCollection reqparm = GetRequestedParams(sessionId, username, password); this.LogRequest(VelocityEndpoint, username: username, password: password, session: sessionId); try { byte[] responsebytes = client.UploadValues(VelocityEndpoint, "POST", reqparm); string responsebody = Encoding.UTF8.GetString(responsebytes); VelocityInfo dInfo = JsonConvert.DeserializeObject <VelocityInfo>(responsebody); return(dInfo); } catch (WebException ex) { HandleWebException(ex); } return(null); } }
private void UpdateVelocity(VelocityInfo velocityInfo) { Vector3 currentVelocity = velocityInfo.currentVelocity; currentVelocity = Vector3.down * PoundSpeed.Value; NewVelocityOut.Value = currentVelocity; }
public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime) { //NOTE: this was moved to states //Kill Y velocity if just get grounded so not to slide // if (charMotor.GroundingStatus.IsStableOnGround && !charMotor.LastGroundingStatus.IsStableOnGround) // { // currentVelocity = Vector3.ProjectOnPlane(currentVelocity , charMotor.CharacterUp); // currentVelocity = charMotor.GetDirectionTangentToSurface(currentVelocity , // charMotor.GroundingStatus.GroundNormal) * currentVelocity .magnitude; // } VelocityInfo velocityInfo = new VelocityInfo() { currentVelocity = currentVelocity, impulseVelocity = impulseVelocity, impulseVelocityRedirectble = impulseVelocityRedirectable }; //Only use NewVelocity if there was subscriber that handled the update //Otherwise, will risk using stale value from last subscriber update! if (onStartUpdateVelocity != null) { onStartUpdateVelocity.Invoke(velocityInfo); currentVelocity = NewVelocity.Value; } #region OverlayedVelocity if (impulseVelocityOverlayed.y > 0f) { UngroundMotor(); } if (!Mathf.Approximately(0f, impulseVelocityOverlayed.sqrMagnitude)) { currentVelocity += impulseVelocityOverlayed; NewVelocity.Value = currentVelocity; //Update new velocity to keep in sync } if (!Mathf.Approximately(0f, impulseVelocityOverlayedOverrideX.sqrMagnitude)) { currentVelocity = impulseVelocityOverlayedOverrideX; NewVelocity.Value = currentVelocity; //Update new velocity to keep in sync } if (!Mathf.Approximately(StoredJumpVelocity.Value, 0f)) { currentVelocity.y = StoredJumpVelocity.Value; NewVelocity.Value = currentVelocity; //Update new velocity to keep in sync } #endregion impulseVelocity = Vector3.zero; impulseVelocityRedirectable = Vector3.zero; impulseVelocityOverlayed = Vector3.zero; impulseVelocityOverlayedOverrideX = Vector3.zero; }
public SimulationStep() { Pitch = new PitchInfo(); Control = new ControlInfo(); Coordinates = new CoordinatesInfo(); Velocity = new VelocityInfo(); Acceleration = new AccelerationInfo(); Atmosphere = new AtmosphereInfo(); Aerodynamics = new AerodynamicsInfo(); Control = new ControlInfo(); }
/// <summary> /// Opposite of freeze effect. /// </summary> public void UnFreeze() { if (VelocityInfo != null) { VelocityInfo.UnFreeze(); } spriteRenderer.color = Color.white; mIsFreeze = false; LiveObjectAnimator.PlayAnimationInFrame(); }
private void UpdateVelocity(VelocityInfo velocityInfo) { //If not grounded yet, keep y velocity going until grounded if (!playerController.GroundingStatus.IsStableOnGround) { NewVelocityOut.Value = velocityInfo.currentVelocity.y * Vector3.one.oyo(); } else { NewVelocityOut.Value = Vector3.zero; } }
protected override Vector3 CalculateVelocity(VelocityInfo velocityInfo) { return(base.CalculateVelocity(velocityInfo)); //If not grounded yet, keep y velocity going until grounded if (!playerController.GroundingStatus.IsStableOnGround) { return(Vector3.down * 10f); } return(Vector3.zero); }
private void UpdateVelocity(VelocityInfo velocityInfo) { NewVelocityOut.Value = SlingshotDirection.Value * currentSpeed; if (slingshotTargetSceneReference.Value != null) { Vector3 playerToTarget = (slingshotTargetSceneReference.Value.position - playerController.transform.position).normalized; NewVelocityOut.Value = playerToTarget * currentSpeed; } previousVelocityOutput = NewVelocityOut.Value; }
protected override Vector3 CalculateVelocity(VelocityInfo velocityInfo) { Vector3 currentVelocity = velocityInfo.currentVelocity; Vector3 impulseVelocity = velocityInfo.impulseVelocity; Vector3 impulseVelocityRedirectble = velocityInfo.impulseVelocityRedirectble; Vector3 totalImpulse = impulseVelocity; Vector3 resultingVelocity; Vector3 horizontalVelocity = CalculateHorizontalVelocity(currentVelocity); Vector3 verticalVelocity = CalculateVerticalVelocity(currentVelocity); //Redirect impulseVelocityRedirectble if conditions met if (EnableRedirect && CheckRedirectConditions(impulseVelocityRedirectble)) { totalImpulse += CalculateRedirectedImpulse(impulseVelocityRedirectble); } else { totalImpulse += impulseVelocityRedirectble; } //Cache moveInput value for fast turn if (MoveInput.Value.magnitude > FastTurnInputDeadZone.Value) { lastMoveInputDirection = MoveInput.Value.normalized; } if (Mathf.Approximately(totalImpulse.magnitude, 0f)) { resultingVelocity = horizontalVelocity + verticalVelocity; } //If y of impulseVelocity is 0, dont override current y component else if (Mathf.Approximately(totalImpulse.y, 0f)) { resultingVelocity = horizontalVelocity + verticalVelocity + totalImpulse; } //Add impulse and override current y component else { resultingVelocity = horizontalVelocity + totalImpulse; } return(resultingVelocity); }
public void TestGetVelocityWebExceptionWithResponse() { try { MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonVeloInfo); AccessSdk sdk = new AccessSdk("gty://bad.host.com", merchantId, apiKey, DEFAULT_VERSION, mockFactory); VelocityInfo vInfo = sdk.GetVelocity(session, user, password); Assert.Fail($"AccessException Not thrown"); } catch (AccessException ae) { Assert.AreEqual(ae.ErrorType, AccessErrorType.NETWORK_ERROR); Assert.IsTrue("BAD RESPONSE(OK):OK. UNKNOWN NETWORK ISSUE.".Equals(ae.Message.Trim())); } }
private void UpdateVelocity(VelocityInfo velocityInfo) { Vector3 currentVelocity = velocityInfo.currentVelocity; if (restrictX) { currentVelocity.x = 0f; } if (restrictY) { currentVelocity.y = 0f; } if (restrictZ) { currentVelocity.z = 0f; } NewVelocityOut.Value = currentVelocity; }
protected override Vector3 CalculateVelocity(VelocityInfo velocityInfo) { Vector3 currentVelocity = velocityInfo.currentVelocity; Vector3 impulseVelocity = velocityInfo.impulseVelocity; Vector3 impulseVelocityRedirectble = velocityInfo.impulseVelocityRedirectble; //Kill Y velocity if just get grounded so not to slide if (characterMotor.GroundingStatus.IsStableOnGround && !characterMotor.LastGroundingStatus.IsStableOnGround) { currentVelocity = Vector3.ProjectOnPlane(currentVelocity, characterMotor.CharacterUp); currentVelocity = characterMotor.GetDirectionTangentToSurface(currentVelocity, characterMotor.GroundingStatus.GroundNormal) * currentVelocity.magnitude; } Vector3 horizontalVelocity = CalculateHorizontalVelocity(currentVelocity); //Addive in XZ but sets in Y return(horizontalVelocity + impulseVelocity); }
public void TestGetVelocity() { try { MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonVeloInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); VelocityInfo vInfo = sdk.GetVelocity(session, user, password); Assert.IsNotNull(vInfo); this.logger.Debug(JsonConvert.SerializeObject(vInfo)); Assert.IsTrue(velocityInfo.Velocity.Password.Equals(vInfo.Velocity.Password)); Assert.AreEqual(vInfo.ResponseId, responseId); } catch (AccessException ae) { Assert.Fail($"Bad exception {ae.ErrorType}:{ae.Message}"); } }
private void UpdateVelocity(VelocityInfo velocityInfo) { NewVelocityOut.Value = Vector3.zero; }
/// <summary> /// Simple Example within the Constructor. /// </summary> public KountAccessExample() { try { // Create the SDK. If any of these values are invalid, an com.kount.kountaccess.AccessException will be // thrown along with a message detailing why. AccessSdk sdk = new AccessSdk(host, merchantId, apiKey); // If you want the device information for a particular user's session, just pass in the sessionId. This // contains the id (fingerprint), IP address, IP Geo Location (country), whether the user was using a proxy // (and it was bypassed), and ... DeviceInfo deviceInfo = sdk.GetDevice(this.session); this.PrintDeviceInfo(deviceInfo.Device); // ... if you want to see the velocity information in relation to the users session and their account // information, you can make an access (velocity) request. Usernames and passwords will be hashed prior to // transmission to Kount within the SDK. You may optionally hash prior to passing them in as long as the // hashing method is consistent for the same value. String username = "******"; String password = "******"; VelocityInfo accessInfo = sdk.GetVelocity(session, username, password); // Let's see the response Console.WriteLine("Response: " + accessInfo); // Each Access Request has its own uniqueID Console.WriteLine("This is our access response_id: " + accessInfo.ResponseId); // The device is included in an access request: this.PrintDeviceInfo(accessInfo.Device); // you can get the device information from the accessInfo object Device device = accessInfo.Device; string jsonVeloInfo = JsonConvert.SerializeObject(accessInfo); Console.WriteLine(jsonVeloInfo); this.PrintVelocityInfo(accessInfo.Velocity); // Or you can access specific Metrics directly. Let's say we want the // number of unique user accounts used by the current sessions device // within the last hour int numUsersForDevice = accessInfo.Velocity.Device.ulh; Console.WriteLine( "The number of unique user access request(s) this hour for this device is:" + numUsersForDevice); // Decision Information is stored in a JSONObject, by entity type DecisionInfo decisionInfo = sdk.GetDecision(session, username, password); Decision decision = decisionInfo.Decision; // Let's look at the data this.PrintDecisionInfo(decision); // Get Kount Access data for session based on what was requested in the info flag String uniq = "uniq(customer identifier)"; DataSetElements dataSet = new DataSetElements() .WithInfo() .WithVelocity() .WithDecision() .WithTrusted() .WithBehavioSec(); Info info = sdk.GetInfo(session, username, password, uniq, dataSet); this.PrintDeviceInfo(info.Device); this.PrintDecisionInfo(info.Decision); this.PrintVelocityInfo(info.Velocity); this.PrintFields(info.Trusted); this.PrintFields(info.BehavioSec); // Get devices that belong to a uniq user. DevicesInfo devices = sdk.GetDevices(uniq); foreach (var d in devices.Devices) { this.PrintFields(d); } // Get the uniq users that belong to a device. string deviceId = "DEVICE_ID"; var uniques = sdk.GetUniques(deviceId); foreach (var u in uniques.Uniques) { this.PrintFields(u); } // Update device trust referenced by session ID sdk.SetDeviceTrustBySession(session, uniq, DeviceTrustState.Banned); // Update device trust referenced by device ID sdk.SetDeviceTrustByDevice(uniq, deviceId, DeviceTrustState.Trusted); // Update behavior data. string timing = "timing data"; // BehavioHost and BehavioEnvironment can be set via AccessSdk constructor too. // sdk.BehavioHost = "https://api.behavio.kaptcha.com"; //sdk.BehavioEnvironment = "sandbox"; //sdk.SetBehavioSec(session, uniq, timing); } catch (AccessException ae) { // These can be thrown if there were any issues making the request. // See the AccessException class for more information. Console.WriteLine("ERROR Type: " + ae.ErrorType); Console.WriteLine("ERROR: " + ae.Message); } }
protected override Vector3 CalculateVelocity(VelocityInfo velocityInfo) { Vector3 currentVelocity = velocityInfo.currentVelocity; Vector3 impulseVelocity = velocityInfo.impulseVelocity; Vector3 impulseVelocityRedirectble = velocityInfo.impulseVelocityRedirectble; Vector3 totalImpulse = impulseVelocity; Vector3 resultingVelocity; Vector3 horizontalVelocity = CalculateHorizontalVelocity(currentVelocity); Vector3 verticalVelocity = CalculateVerticalVelocity(currentVelocity); //Redirect impulseVelocityRedirectble if conditions met if (EnableRedirect && CheckRedirectConditions(impulseVelocityRedirectble)) { totalImpulse += CalculateRedirectedImpulse(impulseVelocityRedirectble); } else { totalImpulse += impulseVelocityRedirectble; } resultingVelocity = horizontalVelocity + verticalVelocity; resultingVelocity += totalImpulse; CharacterGroundingReport GroundingStatus = playerController.GroundingStatus; CharacterTransientGroundingReport LastGroundingStatus = playerController.LastGroundingStatus; #region Bounce //Bounce if just became grounded Vector3 velocityIntoGround = Vector3.Project(previousVelocityOutput, -GroundingStatus.GroundNormal); float velocityGroundDot = Vector3.Dot(previousVelocityOutput.normalized, GroundingStatus.GroundNormal); if (EnableBounce && !LastGroundingStatus.FoundAnyGround && GroundingStatus.FoundAnyGround && velocityIntoGround.magnitude >= BounceThresholdVelocity.Value && -velocityGroundDot > BounceGroundDotThreshold.Value) { playerController.UngroundMotor(); BounceGameEvent.Raise(); //Reflect velocity perfectly then dampen the y based on dot with normal Vector3 reflectedVelocity = Vector3.Reflect(previousVelocityOutput, GroundingStatus.GroundNormal); reflectedVelocity.y *= BounceFactor.Value; //Redirect bounce if conditions met if (EnableRedirect && CheckRedirectConditions(reflectedVelocity)) { reflectedVelocity = CalculateRedirectedImpulse(reflectedVelocity); } resultingVelocity = reflectedVelocity; } #endregion previousVelocityOutput = resultingVelocity; return(resultingVelocity); }
public void TestSdkInit() { ILoggerFactory factory = LogFactory.GetLoggerFactory(); this.logger = factory.GetLogger(typeof(AccessSDKTestBase).ToString()); deviceInfo = new DeviceInfo(); deviceInfo.Device = new Device { Country = ipGeo, Region = "ID", GeoLat = 43.37, GeoLong = -116.200, Id = fingerprint, IpAddress = ipAddress, IpGeo = ipGeo, Mobile = 1, Proxy = 0 }; deviceInfo.ResponseId = responseId; jsonDevInfo = JsonConvert.SerializeObject(deviceInfo); velocityInfo = new VelocityInfo(); velocityInfo.Device = deviceInfo.Device; velocityInfo.ResponseId = responseId; velocityInfo.Velocity = new Velocity(); velocityInfo.Velocity.Account = new SubAccount { dlh = 1, dlm = 1, iplh = 1, iplm = 1, plh = 1, plm = 1, ulh = 1, ulm = 1 }; velocityInfo.Velocity.Device = new SubDevice { alh = 1, alm = 1, iplh = 3, iplm = 3, plh = 2, plm = 2, ulh = 1, ulm = 1 }; velocityInfo.Velocity.IpAddress = new SubAddress { ulm = 3, ulh = 3, plm = 3, plh = 3, alh = 2, alm = 2, dlh = 1, dlm = 1 }; velocityInfo.Velocity.Password = new SubPassword { dlm = 2, dlh = 2, alm = 2, alh = 2, iplh = 1, iplm = 1, ulh = 3, ulm = 3 }; velocityInfo.Velocity.User = new SubUser { iplm = 3, iplh = 3, alh = 2, alm = 2, dlh = 2, dlm = 2, plh = 1, plm = 1 }; jsonVeloInfo = JsonConvert.SerializeObject(velocityInfo); decisionInfo = new DecisionInfo(); decisionInfo.Device = deviceInfo.Device; decisionInfo.ResponseId = responseId; decisionInfo.Velocity = velocityInfo.Velocity; decisionInfo.Decision = new Decision { Errors = new List <string> { "E1", "E2" }, Warnings = new List <string> { "W1", "W2" }, Reply = new Reply { RuleEvents = new RuleEvents { Decision = decision, Total = 10, Events = new List <string> { "Event 1", "Event 2" } } } }; jsonDeciInfo = JsonConvert.SerializeObject(decisionInfo); info = new Info(); info.Device = deviceInfo.Device; info.Decision = decisionInfo.Decision; info.Velocity = velocityInfo.Velocity; info.ResponseId = responseId; info.Trusted = new TrustState() { State = DeviceTrustState.Trusted }; info.BehavioSec = new BehavioSec() { Confidence = 0, IsBot = false, IsTrained = false, PolicyId = 4, Score = 0 }; jsonInfo = JsonConvert.SerializeObject(info); devicesInfo = new DevicesInfo(); devicesInfo.ResponseId = responseId; devicesInfo.Devices = new List <DeviceBasicInfo>() { new DeviceBasicInfo() { DeviceId = "54569fcbd187483a8a1570a3c67d1113", FriendlyName = "Device A", TrustState = DeviceTrustState.Trusted, DateFirstSeen = DateTime.UtcNow.AddHours(-1) }, new DeviceBasicInfo() { DeviceId = "abcdef12345678910abcdef987654321", FriendlyName = "Device B", TrustState = DeviceTrustState.Banned, DateFirstSeen = DateTime.UtcNow.AddHours(-2) } }; jsonDevicesInfo = JsonConvert.SerializeObject(devicesInfo); uniquesInfo = new UniquesInfo(); uniquesInfo.ResponseId = responseId; uniquesInfo.Uniques = new List <Unique>() { new Unique() { UniqueId = "55e9fbfda2ce489d83b4a99c84c6f3e1", DateLastSeen = DateTime.UtcNow.AddHours(-1), TrustState = DeviceTrustState.Trusted }, new Unique() { UniqueId = "55e9fbfda2ce489d83b4a99c84c6f3e2", DateLastSeen = DateTime.UtcNow.AddHours(-2), TrustState = DeviceTrustState.Banned } }; jsonUniquesInfo = JsonConvert.SerializeObject(uniquesInfo); }