Example #1
0
        /// <summary>
        /// Get an activity that will meet the goal
        /// </summary>
        /// <param name="motivator">the goal at hand</param>
        /// <returns>an activity to meet it</returns>
        public Accomplisher HowToDo(Motivator motivator)
        {
            short        motivation = (short)motivator;
            Accomplisher todo       = Accomplisher.Wander;
            Array        activities = Enum.GetValues(typeof(Accomplisher));

            if (activities.Length >= motivation)
            {
                todo = (Accomplisher)motivation;
            }

            return(todo);
        }
Example #2
0
        public void DoTheThing(Motivator motivator)
        {
            Accomplisher action = Hypothalamus.HowToDo(motivator);
            bool         wander = false;

            switch (action)
            {
            case Accomplisher.Drink:
                IInanimate waterBottle = Inventory.EntitiesContained().FirstOrDefault(ent => ent.GetQuality("Water") > 0);

                if (waterBottle != null)
                {
                    waterBottle.SetQuality(-1, "Water", true);
                    Hypothalamus.ApplyPressure(Motivator.Thirst, -10);
                    Exhaust(-10);
                }
                else
                {
                    wander = true;
                }
                break;

            case Accomplisher.Eat:
                IInanimate food = Inventory.EntitiesContained().FirstOrDefault(ent => ent.GetQuality("Food") > 0);

                if (food != null)
                {
                    //TODO: turn this into an eat command
                    int foodValue = food.GetQuality("Food");
                    food.Remove();
                    Hypothalamus.ApplyPressure(Motivator.Hunger, -1 * foodValue);
                    Harm(-1 * foodValue);
                }
                else
                {
                    wander = true;
                }
                break;

            case Accomplisher.Sleep:
                //Can't sleep yet
                break;

            case Accomplisher.Speak:
                if (CurrentLocation.CurrentZone != null)
                {
                    CurrentLocation.CurrentZone.BroadcastEvent("$A$ moos.", this);
                }
                break;

            case Accomplisher.Wander:
                wander = true;
                break;
            }

            if (wander)
            {
                Random rand = new Random();
                MovementDirectionType direction = (MovementDirectionType)rand.Next(0, 7);

                //Run the command like anyone else
                //Interpret.Render(direction.ToString(), this);
            }
        }