Esempio n. 1
0
 public Consumption(Microorganism microorganism, Pollutant pollutant) : base(
         microorganism.name + "-" + pollutant.name,
         Color.Lerp(microorganism.elementColor, pollutant.elementColor, 0.5f),
         ElementType.CONSUMPTION)
 {
     this.microorganism = microorganism;
     this.pollutant     = pollutant;
 }
Esempio n. 2
0
 public override bool Equals(object obj)
 {
     //Check for null and compare run-time types.
     if ((obj == null) || !GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         Pollutant r = (Pollutant)obj;
         return(name == r.name);
     }
 }
Esempio n. 3
0
        public void SetPollutant(Pollutant pollutant, float amount)
        {
            Pollutant       = pollutant;
            PollutantAmount = amount;

            SetPollutantColor(Pollutant);

            // TODO: Move this entire method indo AddPollutant
            if (PollutantAmount <= 0)
            {
                Pollutant = null;
            }
        }
Esempio n. 4
0
        private void SetPollutantColor(Pollutant pollutant)
        {
            Color color = new Color(0, 0, 0, 0);

            if (pollutant != null)
            {
                float transparency = Mathf.Sqrt(PollutantAmount / Config.SLOT_MAX_POLLUTANTS);

                color = new Color(
                    pollutant.elementColor.r,
                    pollutant.elementColor.g,
                    pollutant.elementColor.b,
                    transparency);
            }

            pollutantMeshRenderer.material.color = color;
        }
Esempio n. 5
0
        public void AddPollutant(Pollutant pollutant, float amount)
        {
            if (pollutant == Pollutant)
            {
                PollutantAmount += amount;
            }
            else if (Pollutant is null)
            {
                Pollutant       = pollutant;
                PollutantAmount = amount;
            }

            SetPollutantColor(Pollutant);

            // TODO: This is wrong. Make these functions the same
            if (PollutantAmount <= 0)
            {
                Pollutant = null;
            }
        }