public void UpdateList(string mapName) { warps.Clear(); warpFiles = new string[warpFileCount];//initialize the string[] with the amount of files for (int i = 0; i < warpFileCount; i++)//add a warp item for every file { warpFiles[i] = Directory.GetFiles(@"Content\Warp\")[i]; StreamReader reader = new StreamReader(warpFiles[i]); WarpItem warp = new WarpItem(reader.ReadLine(), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), reader.ReadLine(), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), reader.ReadLine()); reader.Close(); if (warp.isOnMap) { warps.Add(warp); } } //for (int i = 0; i < warps.Count; i++) //{ // Console.WriteLine(warps[i].sourceMap); // WarpItem w = new WarpItem(reader.ReadLine(), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), // int.Parse(reader.ReadLine()), reader.ReadLine(), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), reader.ReadLine()); // reader.Close(); // Console.WriteLine(w.sourceMap); // if (w.sourceMap == mapName.Remove(mapName.Length-1)) // { // warps.Add(w); // Console.WriteLine("Added warp mofo"); // } //} }
//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) { //UpdateList(Game1.map.mapName); for (int x = 0; x < Game1.character.inventory.width; x++)//player inventory slots { for (int y = 0; y < Game1.character.inventory.height; y++) { if ((Game1.character.inventory.inventorySlot[x, y].item == key || key == "."))//checks if the player has the key or if the key is ".", aka no key required { Game1.map = game.Content.Load<H_Map.TileMap>(@"Map\" + map); Game1.map.tileset = game.Content.Load<Texture2D>(@"Game\tileset"); if (warp.targetX != -1)//warp the X value if it isnt -1(tha player's X value) { Game1.character.position.X = warp.targetX; } if (warp.targetY != -1)//warp the Y value if it isnt -1(tha player's Y value) { Game1.character.position.Y = warp.targetY; } break; } else { Console.WriteLine("locked"); break; } } } }
//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); } } }
public void UpdateList(string mapName) { warps.Clear(); warpFiles = new string[warpFileCount];//initialize the string[] with the amount of files for (int i = 0; i < warpFileCount; i++)//add a warp item for every file { warpFiles[i] = Directory.GetFiles(@"Content\Warp\")[i]; StreamReader reader = new StreamReader(warpFiles[i]); WarpItem warp = new WarpItem(reader.ReadLine(), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), reader.ReadLine(), int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()), reader.ReadLine()); reader.Close(); if (warp.isOnMap) { warps.Add(warp); } } }
//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); } } }