public MarioObject build(Vector2 position) { MarioObject block; block = new MarioObject(position, _content, audio); // it would be nice to take in states as strings and change mario's state. Not sure how much 'in-game' use that could have as // a new mario would spawn in his default state (which is produced currently) return(block); }
public override void LoadContent(ContentManager content) { this.content = content; font = content.Load <SpriteFont>("temp_font"); hud = new HudObject(font); string name = "world_1_1_draft.txt"; //string name = "test_level.txt"; // figure out the file pathing later Tokenizer test = new Tokenizer(name, content); //gameObjects = gameObjects.Concat(test.GetSprites()).ToList(); layers[1].Objects = test.GetSprites(); layers[0].Objects.Add(new BGObject(content)); //layers[2].Objects.Add(hud); foreach (AbsObject temp in layers[1].Objects) { if (temp is MarioObject) { avatar = (MarioObject)temp; } else if (temp is EnemyObject) { EnemyObject enemy = (EnemyObject)temp; enemy.Mario = avatar; } } avatar.hud = hud; hud.audio = avatar.audio; keyboard = new KeyboardController(); keyboard.moveCommandDict.Add(Keys.Up, new UpCommand(avatar)); keyboard.releaseCommandDict.Add(Keys.Up, new DownCommand(avatar)); keyboard.moveCommandDict.Add(Keys.W, new UpCommand(avatar)); keyboard.releaseCommandDict.Add(Keys.W, new DownCommand(avatar)); keyboard.moveCommandDict.Add(Keys.Down, new DownCommand(avatar)); keyboard.moveCommandDict.Add(Keys.S, new DownCommand(avatar)); keyboard.releaseCommandDict.Add(Keys.Down, new UpCommand(avatar)); keyboard.releaseCommandDict.Add(Keys.S, new UpCommand(avatar)); keyboard.moveCommandDict.Add(Keys.Left, new LeftCommand(avatar)); keyboard.moveCommandDict.Add(Keys.A, new LeftCommand(avatar)); keyboard.releaseCommandDict.Add(Keys.Left, new RightCommand(avatar)); keyboard.releaseCommandDict.Add(Keys.A, new RightCommand(avatar)); keyboard.moveCommandDict.Add(Keys.Right, new RightCommand(avatar)); keyboard.moveCommandDict.Add(Keys.D, new RightCommand(avatar)); keyboard.releaseCommandDict.Add(Keys.Right, new LeftCommand(avatar)); keyboard.releaseCommandDict.Add(Keys.D, new LeftCommand(avatar)); keyboard.commandDict.Add(Keys.Space, new ThrowFireballCommand(avatar)); keyboard.commandDict.Add(Keys.Y, new StandardCommand(avatar)); keyboard.commandDict.Add(Keys.U, new SuperCommand(avatar)); keyboard.commandDict.Add(Keys.I, new FireCommand(avatar)); keyboard.commandDict.Add(Keys.O, new TakeDamageCommand(avatar)); keyboard.commandDict.Add(Keys.Q, new QuitCommand()); keyboard.commandDict.Add(Keys.P, new PauseCommand(graphics, hud, avatar.audio, graphicsManager)); keyboard.commandDict.Add(Keys.M, new MuteCommand(avatar.audio)); keyboard.commandDict.Add(Keys.Tab, new ThemeCommand(avatar.audio)); keyboard.commandDict.Add(Keys.R, new ResetCommand(graphics, graphicsManager, hud.audio)); gamepad = new GamepadController(); gamepad.moveCommandDict.Add(Buttons.A, new UpCommand(avatar)); gamepad.releaseCommandDict.Add(Buttons.A, new DownCommand(avatar)); gamepad.moveCommandDict.Add(Buttons.DPadDown, new DownCommand(avatar)); gamepad.releaseCommandDict.Add(Buttons.DPadDown, new UpCommand(avatar)); gamepad.moveCommandDict.Add(Buttons.DPadLeft, new LeftCommand(avatar)); gamepad.releaseCommandDict.Add(Buttons.DPadLeft, new RightCommand(avatar)); gamepad.moveCommandDict.Add(Buttons.DPadRight, new RightCommand(avatar)); gamepad.releaseCommandDict.Add(Buttons.DPadRight, new LeftCommand(avatar)); gamepad.commandDict.Add(Buttons.B, new ThrowFireballCommand(avatar)); gamepad.commandDict.Add(Buttons.Start, new QuitCommand()); gamepad.commandDict.Add(Buttons.Back, new PauseCommand(graphics, hud, avatar.audio, graphicsManager)); controllers.Add(keyboard); controllers.Add(gamepad); }
private List <AbsObject> Parse(string[] input) { //let this be a list for the floor List <AbsObject> sprites = new List <AbsObject>(); switch (input[0].ToLower()) { case "item": sprites.Add(new ItemObject(new Vector2(float.Parse(input[1]), float.Parse(input[2])), content, audio, input[3])); break; case "enemy": sprites.Add(new EnemyObject(new Vector2(float.Parse(input[1]), float.Parse(input[2])), content, audio, input[3])); break; case "block": //sprites.Add(new BlockObject(new Vector2(float.Parse(input[1]), float.Parse(input[2])), content, input[3])); ItemObject item = null; Queue <ItemObject> temp = new Queue <ItemObject>(); int coinCount = 0; if (input[4] != "null") { if (input[4] == "coin") { while (coinCount < Convert.ToInt32(input[5])) { item = new ItemObject(new Vector2(float.Parse(input[1]), float.Parse(input[2])), content, audio, input[4]); item.inBlock = true; item.Hitbox = new BoundingBox(new Vector3(0), new Vector3(0)); item.isVisible = false; sprites.Add(item); temp.Enqueue(item); coinCount++; } } else { item = new ItemObject(new Vector2(float.Parse(input[1]), float.Parse(input[2])), content, audio, input[4]); item.inBlock = true; item.Hitbox = new BoundingBox(new Vector3(0), new Vector3(0)); item.isVisible = false; sprites.Add(item); temp.Enqueue(item); } } BlockObject block = new BlockObject(new Vector2(float.Parse(input[1]), float.Parse(input[2])), content, audio, input[3]); if (input[4] != "null") { block.hasItems = true; } block.items = temp; sprites.Add(block); break; // not implemnted for this sprint -SR //case "projectile": //sprites.Add(_projectileFactory.build(new Vector2(float.Parse(input[1]), float.Parse(input[2])), input[3])); //break; case "mario": mario = new MarioObject(new Vector2(float.Parse(input[1]), float.Parse(input[2])), content, audio); //this would allow for initial velocity to be changed, but the state is still in right facing idle //could have to have the state in the level def. as well //mario._velocity = new Vector2(float.Parse(input[3]), float.Parse(input[4])); sprites.Add(mario); //sprites.Add(new MarioObject(new Vector2(float.Parse(input[1]), float.Parse(input[2])), content)); break; case "floor": //there are a few other ways to go about this. I chose this one for (int q = 0; q < (Int32.Parse(input[2]) - Int32.Parse(input[1])) / 16; q++) { //2 rows of blocks sprites.Add(new BlockObject(new Vector2((q * 16 + Int32.Parse(input[1])), 464.0f), content, audio, input[0].ToLower())); sprites.Add(new BlockObject(new Vector2((q * 16 + Int32.Parse(input[1])), 448.0f), content, audio, input[0].ToLower())); } break; case "stairs_up": int i = 0; int first = Int32.Parse(input[1]); // each run of this loop builds one column of the stairs, height input must be at least 1 or nothing will draw for (i = 0; i < (Int32.Parse(input[2])); i++) { //base of column (when i=0 inner loop body wont run) assuming 480 to the bottom of the screen + 2 rows of floor blocksa sprites.Add(new BlockObject(new Vector2((first + (16 * i)), 432.0f), content, audio, "stair")); //now build the height of the column for (int j = 0; j < i; j++) { //same assumptions about floor as above sprites.Add(new BlockObject(new Vector2((first + (16 * i)), (416.0f - (16 * j))), content, audio, "stair")); } } //this loop repeats the last column (this is why i is declared outside of the for loop, should contain the value of i //that 'broke' the outer while loop) for (int r = 0; r < (Int32.Parse(input[3])); r++) { sprites.Add(new BlockObject(new Vector2((first + (16 * i) + (16 * r)), 432.0f), content, audio, "stair")); //i is 1 larger than it needs to be for (int j = 0; j < (i - 1); j++) { sprites.Add(new BlockObject(new Vector2((first + (16 * i) + (16 * r)), (416.0f - (16 * j))), content, audio, "stair")); } } break; case "stairs_down": int fir = Int32.Parse(input[1]); int height = Int32.Parse(input[2]); int repeats = 0; // repeat first for (repeats = 0; repeats < (Int32.Parse(input[3])); repeats++) { sprites.Add(new BlockObject(new Vector2((fir + (16 * repeats)), 432.0f), content, audio, "stair")); for (int j = 0; j < (height - 1); j++) { sprites.Add(new BlockObject(new Vector2((fir + (16 * repeats)), (416.0f - (16 * j))), content, audio, "stair")); } } for (int k = 0; k < height; k++) { //base sprites.Add(new BlockObject(new Vector2((fir + (16 * k) + (16 * repeats)), 432.0f), content, audio, "stair")); for (int j = 0; j < (height - 1 - k); j++) { sprites.Add(new BlockObject(new Vector2((fir + (16 * k) + (16 * repeats)), (416.0f - (16 * j))), content, audio, "stair")); } } break; case "pipe": MiscObject pipeHead = new MiscObject(new Vector2(Int32.Parse(input[1]), Int32.Parse(input[2])), content, "pipe_head"); if (input[4] != "null") { if (input[4] == "warp") { pipeHead.WarpDestination = new Vector2(Int32.Parse(input[5]), Int32.Parse(input[6])); MiscObject destPipeHead = new MiscObject(pipeHead.WarpDestination.Value, content, "pipe_head"); destPipeHead.WarpDestination = new Vector2(Int32.Parse(input[1]), Int32.Parse(input[2])); int destPipeSections = Int32.Parse(input[7]); sprites.Add(destPipeHead); for (int j = 1; j <= destPipeSections; j++) { sprites.Add(new MiscObject(new Vector2(Int32.Parse(input[5]), Int32.Parse(input[6]) + 16 * j), content, "pipe_section")); } } else { pipeHead.Mario = mario; EnemyObject pirhana = new EnemyObject(new Vector2(Int32.Parse(input[1]) + 8, Int32.Parse(input[2])), content, audio, "pirhana"); pirhana.Pipe = pipeHead; sprites.Add(pirhana); } } int pipeSections = Int32.Parse(input[3]); for (int j = 1; j <= pipeSections; j++) { sprites.Add(new MiscObject(new Vector2(Int32.Parse(input[1]), Int32.Parse(input[2]) + 16 * j), content, "pipe_section")); } sprites.Add(pipeHead); break; case "misc": sprites.Add(new MiscObject(new Vector2(Int32.Parse(input[1]), Int32.Parse(input[2])), content, input[3])); break; default: Console.WriteLine($"No match for {input[0].ToLower()}"); break; } return(sprites); }
public ThrowFireballCommand(MarioObject recieve) { this.recievier = recieve; }
public MakeStandardCommand(MarioObject mario) { this.mario = mario; }
public MakeSuperCommand(MarioObject mario) { this.mario = mario; }
public MakeFireCommand(MarioObject mario) { this.mario = mario; }