public MetaMapMatrix(GameSession parent) { parentSession = parent; // create adjacency matrix Random rng = new Random(); for (int i = 0; i < minPortals; i++) { int a = rng.Next(maps); int b = rng.Next(maps); if (a == b || adjacencyMatrix[a, b] == 1) { i--; continue; } adjacencyMatrix[a, b] = 1; adjacencyMatrix[b, a] = 1; } while (!CheckConnectivity()) { int a = rng.Next(maps); int b = rng.Next(maps); if (a == b || adjacencyMatrix[a, b] == 1) { continue; } adjacencyMatrix[a, b] = 1; adjacencyMatrix[b, a] = 1; } // create maps matrix = new MapMatrix[maps]; for (int i = 0; i < maps; i++) { matrix[i] = new MapMatrix(parentSession, MakePortalsList(i), rng.Next(1000 * maps)); } }
// constructor and methods below public GameSession(GamePage parentPage, string playerChoice) { // core this.parentPage = parentPage; CurrentPlayer = new Mage(this); if (playerChoice != null) { if (playerChoice.Contains("Fizyczna")) { CurrentPlayer = new Warrior(this); } } itemPositions = new List <int>(); activeItems = new List <Item>(); parentPage.AddConsoleText("Witaj w grze!"); RefreshStats(); SoundEngine = parentPage.soundEngine; ChildSoundEngines = new List <SoundEngine>(); // map metaMapMatrix = new MetaMapMatrix(this); mapMatrix = metaMapMatrix.GetCurrentMatrix(0); //mapMatrix.Matrix[15, 15] = 3001; AvailableMoves = new bool[4]; InitializeMapDisplay(0); // starting skills and items if (playerChoice != null) { if (playerChoice.Contains("topor")) { ProduceItem("item0003"); CurrentPlayer.Learn(new AxeCut()); CurrentPlayer.Learn(new SwordSlash()); CurrentPlayer.Learn(new SpearStab()); } else if (playerChoice.Contains("miecz")) { ProduceItem("item0004"); CurrentPlayer.Learn(new AxeCut()); CurrentPlayer.Learn(new SwordSlash()); CurrentPlayer.Learn(new SpearStab()); } else if (playerChoice.Contains("wlocznia")) { ProduceItem("item0002"); CurrentPlayer.Learn(new AxeCut()); CurrentPlayer.Learn(new SwordSlash()); CurrentPlayer.Learn(new SpearStab()); } else if (playerChoice.Contains("Ognista")) { ProduceItem("item0001"); CurrentPlayer.Learn(new FireArrow()); } else if (playerChoice.Contains("Podmuch")) { ProduceItem("item0001"); CurrentPlayer.Learn(new WindGust()); } } }
public MetaMapMatrix(GameSession parent) { parentSession = parent; // create adjacency matrix Random rng = new Random(); for (int i = 0; i < minPortals; i++) { int a = rng.Next(maps); int b = rng.Next(maps); if (a == b || adjacencyMatrix[a, b] == 1) { i--; continue; } adjacencyMatrix[a, b] = 1; adjacencyMatrix[b, a] = 1; } while (!CheckConnectivity()) { int a = rng.Next(maps); int b = rng.Next(maps); if (a == b || adjacencyMatrix[a, b] == 1) { continue; } adjacencyMatrix[a, b] = 1; adjacencyMatrix[b, a] = 1; } // generate interactions GenerateInteractions(); // create maps matrix = new MapMatrix[maps]; int totalIntNumber = interactionList.Count; for (int i = 0; i < maps; i++) { List <Interaction> tmp; if (i == maps - 1) { tmp = interactionList; } else { tmp = new List <Interaction>(); for (int u = 0; u < (totalIntNumber / maps + 1); u++) { if (interactionList.Count == 0) { break; } int index = rng.Next(interactionList.Count); tmp.Add(interactionList[index]); interactionList.RemoveAt(index); } } matrix[i] = new MapMatrix(parentSession, MakePortalsList(i), tmp, rng.Next(1000 * maps)); } }
public GameSession(GamePage parentPage, string playerChoice) { // core this.parentPage = parentPage; currentPlayer = new Mage(this); if (playerChoice != null) { if (playerChoice.Contains("Warrior")) { currentPlayer = new Warrior(this); } } itemPositions = new List <int>(); items = new List <Item>(); parentPage.AddConsoleText("Welcome to the game!"); RefreshStats(); // map metaMapMatrix = new MetaMapMatrix(); mapMatrix = metaMapMatrix.GetCurrentMatrix(0); AvailableMoves = new bool[4]; InitializeMapDisplay(0); // starting skills and items if (playerChoice != null) { if (playerChoice.Contains("Axe")) { ProduceItem("item0003"); currentPlayer.Learn(new AxeCut()); } else if (playerChoice.Contains("Sword")) { ProduceItem("item0009"); ProduceItem("item0010"); ProduceItem("item0012"); currentPlayer.Learn(new SwordSlash()); } else if (playerChoice.Contains("Spear")) { ProduceItem("item0002"); currentPlayer.Learn(new SpearStab()); } else if (playerChoice.Contains("Fire")) { ProduceItem("item0001"); currentPlayer.Learn(new FireArrow()); } else if (playerChoice.Contains("Wind")) { ProduceItem("item0001"); currentPlayer.Learn(new WindGust()); } } }
private MapMatrix[] matrix; // an array containing all boards in the game public MetaMapMatrix(GameSession parent) { parentSession = parent; fixedlist = new List <List <string> >(); // read file var list = new List <string>(); var rx = new Regex("\t"); //regex do tabulatur foreach (string el in File.ReadAllLines("../../Maps/MetaMap.txt")) // w folderze glownym gry nalezy stworzyc folder Maps i tam wrzucać pliki { list.Add(el); // otwieramy plik i spisujemy linijki } foreach (string el in list) { string[] tmp = rx.Split(el); var tmpList = new List <string>(); foreach (string elm in tmp) { tmpList.Add(elm); if (tmpList.Contains("randominteractions=true")) { randomInteractionMaps++; } // zliczaj mapy pozwalające na losowe interakcje } fixedlist.Add(tmpList); } // read const string[] pair; maps = list.Count - 1; foreach (string el in fixedlist[0]) { pair = el.Split('='); switch (pair[0]) { case "portals": portals = Convert.ToInt32(pair[1]); break; case "shops": shops = Convert.ToInt32(pair[1]); break; case "interactions": interactions = Convert.ToInt32(pair[1]); break; case "monsters": monsters = Convert.ToInt32(pair[1]); break; case "walls": walls = Convert.ToInt32(pair[1]); break; } } // create adjacency matrix CreateAdjencymatrix(); // generate interactions GenerateInteractions(); GenerateQuests(); CheckPregeneratedQuests(); totalIntNumber = interactionList.Count; // create maps matrix = new MapMatrix[maps]; for (int i = 0; i < maps; i++) { if (fixedlist[i + 1][0].Contains("file=")) { File.WriteAllText("../../Maps/Debug.txt", "map from \"file=\" was created"); matrix[i] = new MapMatrix(parentSession, "../../Maps/" + fixedlist[i + 1][0].Split('=')[1]); } else { matrix[i] = new MapMatrix(parentSession, MakePortalsList(i), CreateQuests(i), rng.Next(1000 * maps), (monsters, walls)); //matrix[i] = new MapMatrix(parentSession, MakePortalsList(i), CreateQuests(i), rng.Next(1000 * maps), CreateMonsters(i), walls); } } }