public void createCutScene() { if (!Constants.DO_CUT_SCENE || game.currentLevel > 1) { loadLevelInfo(); return; } //#if WINDOWS Stream stream = TitleContainer.OpenStream("Content\\CutScene" + cutSceneNumber + "\\info.txt"); System.IO.StreamReader sReader = new System.IO.StreamReader(stream); String textInfo = sReader.ReadToEnd(); StringReader sr = new StringReader(textInfo); String line; char[] delimiterChars = { ' ', ',', ':', '\t' }; while ((line = sr.ReadLine()) != null) { string[] words = line.Split(delimiterChars); float x = System.Convert.ToSingle(words[1]); float y = System.Convert.ToSingle(words[2]); if (words[0].Equals("Normal")) { String spriteName = words[3]; CutSceneItem csi = new CutSceneItem(game, game.Arena, x, y, 1, spriteName, System.Convert.ToSingle(words[4]), System.Convert.ToSingle(words[5])); game.addEntity(csi); } if (words[0].Equals("AButt")) { String spriteName = words[3]; bool butt=Boolean.Parse(words[5]); CutSceneItem csi = new CutSceneItem(game, game.Arena, x, y, 1, spriteName, System.Convert.ToSingle(words[4]), butt); game.addEntity(csi); } if (words[0].Equals("AButtMoveCycle")) { String spriteName = words[3]; bool butt = Boolean.Parse(words[5]); CutSceneMovingItem csi = new CutSceneMovingItem(game, game.Arena, x, y, System.Convert.ToSingle(words[6]), System.Convert.ToSingle(words[7]), 1, spriteName, System.Convert.ToSingle(words[4]), butt); game.addEntity(csi); } if (words[0].Equals("NormalMoveCycle")) { String spriteName = words[3]; CutSceneMovingItem csi = new CutSceneMovingItem(game, game.Arena, x, y, System.Convert.ToSingle(words[6]), System.Convert.ToSingle(words[7]), 1, spriteName, System.Convert.ToSingle(words[4]), System.Convert.ToSingle(words[5])); game.addEntity(csi); } if (words[0].Equals("MultipleMoves")) { String spriteName = words[3]; float totalCount = x; int sizeOfArray = (int)y; bool butt = Boolean.Parse(words[4]); Vector2[] paths = new Vector2[sizeOfArray]; int count = 0; for (int i = 0; i < x;i=i+2 ) { float xVal = System.Convert.ToSingle(words[i + 5]); float yVal = System.Convert.ToSingle(words[i + 6]); paths[count]=(new Vector2(xVal,yVal)); count++; } CutSceneMultipleMoves csmm = new CutSceneMultipleMoves(game, game.Arena, paths, 1, spriteName, butt); game.addEntity(csmm); } if (words[0].Equals("Text")) { //float numberOfLines=System.Convert.ToSingle(words[3]); float orderNumber = System.Convert.ToSingle(words[3]); //String[] text = new String[(int)numberOfLines]; List<String> textItems = new List<String>(); //for (int i = 0; i < numberOfLines; i++) String lineText; int i=0; while(!(lineText=sr.ReadLine()).Contains("$")) { //text[i] = lineText; textItems.Add(lineText); i++; } String[] text=textItems.ToArray(); CutSceneText cst = new CutSceneText(game, game.Arena, new Vector2(x, y), 1, text,orderNumber); game.addEntity(cst); } } //#endif }
public void createLevel(String file) { //if (game.inCutScene) // return; StringReader sr = new StringReader(file); String line; char[] delimiterChars = { ' ', ',', ':', '\t' }; int c = 0; if(game.loadNewLevel) game.clearEntities(); game.camZoomValue = -1; game.deathBlockGoalCollision = false; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); game.stopWatchLagTimer.Reset(); game.magValue = 1; game.blockNumber = 0; while ((line = sr.ReadLine()) != null) { c++; string[] words = line.Split(delimiterChars); if (words[0].Equals("Demi")) { game.maxLeft = Convert.ToInt32(words[1]); game.maxRight = Convert.ToInt32(words[2]); game.maxTop = Convert.ToInt32(words[3]); game.maxButtom = Convert.ToInt32(words[4]); continue; } if (words[0].Equals("BGCOLOR")) { game.backGroundColor= new Color((float)(Convert.ToInt32(words[1]))/252f, (float)(Convert.ToInt32(words[2]))/252f,(float)(Convert.ToInt32(words[3]))/252f); continue; } if (words[0].Equals("CAM")) { float camValue=System.Convert.ToSingle(words[1]); #if XBOX camValue=camValue*0.9f; #endif game.drawingTool.cam.Zoom = camValue; game.camZoomValue = camValue; continue; } if (words[0].Equals("CPOS")) { game.camPosSet = new Vector2(System.Convert.ToSingle(words[1]), System.Convert.ToSingle(words[2])); continue; } if (words[0].Equals("Text")) { float orderNumber = System.Convert.ToSingle(words[3]); float x1 = System.Convert.ToSingle(words[1]); float y1 = System.Convert.ToSingle(words[2]); List<String> textItems = new List<String>(); String lineText; int i = 0; while (!(lineText = sr.ReadLine()).Contains("$")) { textItems.Add(lineText); i++; } String[] text = textItems.ToArray(); CutSceneText cst = new CutSceneText(game, game.Arena, new Vector2(x1, y1), 1, text, orderNumber); game.addEntity(cst); continue; } float x = System.Convert.ToSingle(words[0]); float y = System.Convert.ToSingle(words[1]); String spriteName = words[2]; if (words[3].Equals("Block")) { float rotation = 0; if(words.Length==8) rotation =(Convert.ToInt32(words[7])); Block toBeAdded = new Block(game, game.Arena, new Vector2(x, y), 1, spriteName, System.Convert.ToSingle(words[4]), System.Convert.ToSingle(words[5]), Convert.ToInt32(words[6]), rotation); if (words.Length >= 8) { //toBeAdded.setdisAppearTimer(Convert.ToInt32(words[7])); } if(Convert.ToInt32(words[6])==0) blocks.AddLast(toBeAdded); else if(Convert.ToInt32(words[6])==1) topBlocks.AddLast(toBeAdded); else buttomBlocks.AddLast(toBeAdded); } if (words[3].Equals("DeathBlock")) { float rotation = 0; if(words.Length==5) rotation = System.Convert.ToSingle(words[4]); deathBlocks.AddLast(new DeathBlock(game, game.Arena, new Vector2(x, y), 1, spriteName,rotation)); } if (words[3].Equals("MagnetBlock")) { if (words.Length < 9) magnetBlocks.AddLast(new MagnetBlock(game, game.Arena, new Vector2(x, y), 1, spriteName, new Vector2(Convert.ToInt32(words[4]), Convert.ToInt32(words[5])), Convert.ToInt32(words[6]), Convert.ToInt32(words[7]))); else { bool isFan = Convert.ToInt32(words[8]) == 1; magnetBlocks.AddLast(new MagnetBlock(game, game.Arena, new Vector2(x, y), 1, spriteName, new Vector2(Convert.ToInt32(words[4]), Convert.ToInt32(words[5])), Convert.ToInt32(words[6]), Convert.ToInt32(words[7]), isFan)); } } if (words[3].Equals("GoalBlock")) goalBlocks.AddLast(new GoalBlock(game, game.Arena, new Vector2(x, y), 1, spriteName, Convert.ToInt32(words[4]))); if (words[3].Equals("MovingDeath")) { Vector2 shootAngle = new Vector2(Convert.ToInt32(words[5]), Convert.ToInt32(words[6])); moveDeathBlocks.AddLast(new MovingDeath(game, game.Arena, new Vector2(x, y), 1, spriteName, shootAngle, Convert.ToInt32(words[4]))); } if (words[3].Equals("MovingPath")) { movePathBlock.AddLast(new MovingPath(game, game.Arena, new Vector2(x, y),1,spriteName,Convert.ToInt32(words[4]), new Vector2(Convert.ToInt32(words[5]),Convert.ToInt32(words[6])),new Vector2(Convert.ToInt32(words[7]),Convert.ToInt32(words[8])),false)); } if (words[3].Equals("MovingCycle")) { int count = Convert.ToInt32(words[5]); List<Vector2> paths = new List<Vector2>(); for (int i = 6; i < 6+count*2; i+=2) { int xPos = Convert.ToInt32(words[i]); int yPos = Convert.ToInt32(words[i+1]); Vector2 vectors = new Vector2(xPos, yPos); paths.Add(vectors); } moveCycleBlock.AddLast(new MovingCycle(game, game.Arena, new Vector2(x, y), 1, spriteName, System.Convert.ToSingle(words[4]), paths, true)); } if (words[0].Equals("Demi")) { game.maxLeft = Convert.ToInt32(words[1]); game.maxRight = Convert.ToInt32(words[2]); game.maxTop = Convert.ToInt32(words[3]); game.maxButtom= Convert.ToInt32(words[4]); } if (words[3].Equals("SuperBack")) { game.backGroundImages.Add(new BackgroundBlock(game, game.Arena, new Vector2(x, y), 1, spriteName, System.Convert.ToSingle(words[5]), System.Convert.ToSingle(words[4]))); } if (words[3].Equals("WaterBlock")) { waterBlocks.AddLast(new WaterBlock(game,game.Arena,new Vector2(x,y),1,spriteName,System.Convert.ToSingle(words[4]),System.Convert.ToSingle(words[5]),System.Convert.ToSingle(words[6]))); } if (words[3].Equals("SignBlock")) { signBlocks.AddLast(new SignBlock(game, game.Arena, new Vector2(x, y), 1, spriteName, System.Convert.ToSingle(words[4]), System.Convert.ToSingle(words[5]), System.Convert.ToSingle(words[6]))); } if (words[3].Equals("Missle")) { missles.AddLast(new Missle(game, game.Arena, new Vector2(x, y), 1, spriteName, System.Convert.ToSingle(words[4]),true)); } } stopWatch.Stop(); if (game.preloadLevelOnly) return; foreach (Block i in buttomBlocks) game.addEntity(i); foreach (MovingDeath i in moveDeathBlocks) game.addEntity(i); foreach (MovingCycle i in moveCycleBlock) game.addEntity(i); foreach (Block i in topBlocks) game.addEntity(i); foreach (DeathBlock i in deathBlocks) game.addEntity(i); foreach (MagnetBlock i in magnetBlocks) game.addEntity(i); foreach (MovingPath i in movePathBlock) game.addEntity(i); foreach (Block i in blocks) game.addEntity(i); foreach (GoalBlock i in goalBlocks) game.addEntity(i); foreach (WaterBlock i in waterBlocks) game.addEntity(i); foreach (SignBlock i in signBlocks) game.addEntity(i); foreach (Missle i in missles) game.addEntity(i); foreach (MovingDeath i in moveDeathBlocks) { foreach (MovingDeath j in moveDeathBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (Block i in blocks) { foreach (Block j in blocks) { if (!(j is LayerBlock || i is LayerBlock)) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } } foreach (DeathBlock i in deathBlocks) { foreach (DeathBlock j in deathBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingPath i in movePathBlock) { foreach (MovingPath j in movePathBlock) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingPath i in movePathBlock) { foreach (DeathBlock j in deathBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingPath i in movePathBlock) { foreach (GoalBlock j in goalBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingPath i in movePathBlock) { foreach (Block j in blocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingPath i in movePathBlock) { foreach (MagnetBlock j in magnetBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingCycle i in moveCycleBlock) { foreach (MagnetBlock j in magnetBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingDeath i in moveDeathBlocks) { foreach (MovingDeath j in moveDeathBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingCycle i in moveCycleBlock) { foreach (MovingCycle j in moveCycleBlock) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingCycle i in moveCycleBlock) { foreach (GoalBlock j in goalBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingCycle i in moveCycleBlock) { foreach (Block j in blocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingCycle i in moveCycleBlock) { foreach (DeathBlock j in deathBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingCycle i in moveCycleBlock) { foreach (MovingPath j in movePathBlock) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } foreach (MovingCycle i in moveCycleBlock) { foreach (MagnetBlock j in magnetBlocks) { i.fixture.CollisionFilter.IgnoreCollisionWith(j.fixture); j.fixture.CollisionFilter.IgnoreCollisionWith(i.fixture); } } if (Constants.FIND_LAG) { #if WINDOWS DirectoryInfo di2 = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\DebugInfo"); String name = di2.FullName + @"\LagInfo.txt"; LinkedList<String> lines = new LinkedList<String>(); lines.AddLast("Level"+game.currentLevel); lines.AddLast(stopWatch.Elapsed.ToString()); lines.AddLast(game.stopWatchLagTimer.Elapsed.ToString()); System.IO.File.WriteAllLines(name, lines); #endif } game.gameInsertValues = true; //game.drawingTool.resetCamera(); game.drawingTool.cam.Zoom = game.camZoomValue; game.drawingTool.cam.Pos = game.camPosSet; List<Entity> omg=game.entities; }