Esempio n. 1
0
 void CalcHeights()
 {
     for (int x = Mathf.RoundToInt(centerX - baseWidth); x < centerX + baseWidth; x++)
     {
         for (int y = Mathf.RoundToInt(centerY - leadingLen); y < centerY + trailingLen; y++)
         {
             float xDist = Mathf.Abs(centerX - x);
             float yDist = Mathf.Abs(centerY - y);
             float xMod  = 1;
             float yMod  = 1;
             if (xDist >= apexWdith)
             {
                 var curWidth = xDist - apexWdith;
                 var maxWidth = baseWidth - apexWdith;
                 xMod = 1 - ((curWidth * curWidth) / (maxWidth * maxWidth));
             }
             else
             {
                 xMod = 1;
             }
             if (y > centerY)
             {
                 yMod = 1 - ((yDist * yDist) / (trailingLen * trailingLen));
             }
             else if (y < centerY)
             {
                 yMod = 1 - (yDist / leadingLen);
             }
             water.AddToWaterHeight(x, y, height * yMod * xMod);
         }
     }
 }