public void buildActorsForOgmo1() { List <Dictionary <string, string> > bgString = FlxXMLReader.readNodesFromOel1File("Lemonade/levels/slf/level" + FlxG.level + ".oel", "level/characters"); foreach (Dictionary <string, string> nodes in bgString) { if (nodes["Name"] == "player") { buildActor("andre", Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"])); } if (nodes["Name"] == "liselot") { buildActor("liselot", Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"])); } if (nodes["Name"] == "worker") { buildActor("worker", Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"])); } if (nodes["Name"] == "army") { buildActor("army", Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"])); } if (nodes["Name"] == "inspector") { buildActor("inspector", Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"])); } if (nodes["Name"] == "chef") { buildActor("chef", Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"])); } } List <Dictionary <string, string> > objects = FlxXMLReader.readNodesFromOel1File("Lemonade/levels/slf/level" + FlxG.level + ".oel", "level/objects"); }
public void buildTilesetForOgmo1() //string LevelFile, string Tiles { //push width / height to flxg.levelheight; Dictionary <string, string> w = FlxXMLReader.readAttributesFromOelFile("Lemonade/levels/slf/level1.oel", "level/width"); FlxG.levelWidth = Convert.ToInt32(w["width"]); Dictionary <string, string> h = FlxXMLReader.readAttributesFromOelFile("Lemonade/levels/slf/level1.oel", "level/height"); FlxG.levelHeight = Convert.ToInt32(h["height"]); Console.WriteLine("FlxG.lw = {0} {1}", FlxG.levelWidth, FlxG.levelHeight); // ------------------------------------------ List <Dictionary <string, string> > bgString = FlxXMLReader.readNodesFromOel1File("Lemonade/levels/slf/level" + FlxG.level + ".oel", "level/solids"); foreach (Dictionary <string, string> nodes in bgString) { FlxTileblock ta = new FlxTileblock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"])); ta.loadTiles(FlxG.Content.Load <Texture2D>("Lemonade/slf1/level1/level1_tiles"), 10, 10, 0); ta.auto = FlxTileblock.AUTO; collidableTileblocks.add(ta); } }
public void buildBoxes() { List <Dictionary <string, string> > levelString = FlxXMLReader.readObjectsFromTmxFile("Lemonade/levels/slf2/" + Lemonade_Globals.location + "/" + Lemonade_Globals.location + "_level" + FlxG.level.ToString() + ".tmx", "map", "boxes", FlxXMLReader.NONE); foreach (Dictionary <string, string> nodes in levelString) { foreach (KeyValuePair <string, string> kvp in nodes) { //Console.Write("Level String -- Key = {0}, Value = {1}, ", kvp.Key, kvp.Value); } //Console.Write("\r\n"); } foreach (var item in levelString) { if (item.ContainsKey("pointsX")) { MovingPlatform movingPlatform = new MovingPlatform(Int32.Parse(item["x"]), Int32.Parse(item["y"])); movingPlatform.solid = true; movingPlatform.@fixed = true; movingPlatforms.add(movingPlatform); FlxPath xpath = new FlxPath(null); //xpath.add(Int32.Parse(item["x"]), Int32.Parse(item["y"])); xpath.addPointsUsingStrings(item["pointsX"], item["pointsY"]); movingPlatform.followPath(xpath, 150, FlxSprite.PATH_YOYO, false); movingPlatform.pathCornering = 0.0f; } } }
public void buildTileset() //string LevelFile, string Tiles { transitionPause = 0.0f; List <Dictionary <string, string> > bgString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/" + Lemonade_Globals.location + "/bg" + Lemonade_Globals.location + ".tmx", "map", "bg", FlxXMLReader.TILES); FlxTilemap bgMap = new FlxTilemap(); bgMap.auto = FlxTilemap.STRING; bgMap.indexOffset = -1; bgMap.loadMap(bgString[0]["csvData"], FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_" + Lemonade_Globals.location), 20, 20); bgMap.boundingBoxOverride = false; bgMap.setScrollFactors(0, 0); add(bgMap); levelAttrs = new Dictionary <string, string>(); levelAttrs = FlxXMLReader.readAttributesFromTmxFile("Lemonade/levels/slf2/" + Lemonade_Globals.location + "/" + Lemonade_Globals.location + "_level" + FlxG.level.ToString() + ".tmx", "map"); foreach (KeyValuePair <string, string> kvp in levelAttrs) { //Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); } FlxG.levelWidth = Convert.ToInt32(levelAttrs["width"]) * Convert.ToInt32(levelAttrs["tilewidth"]); FlxG.levelHeight = Convert.ToInt32(levelAttrs["height"]) * Convert.ToInt32(levelAttrs["tileheight"]); levelString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/" + Lemonade_Globals.location + "/" + Lemonade_Globals.location + "_level" + FlxG.level.ToString() + ".tmx", "map", "bg", FlxXMLReader.TILES); //foreach (Dictionary<string, string> nodes in levelString) //{ // foreach (KeyValuePair<string, string> kvp in nodes) // { // //Console.Write("Key = {0}, Value = {1}, ", kvp.Key, kvp.Value); // } // //Console.Write("\r\n"); //} bgElementsTilemap = new FlxTilemap(); bgElementsTilemap.auto = FlxTilemap.STRING; bgElementsTilemap.indexOffset = -1; bgElementsTilemap.stringTileMin = 200; bgElementsTilemap.stringTileMax = 354; bgElementsTilemap.loadMap(levelString[0]["csvData"], FlxG.Content.Load <Texture2D>("Lemonade/tiles_" + Lemonade_Globals.location), 20, 20); bgElementsTilemap.boundingBoxOverride = false; add(bgElementsTilemap); collidableTilemap = new FlxTilemap(); collidableTilemap.auto = FlxTilemap.STRING; // TMX maps have indexOffset of -1; collidableTilemap.indexOffset = -1; collidableTilemap.stringTileMax = 200; collidableTilemap.loadMap(levelString[0]["csvData"], FlxG.Content.Load <Texture2D>("Lemonade/tiles_" + Lemonade_Globals.location), 20, 20); collidableTilemap.boundingBoxOverride = false; add(collidableTilemap); }
public static int calculateTotalCoins() { string[] locs = { "management", "military", "sydney", "newyork", "warehouse", "factory" }; int coinCount = 0; foreach (var loc in locs) { List <Dictionary <string, string> > actorsString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/" + loc + "/" + loc + "_level1" + ".tmx", "map", "bg", FlxXMLReader.ACTORS); string[] actorsSpl = actorsString[0]["csvData"].Split(','); foreach (string item in actorsSpl) { if (item == "390") { coinCount++; } } } return(coinCount); }
override public void create() { FlxG.backColor = FlxColor.ToColor("dedbc3"); base.create(); _world = new World(new Vector2(0, 98.0f)); charactersGrp = new FlxGroup(); blocksGrp = new FlxGroup(); movingBlocksGrp = new FlxGroup(); doors = new FlxGroup(); crates = new FlxGroup(); //Dictionary<string,string> levelAttrs = FlxXMLReader.readAttributesFromOelFile("ogmo/level1.oel", "level/grid"); //FlxTilemap tiles = new FlxTilemap(); //tiles.useExtraMiddleTiles = false; //tiles.auto = FlxTilemap.AUTO; //tiles.indexOffset = -1; //tiles.loadMap(levelAttrs["grid"], FlxG.Content.Load<Texture2D>("level1_tiles"), 10, 10); //tiles.setScrollFactors(0, 0); //tiles.boundingBoxOverride = true; //blocksGrp.add(tiles); List <Dictionary <string, string> > lblocks = FlxXMLReader.readNodesFromOelFile("ogmo/level1.oel", "level/grid"); foreach (Dictionary <string, string> nodes in lblocks) { FarTileblock t = new FarTileblock(Convert.ToInt32(nodes["x"]) + (Convert.ToInt32(nodes["w"]) / 2), Convert.ToInt32(nodes["y"]) + (Convert.ToInt32(nodes["h"]) / 2), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"]), _world); t.auto = FlxTilemap.AUTO; t.loadTiles("level1_tiles", 10, 10, 0); blocksGrp.add(t); t._body.BodyType = BodyType.Static; FlxTileblock t2 = new FlxTileblock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"])); t2.auto = FlxTilemap.AUTO; t2.loadTiles("level1_tiles", 10, 10, 0); blocksGrp.add(t2); } List <Dictionary <string, string> > blocks = FlxXMLReader.readNodesFromOelFile("ogmo/level1.oel", "level/tileblocks"); foreach (Dictionary <string, string> nodes in blocks) { if (nodes["Name"] == "elevator") { MovingBlock block = new MovingBlock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"])); block.loadGraphic("level1_specialBlock", false, true, 40, 20); movingBlocksGrp.add(block); FlxPath xpath = new FlxPath(null); xpath.add(Convert.ToInt32(nodes["x"]) + 20, Convert.ToInt32(nodes["y"]) + 10); xpath.addPointsUsingStrings(nodes["pathNodesX"], nodes["pathNodesY"], 20, 10); block.followPath(xpath, 80, FlxObject.PATH_FORWARD, false); } if (nodes["Name"] == "door") { Door door = new Door(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]) - 100); doors.add(door); } //foreach (var item in nodes) //{ // Console.WriteLine("{0} {1}", item.Key, item.Value); //} } //bat = new Bat(x, y); //actors.add(bat); //Console.WriteLine("Building a bat {0} {1} {2} {3}", x, y, PathNodesX, PathNodesY); //if (PathNodesX != "" && PathNodesY != "") //{ // Console.WriteLine("Building a path {0} {1} {2}", PathNodesX, PathNodesY, PathCornering); // FlxPath xpath = new FlxPath(null); // xpath.add(x, y); // xpath.addPointsUsingStrings(PathNodesX, PathNodesY); // bat.followPath(xpath, PathSpeed, PathType, false); // bat.pathCornering = PathCornering; //} Andre andre = new Andre(0, 0); charactersGrp.add(andre); Liselot liselot = new Liselot(40, 40); charactersGrp.add(liselot); Army army = new Army(30, 20); charactersGrp.add(army); Inspector inspector = new Inspector(50, 50); charactersGrp.add(inspector); Worker worker = new Worker(60, 60); charactersGrp.add(worker); Chef chef = new Chef(100, 30); charactersGrp.add(chef); FlxTileblock bg = new FlxTileblock(0, 0, 240, 800); bg.auto = FlxTileblock.RANDOM; bg.loadTiles("level1_shelfTile", 80, 80, 0); add(bg); bg = new FlxTileblock(640, 0, 240, 800); bg.auto = FlxTileblock.RANDOM; bg.loadTiles("level1_shelfTile", 80, 80, 0); add(bg); for (int i = 0; i < 5; i++) { SmallCrate c = new SmallCrate((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100)); crates.add(c); } for (int i = 0; i < 5; i++) { Bottle b = new Bottle((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100)); crates.add(b); } for (int i = 0; i < 55; i++) { Fruit f = new Fruit((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100), _world); f._body.ApplyLinearImpulse(new Vector2(20, 2120)); crates.add(f); } add(doors); add(charactersGrp); add(blocksGrp); add(movingBlocksGrp); add(crates); FlxG.showHud(); FlxG.setHudTextPosition(1, FlxG.width / 2, 10); FlxG.setHudTextScale(1, 3); }
public void buildActors() { actorsString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/" + Lemonade_Globals.location + "/" + Lemonade_Globals.location + "_level" + FlxG.level.ToString() + ".tmx", "map", "bg", FlxXMLReader.ACTORS); foreach (Dictionary <string, string> nodes in actorsString) { foreach (KeyValuePair <string, string> kvp in nodes) { //Console.Write("Actors Key = {0}, Value = {1}, ", kvp.Key, kvp.Value); } //Console.Write("\r\n"); } //string actorsStr = actorsString[0]["csvData"].Replace(",\n", ","); string[] actorsSpl = actorsString[0]["csvData"].Split(','); int count = 0; foreach (string item in actorsSpl) { int xPos = ((count) % ((Convert.ToInt32(levelAttrs["width"])))); int yPos = ((count) / ((Convert.ToInt32(levelAttrs["width"])))); xPos *= Convert.ToInt32(levelAttrs["tilewidth"]); yPos *= Convert.ToInt32(levelAttrs["tilewidth"]); if (item == "357") { buildActor("largeCrate", xPos, yPos); } if (item == "381") { buildActor("andre", xPos, yPos); } if (item == "382") { buildActor("liselot", xPos, yPos); } if (item == "383") { buildActor("army", xPos, yPos); } if (item == "384") { buildActor("worker", xPos, yPos); } if (item == "385") { buildActor("inspector", xPos, yPos); } if (item == "386") { buildActor("chef", xPos, yPos); } if (item == "387") { buildActor("exit", xPos, yPos); } if (item == "388") { buildActor("trampoline", xPos, yPos); } if (item == "389") { buildActor("smallCrate", xPos, yPos); } if (item == "390") { buildActor("coin", xPos, yPos); } if (item == "391") { buildActor("spike_up", xPos, yPos + 10); } if (item == "392") { buildActor("spike_right", xPos, yPos); } if (item == "393") { buildActor("spike_down", xPos, yPos); } if (item == "394") { buildActor("spike_left", xPos + 10, yPos); } if (item == "341") { buildActor("rampLeft", xPos, yPos); } if (item == "342") { buildActor("rampRight", xPos, yPos); } if (item == "363") { buildActor("plant1", xPos, yPos); } if (item == "364") { buildActor("plant2", xPos, yPos); } if (item == "365") { buildActor("filing1", xPos, yPos); } if (item == "366") { buildActor("filing1", xPos, yPos); } count++; } }
public void loadOgmo() { Console.WriteLine("Ogmo Loading level {0}", Globals.hole); Dictionary <string, string> ogmo = FlxXMLReader.readAttributesFromOelFile("putt/ogmo/hole" + Globals.hole.ToString() + ".oel", "level/roll"); rollTiles = new FlxTilemap(); rollTiles.loadMap(ogmo["roll"], FlxG.Content.Load <Texture2D>("putt/rollIndicators"), 8, 8); rollTiles.color = new Color(1, 1, 1, 0.8f); //add(rollTiles); // ------------------------------------ string[] cols; string[] rows = ogmo["roll"].Split('\n'); int heightInTiles = rows.Length; int r = 0; //int c; foreach (var item in rows) { int l = 0; cols = rows[r].Split(','); foreach (var x in cols) { if (x != "-1" && x != "-1\r") { //Console.WriteLine("Roll: {0}", x); RollIndicator roll = new RollIndicator(l * 8, r * 8, Convert.ToInt32(x)); add(roll); } l++; } r++; } List <Dictionary <string, string> > levelNodes = FlxXMLReader.readNodesFromOelFile("putt/ogmo/hole" + Globals.hole.ToString() + ".oel", "level/bg"); foreach (Dictionary <string, string> nodes in levelNodes) { //foreach (KeyValuePair<string, string> kvp in nodes) //{ // Console.Write("Key = {0}, Value = {1}, ", // kvp.Key, kvp.Value); //} //Console.Write("\r\n"); if (nodes["Name"] == "hole") { hole.reset(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"])); } } }
override public void create() { base.create(); // play some music FlxG.playMp3("Lemonade/music/music_menu_1", 0.75f); // load some tile maps List <Dictionary <string, string> > bgString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/newyork/bgnewyork.tmx", "map", "bg", FlxXMLReader.TILES); ny = new FlxTilemap(); ny.auto = FlxTilemap.STRING; ny.indexOffset = -1; ny.loadMap(bgString[0]["csvData"], FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20); ny.boundingBoxOverride = true; ny.setScrollFactors(0, 0); ny.visible = false; add(ny); bgString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/sydney/bgsydney.tmx", "map", "bg", FlxXMLReader.TILES); sydney = new FlxTilemap(); sydney.auto = FlxTilemap.STRING; sydney.indexOffset = -1; sydney.loadMap(bgString[0]["csvData"], FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_sydney"), 20, 20); sydney.boundingBoxOverride = true; sydney.setScrollFactors(0, 0); sydney.visible = false; add(sydney); bgString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/military/bgmilitary.tmx", "map", "bg", FlxXMLReader.TILES); miltary = new FlxTilemap(); miltary.auto = FlxTilemap.STRING; miltary.indexOffset = -1; miltary.loadMap(bgString[0]["csvData"], FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_military"), 20, 20); miltary.boundingBoxOverride = true; miltary.setScrollFactors(0, 0); miltary.visible = false; add(miltary); //FlxG.mouse.show(FlxG.Content.Load<Texture2D>("Mode/cursor")); FlxButton b = new FlxButton((FlxG.width / 2) - 100, 150, startGame); b.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); b.loadText(new FlxText(-20, 10, 100, "Sydney"), new FlxText(-20, 10, 100, "Sydney!")); buttons.add(b); b = new FlxButton(FlxG.width / 2, 150, startGame); b.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); b.loadText(new FlxText(-20, 10, 100, "New York"), new FlxText(-20, 10, 100, "New York!")); buttons.add(b); b = new FlxButton((FlxG.width / 2) + 100, 150, startGame); b.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); b.loadText(new FlxText(-20, 10, 100, "Military"), new FlxText(-20, 10, 100, "Military!")); buttons.add(b); for (int i = 1; i < 13; i++) { FlxButton a = new FlxButton(175 + (i * 45), 225, startGame); a.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); a.loadText(new FlxText(-40, 10, 100, i.ToString()), new FlxText(-40, 10, 100, i.ToString() + "!")); buttons.add(a); } b = new FlxButton((FlxG.width / 2) - 100, 275, startMultiplayerGame); b.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); b.loadText(new FlxText(-20, 10, 100, "Multiplayer"), new FlxText(-20, 10, 100, "Multiplayer!")); buttons.add(b); location = new FlxText(0, 50, FlxG.width); location.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 3, Color.White, FlxJustification.Center, Color.Black); location.text = ""; add(location); addButtons(); FlxText badges = new FlxText(0, 330, 0, "Badges"); badges.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 3, Color.White, FlxJustification.Left, Color.Black); add(badges); Color notDone = new Color(0.1f, 0.1f, 0.1f); badge1 = new FlxSprite((FlxG.width / 2) - 150, 330); badge1.loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/offscreenIcons"), true, false, 12, 12); badge1.frame = 2; badge1.color = notDone; add(badge1); badge2 = new FlxSprite((FlxG.width / 2) - 50, 330); badge2.loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/offscreenIcons"), true, false, 12, 12); badge2.frame = 3; badge2.color = notDone; add(badge2); badge3 = new FlxSprite((FlxG.width / 2) + 50, 330); badge3.loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/offscreenIcons"), true, false, 12, 12); badge3.frame = 4; badge3.color = notDone; add(badge3); badge4 = new FlxSprite((FlxG.width / 2) + 150, 330); badge4.loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/offscreenIcons"), true, false, 12, 12); badge4.frame = 5; badge4.color = notDone; add(badge4); tweenBounce = new Tweener(5.0f, 8.0f, TimeSpan.FromSeconds(1.12f), Elastic.EaseOut); tweenBounce.PingPong = true; try { FlxG.username = LoadFromDevice(); } catch { Console.WriteLine("Cannot load name from file"); } if (FlxG.username != "") { //_nameEntry.text = FlxG.username; FlxG.setHudText(3, "Username:\n" + FlxG.username); FlxG.setHudTextPosition(3, 50, FlxG.height - 30); FlxG.setHudTextScale(3, 2); } }