void ChangeToPickup() { currentStateTime = 0; bandState = BandState.Pickup; tag = "RubberBand"; gameObject.layer = LayerMask.NameToLayer("RubberBand"); body.velocity = new Vector2 (0, 0); }
public void Shoot(float angle, float power) { Enable (); currentStateTime = 0; animator.SetTrigger ("StartScaling"); body.isKinematic = false; bandState = BandState.Projectile; transform.localEulerAngles = new Vector3 (0, 0, Mathf.Rad2Deg*angle); body.velocity = new Vector2 (Mathf.Cos (angle), Mathf.Sin (angle)) * power; }
public void Copy(Source_FrequencyBand from) { this.band = from.band; this.state = from.state; this.multiplier = from.multiplier; this.divider = from.divider; this.minDACBand = from.minDACBand; this.affinityBand = from.affinityBand; this.maxDACBand = from.maxDACBand; this.guardBand = from.guardBand; }
private void PopulateFrequencyBands() { //Range of a spectrum sample is : (sample rate of clip / number of samples) float sampleWidth = AudioClip.frequency / SampleSize; //Get average frequency of each spectrum sample for (int i = 0; i < SampleSize; i++) { float startFrequency = i * sampleWidth; float endFrequency = (i + 1) * sampleWidth; sampleAverages[i] = (startFrequency + endFrequency) / 2f; } #warning Can optimize this to do all in 1 pass instead of each bands! //See which band the ave freq of each sample falls into //Add value to that band until all checked, divide by len for average for (int b = 0; b < FrequencyBands.Length; b++) { BandState bs = bandStates[b]; bs.averageAmp = 0f; bs.sampleCount = 0; for (int i = 0; i < SampleSize; i++) { if (sampleAverages[i] >= FrequencyBands[b].startFrequency && sampleAverages[i] < FrequencyBands[b].endFrequency) { bs.averageAmp += samples[i]; bs.sampleCount++; } } if (bs.sampleCount > 0) { bs.averageAmp /= bs.sampleCount; } if (bs.averageAmp > bs.maxAmp) { bs.maxAmp = bs.averageAmp; } bs.percentToMaxAmp = Mathf.InverseLerp(0f, bs.maxAmp, bs.averageAmp); } }
private void ApplyBuffer() { for (int b = 0; b < FrequencyBands.Length; b++) { BandState bs = bandStates[b]; if (Mathf.Approximately(bs.lastAmp, 0f)) { bs.lastAmp = bs.averageAmp; } if (bs.averageAmp < bs.lastAmp) { float bufferedAmp = bs.lastAmp * (1 - fallFactor * Time.deltaTime); bs.percentToMaxAmp = Mathf.InverseLerp(0f, bs.maxAmp, bufferedAmp); bs.lastAmp = bufferedAmp; } else { bs.lastAmp = bs.averageAmp; } } }
public Source_FrequencyBand( UInt32 band, BandState state, UInt16 multiplier, UInt16 divider, UInt16 minDACBand, UInt16 affinityBand, UInt16 maxDACBand, UInt16 guardBand ) : base() { this.band = band; this.state = state; this.multiplier = multiplier; this.divider = divider; this.minDACBand = minDACBand; this.affinityBand = affinityBand; this.maxDACBand = maxDACBand; this.guardBand = guardBand; }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this); } audioSource = GetComponent <AudioSource>(); samples = new float[SampleSize]; sampleAverages = new float[SampleSize]; bandStates = new BandState[FrequencyBands.Length]; cubeEmissionStartColors = new Color[FrequencyBands.Length]; for (int b = 0; b < FrequencyBands.Length; b++) { bandStates[b] = new BandState(); cubeEmissionStartColors[b] = new Color(); } }
public Source_FrequencyBand ( UInt32 band, BandState state, UInt16 multiplier, UInt16 divider, UInt16 minDACBand, UInt16 affinityBand, UInt16 maxDACBand, UInt16 guardBand ) : base( ) { this.band = band; this.state = state; this.multiplier = multiplier; this.divider = divider; this.minDACBand = minDACBand; this.affinityBand = affinityBand; this.maxDACBand = maxDACBand; this.guardBand = guardBand; }
// Load frequency info, actually does Nx calls - any // of which may fail and cause an error return public rfid.Constants.Result load ( rfid.Linkage transport, UInt32 readerHandle ) { UInt32 config = 0; UInt32 multdiv = 0; UInt32 pllcc = 0; rfid.Constants.Result result = transport.API_ConfigWriteRegister ( SELECTOR_ADDRESS, this.band ); if (rfid.Constants.Result.OK != result) { return(result); } result = transport.API_ConfigReadRegister ( CONFIG_ADDRESS, ref config ); if (rfid.Constants.Result.OK != result) { return(result); } result = transport.API_ConfigReadRegister ( MULTDIV_ADDRESS, ref multdiv ); if (rfid.Constants.Result.OK != result) { return(result); } result = transport.API_ConfigReadRegister ( PLLCC_ADDRESS, ref pllcc ); if (rfid.Constants.Result.OK != result) { return(result); } try { this.state = ( BandState )(config == 0 ? 0 : 1); } catch (Exception) { this.state = BandState.UNKNOWN; } this.multiplier = ( UInt16 )((multdiv >> 0) & 0xffff); this.divider = ( UInt16 )((multdiv >> 16) & 0xff); this.minDACBand = ( UInt16 )((pllcc >> 0) & 0xff); this.affinityBand = ( UInt16 )((pllcc >> 8) & 0xff); this.maxDACBand = ( UInt16 )((pllcc >> 16) & 0xff); this.guardBand = ( UInt16 )((pllcc >> 24) & 0xff); return(rfid.Constants.Result.OK); }
void PlayerPickup(Player player) { Disable (); activeBand = false; bandState = BandState.Disabled; player.AddRubberBandAmmo (gameObject); }
// Load frequency info, actually does Nx calls - any // of which may fail and cause an error return public rfid.Constants.Result load( rfid.Linkage transport, UInt32 readerHandle ) { UInt32 config = 0; UInt32 multdiv = 0; UInt32 pllcc = 0; rfid.Constants.Result result = transport.API_ConfigWriteRegister ( SELECTOR_ADDRESS, this.band ); if ( rfid.Constants.Result.OK != result ) { return result; } result = transport.API_ConfigReadRegister ( CONFIG_ADDRESS, ref config ); if ( rfid.Constants.Result.OK != result ) { return result; } result = transport.API_ConfigReadRegister ( MULTDIV_ADDRESS, ref multdiv ); if ( rfid.Constants.Result.OK != result ) { return result; } result = transport.API_ConfigReadRegister ( PLLCC_ADDRESS, ref pllcc ); if ( rfid.Constants.Result.OK != result ) { return result; } try { this.state = ( BandState ) ( config == 0 ? 0 : 1 ); } catch ( Exception ) { this.state = BandState.UNKNOWN; } this.multiplier = ( UInt16 ) ( ( multdiv >> 0 ) & 0xffff ); this.divider = ( UInt16 ) ( ( multdiv >> 16 ) & 0xff ); this.minDACBand = ( UInt16 ) ( ( pllcc >> 0 ) & 0xff ); this.affinityBand = ( UInt16 ) ( ( pllcc >> 8 ) & 0xff ); this.maxDACBand = ( UInt16 ) ( ( pllcc >> 16 ) & 0xff ); this.guardBand = ( UInt16 ) ( ( pllcc >> 24 ) & 0xff ); return rfid.Constants.Result.OK; }
public void Copy( Source_FrequencyBand from ) { this.band = from.band; this.state = from.state; this.multiplier = from.multiplier; this.divider = from.divider; this.minDACBand = from.minDACBand; this.affinityBand = from.affinityBand; this.maxDACBand = from.maxDACBand; this.guardBand = from.guardBand; }