コード例 #1
0
        /// <summary>
        /// Return an echo from a pulse this radar emited.
        /// </summary>
        /// <param name="returnedEcho">The echo to return.</param>
        /// <returns></returns>
        public IStatus <CruiseRadar> ReturnEcho(RadarEcho returnedEcho)
        {
            var response = new Status <CruiseRadar>();

            try
            {
                if (_pulses.Contains(returnedEcho.OriginatingPulse))
                {
                    ContactOrClutter(returnedEcho);
                }
                else
                {
                    response.AddError
                        ("Echos can only be returned to the radars that " +
                        "emited the original pulse. ");
                }
            }
            catch (Exception ex)
            {
                response.AddException(ex);
            }

            response.RespondWithObject(this);
            return(response);
        }
コード例 #2
0
        /// <summary>
        /// Evatulate a single new echo as Clutter or Contact.
        /// </summary>
        /// <param name="echo"></param>
        /// <remarks>
        /// 1. Cruise’s owning customer can not be blocked by my cruises’s
        ///     owning customer.
        /// 2. I can’t be blocked by echo’s owning customer.
        /// 3. Cruises must be valid
        /// 4. Cruises can’t already be in the my Radar.
        /// 5. Cruise's Avatar can’t have handkerchiefs in my hard pass
        /// handkerchiefs collection.
        /// 6. Cruise can’t be clutter
        /// 8. match one of my handkerchiefs.
        /// </remarks>
        private void ContactOrClutter(RadarEcho echo)
        {
            // Already in clutter, stop evaluating as new echo.
            if (_clutter.Contains(echo.Source))
            {
                return;
            }

            // Already in contacts, stop evaluating as new echo.
            if (_contacts.Contains(echo.Source))
            {
                return;
            }

            if (MeetsClutterConditions(echo.Source))
            {
                FlagAsClutter(echo.Source);
            }
            else
            {
                FlagAsContact(echo.Source);
            }
        }