public async Task ProcessRecords() { await GetSQLRecords(); await fetchPoissonAsync(lamba, Forecasts.Count()); var CurrentForecasts = Forecasts.Where(pr => Forecasts.Any(p => pr.fdate >= DateTime.Today)).ToList(); List <DailyForecast> finalRecords = new List <DailyForecast>(); foreach (var item in CurrentForecasts) { DailyForecast newItem = new DailyForecast(per_loc, per_admit, per_vent); newItem.EstimatedGloveSurgical = GloveSurgical; newItem.EstimatedGloveExamNitrile = GloveExamNitrile; newItem.EstimatedGloveExamVinyl = GloveExamVinyl; newItem.EstimatedMaskFaceAntiFog = MaskFaceAntiFog; newItem.EstimatedMaskFluidResistant = MaskFluidResistant; newItem.EstimatedGownIsolationXLYellow = GownIsolationXLYellow; newItem.EstimatedMaskAntiFogWFilm = MaskAntiFogWFilm; newItem.EstimatedShieldFaceFullAntiFog = ShieldFaceFullAntiFog; newItem.EstimatedRespPartFilterReg = RespPartFilterReg; newItem.fdate = item.fdate; newItem.ForecastValues = item.ForecastValues; newItem.NewCases = item.NewCases; newItem.Total_cc = item.Total_cc; newItem.Total_nc = item.Total_nc; finalRecords.Add(newItem); } data = Tricks.ToDataTable(finalRecords); }
public static uint MulOvf(uint x, uint y) { int m = Tricks.Nlz(x); int n = Tricks.Nlz(y); if (m + n <= 30) { throw new OverflowException(); } uint t = x * (y >> 1); if ((int)t < 0) { throw new OverflowException(); } uint z = t * 2; if ((y & 1) != 0) { z = z + x; if (z < x) { throw new OverflowException(); } } return(z); }
public void AddTrick(ITrick trick) { if (trick is Trick) { Tricks.Add((Trick)trick); } }
public PlayerPosition PlayCard(Card card, PlayerPosition playerPosition) { _nextPlayer = BridgeHelper.GetNextPlayerPosition(playerPosition); if (_currentTrick.Deck.Count == 0) { _currentTrick = new Trick(); _currentTrick.TrickDealer = playerPosition; } if (_currentTrick.Deck.Count <= 4) { card.PlayerPosition = playerPosition; _currentTrick.Deck.Cards.Add(card); } if (_currentTrick.Deck.Count == 4) { Tricks.Add(_currentTrick); var winner = FindWinner(_currentTrick, Contract.Trump); _currentTrick.TrickWinner = winner; _nextPlayer = winner; _currentTrick = new Trick() { TrickDealer = winner }; } GameState[playerPosition].RemoveCard(card); return(_nextPlayer); }
private void ClearSpinner() { if (thisSpinner != null) { bodyParts.zeroPointPosition = 0f; BodyParts.instance = null; envVariables.bodyParts = null; Destroy(thisSpinner); thisSpinner = null; envVariables.halfTrailSpeed = false; envVariables.halfTrailSpeedUsed = false; envVariables.propTrailSpeed = envVariables.trailSpeedSlider.value; //re-initialize trick cycle counters envVariables.trickStepper = 0f; envVariables.eigthSteps = 0; envVariables.stepsInTrick = 8; trickStage = 0; //trickCycles = 0; doingTrick = false; trick = Tricks.None; thisSimulationName.text = "Not Currently Simulating"; thisSimulationDescription.text = ""; } }
public void InspinWheelPlaneFlowerSameSame() { if (trick != Tricks.InspinWheelPlaneFlowerSameSame) { ClearSpinner(); SetSpinner(spinnerWheelPlane); setupTrick = true; trick = Tricks.InspinWheelPlaneFlowerSameSame; envVariables.halfTrailSpeed = true; } if (doingTrick) { //set rotation speed modifier on props to 2 for 2 points on the inspin bodyParts.leftPropSpin.rotationSpeedModifier = 2f; bodyParts.rightPropSpin.rotationSpeedModifier = 2f; //rotate props forward bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Backward); bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Backward); //rotate arms forward bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Backward); bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Backward); } if (setupTrick) { bodyParts.leftProp.transform.RotateAround(bodyParts.leftHand.transform.position, Vector3.forward, 180f); bodyParts.rightProp.transform.RotateAround(bodyParts.rightHand.transform.position, Vector3.forward, 180f); setupTrick = false; doingTrick = true; thisSimulationName.text = "Inspin Wheel Plane Flower"; thisSimulationDescription.text = "Same Time / Same Direction"; } }
public void InspinAntispinWheelPlaneFlowerSplitSame() { if (trick != Tricks.InspinVsAntispinFlowerSplitSame) { ClearSpinner(); SetSpinner(spinnerWheelPlane); setupTrick = true; trick = Tricks.InspinVsAntispinFlowerSplitSame; } if (doingTrick) { InspinAntispinWheelPlaneFlowerSameDirection(); } if (setupTrick) { //put left hand (inSpin hand) in Inspin starting location bodyParts.leftProp.transform.RotateAround(bodyParts.leftHand.transform.position, new Vector3(0, 0, 180f), 180f); //rotate shoulders to lower position bodyParts.leftShoulder.transform.RotateAround(bodyParts.torso.transform.position, new Vector3(0, 0, 90f), -90f); bodyParts.rightShoulder.transform.RotateAround(bodyParts.torso.transform.position, new Vector3(0, 0, 90f), 90f); //need to give it a cycle for the new spinner to be instantiated setupTrick = false; doingTrick = true; thisSimulationName.text = "Wheel Plane Inspin vs. Antispin Flower"; thisSimulationDescription.text = "Split Time / Same Direction"; } }
public void StandardTriquetra() { if (trick != Tricks.Triquetra) { ClearSpinner(); SetSpinner(spinnerWheelPlane); setupTrick = true; trick = Tricks.Triquetra; } if (doingTrick) { //rotate arms back bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Backward); bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Backward); //set speed modifier to 3 for 3 points in triquetra bodyParts.rightPropSpin.rotationSpeedModifier = 3f; bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Forward); } if (setupTrick) { //rotate both arms to have prop above head bodyParts.rightArm.transform.RotateAround(bodyParts.rightShoulder.transform.position, Vector3.back, 90f); bodyParts.leftArm.transform.RotateAround(bodyParts.leftShoulder.transform.position, Vector3.forward, 90f); setupTrick = false; doingTrick = true; thisSimulationName.text = "Triquetra"; thisSimulationDescription.text = ""; } }
public void AntispinWheelPlaneFlowerSplitSame() { if (trick != Tricks.AntispinWheelPlaneFlowerSplitSame) { ClearSpinner(); SetSpinner(spinnerWheelPlane); setupTrick = true; trick = Tricks.AntispinWheelPlaneFlowerSplitSame; envVariables.halfTrailSpeed = true; } if (doingTrick) { //set prop speed modifier to 4 to get 4 zero points bodyParts.leftPropSpin.rotationSpeedModifier = 4f; bodyParts.rightPropSpin.rotationSpeedModifier = 4f; //rotate arms around shoulders in same directions bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Forward); bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Forward); //spin props in opposite directions to get antispin bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Backward); bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Backward); } if (setupTrick) { setupTrick = false; doingTrick = true; thisSimulationName.text = "Wheel Plaine Antispine Flower"; thisSimulationDescription.text = "Split Time / Same Direction"; } }
//stall moves public void ButterflyTaceVertical() { if (trick != Tricks.ButterflyTraceVertical) { ClearSpinner(); SetSpinner(spinnerWallPlane); setupTrick = true; trick = Tricks.ButterflyTraceVertical; envVariables.halfTrailSpeed = true; } if (doingTrick) { if ((envVariables.eigthSteps >= 0 && envVariables.eigthSteps < 4) || envVariables.eigthSteps == 8) { trickStage = 0; } else { trickStage = 1; } if (trickStage == 0) { //rotate arms up bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Right); bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Right); //rotate hands against arm rotation to keep props in plane bodyParts.leftHandSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Left); bodyParts.rightHandSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Left); //rotate props bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Forward); bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Backward); } if (trickStage == 1) { //rotate arms down bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Left); bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Left); //rotate hands against arm rotation to keep props in plane bodyParts.leftHandSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Right); bodyParts.rightHandSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Right); //rotate props bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Forward); bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Backward); } } if (setupTrick) { //rotate shoulders to lower position bodyParts.leftArm.transform.RotateAround(bodyParts.leftShoulder.transform.position, new Vector3(0, 0, 1f), -105); bodyParts.rightArm.transform.RotateAround(bodyParts.rightShoulder.transform.position, new Vector3(0, 0, 1f), 105f); //rotate props to match additional rotation of arms bodyParts.leftProp.transform.RotateAround(bodyParts.leftHand.transform.position, new Vector3(0, 0, 1f), 15f); bodyParts.rightProp.transform.RotateAround(bodyParts.rightHand.transform.position, new Vector3(0, 0, 1f), -15f); setupTrick = false; doingTrick = true; thisSimulationName.text = "Butterfly Tracing Vertically"; } }
public void TestNlzBitwiseViaNlz() { for (int i = -100; i < 100; ++i) { Assert.AreEqual(Tricks.NlzBitwise((uint)i), Tricks.Nlz((uint)i)); } }
public void TestNLZ() { Assert.AreEqual(32, Tricks.Nlz(0)); Assert.AreEqual(31, Tricks.Nlz(1)); Assert.AreEqual(16, Tricks.Nlz(0x0000FFFF)); Assert.AreEqual(14, Tricks.Nlz(0x0003FFFF)); Assert.AreEqual(0, Tricks.Nlz(0xF000FFFF)); }
public bool IsComplete() { if (MustRedeal) { return(true); } return(Tricks.Count() == IGame.TrickCount && Tricks.Last().IsComplete()); }
public void AntiSpinPointsSameOps() { if (trick != Tricks.AntispinPointsSameOps) { ClearSpinner(); SetSpinner(spinnerWheelPlane); setupTrick = true; trick = Tricks.AntispinPointsSameOps; envVariables.halfTrailSpeed = true; } if (doingTrick) { if ((envVariables.eigthSteps >= 0 && envVariables.eigthSteps < 4) || envVariables.eigthSteps == 8) { trickStage = 0; } else { trickStage = 1; } if (trickStage == 0) { //set poi speed modifier to 4 to get 4 zero points on each arm rotation bodyParts.leftPropSpin.rotationSpeedModifier = 4f; bodyParts.rightPropSpin.rotationSpeedModifier = 4f; //spin poi bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Forward); bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Backward); //rotate shoulders bodyParts.leftShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Backward); bodyParts.rightShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Forward); } else if (trickStage == 1) { //kill velocity on both props bodyParts.leftPropSpin.rotationSpeedModifier = 0f; bodyParts.rightPropSpin.rotationSpeedModifier = 0f; //rotate shoulders in opposite directions bodyParts.leftShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Forward); bodyParts.rightShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Backward); } } if (setupTrick) { //need to give it a cycle for the new spinner to be instantiated doingTrick = true; setupTrick = false; //rotate shoulders to have right hand down and left hand up bodyParts.leftShoulder.transform.RotateAround(bodyParts.torso.transform.position, new Vector3(0, 0, 90f), 90f); bodyParts.rightShoulder.transform.RotateAround(bodyParts.torso.transform.position, new Vector3(0, 0, 90f), 90f); thisSimulationName.text = "Antispin Points"; thisSimulationDescription.text = "Same Time / Opposite Direction"; } }
public void ReadRiff(byte[] inFs) { int id = BitConverter.ToInt32(inFs, 0); id = Tricks.SwapEndianness(id); Debug.Assert(id == 0x52494646, "RIFF not valids"); m_RiffSize = BitConverter.ToUInt32(inFs, 4); }
public void AntiSpinWallPlaneFlowerWithInSpin() { if (trick != Tricks.AntispinWallPlaneFlowerWithInSpin) { ClearSpinner(); SetSpinner(spinnerWallPlane); setupTrick = true; trick = Tricks.AntispinWallPlaneFlowerWithInSpin; } if (doingTrick) { if (envVariables.eigthSteps < 2 || envVariables.eigthSteps >= 6) { trickStage = 0; } else { trickStage = 1; } if (trickStage == 0) { //set poi speed modifier to 4 to get 4 zero points on each arm rotation bodyParts.leftPropSpin.rotationSpeedModifier = 4f; bodyParts.rightPropSpin.rotationSpeedModifier = 4f; //spin poi bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Forward); bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Forward); //rotate shoulders bodyParts.leftShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Backward); bodyParts.rightShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Backward); } else if (trickStage == 1) { //set rotation speed modifier on props to 2 for 2 points on the inspin bodyParts.leftPropSpin.rotationSpeedModifier = 2f; bodyParts.rightPropSpin.rotationSpeedModifier = 2f; //rotate props forward bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Forward); bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Forward); //rotate arms forward bodyParts.leftShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Forward); bodyParts.rightShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Forward); } } if (setupTrick) { //need to give it a cycle for the new spinner to be instantiated doingTrick = true; setupTrick = false; thisSimulationName.text = "Wall Plane Antispin Flower with In Spin"; } }
public void TestTrick() { if (trick != Tricks.TestTrick) { ClearSpinner(); SetSpinner(spinnerWheelPlane); setupTrick = true; trick = Tricks.TestTrick; } if (doingTrick) { //pibot body around in circle bodyParts.leftShoulderSpin.rotationSpeedModifier = 2f; bodyParts.rightShoulderSpin.rotationSpeedModifier = 2f; bodyParts.leftShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Up); bodyParts.rightShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Up); //set speed modifier on props to 2 to get 2 points on inspin //bodyParts.leftPropSpin.rotationSpeedModifier = 2f; //bodyParts.rightPropSpin.rotationSpeedModifier = 2f; //rotate props in opposite directions //bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Forward); //bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Backward); //rotate arms in opposite directions, same direction as holding prop //bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Forward); bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Backward); //counter rotations to keep props in plane bodyParts.rightHandSpin.rotationSpeedModifier = 2f; bodyParts.rightHandSpin.RotateBodyPartAround(bodyParts.rightWrist, SpinDirections.Down); //bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Right); } if (setupTrick) { //rotate both arms to have prop on left side of body bodyParts.rightArm.transform.RotateAround(bodyParts.rightShoulder.transform.position, Vector3.back, 180f); //rotate both props to inspin starting position //bodyParts.leftProp.transform.RotateAround(bodyParts.leftHand.transform.position, Vector3.forward, 90f); //bodyParts.rightProp.transform.RotateAround(bodyParts.rightHand.transform.position, Vector3.forward, 90f); //rotate both hand to be on inside of body bodyParts.leftHand.transform.RotateAround(bodyParts.leftWrist.transform.position, Vector3.up, 180f); bodyParts.rightHand.transform.RotateAround(bodyParts.rightWrist.transform.position, Vector3.up, 180f); setupTrick = false; doingTrick = true; thisSimulationName.text = "Test Trick"; thisSimulationDescription.text = ""; } }
public string ToByteString() { StringBuilder builder = new StringBuilder(); var id = BitConverter.GetBytes(RiffID); var size = BitConverter.GetBytes(RiffSize); var format = BitConverter.GetBytes(RiffFormat); builder.AppendLine("RIFF ID: " + Tricks.ToByteString(id)); builder.AppendLine("RIFF Size: " + Tricks.ToByteString(size)); builder.AppendLine("Riff Format: " + Tricks.ToByteString(format)); return(builder.ToString()); }
public static int GetMinBits(this int value) { uint v = (uint)value; if (value >= 0) { return(v.GetMinBits() + 1); } v = ~v; int n = Tricks.Nlz(v); return(33 - n); }
//3D tricks public void ThreeDimFlowerXZ() { if (trick != Tricks.ThreedFlowerXZ) { ClearSpinner(); SetSpinner(spinnerWheelPlane); setupTrick = true; trick = Tricks.ThreedFlowerXZ; } if (doingTrick) { //set speed modifiers on both props to 4 to get our 4 stall/zero points bodyParts.leftPropSpin.rotationSpeedModifier = 4f; bodyParts.rightPropSpin.rotationSpeedModifier = 4f; //rotate shoulders around torse bodyParts.leftShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Down); bodyParts.rightShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Down); //rotate left arm around shoulder joint to counter rotation around torso bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Up); //rotate left arm back bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Forward); //rotate left props to get antispin bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Backward); bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Up); } if (setupTrick) { //rotate right hand 90degrees to hold prop on Z plane bodyParts.rightHand.transform.RotateAround( bodyParts.rightWrist.transform.position, Vector3.right, 90f); //rotate right arm outward bodyParts.rightArm.transform.RotateAround( bodyParts.rightShoulder.transform.position, Vector3.down, 90f); //rotate left arm to up position bodyParts.leftArm.transform.RotateAround( bodyParts.leftShoulder.transform.position, Vector3.forward, 90f); setupTrick = false; doingTrick = true; thisSimulationName.text = "3D Flower XZ-Planes"; thisSimulationDescription.text = ""; } }
public void AntiSpinWallPlaneFlower() { if (trick != Tricks.AntispinWallPlaneFlower) { ClearSpinner(); SetSpinner(spinnerWallPlane); setupTrick = true; trick = Tricks.AntispinWallPlaneFlower; } if (doingTrick) { if (envVariables.eigthSteps < 2 || envVariables.eigthSteps >= 6) { trickStage = 0; } else { trickStage = 1; } if (trickStage == 0) { //set poi speed modifier to 4 to get 4 zero points on each arm rotation bodyParts.leftPropSpin.rotationSpeedModifier = 4f; bodyParts.rightPropSpin.rotationSpeedModifier = 4f; //spin poi bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Forward); bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Forward); //rotate shoulders bodyParts.leftShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Backward); bodyParts.rightShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Backward); } else if (trickStage == 1) { //no need to apply rotation force to poi, we want them to follow the hands, relative velocity is zero //rotate shoulders bodyParts.leftShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Forward); bodyParts.rightShoulderSpin.RotateBodyPartAround(bodyParts.torso, SpinDirections.Forward); } } if (setupTrick) { //need to give it a cycle for the new spinner to be instantiated doingTrick = true; setupTrick = false; thisSimulationName.text = "Wall Plane Antispin Flower"; } }
public void ReadData(byte[] data, FmtBlock fmt) { int id = BitConverter.ToInt32(data, 36); id = Tricks.SwapEndianness(id); if (id != 0x64617461) { Console.WriteLine("Something happened"); } DataSize = BitConverter.ToUInt32(data, 40); NumSamples = (int)(DataSize / 2); }
static void Main() { bool fullScreen = false; SdlHardware.Init(1024, 700, 24, fullScreen); ChooseLanguage l = new ChooseLanguage(); WelcomeScreen w = new WelcomeScreen(); do { if (l.GetChosenOption() == 0) { l.Run(); } if (l.GetChosenOption() != 0) { w.Run(); if (w.GetChosenOption() == 1) { Game g = new Game(); g.Run(); } else if (w.GetChosenOption() == 2) { Controls controls = new Controls(); controls.Run(); } else if (w.GetChosenOption() == 3) { CreditsScreen credits = new CreditsScreen(); credits.Run(); } else if (w.GetChosenOption() == 5) { Tricks tricks = new Tricks(); tricks.Run(); } } }while (w.GetChosenOption() != 4); }
public string ToByteString() { StringBuilder builder = new StringBuilder(); var size = BitConverter.GetBytes(_FormatSize); var numOfChannels = BitConverter.GetBytes(_NumChannels); var samplesASec = BitConverter.GetBytes(_SamplesPerSec); var averageBytes = BitConverter.GetBytes(_AverageBytesPerSec); var blocks = BitConverter.GetBytes(_BlockAlign); var bits = BitConverter.GetBytes(_BitsPerSample); builder.AppendLine("Format Size: " + Tricks.ToByteString(size)); builder.AppendLine("Format Tag: " + FormatCode); builder.AppendLine("Number of Channels: " + Tricks.ToByteString(numOfChannels)); builder.AppendLine("Samples per Samples: " + Tricks.ToByteString(samplesASec)); builder.AppendLine("Average Bytes Per Seconds: " + Tricks.ToByteString(averageBytes)); builder.AppendLine("Block Align: " + Tricks.ToByteString(blocks)); builder.AppendLine("Bits Per Sample: " + Tricks.ToByteString(bits)); return(builder.ToString()); }
public string ToBitString() { StringBuilder builder = new StringBuilder(); var dataSize = BitConverter.GetBytes(DataSize); var numSamples = BitConverter.GetBytes(NumSamples); var dataSizeString = Tricks.ToByteString(dataSize); var numSamplesString = Tricks.ToByteString(numSamples); builder.AppendLine("Data Size: " + dataSizeString); builder.AppendLine("Number of Samples: " + numSamplesString); builder.AppendLine("Data: "); Task <string>[] tasks = new Task <string> [_data.Count]; foreach (var item in _data) { var task = new Task <string>(() => { StringBuilder build = new StringBuilder(); build.AppendLine(item.ToBitString()); return(build.ToString()); }); tasks[item.channelNumber - 1] = task; task.Start(); } Task.WaitAll(tasks); foreach (var item in tasks) { builder.AppendLine(item.Result); } return(builder.ToString()); }
public void ReadFmt(byte[] inFS) { var id = BitConverter.ToInt32(inFS, 12); id = Tricks.SwapEndianness(id); Debug.Assert(id == _FormatID, "Format ID Not Valid"); _FormatSize = BitConverter.ToUInt32(inFS, 16); _FormatCode = BitConverter.ToUInt16(inFS, 20); _NumChannels = BitConverter.ToUInt16(inFS, 22); _SamplesPerSec = BitConverter.ToUInt32(inFS, 24); _AverageBytesPerSec = BitConverter.ToUInt32(inFS, 28); _BlockAlign = BitConverter.ToUInt16(inFS, 32); _BitsPerSample = BitConverter.ToUInt16(inFS, 34); //TODO: Determine format code and react to it var size = BitConverter.ToUInt16(inFS, 36); if (size == 0) { return; } }
public void AddTrick(string trick) { Tricks.Add(trick); }
public static int GetMinBits(this uint value) { return(32 - Tricks.Nlz(value)); }
void Update() { if(Stuck) { transform.position = stuckPosition; rigid.velocity = new Vector2(0, 0); return; } if (isDead || rigid == null) return; //rigid.velocity = new Vector2(baseSpeed, rigid.velocity.y); Vector3 wantedPosition = transform.position; speed = (gameObject.transform.position - lastPosition) / Time.deltaTime; currentSpeed += 0.1f * Time.deltaTime; wantedPosition.x += currentSpeed * Time.deltaTime; transform.position = wantedPosition; var hit = Physics2D.RaycastAll(playerPosition.position, -Vector2.up, .20f); Debug.DrawLine(playerPosition.position, playerPosition.position + -Vector3.up * .20f); if (hit.Length != 0) { isGrounded = hit.Any(x => x.collider.tag == "ground"); if (hit.Any(x => x.collider.tag == "death")) Die(); } else isGrounded = false; #region input //OLLIE TRICK || GRIND TRICK if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) { if (isGrounded) { SwitchState(State.Preparing); currentTrick = Tricks.Ollie; } else { currentTrick = Tricks.Ollie; grindTrick = GrindTrick.Grind; Grind(hit); } if(!isGrounded && !grinding) { rigid.velocity = new Vector2(rigid.velocity.x, rigid.velocity.y - 10 * Time.deltaTime); } } else if(Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) { if (isGrounded) { SwitchState(State.Preparing); currentTrick = Tricks.Kickflip; } else { currentTrick = Tricks.Kickflip; grindTrick = GrindTrick.ForwardGrind; Grind(hit); } if (!isGrounded && !grinding) { rigid.velocity = new Vector2(rigid.velocity.x, rigid.velocity.y - 10 * Time.deltaTime); } } else if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) { if (isGrounded) { SwitchState(State.Preparing); currentTrick = Tricks.Heelflip; } else { currentTrick = Tricks.Heelflip; grindTrick = GrindTrick.BackGrind; Grind(hit); } if (!isGrounded && !grinding) { rigid.velocity = new Vector2(rigid.velocity.x, rigid.velocity.y - 10 * Time.deltaTime); } } else { if (currentTrick == Tricks.Ollie && (currentState == State.Preparing || currentState == State.Grinding)) { if (isGrounded || grinding) { SwitchState(State.Trick); grinding = false; Jump(); } }else if (currentTrick == Tricks.Heelflip && (currentState == State.Preparing || currentState == State.Grinding)) { if (isGrounded || grinding) { SwitchState(State.Trick); grinding = false; Jump(); } }else if (currentTrick == Tricks.Kickflip && (currentState == State.Preparing || currentState == State.Grinding)) { if (isGrounded || grinding) { SwitchState(State.Trick); grinding = false; Jump(); } } } //IF GROUNDED if (isGrounded && rigid.velocity.y < 0.00001) { if (currentState == State.Falling) SwitchState(State.ShortLanding); else if (currentState == State.Preparing) SwitchState(State.Preparing); else if (currentState == State.ShortLanding) { var info = pAnim.GetCurrentAnimatorStateInfo(0); if (info.normalizedTime > 0.98f) { SwitchState(State.Skating); } } else SwitchState(State.Skating); } //IF GRINDING else if(grinding) SwitchState(State.Grinding); //IF FALLING else if (!isGrounded && rigid.velocity.y < -1.99) { currentState = State.Falling; } //IF NOT GROUNDED AND PREPARING TRICK else if (!isGrounded && currentState == State.Preparing) SwitchState(State.Skating); if (Input.GetKeyDown(KeyCode.Q)) Die(); if (Input.GetKeyDown(KeyCode.R)) Application.LoadLevel(Application.loadedLevel); #endregion #region Animations switch (currentState) { case State.Skating: pAnim.Play(hash.skatingState); sAnim.Play(hash.skateSkatingState); break; case State.Preparing: pAnim.Play(hash.preparingState); sAnim.Play(hash.skateSkatingState); break; case State.Trick: if (currentTrick == Tricks.Ollie && newAnim) { pAnim.Play(hash.ollieState, -1, 0); sAnim.Play(hash.skateOllieState, -1, 0); } else if (currentTrick == Tricks.Kickflip && newAnim) { pAnim.Play(hash.ollieState, -1, 0); sAnim.Play(hash.skateKickflip, -1, 0); } else if (currentTrick == Tricks.Heelflip && newAnim) { pAnim.Play(hash.ollieState, -1, 0); sAnim.Play(hash.skateHeelflip, -1, 0); } newAnim = false; break; case State.Falling: pAnim.Play(hash.fallingState); break; case State.Dying: break; case State.Dead: break; case State.Landing: break; case State.ShortLanding: if (newAnim) { pAnim.Play(hash.shortLandState, -1, 0); sAnim.Play(hash.skateSkatingState, -1, 0); } newAnim = false; break; case State.Grinding: if (grindTrick == GrindTrick.Grind) { sAnim.Play(hash.skateGrind); pAnim.Play(hash.grindState); } else if (grindTrick == GrindTrick.ForwardGrind) { sAnim.Play(hash.skateGrind2); pAnim.Play(hash.grindFront); } else if (grindTrick == GrindTrick.BackGrind) { sAnim.Play(hash.skateGrind2); pAnim.Play(hash.grindBack); } break; default: break; } if (grinding) rigid.isKinematic = true; else rigid.isKinematic = false; #endregion #region Sound if (isGrounded) { //if (speed.x < 0.1) // Die(); if (!wasGrounded) audio2.PlayOneShot(SkateLand, 1); rigid.isKinematic = false; if (!audio.clip == SkateLoop) { audio.loop = true; audio.clip = SkateLoop; audio.Play(); } } else if (grinding) { if (!wasGrinding) audio2.PlayOneShot(SkateGrindLand, 1); if (!particlesPlaying) { for (int i = 0; i < particles.Length; i++) { particles[i].Play(true); } particlesPlaying = true; } if (!audio.clip == SkateGrindLoop) { audio.loop = true; audio.clip = SkateGrindLoop; audio.Play(); } } else { rigid.isKinematic = false; if (particlesPlaying) { for (int i = 0; i < particles.Length; i++) { particles[i].Stop(true); } particlesPlaying = false; } audio.Stop(); audio.clip = null; } #endregion lastPosition = gameObject.transform.position; wasGrounded = isGrounded; wasGrinding = grinding; }
public void ThreeDimDrills() { if (trick != Tricks.ThreedDrills) { ClearSpinner(); SetSpinner(spinnerWheelPlane); setupTrick = true; trick = Tricks.ThreedDrills; envVariables.stepsInTrick = 12; } if (doingTrick) { //set speed modifier on props to 4 to get 4 zeropoint bodyParts.leftPropSpin.rotationSpeedModifier = 4f; bodyParts.rightPropSpin.rotationSpeedModifier = 4f; if (envVariables.eigthSteps >= 0 && envVariables.eigthSteps < 2) { trickStage = 0; if (EighthStepUpdate()) { bodyParts.rightHand.transform.RotateAround(bodyParts.rightWrist.transform.position, Vector3.right, 90f); bodyParts.leftHand.transform.RotateAround(bodyParts.leftWrist.transform.position, Vector3.right, 90f); } } else if (envVariables.eigthSteps >= 2 && envVariables.eigthSteps < 4) { trickStage = 1; if (EighthStepUpdate()) { //TODO: Smooth rotation into position bodyParts.rightHand.transform.RotateAround(bodyParts.rightWrist.transform.position, Vector3.down, 90f); bodyParts.leftHand.transform.RotateAround(bodyParts.leftWrist.transform.position, Vector3.down, 90f); } } else if (envVariables.eigthSteps >= 4 && envVariables.eigthSteps < 6) { trickStage = 2; if (EighthStepUpdate()) { bodyParts.rightHand.transform.RotateAround(bodyParts.rightWrist.transform.position, Vector3.forward, 90f); bodyParts.leftHand.transform.RotateAround(bodyParts.leftWrist.transform.position, Vector3.forward, 90f); } } else if (envVariables.eigthSteps >= 6 && envVariables.eigthSteps < 8) { trickStage = 3; if (EighthStepUpdate()) { bodyParts.rightHand.transform.RotateAround(bodyParts.rightWrist.transform.position, Vector3.left, 90f); bodyParts.leftHand.transform.RotateAround(bodyParts.leftWrist.transform.position, Vector3.left, 90f); } } else if (envVariables.eigthSteps >= 8 && envVariables.eigthSteps < 10) { trickStage = 4; if (EighthStepUpdate()) { bodyParts.rightHand.transform.RotateAround(bodyParts.rightWrist.transform.position, Vector3.up, 90f); bodyParts.leftHand.transform.RotateAround(bodyParts.leftWrist.transform.position, Vector3.up, 90f); } } else if (envVariables.eigthSteps >= 10 && envVariables.eigthSteps < 12) { trickStage = 5; if (EighthStepUpdate()) { bodyParts.rightHand.transform.RotateAround(bodyParts.rightWrist.transform.position, Vector3.forward, 90f); bodyParts.leftHand.transform.RotateAround(bodyParts.leftWrist.transform.position, Vector3.forward, 90f); } } else if (envVariables.eigthSteps == 12) { trickStage = 0; } //do the actual things during the stages if (trickStage == 0) { //right prop: from back to down bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Forward); bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Forward); //spin prop anti to arms bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Backward); bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Backward); ////smooth hand rotation into position //if (bodyParts.rightPropRegionXY == ZeroPointRegion.LocalDown && intermidiateStageRotationCounter < 90) //{ // bodyParts.rightHand.transform.RotateAround(bodyParts.rightWrist.transform.position, Vector3.down, 15f); // bodyParts.leftHand.transform.RotateAround(bodyParts.leftWrist.transform.position, Vector3.down, 15f); // intermidiateStageRotationCounter += 15; //} } else if (trickStage == 1) { //right prop: from down to out bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Right); bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Right); //spin prop anti to arms bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Left); bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Left); } else if (trickStage == 2) { //right prop: from out to forward bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Down); bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Down); //spin prop anti to arms bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Up); bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Up); } else if (trickStage == 3) { //right prop: forward to up bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Forward); bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Forward); //spin prop anti to arms bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Backward); bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Backward); } else if (trickStage == 4) { //right prop: up to out bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Left); bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Left); //spin prop anti to arms bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Right); bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Right); } else if (trickStage == 5) { //right prop: out to back bodyParts.rightArmSpin.RotateBodyPartAround(bodyParts.rightShoulder, SpinDirections.Up); bodyParts.leftArmSpin.RotateBodyPartAround(bodyParts.leftShoulder, SpinDirections.Up); //spin prop anti to arms bodyParts.rightPropSpin.RotateBodyPartAround(bodyParts.rightHand, SpinDirections.Down); bodyParts.leftPropSpin.RotateBodyPartAround(bodyParts.leftHand, SpinDirections.Down); } } if (setupTrick) { setupTrick = false; doingTrick = true; thisSimulationName.text = "3D Drills"; thisSimulationDescription.text = ""; } }
public String print() { return(String.Format(@"<td>{0}</td><td>{1}</td><td>{2}</td><td class=""right"">{3}</td><td {5}>{4}</td>", HtmlProtocols.ReplaceSuit(Contract), Dealer, HtmlProtocols.ReplaceSuit(Lead), Tricks == 0 ? "=" : (Tricks > 0 ? String.Format("+{0}", Tricks) : Tricks.ToString()), Score, IsPositive ? "" : @"class=""right""")); }