public void Init() { _colorModel.SetRGB( Random.value * _Mulitiplier[0], Random.value * _Mulitiplier[1], Random.value * _Mulitiplier[2]); _colorModel.SetDensity(Random.Range(_MinDensity, _MaxDensity)); }
public void OnTriggerStay2D(Collider2D other) { float dt = Time.deltaTime; ColorTransfer transferOther = other.GetComponent <ColorTransfer> (); if (transferOther == null) { return; } ColorModel colorModelOther = transferOther.GetColorModel(); float ColorAmt = _colorModel.GetColorAmount(); Vector3 RGBThis = _colorModel.GetRGB(); Vector3 RGBOther = colorModelOther.GetRGB(); float densityThis = _colorModel.GetDensity(); float densityOther = colorModelOther.GetDensity(); for (int i = 0; i < 3; i++) { float CThis = RGBThis [i]; float COther = RGBOther [i]; float deltaC = _DeltaFactor * (CThis - COther) + 1.0f; float CAbsorb = dt * _AbsorbPower * ColorAmt * densityThis / (deltaC * densityOther); CAbsorb = Mathf.Min(RGBOther [i], CAbsorb); RGBOther [i] -= CAbsorb; RGBThis [i] += CAbsorb; } _colorModel.SetRGB(RGBThis); colorModelOther.SetRGB(RGBOther); }