public static float GetWaveHeight(this WaveOptions wave, WaveMode waveMode, Vector3 worldPos, float time) { Texture2D waveTexture = wave.Texture as Texture2D; if (waveTexture == null) { return(0); } float height = 0; switch (waveMode) { case WaveMode.Wave1: height += GetWaveHeight(wave, waveTexture, worldPos, 0, 1, 2, time); break; case WaveMode.Wave2: height += GetWaveHeight(wave, waveTexture, worldPos, 0, 1, 0, time); height += GetWaveHeight(wave, waveTexture, worldPos, 2, 3, 1, time); break; case WaveMode.Wave3: height += GetWaveHeight(wave, waveTexture, worldPos, 0, 0, time); height += GetWaveHeight(wave, waveTexture, worldPos, 1, 1, time); height += GetWaveHeight(wave, waveTexture, worldPos, 2, 2, time); break; } return(height); }
public static float GetWaveHeight(WaveOptions wave, Texture2D waveTexture, Vector3 worldPos, int colorIndex, int index, float time) { Vector2 uv = GetWorldWaveUV(new Vector2(worldPos.x, worldPos.z), wave.Radian[index], wave.GetRect(index)); uv.y -= wave.SpeedZ[index] * time; float height = GetColor(waveTexture, uv.x, uv.y)[colorIndex]; height = Mathf.Pow(height, wave.HeightPow[index]) * wave.HeightScale[index]; return(height); }