Ejemplo n.º 1
0
    private Color CalculateTileColor(Vector3 _tilePosition)
    {
        Color belowZero = planetData.GetColorBelowZero();
        Color zero      = planetData.GetColorZero();
        Color levelOne  = planetData.GetColorLevelOne();
        Color levelTwo  = planetData.GetColorLevelTwo();

        float[] distances = new float[] {
            Mathf.Abs(_tilePosition.y - (-7f + mapGenerator.GetSeaLevel())),
            Mathf.Abs(_tilePosition.y - (0f + mapGenerator.GetSeaLevel())),
            Mathf.Abs(_tilePosition.y - (7f + mapGenerator.GetSeaLevel())),
            Mathf.Abs(_tilePosition.y - (12f + mapGenerator.GetSeaLevel()))
        };

        Color averageColor = new Color(
            //first component (RED)
            CalculateWeightedValue(new float[] { belowZero.r, zero.r, levelOne.r, levelTwo.r }, distances),
            //second component (GREEN)
            CalculateWeightedValue(new float[] { belowZero.g, zero.g, levelOne.g, levelTwo.g }, distances),
            //third component (BLUE)
            CalculateWeightedValue(new float[] { belowZero.b, zero.b, levelOne.b, levelTwo.b }, distances)
            );

        return(averageColor);
    }