public void SpawnRandomAnimal() { Animal a; OrderedPair <int> spawnLocation = Utilities.GetRandomPoint(); int x = spawnLocation.X; int y = spawnLocation.Y; AnimalType animalType = UtilityDecider <AnimalType> .WeightedRandomChoice(animalSpawnWeights); switch (animalType) { case AnimalType.Bear: a = Animal.CreateBear(x, y); break; case AnimalType.Wolf: a = Animal.CreateWolf(x, y); break; case AnimalType.Hog: a = Animal.CreateHog(x, y); break; default: a = Animal.CreateGoat(x, y); break; } Console.WriteLine("Spawning a {0}", animalType); EntitiesAdd(a); }
public override void Do(Entity entity) { moveTime++; moveAction.Do(entity); // GotoAction checks collision with destination and hitting walls. bool result = moveAction.IsActive; if (moveTime == changeCount) // Change directions after a set time. { moveTime = 0; double d = Utilities.Rng.NextDouble(); if (d < changeProbability) { // Applies goto to set direction to (x, y). Goto applies Move(). False means the entity hit a wall and needs to head to another square. destination = Utilities.GetRandomPoint(); moveAction = new GotoAction(destination.X, destination.Y, entitySize); } else if (d > 0.75) { entity.Stop(); } } // The entity has hit a wall or reached the destination. else if (!result && entity.CollisionDirection != Direction.None) { destination = Utilities.GetDirectionalPoint(entity.CollisionDirection, entity.Position); moveAction = new GotoAction(destination.X, destination.Y, entitySize); } //entity.ApplyNeedDeltas(UtilityDeltas); // Advertise needs deltas to entities but don't actually give them the reward. This is for a default action. }
public void CreateObjects(OrderedPair <int> center) { Plant potato = GeneralPlant.Potato(80, 80); List <Plant> yuccaPlants = new List <Plant>(); Plant pineTree1 = GeneralPlant.PineTree(230, 400); List <Plant> appleTrees = new List <Plant> { new AppleTree(center.X + 50, center.Y + 120), new AppleTree(center.X + 180, center.Y + 50) }; for (int i = 0; i < 10; i++) { var p = Utilities.GetRandomPoint(); appleTrees.Add(new AppleTree(p.X, p.Y)); } for (int i = 0; i < 10; i++) { var p = Utilities.GetRandomPoint(); yuccaPlants.Add(GeneralPlant.Yucca(p.X, p.Y)); } List <Plant> plants = new List <Plant>() { potato, pineTree1 } .Concat(appleTrees) .Concat(yuccaPlants) .ToList(); // Spawn shrubs in random locations. for (int i = 0; i < 20; i++) { OrderedPair <int> position = Utilities.GetRandomPoint(); plants.Add(GeneralPlant.Shrub(position.X, position.Y)); } Plants = new List <Plant>(); foreach (Plant plant in plants) { AddPlant(plant); } }
private void SpawnRandomPlant() { Plant p; OrderedPair <int> randomPoint = Utilities.GetRandomPoint(); // TODO: Create a range of random values for different plants to generate. Then use the frequency selection method from UtilityDecider class // to pick the plant to spawn. if (Utilities.Rng.Next(0, 2) == 0) { p = GeneralPlant.PineTree(randomPoint.X, randomPoint.Y); } else { p = GeneralPlant.Yucca(randomPoint.X, randomPoint.Y); } AddPlant(p); }
// Add default EntityController controlled objects to the world after WorldController is listening for their creation. public void CreateObjects(OrderedPair <int> center) { Person playerPerson = new Person("Ryan", "Bressette", Sex.Male, center.X - 80, center.Y - 60); Player = new Player(playerPerson); Player.BasePerson.AddItem(new Item(0, 0, ItemType.Rock, 1)); //player.BasePerson.RenderContext.AddAccessory(new Halo(-100, -100)); Person hazel = new Person("Hazel", "Brunelle", Sex.Female, center.X - 100, center.Y - 20, true); OrderedPair <int> position = Utilities.GetRandomPoint(); Animal g = Animal.CreateGoat(position.X, position.Y); position = Utilities.GetRandomPoint(); Animal h = Animal.CreateHog(position.X, position.Y); position = Utilities.GetRandomPoint(); Animal w = Animal.CreateWolf(position.X, position.Y); List <Entity> entities = new List <Entity>() { hazel, g, h, w }; // Spawn random people. for (int i = 0; i < 4; i++) { position = Utilities.GetRandomPointCloseToPoint(HousePosition.X, HousePosition.Y, 100); Sex sex = Utilities.Rng.Next(0, 2) == 0 ? Sex.Male : Sex.Female; Person p = new Person(sex, position.X, position.Y, true); entities.Add(p); } // Add people to the world. EntitiesAdd(Player.BasePerson, false); Player.BasePerson.Age(); foreach (Entity e in entities) { e.Age(); EntitiesAdd(e); } }
public WanderAction() : base(true) { destination = Utilities.GetRandomPoint(); moveAction = new GotoAction(destination.X, destination.Y, entitySize); }
public void SpawnItem(ItemType type) { OrderedPair <int> location = Utilities.GetRandomPoint(); Items.Add(new Item(location.X, location.Y, type, 1)); }