public float GetScale() { float colorAmt = _colorModel.GetColorAmount(); float density = _colorModel.GetDensity(); float scale = Mathf.Pow(colorAmt, 1.0f / _Power) * _ScaleFactor / density; return(scale); }
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); }