Beispiel #1
0
        /// <summary>
        ///  Helper function used to fire movement events.
        /// </summary>
        /// <param name="e">The movement event arguments.</param>
        /// <param name="clearOnly">Only clear the action, don't fire the event.</param>
        private void OnMoveCompleted(MoveCompletedEventArgs e, bool clearOnly)
        {
            if (InProgressActions.MoveToAction != null &&
                e.ActionID == InProgressActions.MoveToAction.ActionID)
            {
                // the action is no longer in progress. If this is the most recent MoveToAction,
                // remove it since there is no action in progress now
                InProgressActions.SetMoveToAction(null);
            }

            if (!clearOnly && MoveCompleted != null)
            {
                MoveCompleted(this, e);
            }
        }
Beispiel #2
0
        // Fired when we've finished moving.
        private void MyAnimal_MoveCompleted(object sender, MoveCompletedEventArgs e)
        {
            // Reset the antenna value
            Antennas.AntennaValue = 0;

            // If we've stopped because something is blocking us...
            if (e.Reason == ReasonForStop.Blocked)
            {
                WriteTrace("Something's blocking my way.");
                if (e.BlockingOrganism is AnimalState)
                {
                    AnimalState blockingAnimal = (AnimalState) e.BlockingOrganism;

                    if (blockingAnimal.AnimalSpecies.IsSameSpecies(Species))
                    {
                        // Signal to our friend to move out of our way.
                        WriteTrace("One of my friends is blocking my way.  I'll ask him to move.");
                        Antennas.AntennaValue = 13;
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///  Helper function used to fire movement events.
        /// </summary>
        /// <param name="e">The movement event arguments.</param>
        /// <param name="clearOnly">Only clear the action, don't fire the event.</param>
        private void OnMoveCompleted(MoveCompletedEventArgs e, bool clearOnly)
        {
            if (InProgressActions.MoveToAction != null &&
                e.ActionID == InProgressActions.MoveToAction.ActionID)
            {
                // the action is no longer in progress. If this is the most recent MoveToAction,
                // remove it since there is no action in progress now
                InProgressActions.SetMoveToAction(null);
            }

            if (!clearOnly && MoveCompleted != null)
            {
                MoveCompleted(this, e);
            }
        }