public RangedFloatState(float initialValue, float minValue, float maxValue) { _max = new FloatState(maxValue); _min = new FloatState(minValue); _value = new FloatState(Clamp(initialValue, _min.Value, _max.Value)); Init(); }
private void Awake() { desScript = GetComponent <DesScript>(); floatState = new FloatState(this); lightBulbState = new LightBulbAttackState(this); dieState = new DieAttackState(this); createLevelState = new CreateLevelAttackState(this); }
private IEnumerator Wait() { floatState = FloatState.idle; float waitTime = Random.Range(minWaitTime, maxWaitTime); yield return(new WaitForSeconds(waitTime)); SetTargetPosition(); }
private void Init() { state = State.Head1; val = 0f; pow = 1; fSt = FloatState.Integer; temp = 0f; hum = 0f; coVal = 0f; co2Val = 0f; }
private void SetTargetPosition() { targetPosition = new Vector3( originPosition.x + Random.Range(-maxFloatDistance, maxFloatDistance), originPosition.y + Random.Range(-maxFloatDistance, maxFloatDistance), originPosition.z + Random.Range(-maxFloatDistance, maxFloatDistance) ); SetupSingleAxisMovement(); RestrainAxes(); floatState = FloatState.floating; }
private void OnTriggerEnter(Collider other) { Debug.Log("Trigger for whispers and chilling!"); stayCount = 0f; if (!whispered) { audioData.Play(0); mystate = FloatState.WHISPERING; } else if (!chilled) { audioData.PlayOneShot(chill); mystate = FloatState.CHILLING; } }
void InitPercentage() { if (_percentageInited) { return; } _percentageInited = true; if (_percentage == null) { _percentage = new FloatState(0); } _min.OnChange.Register(UpdatePercentage); _max.OnChange.Register(UpdatePercentage); _value.OnChange.Register(UpdatePercentage); UpdatePercentage(); }
private void Temperature(string buffer) { state = State.Temp; bool done = ParseFloat(buffer); if (done) { fSt = FloatState.Integer; temp = val; val = 0f; pow = 1; pos++; Humidity(buffer); } }
private void Humidity(string buffer) { state = State.Hum; bool done = ParseFloat(buffer); if (done) { fSt = FloatState.Integer; hum = val; val = 0f; pow = 1; pos++; CO(buffer); } }
private void CO(string buffer) { state = State.CO; bool done = ParseFloat(buffer); if (done) { fSt = FloatState.Integer; coVal = val; val = 0f; pow = 1; pos++; CO2(buffer); } }
private void CO2(string buffer) { state = State.CO2; bool done = ParseFloat(buffer); if (done) { fSt = FloatState.Integer; co2Val = val; val = 0f; pow = 1; current = new Reading(temp, hum, coVal, co2Val); pos++; S(buffer); } }
private void OnTriggerExit(Collider other) { audioData.Stop(); mystate = FloatState.NONE; }
// Start is called before the first frame update void Start() { audioData = GetComponent <AudioSource>(); mystate = FloatState.NONE; }
private bool ParseFloat(string buffer) { if (pos == buffer.Length) return false; //In case the next string begins with # ending the previous data string if (buffer[pos] == '#') { pos++; return true; } bool neg = false; if (buffer[pos] == '-') { neg = true; pos++; } if (fSt == FloatState.Integer) { while (buffer[pos] != '.') { val = val * 10 + int.Parse(buffer[pos].ToString()); pos++; if (pos == buffer.Length) return false; } } fSt = FloatState.Decimal; pos++; if (pos == buffer.Length) return false; while (buffer[pos] != '#') { val = val + (float)(int.Parse(buffer[pos].ToString()) * Math.Pow(10, -pow)); pow++; pos++; if (pos == buffer.Length) return false; } if (neg) val *= -1; return true; }
private bool ParseFloat(string buffer) { if (pos == buffer.Length) { return(false); } //In case the next string begins with # ending the previous data string if (buffer[pos] == '#') { pos++; return(true); } bool neg = false; if (buffer[pos] == '-') { neg = true; pos++; } if (fSt == FloatState.Integer) { while (buffer[pos] != '.') { val = val * 10 + int.Parse(buffer[pos].ToString()); pos++; if (pos == buffer.Length) { return(false); } } } fSt = FloatState.Decimal; pos++; if (pos == buffer.Length) { return(false); } while (buffer[pos] != '#') { val = val + (float)(int.Parse(buffer[pos].ToString()) * Math.Pow(10, -pow)); pow++; pos++; if (pos == buffer.Length) { return(false); } } if (neg) { val *= -1; } return(true); }