예제 #1
0
파일: Consumption.cs 프로젝트: GPMM/EcoLab
 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;
 }
예제 #2
0
파일: Pollutant.cs 프로젝트: GPMM/EcoLab
 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);
     }
 }
예제 #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;
            }
        }
예제 #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;
        }
예제 #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;
            }
        }