/* IEEE1363 ECDSA Signature Verification. Signature C and D on F is verified using public key W */ public static int ECPVP_DSA(sbyte[] W, sbyte[] F, sbyte[] C, sbyte[] D) { BIG r, gx, gy, f, c, d, h2; int res = 0; ECP G, WP, P; HASH H = new HASH(); H.process_array(F); sbyte[] B = H.hash(); gx = new BIG(ROM.CURVE_Gx); gy = new BIG(ROM.CURVE_Gy); G = new ECP(gx, gy); r = new BIG(ROM.CURVE_Order); c = BIG.fromBytes(C); d = BIG.fromBytes(D); f = BIG.fromBytes(B); if (c.iszilch() || BIG.comp(c, r) >= 0 || d.iszilch() || BIG.comp(d, r) >= 0) { res = INVALID; } if (res == 0) { d.invmodp(r); f.copy(BIG.modmul(f, d, r)); h2 = BIG.modmul(c, d, r); WP = ECP.fromBytes(W); if (WP.is_infinity()) { res = ERROR; } else { P = new ECP(); P.copy(WP); P = P.mul2(h2, G, f); if (P.is_infinity()) { res = INVALID; } else { d = P.X; d.mod(r); if (BIG.comp(d, c) != 0) { res = INVALID; } } } } return(res); }
protected void InitHealth() { hp = new Health(new AffectedByStat(Stats.Endurance, 5)); wp = new Health(new AffectedByStat(Stats.Willpower, 5)); HP.FullGain(); WP.FullGain(); }
// Use this for initialization void Start() { uStats = GetComponent <UnitStats> (); UpdateUnitPos(); // currentWp = GetWpFromPos (unitPos); currentTile = GetTileFromPos(unitPos); direction = Vector2.right; //Debug }
// Use this for initialization void Start() { pStats = GetComponent <PlayerStats> (); UpdateUnitPos(); // currentWp = GetWpFromPos (unitPos); currentTile = GetTileFromPos(unitPos); Shadow = transform.Find("FakeShadow").gameObject; }
public WP getAllData(int id) { var wp = new WP(); var convert = new Converters(); wp.RaceID = id; wp.Name = WpName; wp.Latitude =(decimal)convert.ConvertGeoCoordinatesToDecimal(WpLat_st, WpLat_mm_ss, getGeoDirectLat()); wp.Longitude = (decimal)convert.ConvertGeoCoordinatesToDecimal(WpLong_st, WpLong_mm_ss, getGeoDirectLong()); return wp; }
public vec3 CoordinatesAtTimeAtHighPart(float time, bool GiveMeNewVers = false) { if (!Projectile.settings.AdvancedPhysics && !GiveMeNewVers) { return(CoordinatesAtTime(TimeOfFlight() + time) + half_height * glm.normalize(Velocity())); } else { return(WP.get_vec3_Predicted_Position(time) + half_height * glm.normalize(Velocity(true)) - glm.normalize(Velocity(true))); } }
public vec3 AbsoluteEstimatedLocation(bool GiveMeNewVers = false) { if (!Projectile.settings.AdvancedPhysics && !GiveMeNewVers) { return(sd.Get_Center() + Projectile.jp.CoordinatesAtTime(TimeOfFlight() + TimePauseUntilExplosion)); } else { return(sd.Get_Center() + WP.get_vec3_Predicted_Position(TimePauseUntilExplosion)); } }
// if the destination is reached, everything will be cleared, so it can be repeated for the next destination public static void clearRoute() { destinationFound = false; routeFound = false; foreach (GameObject WP in waypoints) { if (showCalculations) { WP.GetComponent <Waypoint>().distanceText.text = ""; WP.GetComponent <Waypoint>().distanceText.color = Color.black; } WP.GetComponent <Waypoint>().shortestDistance = 1000; } RoutePoints.Clear(); }
void Move() { //only change direction if input matches grid possibility's if (WayPointManager.instance.tile.ContainsKey(currentTile.Pos + direction)) { isMoving = true; if (direction != Vector2.zero) { WP nextTile = GetTileFromPos(currentTile.Pos + direction); RotatePlayer(direction); // direction should only be changed at this point if (GetDistance(nextTile.Pos) < 0.01f) { currentTile = nextTile; if (currentTile.GetComponent <EnemyWP> () != null) { // currentWp = GetWpFromPos (currentTile.Pos); if (WayPointManager.instance.tile.ContainsKey(currentTile.Pos + newDirection)) { ChangeDirection(); } } } //enable going in reverse direction if (newDirection == direction * -1) { // currentWp = null; ChangeDirection(); } float newX = direction.x * pStats.playaSpeed; float newZ = direction.y * pStats.playaSpeed; transform.position += new Vector3(newX, 0, newZ) * Time.deltaTime; } } else { isMoving = false; ChangeDirection(); } }
/// <summary> /// event when the sync for caseload is complete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void client_GeefCaseLoadCompleted(object sender, WP.ijMobile.GeefCaseLoadCompletedEventArgs e) { var result = new List<QNHDemo.Data.Entities.Jeugdige>(); //convert to app list foreach (var item in e.Result.Jeugdigen) { result.Add(new Data.Entities.Jeugdige { Id = item.Id, Name = item.Naam }); } //save the xml System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Add("jeugdige", QNHDemo.Data.DAL.Dal.SerializeObject<List<QNHDemo.Data.Entities.Jeugdige>>(result)); lbxJeugdigen.ItemsSource = result; }
/* Calculate a public/private EC GF(p) key pair W,S where W=S.G mod EC(p), * where S is the secret key and W is the public key * and G is fixed generator. * If RNG is NULL then the private key is provided externally in S * otherwise it is generated randomly internally */ public static int KEY_PAIR_GENERATE(RAND RNG, sbyte[] S, sbyte[] W) { BIG r, gx, gy, s; ECP G, WP; int res = 0; sbyte[] T = new sbyte[EFS]; gx = new BIG(ROM.CURVE_Gx); if (ROM.CURVETYPE != ROM.MONTGOMERY) { gy = new BIG(ROM.CURVE_Gy); G = new ECP(gx, gy); } else { G = new ECP(gx); } r = new BIG(ROM.CURVE_Order); if (RNG == null) { s = BIG.fromBytes(S); } else { s = BIG.randomnum(r, RNG); s.toBytes(T); for (int i = 0; i < EGS; i++) { S[i] = T[i]; } } WP = G.mul(s); WP.toBytes(W); return(res); }
void Move() { if (WayPointManager.instance.tile.ContainsKey(currentTile.Pos + direction)) { if (direction != Vector2.zero) //fix if pdist < tdist { isMoving = true; WP nextTile = GetTileFromPos(currentTile.Pos + direction); RotateUnit(direction); if (GetDistanceDirection(nextTile.Pos) < 0.01f) //Debug direction should only be changed at this point { currentTile = nextTile; if (currentTile.GetComponent <EnemyWP> () != null) //has EWP { currentWp = currentTile.GetComponent <EnemyWP>(); //Begin to look for new direction if (WayPointManager.instance.tile.ContainsKey(currentTile.Pos + newDirection)) { Checkdirections(currentWp, getTargetPos()); } } } float newX = direction.x * uStats.BaseSpeed; float newZ = direction.y * uStats.BaseSpeed; transform.position += new Vector3(newX, 0, newZ) * Time.deltaTime; } } else { isMoving = false; Checkdirections(currentWp, getTargetPos()); } }
float GetDistanceDirection(Vector2 target) { WP targetObj = WayPointManager.instance.tile [target].GetComponent <WP> (); float distX = (targetObj.transform.position.x - transform.position.x); float distY = (targetObj.transform.position.z - transform.position.z); if (direction == Vector2.left || direction == Vector2.right) { float distance = distX * distX; return(distance); } else if (direction == Vector2.up || direction == Vector2.down) { float distance = distY * distY; return(distance); } return(666f); }
/// <summary> /// Event for when login is completed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void client_LoginCompleted(object sender, WP.ijMobile.LoginCompletedEventArgs e) { var result = e.Result; if (result.Status != WP.ijMobile.LoginStatus.Succes) { lblError.Text = "login failed"; } else { lblError.Text = "login success"; Thread.Sleep(1000); if (!IsolatedStorageSettings.ApplicationSettings.Contains("token")) { IsolatedStorageSettings.ApplicationSettings.Add("token", result.Token); } //write to xml file QNHDemo.WP.Storage.StoreLogin(result.NaamMedewerker, result.Token); NavigationService.Navigate(new Uri("/List.xaml", UriKind.Relative)); } }
private void OnMovementSpeedChanged(object sender, WP.Stat.StatValueEventArgs e) { _movementSpeed = (float)e.Value; }
private void OnControllerModeChanged(WP.Controller.CONTROLLER_MODE mode) { if (mode == WP.Controller.CONTROLLER_MODE.NORMAL) { int stateC=1; myNet.RPC("SetPlayerStateInWorld",RPCMode.AllBuffered,stateC); } else { int stateC =2; myNet.RPC("SetPlayerStateInWorld",RPCMode.AllBuffered,stateC); } }
private void OnActionSpeedChanged(object sender, WP.Stat.StatValueEventArgs args) { if (args.Id == "ActionSpeed") { float newSpeedVal = (float)(args.Value); _actionCooldown = 1f / (Mathf.Clamp (newSpeedVal, float.Epsilon, float.MaxValue)); } }
void DoPaint() { int i; TBaseWorkShape WP; TBaseShape BS; TListForPaintItem ItemPaint; if (f_RefreshFon) { RepaintFon(f_X_offsSum, f_Y_offsSum); } else { CopyFon(); } if ((f_ListForPaint.Count == 0) && (f_RefreshFon || (f_CurrentCommand != 0))) { f_InvalidateList.Clear(); WP = g_PainterList.First(); while (WP != null) { f_InvalidateList.AddWorkShape(WP); if ((WP == f_LineCutting.WorkShape) && (f_WSMovingCount == 0)) { continue; } ApplyAttributeForWorkShape(WP); WP.Paint(f_Canvas); WP = g_PainterList.Next(); } } if ((f_ListForPaint.Count == 0) && (!f_RefreshFon && (f_CurrentCommand == 0))) { for (i = 0; i <= f_InvalidateList.Count - 1; i++) { WP = (TBaseWorkShape)f_InvalidateList.Items[i]; if ((WP == f_LineCutting.WorkShape) && (f_WSMovingCount == 0)) { continue; } ApplyAttributeForWorkShape(WP); WP.Paint(f_Canvas); } } if (f_ListForPaint.Count > 0) { for (i = 0; i <= f_ListForPaint.Count - 1; i++) { ItemPaint = (TListForPaintItem)f_ListForPaint.Items[i]; switch (ItemPaint.Type) { case 0: BS = (TBaseShape)ItemPaint.ClassPoint; BS.Paint(f_Canvas); break; case 1: WP = (TBaseWorkShape)ItemPaint.ClassPoint; ApplyAttributeForWorkShape(WP); if ((WP == f_LineCutting.WorkShape) && (f_WSMovingCount == 0)) { continue; } WP.Paint(f_Canvas); break; } } f_ListForPaint.Clear(); } PaintAlternateList(); f_RefreshFon = false;//f_Srolling; f_CurrentCommand = 0; }
private void OnWeaponTypeChanged(object sender, WP.Stat.StatValueEventArgs args) { SetInt ("WeaponType", (int)args.Value); }
/// <summary> /// This is the timestepping procedure /// </summary> /// <param name="TimeStep"></param> public void Update(DateTime NewTime) { CurrentTimeStep = NewTime.Subtract(CurrentTime); #region Sum of Sinks and sources //Sum the sources var GWFlow = GroundwaterBoundaries.Where(var => var.IsSource(CurrentTime)).Select(var => var.GetSourceWater(CurrentTime, CurrentTimeStep)); var SourceFlow = Sources.Select(var => var.GetSourceWater(CurrentTime, CurrentTimeStep)); IWaterPacket InFlow = WaterMixer.Mix(GWFlow.Concat(SourceFlow)); double InflowVolume = 0; if (InFlow != null) { InflowVolume = InFlow.Volume; } //Sum the Evaporation boundaries double EvapoVolume = _evapoBoundaries.Sum(var => var.GetSinkVolume(CurrentTime, CurrentTimeStep)); //Sum the sinks double SinkVolume = Sinks.Sum(var => var.GetSinkVolume(CurrentTime, CurrentTimeStep)); //Add the sinking groundwater boundaries SinkVolume += GroundwaterBoundaries.Where(var => !var.IsSource(CurrentTime)).Sum(var => var.GetSinkVolume(CurrentTime, CurrentTimeStep)); double sumSinkSources = InflowVolume - EvapoVolume - SinkVolume; //If we have no water from upstream but Inflow, remove water from inflow to fill stream if (sumSinkSources / Volume > 5) { AddWaterPacket(CurrentTime, NewTime, InFlow.Substract(sumSinkSources - Volume * 5)); InflowVolume = InFlow.Volume; sumSinkSources = InflowVolume - EvapoVolume - SinkVolume; } //Sort the incoming water an put in to queue PrePareIncomingWater(); //Calculate the surplus WaterToRoute = _waterInStream.Sum(var => var.Volume) + InflowVolume - EvapoVolume - SinkVolume - Volume + _incomingWater.Sum(var => var.Volume); //If the loss is bigger than available water, reduce Evaporation and Sinks if (WaterToRoute + Volume < 0) { double reductionfactor = 1 + (WaterToRoute + Volume) / (EvapoVolume + SinkVolume); EvapoVolume *= reductionfactor; SinkVolume *= reductionfactor; WaterToRoute = 0; } //Convert to rates double qu = sumSinkSources / CurrentTimeStep.TotalSeconds / Volume; double qop = _incomingWater.Sum(var => var.Volume) / CurrentTimeStep.TotalSeconds; double qout = qu * Volume + qop; //Create a mixer class Mixer M = new Mixer(InFlow, EvapoVolume, SinkVolume); #endregion #region Stored water //Send stored water out if (WaterToRoute > 0) { double OutflowTime = 0; //The volume that needs to flow out to meet the watertotroute double VToSend = WaterToRoute; if (qu != 0) { VToSend = qout / qu * (1 - 1 / (Math.Exp(qu * CurrentTimeStep.TotalSeconds))); } //There is water in the stream that should be routed while (VToSend > 0 & _waterInStream.Count > 0) { IWaterPacket IW; //Mixing during flow towards end of stream double dv = _waterInStream.Peek().Volume *(Math.Exp(qu * OutflowTime) - 1); //Check if the entire water packet should flow out or it should be split if (_waterInStream.Peek().Volume + dv < VToSend) { IW = _waterInStream.Dequeue(); } else { IW = _waterInStream.Peek().Substract(VToSend); } //Update how mush water is yet to be routed VToSend -= IW.Volume; //Now do the mix M.Mix(dv, IW); //Calculate outflow time double dt; if (qu == 0) { dt = IW.Volume / qop; } else { dt = Math.Log(qout / (qout - qu * IW.Volume)) / qu; } //Mixing during outflow M.Mix(qout * dt - IW.Volume, IW); IW.MoveInTime(TimeSpan.FromSeconds(OutflowTime + dt / 2), IW.Volume / Depth); SendWaterDownstream(IW); OutflowTime += dt; } } //Now move the remaining packets to their final destination and time foreach (IWaterPacket IWP in _waterInStream) { if (qu != 0) { M.Mix(IWP.Volume * (Math.Exp(qu * CurrentTimeStep.TotalSeconds) - 1), IWP); } IWP.MoveInTime(CurrentTimeStep, IWP.Volume / Depth); } #endregion #region Water packets traveling right through double inflowtime = 0; //No water in stream and incoming water. Just pass through if (_waterInStream.Count == 0 & _incomingWater.Count > 0) { //Calculate how much incoming water is required to fill stream volume; double VToStore = Volume; if (qu != 0) { VToStore = qop / qu * Math.Log(Volume * qu / qop + 1); } //Now send water through double incomingVolume = _incomingWater.Sum(var => var.Volume); //Send packets through until the remaining will just fill the stream while (incomingVolume > VToStore + 1e-12 & _incomingWater.Count != 0) { IWaterPacket WP; if (incomingVolume - _incomingWater.Peek().Volume > VToStore) { WP = _incomingWater.Dequeue(); } else { WP = _incomingWater.Peek().Substract(incomingVolume - VToStore); } incomingVolume -= WP.Volume; //Keep track of inflow time. inflowtime += WP.Volume / qop; if (qu != 0) { double dvr = WP.Volume * qu * Volume / qop; M.Mix(dvr, WP); } //Calculate the time a water package uses to travel through the stream TimeSpan CurrentTravelTime; if (qu != 0) { CurrentTravelTime = TimeSpan.FromSeconds(1 / qu * Math.Log(Volume * qu / qop + 1)); } else { CurrentTravelTime = TimeSpan.FromSeconds(Volume / qout); } //Moves right through WP.MoveInTime(CurrentTravelTime, WP.Volume / Depth); SendWaterDownstream(WP); } } #endregion #region Fill the stream //The remaining incoming water is moved forward and stays in the stream. while (_incomingWater.Count > 0) { IWaterPacket WP = _incomingWater.Dequeue(); double dt = WP.Volume / qop; inflowtime += dt; double dt2 = CurrentTimeStep.TotalSeconds - inflowtime; //How much of the timestep is left when this packet has moved in. if (qu != 0) { //Volume change during inflow double Vnew = qop * (Math.Exp(qu * dt) - 1) / qu; //Volume change while in stream Vnew *= Math.Exp(qu * dt2); M.Mix(Vnew - WP.Volume, WP); } //The time is half the inflowtime + the time in stream WP.MoveInTime(TimeSpan.FromSeconds(dt2 + dt / 2), WP.Volume / Depth); _waterInStream.Enqueue(WP); } #endregion Output.Outflow.AddSiValue(CurrentTime, NewTime, WaterToRoute / CurrentTimeStep.TotalSeconds); CurrentTime = NewTime; StartofFlowperiod = CurrentTime; }
public static void Load(Player p) { if (File.Exists("extra/Waypoints/" + p.name + ".save")) { using (StreamReader SR = new StreamReader("extra/Waypoints/" + p.name + ".save")) { bool failed = false; string line; while (SR.EndOfStream == false) { line = SR.ReadLine().ToLower().Trim(); if (!line.StartsWith("#") && line.Contains(":")) { failed = false; string[] LINE = line.ToLower().Split(':'); WP wp = new WP(); try { wp.name = LINE[0]; wp.lvlname = LINE[1]; wp.x = ushort.Parse(LINE[2]); wp.y = ushort.Parse(LINE[3]); wp.z = ushort.Parse(LINE[4]); wp.rotx = byte.Parse(LINE[5]); wp.roty = byte.Parse(LINE[6]); } catch { Server.s.Log("Couldn't load a Waypoint!"); failed = true; } if (failed == false) { p.Waypoints.Add(wp); } } } SR.Dispose(); } } }
private void OnSpeedStatsChanged(object sender, WP.Stat.StatValueEventArgs args) { _movementSpeed = (float)args.Value; UpdateForwardSpeed (); UpdateSideSpeed (); }