/// <summary> /// Constructor /// </summary> /// <param name="subject">Who's performing the action.</param> /// <param name="action">What the action is.</param> /// <param name="reaction">The next link</param> /// <param name="parameters">The parameters for the function.</param> /// <param name="reactionCertainty">How certain you are that this action is actually legit.</param> /// <param name="netPositive">How much it will make you happy</param> public Action(Person subject, Person.action action, Action reaction, dynamic[] parameters, int reactionCertainty, int netPositive) { this.subject = subject; this.action = action; this.reaction = reaction; this.parameters = parameters; this.reactionCertainty = reactionCertainty; this.netPositive = netPositive; }
public List<BaseObject> runCollision(Person checkWith) { List<BaseObject> toRemove = new List<BaseObject>(); //Run through all of the other objects and check a collision. foreach (BaseObject b in objects) { if (checkWith != b /* no self collisions */ && checkWith.position.X > b.position.X - Main.characterDimension.X && checkWith.position.X < b.position.X + Main.characterDimension.X && checkWith.position.Y > b.position.Y - Main.characterDimension.Y && checkWith.position.Y < b.position.Y + Main.characterDimension.Y) { //Do collision. if (checkWith.doCollision(b)) toRemove.Add(b); } } return toRemove; }
/// <summary> /// Constructor for world. /// </summary> /// <param name="startX">The starting x position.</param> /// <param name="startY">Starting y position.</param> /// <param name="width">Width of world.</param> /// <param name="height">Height of world.</param> /// <param name="numberOfFlowers">Number of starting flowers.</param> /// <param name="numberOfPeople">Number of starting people.</param> public World(int startX, int startY, int width, int height, int numberOfFlowers, int numberOfPeople) { objects = new List<BaseObject>(); for (int i = 0; i < numberOfFlowers; i++) { //Add flowers. objects.Add(new Flower(Main.random.Next(startX, startX + width), Main.random.Next(startY, startY + height))); } for (int i = 0; i < numberOfPeople; i++) { //Add people. objects.Add(new Person(Main.random.Next(startX, startX + width), Main.random.Next(startY, startY + height), this, false)); } //Add the player. Also set the world dimensions. objects.Add(player = new Person(Main.random.Next(this.startX = startX, this.endX = startX + width), Main.random.Next(this.startY = startY, this.endY = startY + height), this, true)); }
/// <summary> /// Get a flower from another person. /// </summary> /// <param name="parameters">the color of the flower (int) - the person giving the flower (Person)</param> public void getFlowerReal(int color, Person person) { inventory.Add(color); if (color == favoriteColor) { world.broadcastAction(new Action(this, this.getFlower, null, new dynamic[] { color }, 100, 50)); increaseOwnHappiness(flowerInterest); //Get happy. if (!peopleOfInterest.ContainsKey(person)) //Pay attention to this guy. { peopleOfInterest.Add(person, flowerInterest); //I'm going to set up some basic logic for this person. for (int i = 0; i < Main.colors.Length - 1; i++) //For each flower color. { Action get = new Action(person, person.getFlower, null, new dynamic[] { i }, 0, 0); //If it's your favorite color, you feel a loss by giving it. knownCausality.Add(new Action(this, giveFlower, get, new dynamic[] { person, i }, 100, ((color == favoriteColor)? -5 : 0))); knownCausality.Add(get); } //Also increase your empathy, which doesn't exist yet. } else peopleOfInterest[person] += 1; //I'm even more interested in you. Also fixes the problem with people that aren't interested in anything. //This is where the empathy stat would come in. } }