public TrashBin(TimeSpan birthTime, Texture texture, Vector startingPosition, string name, int price, string description, string iconTextureKey, NecessityEffect necessityEffect, SkillEffect skillEffect) : base(birthTime, name, texture, startingPosition, price, description, iconTextureKey) { NecessityEffect = necessityEffect; SkillEffect = skillEffect; }
public void Execute(NecessityEffect affector) { foreach (var actionKey in actions.Keys) { Action action; bool success = actions.TryGetValue(actionKey, out action); if (success) { List <Subscription> subscriptionsToRemove = new List <Subscription>(); foreach (var subscription in action.Subscriptions) { var subscriber = subscription.Subscriber; subscriber.ReactToAction(action.Type, affector); // if the subscriber only subscribed to be notified once, queue them to be removed once the notifications are complete if (subscription.Type == SubscriptionType.Once) { subscriptionsToRemove.Add(subscription); } } foreach (var subscription in subscriptionsToRemove) { action.RemoveSubscription(subscription.Subscriber); } } } }
public void SetNeedsValues(NecessityEffect necessityEffect) { labelHealthValue.Text = String.Format("{0} {1}", (int)necessityEffect.HealthEffectiveness, necessityEffect.HealthEffectivenessToString()); labelHygieneValue.Text = String.Format("{0} {1}", (int)necessityEffect.HygieneEffectiveness, necessityEffect.HygieneEffectivenessToString()); labelSleepValue.Text = String.Format("{0} {1}", (int)necessityEffect.SleepEffectiveness, necessityEffect.SleepEffectivenessToString()); labelHungerValue.Text = String.Format("{0} {1}", (int)necessityEffect.HungerEffectiveness, necessityEffect.HungerEffectivenessToString()); labelThirstValue.Text = String.Format("{0} {1}", (int)necessityEffect.ThirstEffectiveness, necessityEffect.ThirstEffectivenessToString()); }
private void AdjustNecessities(NecessityEffect necessityEffect) { Necessities.AdjustSleep(necessityEffect.SleepEffectiveness); Eat(necessityEffect.HungerEffectiveness); Drink(necessityEffect.ThirstEffectiveness); Necessities.AdjustHygiene(necessityEffect.HygieneEffectiveness); Necessities.AdjustHealth(necessityEffect.HealthEffectiveness); }
public AgentMetadata(int price, string name, string description, string iconKey, NecessityEffect necessityEffect, SkillEffect skillEffect) { Price = price; Name = name; IconKey = iconKey; NecessityEffect = necessityEffect; SkillEffect = skillEffect; Description = description; }
/// <summary> /// Reacts to an action fired as the result of a trigger. /// </summary> /// <param name="actionType">Action type.</param> /// <param name="affector">Affector.</param> public override void ReactToAction(ActionType actionType, NecessityEffect affector) { if (actionType == ActionType.DispenseDrink) { Drink(affector.ThirstEffectiveness); } else if (actionType == ActionType.DispenseFood) { Eat(affector.HungerEffectiveness); } }
public abstract void ReactToAction(ActionType actionType, NecessityEffect affector);
private void LoadAgentMetadata(string json) { if (json == null) { throw new ArgumentNullException("json"); } JObject o = JObject.Parse(json); foreach (var equipment in o["equipment"]) { NecessityEffect necessityEffectData = null; SkillEffect skillEffectData = null; string key = equipment["key"].ToString(); string name = equipment["name"].ToString(); int price = Int32.Parse(equipment["price"].ToString()); string iconKey = equipment["icon"].ToString(); string description = equipment["description"].ToString(); foreach (var necessityEffect in equipment["necessityEffect"]) { int health = Int32.Parse(necessityEffect["health"].ToString()); int hygiene = Int32.Parse(necessityEffect["hygiene"].ToString()); int sleep = Int32.Parse(necessityEffect["sleep"].ToString()); int thirst = Int32.Parse(necessityEffect["thirst"].ToString()); int hunger = Int32.Parse(necessityEffect["hunger"].ToString()); necessityEffectData = new NecessityEffect(health, hygiene, sleep, thirst, hunger); } foreach (var skillEffect in equipment["skillEffect"]) { int intelligence = Int32.Parse(skillEffect["intelligence"].ToString()); int creativity = Int32.Parse(skillEffect["creativity"].ToString()); int communication = Int32.Parse(skillEffect["communication"].ToString()); int leadership = Int32.Parse(skillEffect["leadership"].ToString()); skillEffectData = new SkillEffect(intelligence, creativity, communication, leadership); } AgentMetadata agentMetadata = new AgentMetadata(price, name, description, iconKey, necessityEffectData, skillEffectData); agentMetadataDictionary.Add(key, agentMetadata); } foreach (var room in o["rooms"]) { NecessityEffect necessityEffectData = null; SkillEffect skillEffectData = null; string key = room["key"].ToString(); string name = room["name"].ToString(); int price = Int32.Parse(room["price"].ToString()); string iconKey = room["icon"].ToString(); string mapPathKey = room["map"].ToString(); string description = room["description"].ToString(); foreach (var necessityEffect in room["necessityEffect"]) { int health = Int32.Parse(necessityEffect["health"].ToString()); int hygiene = Int32.Parse(necessityEffect["hygiene"].ToString()); int sleep = Int32.Parse(necessityEffect["sleep"].ToString()); int thirst = Int32.Parse(necessityEffect["thirst"].ToString()); int hunger = Int32.Parse(necessityEffect["hunger"].ToString()); necessityEffectData = new NecessityEffect(health, hygiene, sleep, thirst, hunger); } foreach (var skillEffect in room["skillEffect"]) { int intelligence = Int32.Parse(skillEffect["intelligence"].ToString()); int creativity = Int32.Parse(skillEffect["creativity"].ToString()); int communication = Int32.Parse(skillEffect["communication"].ToString()); int leadership = Int32.Parse(skillEffect["leadership"].ToString()); skillEffectData = new SkillEffect(intelligence, creativity, communication, leadership); } RoomMetadata roomMetadata = new RoomMetadata(price, name, description, iconKey, necessityEffectData, skillEffectData, mapPathKey); roomMetadataDictionary.Add(key, roomMetadata); } }
public RoomMetadata(int price, string name, string description, string iconKey, NecessityEffect necessityEffect, SkillEffect skillEffect, string mapPathKey) : base(price, name, description, iconKey, necessityEffect, skillEffect) { MapPathKey = mapPathKey; }
public Library(string name, int price, string description, string iconTextureKey, TiledMap tiledMap) : base(name, price, description, iconTextureKey, tiledMap) { NecessityEffect = new NecessityEffect(0, 0, -1, 0, 0); SkillEffect = new SkillEffect(1, 1, 0, 0); }