private void CreateFauna() { int numFauna = 100; for (int i = 0; i < numFauna; i++) { int tileIndex = 0; Npc fauna = new Npc(Color.Blue, Color.Transparent, "a helpless Cherub"); while (CurrentMap.Tiles[tileIndex].IsImpassible) { tileIndex = GameLoop.rndNum.Next(0, CurrentMap.Width * CurrentMap.Height); } fauna.Position = new Point(tileIndex % CurrentMap.Width, tileIndex / CurrentMap.Width); CurrentMap.Add(fauna); CurrentMap.Actors.Add(fauna); } }
private void CreateFlora() { int numFlora = 100; for (int i = 0; i < numFlora; i++) { int tileIndex = 0; BodyPart mushroom = new BodyPart(Color.GreenYellow, Color.Transparent, "mushroom", (Spritesheet.Anatomy)Spritesheet.Flora.Spindly); //Temporary, while mushrooms are BPs while (CurrentMap.Tiles[tileIndex].IsImpassible) { tileIndex = GameLoop.rndNum.Next(0, CurrentMap.Width * CurrentMap.Height); } mushroom.Name = "a mushroom"; mushroom.Position = new Point(tileIndex % CurrentMap.Width, tileIndex / CurrentMap.Width); CurrentMap.Add(mushroom); } }
/// <summary> /// Get the Field definitions from the grid /// </summary> public DataTableMapMsx GetColumnMapList() { DataTableMapMsx map = new DataTableMapMsx(); map.ParentMapList = SVP.DataTableMaps; DataTableMaps.CurrentMap = map; foreach (DataRow dr in FieldDataTable.Rows) { ColumnMapMsx fli = dr["ColumnMapMsxRefField"] as ColumnMapMsx; if (fli == null) continue; QueryColumn qc = fli.QueryColumn; if (qc == null) continue; fli.QueryColumn = qc; fli.SpotfireColumnName = dr["SpotfireColNameField"] as string; fli.Selected = (bool)dr["SelectedField"]; // not currently used CurrentMap.Add(fli); } return CurrentMap; }
// Create some random monsters // and drop them all over the map in // random places. private void CreateMonsters() { // number of monsters to create int numMonsters = 10; // random position generator Random rndNum = new Random(); // Create several monsters with random attack and defense values and // pick a random position on the map to place them. // check if the placement spot is blocking (e.g. a wall) // and if it is, try a new position for (int i = 0; i < numMonsters; i++) { int monsterPosition = 0; Monster newMonster = new Monster(Color.Blue, Color.Transparent); newMonster.Components.Add(new EntityViewSyncComponent()); while (CurrentMap.Tiles[monsterPosition].IsBlockingMove) { // pick a random spot on the map monsterPosition = rndNum.Next(0, CurrentMap.Width * CurrentMap.Height); } // plug in some magic numbers for attack and defense values newMonster.Defense = rndNum.Next(0, 10); newMonster.DefenseChance = rndNum.Next(0, 50); newMonster.Attack = rndNum.Next(0, 10); newMonster.AttackChance = rndNum.Next(0, 50); newMonster.Name = "Goblin"; // Set the monster's new position // Note: this fancy math will be replaced by a new helper method // in the next revision of SadConsole newMonster.Position = new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width); CurrentMap.Add(newMonster); } }
// Create a player using the Player class // and set its starting position private void CreatePlayer() { // Place the player on the first non-movement-blocking tile on the map for (int i = 0; i < CurrentMap.Tiles.Length; i++) { if (!CurrentMap.Tiles[i].IsBlockingMove) { // Set the player's position to the index of the current map position var pos = Point.FromIndex(i, CurrentMap.Width); Player = new Player(Color.White, Color.Black, pos) { Position = pos, Description = "Here is you, you are beautiful" }; //Player.AddComponent(new Components.HealthComponent(10, 10, 0.1f)); break; } } // add the player to the Map's collection of Entities CurrentMap.Add(Player); }
private void CreateLoot() { // number of treasure drops to create int numLoot = 20; // Produce loot up to a max of numLoot for (int i = 0; i < numLoot; i++) { // Create an Item with some standard attributes int lootPosition = 0; // Try placing the Item at lootPosition; if this fails, try random positions on the map's tile array while (CurrentMap.Tiles[lootPosition].IsBlockingMove) { // pick a random spot on the map lootPosition = rndNum.Next(0, CurrentMap.Width * CurrentMap.Height); } // set the loot's new position Point posNew = new Point(lootPosition % CurrentMap.Width, lootPosition / CurrentMap.Height); Item newLoot = EntityFactory.ItemCreator(posNew, new ItemTemplate("Gold Bar", Color.Gold, Color.White, '=', 12.5f, 15, "Here is a gold bar, pretty heavy")); // add the Item to the MultiSpatialMap CurrentMap.Add(newLoot); } IList <ItemTemplate> itemTest = Utils.JsonUtils.JsonDeseralize <List <ItemTemplate> >(Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Entities", "Items", "Bars.json")); Item test = EntityFactory.ItemCreator(new Point(10, 10), itemTest.FirstOrDefault(i => i.Id == "test")); CurrentMap.Add(test); }
public override bool Walk(MirDirection dir) { if (!CanMove) { return(false); } Point location = Functions.PointMove(CurrentLocation, dir, 1); if (!CurrentMap.ValidPoint(location)) { return(false); } //Cell cell = CurrentMap.GetCell(location); if (CurrentMap.Objects[location.X, location.Y] != null) { for (int i = 0; i < CurrentMap.Objects[location.X, location.Y].Count; i++) { MapObject ob = CurrentMap.Objects[location.X, location.Y][i]; if (AvoidFireWall && ob.Race == ObjectType.Spell) { if (((SpellObject)ob).Spell == Spell.FireWall) { return(false); } } if (!ob.Blocking) { continue; } return(false); } } CurrentMap.Remove(CurrentLocation.X, CurrentLocation.Y, this); Direction = dir; RemoveObjects(dir, 1); CurrentLocation = location; CurrentMap.Add(CurrentLocation.X, CurrentLocation.Y, this); AddObjects(dir, 1); if (Hidden) { Hidden = false; for (int i = 0; i < Buffs.Count; i++) { if (Buffs[i].Type != BuffType.Hiding) { continue; } Buffs[i].ExpireTime = 0; break; } } CellTime = Envir.Time + 500; ActionTime = Envir.Time + 300; MoveTime = Envir.Time + MoveSpeed; InSafeZone = CurrentMap.GetSafeZone(CurrentLocation) != null; Broadcast(new S.ObjectWalk { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); //cell = CurrentMap.GetCell(CurrentLocation); for (int i = 0; i < CurrentMap.Objects[CurrentLocation.X, CurrentLocation.Y].Count; i++) { if (CurrentMap.Objects[CurrentLocation.X, CurrentLocation.Y][i].Race != ObjectType.Spell) { continue; } SpellObject ob = (SpellObject)CurrentMap.Objects[CurrentLocation.X, CurrentLocation.Y][i]; ob.ProcessSpell(this); //break; } return(true); }
// See above comment. private static void AddTestDummy(Coord position) { CurrentMap.Add(new TestDummy(position)); }
// See comment on above function. private static void AddPlayer(Coord position) { Player = new Player(position); CurrentMap.Add(Player); }
private void CreateMonsters() { List <Point> TakenLocation = new List <Point>(); int impNum = 35; Random rndNum = new Random(); for (int i = 0; i < impNum; i++) { int monsterPosition = 0; Monster newMonster = new Monster("An Imp", 2, 4, 25, 3, 50, 25, 12, 20, 9); newMonster.Components.Add(new EntityViewSyncComponent()); while (CurrentMap.Tiles[monsterPosition].IsBlockingMove && !(TakenLocation.Contains(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)))) { monsterPosition = rndNum.Next(0, CurrentMap.Width * CurrentMap.Height); } newMonster.Position = new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width); TakenLocation.Add(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)); CurrentMap.Add(newMonster); } int mancubusNum = 10; Random rndNum2 = new Random(); for (int i = 0; i < mancubusNum; i++) { int monsterPosition = 0; Monster newMonster = new Monster("A Mancubus", 3, 9, 30, 5, 40, 30, 25, 20, 7); newMonster.Components.Add(new EntityViewSyncComponent()); while (CurrentMap.Tiles[monsterPosition].IsBlockingMove && !(TakenLocation.Contains(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)))) { monsterPosition = rndNum2.Next(0, CurrentMap.Width * CurrentMap.Height); } newMonster.Position = new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width); TakenLocation.Add(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)); CurrentMap.Add(newMonster); } int cacodemonNum = 10; Random rndNum3 = new Random(); for (int i = 0; i < cacodemonNum; i++) { int monsterPosition = 0; Monster newMonster = new Monster("A Cacodemon", 4, 7, 50, 4, 30, 20, 10, 40, 12); newMonster.Components.Add(new EntityViewSyncComponent()); while (CurrentMap.Tiles[monsterPosition].IsBlockingMove && !(TakenLocation.Contains(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)))) { monsterPosition = rndNum3.Next(0, CurrentMap.Width * CurrentMap.Height); } newMonster.Position = new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width); TakenLocation.Add(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)); CurrentMap.Add(newMonster); } int pinkyNum = 10; Random rndNum4 = new Random(); for (int i = 0; i < pinkyNum; i++) { int monsterPosition = 0; Monster newMonster = new Monster("A Pinky", 5, 3, 60, 20, 4, 20, 15, 80, 15); newMonster.Components.Add(new EntityViewSyncComponent()); while (CurrentMap.Tiles[monsterPosition].IsBlockingMove && !(TakenLocation.Contains(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)))) { monsterPosition = rndNum4.Next(0, CurrentMap.Width * CurrentMap.Height); } newMonster.Position = new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width); TakenLocation.Add(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)); CurrentMap.Add(newMonster); } int baronNum = 5; Random rndNum5 = new Random(); for (int i = 0; i < baronNum; i++) { int monsterPosition = 0; Monster newMonster = new Monster("A Baron of Hell", 6, 8, 65, 10, 35, 0, 25, 20, 11); newMonster.Components.Add(new EntityViewSyncComponent()); while (CurrentMap.Tiles[monsterPosition].IsBlockingMove && !(TakenLocation.Contains(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)))) { monsterPosition = rndNum5.Next(0, CurrentMap.Width * CurrentMap.Height); } newMonster.Position = new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width); TakenLocation.Add(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)); CurrentMap.Add(newMonster); } int marauderNum = 2; Random rndNum6 = new Random(); for (int i = 0; i < marauderNum; i++) { int monsterPosition = 0; Monster newMonster = new Monster("The Marauder", 7, 13, 50, 5, 50, 0, 45, 30, 11); newMonster.Components.Add(new EntityViewSyncComponent()); while (CurrentMap.Tiles[monsterPosition].IsBlockingMove && !(TakenLocation.Contains(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)))) { monsterPosition = rndNum6.Next(0, CurrentMap.Width * CurrentMap.Height); } newMonster.Position = new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width); TakenLocation.Add(new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width)); CurrentMap.Add(newMonster); } }