//the key to unlock the door, targeted x coordinate, targeted y coordinate, targeted map public void Warp(WarpItem warp, string key, int targetX, int targetY, string map, Game1 game, GameTime gameTime) { UpdateList(Game1.map.mapName); for (int y = 0; y < Game1.character.inventory.height; y++) { if ((Game1.character.inventory.inventorySlot[0, y].item == key || key == "."))//checks if the player has the key or if the key is ".", aka no key required { hasKey = true; Game1.map = game.Content.Load<H_Map.TileMap>(@"Map\" + map); Game1.map.tileset = game.Content.Load<Texture2D>(@"Game\tileset"); game.UpdateActiveNpcs(); if (warp.targetX != -1)//warp the X value if it isnt -1(the player's X value) { Game1.character.position.X = warp.targetX; } if (warp.targetY != -1)//warp the Y value if it isnt -1(the player's Y value) { Game1.character.position.Y = warp.targetY; } #region story stuff if (map == "Map4_C") { for (int i = 0; i < game.Npcs.Count; i++) { if (game.Npcs[i].name == "Ziva") { if (game.Npcs[i].health > 0) { game.Npcs[i].isInteracting = true; game.Npcs[i].dialogue.isTalking = true; Game1.currentGameState = Game1.GameState.INTERACT; } } } } else if (map == "Map3_B") { for (int i = 0; i < game.Npcs.Count; i++) { if (game.Npcs[i].name == "Headmaster") { game.Npcs[i].mapName = map; } if (game.Npcs[i].name == "Celine") { game.Npcs[i].position.X = 1625; game.Npcs[i].position.Y = 1521; game.Npcs[i].mapName = map; } } } else if (map == "Map4_B") { Game1.character.waypointManager = new Player.CharacterWaypointManager(Game1.character.position, map, 3); for (int i = 0; i < game.Npcs.Count; i++) { if (game.Npcs[i].name == "Celine") { game.Npcs[i].mapName = map; game.Npcs[i].position.X = 834; game.Npcs[i].position.Y = 711; game.Npcs[i].left = true; game.Npcs[i].right = false; game.Npcs[i].up = false; game.Npcs[i].down = false; game.Npcs[i].MoveLeft(ref game.Npcs[i].position); game.Npcs[i].animation.LoopAnimation(7); } if (game.Npcs[i].name == "Laune") { game.Npcs[i].mapName = map; game.Npcs[i].position.X = 834; game.Npcs[i].position.Y = 793; game.Npcs[i].left = true; game.Npcs[i].right = false; game.Npcs[i].up = false; game.Npcs[i].down = false; game.Npcs[i].MoveLeft(ref game.Npcs[i].position); game.Npcs[i].animation.LoopAnimation(9); } if (game.Npcs[i].name == "Melitta") { game.Npcs[i].mapName = map; game.Npcs[i].position.X = 834; game.Npcs[i].position.Y = 867; game.Npcs[i].left = true; game.Npcs[i].right = false; game.Npcs[i].up = false; game.Npcs[i].down = false; game.Npcs[i].MoveLeft(ref game.Npcs[i].position); game.Npcs[i].animation.LoopAnimation(7); } if (game.Npcs[i].name == "Sylian") { game.Npcs[i].mapName = map; game.Npcs[i].position.X = 834; game.Npcs[i].position.Y = 948; game.Npcs[i].left = true; game.Npcs[i].right = false; game.Npcs[i].up = false; game.Npcs[i].down = false; game.Npcs[i].MoveLeft(ref game.Npcs[i].position); game.Npcs[i].animation.LoopAnimation(7); } if (game.Npcs[i].name == "Ziva") { game.Npcs[i].mapName = map; game.Npcs[i].position.X = 834; game.Npcs[i].position.Y = 1029; game.Npcs[i].left = true; game.Npcs[i].right = false; game.Npcs[i].up = false; game.Npcs[i].down = false; game.Npcs[i].MoveLeft(ref game.Npcs[i].position); game.Npcs[i].animation.LoopAnimation(7); } game.Npcs[i].vulnerable = false; } } #endregion } } if (!hasKey) { if (!showedLocked) { dialogue.isTalking = true; showedLocked = true; Game1.currentGameState = Game1.GameState.INTERACT; Vector2 dir = new Vector2(warp.warpField.X, warp.warpField.Y) - Game1.character.position; dir.Normalize(); dir *= -1; Game1.character.Push(dir, 3); } } }
//the key to unlock the door, targeted x coordinate, targeted y coordinate, targeted map public void Warp(WarpItem warp, string key, int targetX, int targetY, string map, Game1 game, GameTime gameTime) { UpdateList(Game1.map.mapName); for (int y = 0; y < Game1.character.inventory.height; y++) { if ((Game1.character.inventory.inventorySlot[0, y].item == key || key == "."))//checks if the player has the key or if the key is ".", aka no key required { hasKey = true; Game1.map = game.Content.Load<H_Map.TileMap>(@"Map\" + map); Game1.map.tileset = game.Content.Load<Texture2D>(@"Game\tileset"); game.UpdateActiveNpcs(); if (warp.targetX != -1)//warp the X value if it isnt -1(the player's X value) { Game1.character.position.X = warp.targetX; } if (warp.targetY != -1)//warp the Y value if it isnt -1(the player's Y value) { Game1.character.position.Y = warp.targetY; } if (map == "Map4_C") { for (int i = 0; i < game.Npcs.Count; i++) { if (game.Npcs[i].name == "Ziva") { if (game.Npcs[i].health > 0) { game.Npcs[i].isInteracting = true; game.Npcs[i].dialogue.isTalking = true; Game1.currentGameState = Game1.GameState.INTERACT; } } } } else if(map == "Map3_B") { for (int i = 0; i < game.Npcs.Count; i++) { if (game.Npcs[i].name == "Headmaster") { game.Npcs[i].mapName = map; } if (game.Npcs[i].name == "Celine") { game.Npcs[i].position.X = 1625; game.Npcs[i].position.Y = 1521; game.Npcs[i].mapName = map; } } } } } if (!hasKey) { if (!showedLocked) { dialogue.isTalking = true; showedLocked = true; Game1.currentGameState = Game1.GameState.INTERACT; Vector2 dir = new Vector2(warp.warpField.X, warp.warpField.Y) - Game1.character.position; dir.Normalize(); dir *= -1; Game1.character.Push(dir, 3); } } }