Exemple #1
0
    public void SetColor()
    {
        //get percentage of opposite color used based on health. Get that percentage of the dist from this and optimum color
        //and add that onto the optimum to get a blend of the 2 colors

        PlantRates pr = transform.root.gameObject.GetComponent <PlantRates>();
        float      colorPerc;

        if (pr.Health() >= healthToColorRatio)
        {
            colorPerc     = NumOp.Cutoff(pr.Health() - GetComponent <Grow>().growthAmount, 0f, 1f);
            realTimeColor = NumOp.GetColorBlend(optimumColor, earlyColor, colorPerc);
        }
        else
        {
            float tmp = (healthToColorRatio - pr.Health()) * (1f / healthToColorRatio);
            colorPerc     = NumOp.Cutoff(1f - (GetComponent <Grow>().growthAmount - tmp), 0f, 1f);
            realTimeColor = NumOp.GetColorBlend(optimumColor, lateColor, colorPerc);
        }

        realTimeColor = new Color(realTimeColor[0], realTimeColor[1], realTimeColor[2], alphaValue);
        if (debug)
        {
            print("percentage of opposite used: " + colorPerc.ToString());
        }
    }
Exemple #2
0
 public static Color GetValueMix(Color val1, Color val2, float offsetPercentage)
 {
     return(NumOp.GetColorBlend(val1, val2, offsetPercentage));
 }