void LavaFlow(Lava lava) { if (lava.Flowing) { int size = spriteSize.X; Vector2 lavaUp = new Vector2((int)lava.GetPosition.X - size, (int)lava.GetPosition.Y); Vector2 lavaDown = new Vector2((int)lava.GetPosition.X + size, (int)lava.GetPosition.Y); Vector2 lavaLeft = new Vector2((int)lava.GetPosition.X, (int)lava.GetPosition.Y - size); Vector2 lavaRight = new Vector2((int)lava.GetPosition.X, (int)lava.GetPosition.Y + size); if (CheckCollisions(lavaUp, true) && CheckCollisions(lavaDown, true) && CheckCollisions(lavaLeft, true) && CheckCollisions(lavaRight, true)) { lava.Flowing = false; } else { if (!CheckCollisions(lavaUp, true)) { Lava newLava = new Lava(lavaTexture, lavaUp, spriteSize, 0, Vector2.Zero, 0, 15000); newLava.LavaFlowEvent += new Lava.Flow(this.LavaFlow); levelObjects.Add(newLava); } if (!CheckCollisions(lavaDown, true)) { Lava newLava = new Lava(lavaTexture, lavaDown, spriteSize, 0, Vector2.Zero, 0, 15000); newLava.LavaFlowEvent += new Lava.Flow(this.LavaFlow); levelObjects.Add(newLava); } if (!CheckCollisions(lavaLeft, true)) { Lava newLava = new Lava(lavaTexture, lavaLeft, spriteSize, 0, Vector2.Zero, 0, 15000); newLava.LavaFlowEvent += new Lava.Flow(this.LavaFlow); levelObjects.Add(newLava); } if (!CheckCollisions(lavaRight, true)) { Lava newLava = new Lava(lavaTexture, lavaRight, spriteSize, 0, Vector2.Zero, 0,15000); newLava.LavaFlowEvent += new Lava.Flow(this.LavaFlow); levelObjects.Add(newLava); } } } }
private void ExtractMap() { //---------------------------read through the list<string> and create objects---------------// int mapX = 0; int mapY = 0; Vector2 position; /* This is used to grab the data out of the level map and * to filter in into objects / lists for easier updating later on */ #region for loop for (int y = 0; y < levelMap.Count(); y++) { for (int x = 0; x < levelMap[y].Length; x++) { mapX = x * spriteSize.X; mapY = y * spriteSize.Y; position.X = mapX; position.Y = mapY; //position = new Vector2(x, y); //---------------------------FLOORS-------------------------------------------------- levelObjects.Add(new Floor(floorTexture, position, spriteSize, 0, Vector2.Zero, 0, 0, white)); levelLocations[y, x].Add(new Floor(floorTexture, position, spriteSize, 0, Vector2.Zero, 0, 0, white)); //-----------------------REGUALR WALLS----------------------------------------------------------// if (levelMap[y][x] == '#') //gray levelLocations[y, x].Add(new Wall(wallTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, false, true, white)); if (levelMap[y][x] == '4') //gray { wallsToTrigger['4'].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, gray)); levelLocations[y, x].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, gray)); } if (levelMap[y][x] == '5') //brown { wallsToTrigger['5'].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, gray)); levelLocations[y, x].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, gray)); } if (levelMap[y][x] == '6') //brown { wallsToTrigger['6'].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, gray)); levelLocations[y, x].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, gray)); } //---------------------INVISIBLE WALLS--------------------------------------// if(levelMap[y][x] == ':') //invisible levelLocations[y, x].Add(new Wall(wallTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, false, false, white)); if (levelMap[y][x] == ';') levelLocations[y, x].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, false, white)); //---------------------BREAKABLE WALLS--------------------------------------------------// if(levelMap[y][x] == 'X') levelLocations[y, x].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, white)); if (levelMap[y][x] == 'Y') { levelLocations[y, x].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, gray)); wallsToTrigger['y'].Add(new Wall(breakableTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, gray)); } if (levelMap[y][x] == '/') levelLocations[y, x].Add(new Wall(treeWallTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, true, true, Color.White)); //---------------------WATER-------------------------------------------------------------// if(levelMap[y][x] == 'R') levelLocations[y, x].Add(new Wall(waterTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, false, true, white)); //----------------------LAVA-------------------------------------------------------------------- if (levelMap[y][x] == 'V') { Lava lava = new Lava(lavaTexture, position, spriteSize, 0, Vector2.Zero, 0, 15000); lava.LavaFlowEvent += new Lava.Flow(this.LavaFlow); levelLocations[y, x].Add(lava); } //----------------------BOTTOMLESS PIT--------------------------------------------------------- if (levelMap[y][x] == '=') { BottomlessPit pit = new BottomlessPit(pitTexture, position, spriteSize, 0, Vector2.Zero, 0, 0); pit.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(pit); } //-----------------------GEMS---------------------------------------------------------------// if (levelMap[y][x] == '+') levelLocations[y, x].Add(new Gem(gemTexture, position, spriteSize, 0, Vector2.Zero, 5, 0)); //-----------set the player position-------------------------------------// if (levelMap[y][x] == 'P') player.SetPosition = new Vector2(x, y); //player.SetPosition = position; //-----------ITEM POS--------------------------------------- if (levelMap[y][x] == '*') levelLocations[y, x].Add(new Gold(goldTexture, position, spriteSize, 0, Vector2.Zero, 50, 0)); if (levelMap[y][x] == 'W') levelLocations[y, x].Add(new Whip(whipTexture, position, spriteSize, 0, Vector2.Zero, 5, 0)); if (levelMap[y][x] == 'C') levelLocations[y, x].Add(new Chest(chestTexture, position, spriteSize, 0, Vector2.Zero, 0, 0)); if(levelMap[y][x] == 'K') levelLocations[y, x].Add(new Key(keyTexture, position, spriteSize, 0, Vector2.Zero, 0, 0)); if (levelMap[y][x] == 'T') levelLocations[y, x].Add(new TeleportScroll(teleportTexture, position, spriteSize, 0, Vector2.Zero, 0, 0)); if (levelMap[y][x] == 'D') levelLocations[y, x].Add(new Door(doorTexture, position, spriteSize, 0, Vector2.Zero, 0, 0, true)); if (levelMap[y][x] == '^') //invisible door levelLocations[y, x].Add(new Door(doorTexture, position, spriteSize, 0, Vector2.Zero, 0, 0, false)); if (levelMap[y][x] == 'I') levelLocations[y, x].Add(new PlayerInvisible(invisTexture, position, spriteSize, 0, Vector2.Zero, 0, 0)); if (levelMap[y][x] == 'Q') { WhipPowerRing ring = new WhipPowerRing(powerRingTexture, position, spriteSize, 0, Vector2.Zero, 0, 0); ring.OnCollisionEvent += new Sprite.CollisionEvent(playerWhip.EventHandler); levelLocations[y, x].Add(ring); } if(levelMap[y][x] == 'S') { SlowMobs slow = new SlowMobs(slowMobTexture, position, spriteSize, 0, Vector2.Zero, 0, 0); slow.OnCollisionEvent += new Sprite.CollisionEvent(BaseMob.EventHandler); levelLocations[y, x].Add(slow); } if (levelMap[y][x] == '?') levelLocations[y, x].Add(new SackOfGems(sackTexture, position, spriteSize, 0, Vector2.Zero, 0, 0)); if (levelMap[y][x] == 'B') { Bomb bomb = new Bomb(bombTexture, position, spriteSize, 0, Vector2.Zero, 500, 0); bomb.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(bomb); } if (levelMap[y][x] == ']') { AddMobs more = new AddMobs(sackTexture, position, spriteSize, 0, Vector2.Zero, 0, 0); more.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(more); } if (levelMap[y][x] == '%') { RemoveMobs less = new RemoveMobs(removeMobTexture, position, spriteSize, 0, Vector2.Zero, 0, 0); less.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(less); } if(levelMap[y][x] == 'G') { MobGenerator generator = new MobGenerator(mobGeneratortexture, position, spriteSize, 0, Vector2.Zero, 0, 5000); generator.GenerateMobEvent += new MobGenerator.Generate(this.GenerateMobEventHandler); levelLocations[y, x].Add(generator); } if (levelMap[y][x] == '>') { Statue statue = new Statue(playerTexture, position, spriteSize, 0, Vector2.Zero, 500, 1000); statue.CheckPlayerDistanceEvent += new Statue.StatueEvent(this.EventHandler); levelLocations[y, x].Add(statue); } if (levelMap[y][x] == 'U') { Teleporter teleporter = new Teleporter(teleporterTexture, position, spriteSize, 0, Vector2.Zero, 0, 0,Color.White); teleporter.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(teleporter); } //----------------KROZ letters---------------------------------------------------------------------- if (levelMap[y][x] == '<') levelLocations[y, x].Add(new KrozLetter(kTexture, position, spriteSize, 0, Vector2.Zero, 0, 0, 'k')); if (levelMap[y][x] == '[') levelLocations[y, x].Add(new KrozLetter(rTexture, position, spriteSize, 0, Vector2.Zero, 0, 0, 'r')); if (levelMap[y][x] == '|') levelLocations[y, x].Add(new KrozLetter(oTexture, position, spriteSize, 0, Vector2.Zero, 0, 0, 'o')); if (levelMap[y][x] == '"') levelLocations[y, x].Add(new KrozLetter(zTexture, position, spriteSize, 0, Vector2.Zero, 0, 0, 'z')); //----------------FREEZE MOBS-------------------------------------------------------------------------------// if (levelMap[y][x] == 'Z') { FreezeMobs freeze = new FreezeMobs(freezeTexture, position, spriteSize, 0, Vector2.Zero, 0, 0); freeze.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(freeze); } //--------------------STAIRS------------------------------------------------------------------------ if (levelMap[y][x] == 'L') { Stairs exit = new Stairs(stairsTexture, position, spriteSize); exit.OnStairs += new Stairs.FiredEvent(this.NewLevel); levelLocations[y, x].Add(exit); } //---------------ANCIENT TABLET------------------------------------------------------------------------// if (levelMap[y][x] == '!') levelLocations[y, x].Add(new AncientTablet(ancientTabletTexture, position, spriteSize, 0, Vector2.Zero, 1000, 0, this.level)); //--------------TRIGGERS------------------------------------------------------------------------- if (levelMap[y][x] == '.') { TeleportTrap trap = new TeleportTrap(teleportTrapTexture, position, spriteSize, 0, Vector2.Zero, 0, 0); trap.SetEmptySpaces = FindEmptySpaces(false); levelLocations[y, x].Add(trap); } if (levelMap[y][x] == 'H') { AddRandomGemsTrigger trigger = new AddRandomGemsTrigger(transparentTexture, position, spriteSize); trigger.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(trigger); } if (levelMap[y][x] == 'A') { ActivateMobileWallTrigger wallTrigger = new ActivateMobileWallTrigger(transparentTexture, position, spriteSize); wallTrigger.OnCollisionEvent += new ActivateMobileWallTrigger.ActivateWalls(MobileWall.ActivateEventHandler); levelLocations[y, x].Add(wallTrigger); } if(levelMap[y][x] == 'E') { Earthquake quake = new Earthquake(transparentTexture, position, spriteSize); quake.StartEarthquake += new Earthquake.QuakeEvent(this.EventHandler); levelLocations[y, x].Add(quake); } if(levelMap[y][x] == 'N') { HideWalls hide = new HideWalls(transparentTexture, position, spriteSize); hide.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(hide); } //---------------HIDDEN WALL 9 TRIGGER----------------------------------------// if (levelMap[y][x] == '$') { AddWallsTrigger trigger = new AddWallsTrigger(transparentTexture, position, spriteSize, '9'); trigger.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(trigger); } if (levelMap[y][x] == '9') wallsToTrigger['9'].Add(new Wall(wallTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, false, true, white)); //---------------HIDDEN WALL '8' TRIGGER -------------------------------------// if (levelMap[y][x] == ',') { AddWallsTrigger trigger = new AddWallsTrigger(transparentTexture, position, spriteSize, '8'); trigger.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(trigger); } if (levelMap[y][x] == '8') wallsToTrigger['8'].Add(new Wall(wallTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, false, true, white)); //-------------HIDDEN WALL '7' TRIGGER ----------------------------------------------------------// if (levelMap[y][x] == '`') { AddWallsTrigger trigger = new AddWallsTrigger(transparentTexture, position, spriteSize, '7'); trigger.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(trigger); } if (levelMap[y][x] == '7') wallsToTrigger['7'].Add(new Wall(wallTexture, position, spriteSize, 2, Vector2.Zero, 0, 0, false, true, white)); //--------------REMOVE WALLS TRIGGERs------------------------------------- if (levelMap[y][x] == '~') { RemoveWallsTrigger trigger = new RemoveWallsTrigger(transparentTexture, position, spriteSize, 'y'); trigger.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(trigger); } if (levelMap[y][x] == '@') { RemoveWallsTrigger trigger = new RemoveWallsTrigger(transparentTexture, position, spriteSize, '6'); trigger.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(trigger); } if (levelMap[y][x] == ')') { RemoveWallsTrigger trigger = new RemoveWallsTrigger(transparentTexture, position, spriteSize, '5'); trigger.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(trigger); } if (levelMap[y][x] == '(') { RemoveWallsTrigger trigger = new RemoveWallsTrigger(transparentTexture, position, spriteSize, '4'); trigger.OnCollisionEvent += new Sprite.CollisionEvent(this.EventHandler); levelLocations[y, x].Add(trigger); } //----------------------MOBS--------------------------------------------// if (levelMap[y][x] == 'a')//a levelLocations[y, x].Add(new Gnome(gnomeTexture, position = new Vector2(x, y), spriteSize, 0, new Vector2(1, 1), 5, 1000)); if (levelMap[y][x] == 'b') //b levelLocations[y, x].Add(new ElfMummy(elfMummyTexture, position = new Vector2(x, y), spriteSize, 0, new Vector2(1, 1), 10, 750)); if (levelMap[y][x] == 'c') //c levelLocations[y, x].Add(new OgreLord(ogreLordTexture, position = new Vector2(x, y), spriteSize, 0, new Vector2(1, 1), 15, 500)); if (levelMap[y][x] == 'd') //d levelLocations[y, x].Add(new UmberHulk(umberHulkTexture, position = new Vector2(x, y), spriteSize, 0, new Vector2(1, 1), 20, 250)); //bubble monster can be e if (levelMap[y][x] == 'M') levelLocations[y, x].Add(new MobileWall(breakableTexture, position = new Vector2(x, y), spriteSize, 0, new Vector2(1, 1), 10, 1500)); }//end inner for loop }//end the for loops that look through the entire map and create the contents #endregion }//END EXTRACT MAP