Esempio n. 1
0
        /// <summary>
        /// find and apply a specified image from the pony's cache of them.
        /// </summary>
        /// <param name="action"></param>
        /// <param name="direction"></param>
        private void LoadImage(PonyAction action, PonyDirection direction)
        {
            PonyImage image;

            // find the requested image from the cache.
            image = this.Image.Find(delegate(PonyImage img){
                if (img.Action == action && img.Direction == direction)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            if (image == null)
            {
                Trace.WriteLine(String.Format(
                                    "!! no image for {0} {1} {2}",
                                    this.Name,
                                    action.ToString(),
                                    direction.ToString()
                                    ));

                return;
            }
            ;

            // and apply it to the pony window.
            image.ApplyToPonyWindow(this.Window);
        }
Esempio n. 2
0
 public static Uri SelectImagePath(string name, PonyAction action, PonyDirection direction)
 {
     return new Uri(
         String.Format(
             "{0}Resources\\{1}\\{2}{3}.gif",
             AppDomain.CurrentDomain.BaseDirectory,
             name,
             action.ToString(),
             direction.ToString()
         ),
         UriKind.Absolute
     );
 }
Esempio n. 3
0
 public static Uri SelectImagePath(string name, PonyAction action, PonyDirection direction)
 {
     return(new Uri(
                String.Format(
                    "{0}Resources\\{1}\\{2}{3}.gif",
                    AppDomain.CurrentDomain.BaseDirectory,
                    name,
                    action.ToString(),
                    direction.ToString()
                    ),
                UriKind.Absolute
                ));
 }
Esempio n. 4
0
        /// <summary>
        /// find and apply a specified image from the pony's cache of them.
        /// </summary>
        /// <param name="action"></param>
        /// <param name="direction"></param>
        private void LoadImage(PonyAction action, PonyDirection direction)
        {
            PonyImage image;

            // find the requested image from the cache.
            image = this.Image.Find(delegate(PonyImage img){
                if(img.Action == action && img.Direction == direction) return true;
                else return false;
            });

            if(image == null) {
                Trace.WriteLine(String.Format(
                    "!! no image for {0} {1} {2}",
                    this.Name,
                    action.ToString(),
                    direction.ToString()
                ));

                return;
            };

            // and apply it to the pony window.
            image.ApplyToPonyWindow(this.Window);
        }
Esempio n. 5
0
        /// <summary>
        /// tell the pony exactly what to do (even if she is telling herself).
        /// </summary>
        /// <param name="action"></param>
        /// <param name="direction"></param>
        public void TellWhatDo(PonyAction action, PonyDirection direction)
        {
            bool able = true;

            // if an invalid action was specified, then no.
            if(direction == PonyDirection.None || action == PonyAction.None) able = false;

            // if this is an action she is not configured to be able to do then
            // of course the answer is no.
            if(!this.CanDo(action)) able = false;

            if(!able) {
                Trace.WriteLine(String.Format(
                    "!! {0} cannot {1} {2}",
                    this.Name,
                    action.ToString(),
                    direction.ToString()
                ));
                return;
            }

            Trace.WriteLine(String.Format(
                ">> {0} will {1} to the {2}",
                this.Name,
                action.ToString(),
                direction.ToString()
            ));

            // if this is the first action our pony has done, then we also need to
            // spool the decision engine up.
            if(this.ChoiceTimer == null) {
                this.ChoiceTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle, this.Window.Dispatcher);
                this.ChoiceTimer.Tick += ChooseWhatDo;
                this.ResetChoiceTimer();
            }

            // no need to muck with the image and window if we are doing more of the
            // same yeh? also check choicetimer as a means of "is this the first
            // action ever" to make sure the default gets loaded.
            if(action != this.Action || direction != this.Direction) {
                this.Action = action;
                this.Direction = direction;
                this.StartAction();

                // reset the choice timer to a new interval based on the action
                // that just happened, but only if it was still enabled.
                if(this.ChoiceTimer.IsEnabled)
                    this.ResetChoiceTimer();

            }

            // spend the energy associated with this action.
            if(this.Mode != PonyMode.Clingy)
            this.EnergySpend();
        }
Esempio n. 6
0
        /// <summary>
        /// tell the pony exactly what to do (even if she is telling herself).
        /// </summary>
        /// <param name="action"></param>
        /// <param name="direction"></param>
        public void TellWhatDo(PonyAction action, PonyDirection direction)
        {
            bool able = true;

            // if an invalid action was specified, then no.
            if (direction == PonyDirection.None || action == PonyAction.None)
            {
                able = false;
            }

            // if this is an action she is not configured to be able to do then
            // of course the answer is no.
            if (!this.CanDo(action))
            {
                able = false;
            }

            if (!able)
            {
                Trace.WriteLine(String.Format(
                                    "!! {0} cannot {1} {2}",
                                    this.Name,
                                    action.ToString(),
                                    direction.ToString()
                                    ));
                return;
            }

            Trace.WriteLine(String.Format(
                                ">> {0} will {1} to the {2}",
                                this.Name,
                                action.ToString(),
                                direction.ToString()
                                ));

            // if this is the first action our pony has done, then we also need to
            // spool the decision engine up.
            if (this.ChoiceTimer == null)
            {
                this.ChoiceTimer       = new DispatcherTimer(DispatcherPriority.ApplicationIdle, this.Window.Dispatcher);
                this.ChoiceTimer.Tick += ChooseWhatDo;
                this.ResetChoiceTimer();
            }

            // no need to muck with the image and window if we are doing more of the
            // same yeh? also check choicetimer as a means of "is this the first
            // action ever" to make sure the default gets loaded.
            if (action != this.Action || direction != this.Direction)
            {
                this.Action    = action;
                this.Direction = direction;
                this.StartAction();

                // reset the choice timer to a new interval based on the action
                // that just happened, but only if it was still enabled.
                if (this.ChoiceTimer.IsEnabled)
                {
                    this.ResetChoiceTimer();
                }
            }

            // spend the energy associated with this action.
            if (this.Mode != PonyMode.Clingy)
            {
                this.EnergySpend();
            }
        }