Ejemplo n.º 1
0
        /// <summary>
        /// Sets odor strength to new strength if is it stronger (more "fresh").
        /// </summary>
        /// <param name="odor"></param>
        /// <param name="freshStrength"></param>
        /// <param name="position"></param>
        public void RefreshScentAt(Odor odor, int freshStrength, Point position)
        {
            if (!IsInBounds(position))
            {
                throw new ArgumentOutOfRangeException(String.Format("position; ({0},{1}) map {2} odor {3}", position.X, position.Y, this.m_Name, odor.ToString()));
            }

            OdorScent oldScent = GetScentByOdor(odor, position);

            if (oldScent == null)
            {
                // new odor there.
                OdorScent newScent = new OdorScent(odor, freshStrength, position);
                AddNewScent(newScent);
            }
            else
            {
                // existing odor here.
                if (oldScent.Strength < freshStrength)
                {
                    oldScent.Set(freshStrength);
                }
            }
        }