public Pathfinder(HexMap hexMap) { this.HexMap = hexMap; levelWidth = hexMap.Layout.GetLength(1); levelHeight = hexMap.Layout.GetLength(0); InitializeTiles(); }
public SpawnGroup(int numberOfCreatures, Creature creature, int spawnFrequency, int spawnDuration) { ParentGame = creature.ParentGame; ParentMap = CurrentGame.currentMap; ExampleCreature = creature; Creatures = new Creature[numberOfCreatures]; if (creature.Spritesheet != null && File.Exists(CurrentGame.ContentDir + "Creatures\\Smalls\\NEXTWAVE" + creature.Spritesheet.Name + ".xnb")) { InfoTexture = ParentGame.Content.Load <Texture2D>("Creatures\\Smalls\\NEXTWAVE" + creature.Spritesheet.Name); } else { InfoTexture = CurrentGame.pixel; } infoTexOrigin = new Vector2(InfoTexture.Width * 0.5f, InfoTexture.Height * 0.5f); //SpawnTimetable = new int[numberOfCreatures]; SpawnPointIndex = creature.SpawnPointIndex; GoalPointIndex = creature.GoalPointIndex; AliveCreatures = new List <Creature>(); for (int i = 0; i < numberOfCreatures; i++) { //Creatures[i] = creatureType.Clone(); //---------------------------------------YKSILÖT?!------------- Creatures[i] = Creature.Clone(creature); Creatures[i].Alive = true; Creatures[i].ParentGroup = this; Creatures[i].FindPath(); //-----------------------------pitäs kattoo reittivaihtoehdot vain kerran, jakaa niitä rndisti öröille ja sit individualisoida AliveCreatures.Add(Creatures[i]); //SpawnTimetable[i] = spawnFrequency; } SpawnFrequency = spawnFrequency; GroupDuration = spawnDuration; }
//--------Constructors------------------------------ public Bullet(Creature targetCreature, float speed, float dmg, DmgType dmgType, float splashRange, float[] slow, GeneSpecs elems, Vector2 originPoint, Texture2D texture, HexMap currMap) { this.targetCreature = targetCreature; this.speed = speed; this.dmg = dmg; DmgType = dmgType; this.slow = slow; ElemSpecs = elems; this.originPoint = originPoint; this.texture = texture; //active = true; textureOrigin = new Vector2(texture.Width / 2, texture.Height / 2); //Rnd = targetCreature.ParentMap.rnd; //rndWobble = new Vector2((float)(Rnd.NextDouble() - 0.5), (float)(Rnd.NextDouble() - 0.5)); //ShootAt(targetCreature); SplashRange = splashRange; ParentMap = currMap; ExplosionAnim = new AnimSprite(ParentMap.ParentGame.Content.Load <Texture2D>("MetroPlos"), Point.Zero, 1, 5); }
public Wave(HexMap map, SpawnGroup[] groups) { ParentMap = map; Groups = groups; ParentGame = map.ParentGame; Initialize(); }
public Creature(HexMap map, string creatureType, int spawnPointIndex, int goalPointIndex, Texture2D spriteSheet, int spritesheetRows, int spritesheetColumns) : this(map, creatureType, spawnPointIndex, goalPointIndex, spriteSheet) { SpritesheetRows = spritesheetRows; SpritesheetColumns = spritesheetColumns; totalFrames = spritesheetRows * spritesheetColumns; currentFrame = 0; AnimationUpdatePhase = 0; }
public Creature(string creatureType, string name, HexMap map, Texture2D spritesheet, int spawnPointIndex, int goalPointIndex, int initHp, float defaultSpeed, byte lifeDamage, float spriteScale, string textureName) : this(creatureType, name, map, spawnPointIndex, goalPointIndex, spritesheet, initHp, defaultSpeed) { SpriteScale = spriteScale; Origin = spritesheet != null ? new Vector2(Width / 2, Height / 2) : Vector2.Zero; currentFrame = 0; AnimationUpdatePhase = 0; LifeDmg = lifeDamage; Spritesheet.Name = textureName; }
public Creature(string creatureType, string name, HexMap map, string textureName, int spawnPointIndex, int goalPointIndex, int initHp, float defaultSpeed, GeneSpecs elementWeaknesses, byte lifeDamage, int nrgBounty, float spriteScale) : this(creatureType, name, map, spawnPointIndex, goalPointIndex, Array.Find <Texture2D>(CurrentGame.CreatureTextures, tex => tex.Name == textureName), initHp, defaultSpeed) { EnergyBounty = nrgBounty; ElemArmors = elementWeaknesses; SpriteScale = spriteScale; currentFrame = 0; AnimationUpdatePhase = 0; LifeDmg = lifeDamage; //Spritesheet.Name = textureName; }
public Creature(string creatureType, string name, HexMap map, int spawnPointIndex, int goalPointIndex, Texture2D texture, int initHp, float defaultSpeed) : this(map, creatureType, spawnPointIndex, goalPointIndex, texture) { Name = name; InitHp = initHp; hp = initHp; defSpeed = defaultSpeed; Speed = defaultSpeed; Splatter = new ParticleEngine(CurrentGame.smallBall, Location, 50 + (int)InitHp, 5, ParentMap.rnd); //---------------------täällä kuoloparticlemäärä----------!! TrailEngine = new ParticleEngine(CurrentGame.pixel, Location, 5000, 5000, ParentMap.rnd); //-----------TRAIL TrailEngine.SourceCreature = this; //-----------TRAIL TrailEngine.ParticleSpeed = 0; //-----------TRAIL }
//--------Constructors------------------------------ public Tower(char symbol, string name, Point mapCoord, float range, float firerate, Texture2D[] textures, GeneSpecs geneSpecs, Texture2D bulletTexture, float bulletSpeed, short dmg, DmgType dmgType, int splashRange, float[] slow, int cost, int buildTime, bool isExample) { ParentMap = CurrentGame.currentMap; Name = name; Symbol = symbol; MapCoord = mapCoord; //ScreenLocation = map.ToScreenLocation(mapCoord); /*this.screenLocation = new Vector2((float)(mapLocation[0] * map.stackedWidth + map.drawPos.X), * (float)(mapLocation[1] * map.TileHeight + mapLocation[0] % 2 * (map.TileHeight / 2)) + map.drawPos.Y);*/ Range = range; InitRange = range; FireRate = firerate; BulletSpeed = bulletSpeed; radiusTextures = new Texture2D[2]; //this.radiusTextures[0] = radiusTexture; MakeRadiusCircle(); ShowRadius = false; Textures = textures; //this.angleOffset = angleOffset; //angle = (float)Math.PI * 1.5f; texOrigin = new Vector2(textures[0].Width / 2, textures[0].Height / 2); this.bulletTexture = bulletTexture; Dmg = dmg; DmgType = dmgType; this.slow = slow; Cost = cost; BuildTime = buildTime; buildTimer = buildTime; IsExample = isExample; if (!IsExample) { buildFinishedCounter = buildFinishedInit; //---------------------------ist dies der rihl leif? } Built = false; Bullets = new List <Bullet>(10); towerTypeIdx = Array.IndexOf(TowerSymbols, symbol); towerBranch = towerTypeIdx % 6; SplashRange = splashRange; CreaturesInRange = new List <Creature>(); ColoredInRange = new List <Creature>(); PossibleTargets = new List <Creature>(); GeneSpecs = geneSpecs; GeneSpecs.BaseTiers[Math.Max((int)GeneSpecs.GetPrimaryElem() - 1, 0)] = (int)(GeneSpecs.GetPrimaryElemStrength() * 100) / GeneSpecs.TierSize; FireRateSec = 1000 / (firerate * (float)ParentMap.ParentGame.TargetElapsedTime.TotalMilliseconds); DPS = dmg * FireRateSec; }
//--------------------------Constructors------------------------------------ //---------------------------------------------------muista että tuki useammalle maalille on! public Creature(HexMap map, string creatureType, int spawnPointIndex, int goalPointIndex, Texture2D texture) { ParentGame = map.ParentGame; ParentMap = map; OrigPath = new List <Vector2>(); Type = creatureType; SpawnPointIndex = spawnPointIndex; GoalPointIndex = goalPointIndex; Location = map.SpawnPoints.Length > 0 ? map.ToScreenLocation(map.SpawnPoints[spawnPointIndex]) : Vector2.Zero; nextWaypoint = 1; Spritesheet = texture; SpriteScale = 1f; SpritesheetRows = 1; if (texture != null) { SpritesheetColumns = texture.Width / texture.Height <= 1 ? 1 : texture.Width / texture.Height; } totalFrames = SpritesheetRows * SpritesheetColumns; animationCycles = 30; //Angle = (float)Math.Atan2(PosY - Path[nextWaypoint].Y, PosX - Path[nextWaypoint].X); //Angle = AnglesBetweenWaypoints[0]; //------------------------------------------------------fix //AngleOffset = (float)Math.PI; Origin = texture != null ? new Vector2(Width / 2, Height / 2) : Vector2.Zero; Alive = false; LifeDmg = 1; hpBarWidth = 25; spin = (float)(ParentMap.rnd.NextDouble() - 0.5f) * 0.08f; TowersTargetingThis = new List <Tower>(); CurrentSlowEffect = new float[2]; DmgHeadedThisWay = new List <KeyValuePair <uint, int> >(); ElemArmors = new GeneSpecs(); HpBarColor = new Color(0, 255, 0); }
public Wave(HexMap map) { ParentMap = map; ParentGame = map.ParentGame; Initialize(); }
public void Update(MouseState mouse, KeyboardState keyboard) { // AUTOMATED LEVEL SELECTOR.................................................................................................................................................! //LoadPlayerData(0); LoadMap(MapButtons[5]); if (CurrentGame.gameState != GameState.MapEditor) { CurrentGame.gameState = GameState.MapEditor; CurrentGame.HUD.MapEditorSpawnPoints = new List <Point>(); CurrentGame.HUD.MapEditorGoalPoints = new List <Point>(); CurrentGame.currentMap = new HexMap(ParentGame, new char[11, 21], new Point[1], new Point[1], new Player[] { new Player("map editor person") }); //-----------------------------------------------täällä !; CurrentGame.HUD.ParentMap = CurrentGame.currentMap; CurrentGame.currentMap.MapEditorTempWaves = new List <Wave>(); CurrentGame.HUD.EditorMapLoad(MapButtons[0]); } if (keyboard.IsKeyDown(Keys.Escape)) { menuState = MenuState.Main; } for (int r = 0; r < RootButtons.Length; r++) { RootButtons[r].Update(mouse, CurrentGame.prevMouse); if (RootButtons[r].State == ButnState.Released) { switch (r) { case 0: menuState = MenuState.NewGame; nameAlreadyExists = false; backspaceRefreshCounter = 0; nameInput = ""; break; case 1: menuState = MenuState.Continue; break; case 2: menuState = MenuState.Options; break; case 3: menuState = MenuState.MapEditor; break; case 4: ParentGame.Exit(); break; } } } if (menuState == MenuState.NewGame) { #region NAME INPUT & PLAYER FILE CREATION { if (keyboard.IsKeyUp(Keys.Back)) { backspaceRefreshCounter = 20; } foreach (Keys key in keyboard.GetPressedKeys()) { if ((byte)key > 8 && (byte)key < 48 && key != Keys.Space && key != Keys.Enter || (byte)key > 90) { continue; //unpractical exclusion of keys } if (key == Keys.Back) { if (backspaceRefreshCounter == 20 && nameInput.Length > 0) { nameInput = nameInput.Remove(nameInput.Length - 1, 1); } if (backspaceRefreshCounter == 0 && nameInput.Length > 0) { nameInput = nameInput.Remove(nameInput.Length - 1, 1); backspaceRefreshCounter = 4; } backspaceRefreshCounter -= 1; nameAlreadyExists = false; } else if (CurrentGame.prevKeyboard.IsKeyUp(key)) { if (key == Keys.Enter) { if (nameInput.Length <= 0) { return; } for (int i = 0; i < PlayerNames.Length; i++) { if (PlayerNames[i].Equals(nameInput, StringComparison.CurrentCultureIgnoreCase)) { nameAlreadyExists = true; return; } } using (StreamWriter sw = new StreamWriter(CurrentGame.SaveDir + nameInput + ".txt")) { Debug.WriteLine("Creating player file!"); sw.WriteLine("CompletedLevels: " + Environment.NewLine + "0"); sw.WriteLine("HighScores:\r\n0\r\n0\r\n0"); }; CurrentGame.players[0] = new Player(nameInput); //CurrentPlayerIndexes[0] = ParentGame.SaveDir + nameInput + ".txt"; CurrentPlayerIndexes[0] = 0; RefreshPlayerSaveData(); menuState = MenuState.MapSelection; } else if (nameInput.Length < 15) { nameAlreadyExists = false; if (key == Keys.Space) { nameInput += " "; } else if (!keyboard.IsKeyDown(Keys.LeftShift) && !keyboard.IsKeyDown(Keys.RightShift)) { nameInput += key.ToString().ToLower(); } else { nameInput += key.ToString(); } } } } } #endregion NewPlayerButtons[1].Text = nameInput; int width = (int)Font.MeasureString(nameInput).X; if (width > playerButtonWidth - padding * 2) { NewPlayerButtons[1].Width = width + padding * 2; } RootButtons[0].State = ButnState.Pressed; } else if (menuState == MenuState.Continue || menuState == MenuState.MapSelection) { for (int p = 0; p < PlayerButtons.Length; p++) { PlayerButtons[p].Update(mouse, CurrentGame.prevMouse); if (PlayerButtons[p].State == ButnState.Released) { LoadPlayerData(p); CurrentPlayerIndexes[0] = p; menuState = MenuState.MapSelection; } RootButtons[1].State = ButnState.Pressed; } } else if (menuState == MenuState.MapEditor) { for (int m = 0; m < MapButtons.Length; m++) { MapButtons[m].Update(mouse, CurrentGame.prevMouse); if (MapButtons[m].State == ButnState.Released) { CurrentGame.gameState = GameState.MapEditor; CurrentGame.HUD.MapEditorSpawnPoints = new List <Point>(); CurrentGame.HUD.MapEditorGoalPoints = new List <Point>(); CurrentGame.currentMap = new HexMap(ParentGame, new char[11, 21], new Point[1], new Point[1], new Player[] { new Player("map editor person") }); //-----------------------------------------------täällä !; CurrentGame.HUD.ParentMap = CurrentGame.currentMap; CurrentGame.currentMap.MapEditorTempWaves = new List <Wave>(); CurrentGame.HUD.EditorMapLoad(MapButtons[m]); } } for (int e = 0; e < MapEditorButtons.Length; e++) { MapEditorButtons[e].Update(mouse, CurrentGame.prevMouse); } //MapEditorButtons[0].State = ButnState.Released;//-------------------------------------------------------------------------------------------------------------------------------------------------------------------!!poista //ParentGame.HUD.inWaveEdit = true;//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------!!poista if (MapEditorButtons[0].State == ButnState.Released) { char[,] emptyLayout = new char[11, 21]; for (int dim1 = 0; dim1 < emptyLayout.GetLength(0); dim1++) { for (int dim2 = 0; dim2 < emptyLayout.GetLength(1); dim2++) { emptyLayout[dim1, dim2] = ' '; } } HexMap TempMap = new HexMap(ParentGame, emptyLayout, new Point[1], new Point[1], new Player[] { new Player("map editor person") }); //-----------------------------------------------täällä temp mappia ku static CoordToScrLoc puuttuu! CurrentGame.HUD.MapEditorSpawnPoints = new List <Point>(); CurrentGame.HUD.MapEditorGoalPoints = new List <Point>(); TempMap.MapEditorTempWaves = new List <Wave>(); TempMap.MapEditorTempWaves.Add(new Wave(TempMap)); TempMap.MapEditorTempWaves[0].TempGroups = new List <SpawnGroup>(); TempMap.MapEditorTempWaves[0].TempGroups.Add(new SpawnGroup()); CurrentGame.HUD.MapEditorResourceCells[0].Text = "0"; CurrentGame.HUD.MapEditorResourceCells[1].Text = "0"; CurrentGame.HUD.MapEditorResourceCells[2].Text = "0"; CurrentGame.HUD.MapNameBox.Text = ""; CurrentGame.currentMap = TempMap; CurrentGame.HUD.ParentMap = TempMap; CurrentGame.gameState = GameState.MapEditor; } //RootButtons[3].State = ButnState.Pressed; //--------------------------------------MAKE AS TOGGLE--------! } if (menuState == MenuState.MapSelection) { for (int m = 0; m < MapButtons.Length; m++) { MapButtons[m].Update(CurrentGame.mouse, CurrentGame.prevMouse); if (MapButtons[m].State == ButnState.Released) { HexMap TempMap = new HexMap(ParentGame, new char[11, 21], null, null, new Player[] { new Player("map editor person") }); //----------täällä temp mappia ku static CoordToScrLoc puuttuu! CurrentGame.currentMap = TempMap; LoadMap(MapButtons[m]); } } PlayerButtons[CurrentPlayerIndexes[0]].State = ButnState.Pressed; } #region OLD BUTTONSYSTEM /*for (int i = 0; i < ButtonBoundses.Length; i++) * { * if ((menuState == MenuState.Main || menuState == MenuState.NewGame) && i > 3) continue; // in Main and NewGame, ignore maps, options and player buttons * else if (menuState == MenuState.Continue && (i > 3 && i < 8)) continue; // in Continue, ignore maps and options * else if (menuState == MenuState.Options && ((i > 3 && i < 7) || i > 7)) continue; // in Options, ignore maps and players * else if (menuState == MenuState.MapSelection && (i < 4 || i > 4 + ParentGame.players[0].CompletedLevels)) continue; // in MapSelection, ignore main, option, player and incompleted level buttons * * if (ButtonBoundses[i].Contains(mouse.X, mouse.Y)) * { * if (mouse.LeftButton == ButtonState.Released && prevMouse.LeftButton == ButtonState.Pressed) * { * ButtonStates[i] = MenuButtonState.Released; * switch (i) * { * case 0: menuState = MenuState.NewGame; * nameAlreadyExists = false; * backspaceRefreshCounter = 0; * nameInput = ""; break; * case 1: menuState = MenuState.Continue; break; * case 2: menuState = MenuState.Options; break; * case 3: ParentGame.Exit(); break; * case 4: LoadMap("map1"); currentMap = 1; break; * case 5: LoadMap("map2"); currentMap = 2; break; * case 6: LoadMap("map3"); currentMap = 3; break; * case 7: break; //-----------------------------------Resolution! * default: LoadPlayerData(i - 8); * CurrentPlayersFilePaths[0] = PlayerFilePaths[i - 8]; * menuState = MenuState.MapSelection; * break; * } * } * else if (mouse.LeftButton == ButtonState.Pressed) ButtonStates[i] = MenuButtonState.Pressed; * else ButtonStates[i] = MenuButtonState.Hovered; * } * else ButtonStates[i] = MenuButtonState.Passive; * }*/ #endregion prevMouse = mouse; }
void LoadMap(Button mapButton) { //currentMap = byte.Parse(mapName.Substring(mapName.Length -1, 1)); //-------------------------------------------------risky. if (File.Exists(CurrentGame.MapDir + mapButton.Text + ".txt")) { //try //{ string[] read; HexMap loadedMap = new HexMap(ParentGame, new char[1, 1], null, null, CurrentGame.players); char[,] layout = new char[11, 21]; List <Point> spawnPoints = new List <Point>(); List <Point> goalPoints = new List <Point>(); List <Wave> waves = new List <Wave>(); byte initLife; int initEnergy; int[] initGenePoints; byte[] availableTowers = new byte[6]; List <Tower> initTowers = new List <Tower>(); using (StreamReader reader = new StreamReader(CurrentGame.MapDir + mapButton.Text + ".txt")) { //for (int i = 0; i < 12; i++) // Debug.WriteLine(reader.ReadLine()); for (int row = 0; row < 11; row++) { for (int col = 0; col < 21; col++) { int ascii = reader.Peek(); if (ascii != 32 && ascii != 13 && ascii != 39 && ascii != 46 && ascii != 48) { reader.Peek(); } while (reader.Peek() < 32) { reader.Read(); //run through whitespace characters, except space (32), which is last of the whitespace in the ascii table } layout[row, col] = (char)reader.Read(); if ((int)layout[row, col] >= 49 && (int)layout[row, col] <= 57) { spawnPoints.Add(new Point(col, row)); } else if ((int)layout[row, col] >= 97 && (int)layout[row, col] <= 122) { goalPoints.Add(new Point(col, row)); } else { for (int i = 0; i < HexMap.ExampleTowers.Length; i++) { if (ascii == (int)HexMap.ExampleTowers[i].Symbol) { Tower tempTower = Tower.Clone(HexMap.ExampleTowers[i]); //-------------------------------------ADD MAPCOORD---------------------------------- tavallaan tehty mut tower-olemassaoloa pitäs hienontaa tempTower.ParentMap = CurrentGame.currentMap; //---------------------------------------------------------------------- mukaanlukien nää ihme initit (tää koska MapCoordToScrLoc ei static!) tempTower.MapCoord = new Point(col, row); //tempTower.buildTimer = 0; //tempTower.buildFinishedCounter = 0; initTowers.Add(tempTower); } } } } } reader.ReadLine(); reader.ReadLine(); read = reader.ReadLine().Split(':', ' '); for (int i = 0; i < availableTowers.Length; i++) { byte.TryParse(read[i + 3], out availableTowers[i]); } initLife = byte.Parse(reader.ReadLine().Split(':')[1]); initEnergy = int.Parse(reader.ReadLine().Split(':')[1]); read = reader.ReadLine().Split(':', ','); initGenePoints = new int[] { int.Parse(read[1]), int.Parse(read[2]), int.Parse(read[3]) }; loadedMap = new HexMap(ParentGame, layout, spawnPoints.ToArray(), goalPoints.ToArray(), CurrentGame.players); CurrentGame.currentMap = loadedMap; CurrentGame.HUD.ParentMap = loadedMap; for (int i = 0; i < initTowers.Count; i++) { initTowers[i].ParentMap = loadedMap; CurrentGame.players[0].Towers.Add(Tower.Clone(initTowers[i])); CurrentGame.players[0].Towers[i].MapCoord = initTowers[i].MapCoord; } loadedMap.InitTowers = initTowers; while (!reader.ReadLine().Contains("Creamt")) { ; } for (int w = 0; reader.Peek() == 87; w++) //wave lines begin with a W (87) { waves.Add(new Wave(loadedMap)); waves[w].TempGroups = new List <SpawnGroup>(); reader.ReadLine(); while (reader.Peek() == 9) //group lines begin with a tab (9) { read = reader.ReadLine().Split(new char[] { '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); waves[w].TempGroups.Add(new SpawnGroup(int.Parse(read[0]), new Creature(read[1], read[2], loadedMap, read[3], int.Parse(read[4]) - 1, (int)(char.Parse(read[5])) - 97, //Goalpoint int.Parse(read[6]), //(Element)Enum.Parse(typeof(Element), read[7], true), float.Parse(read[7], System.Globalization.NumberFormatInfo.InvariantInfo), new GeneSpecs(), //TÄHÄ VÄLIIN ELEMS byte.Parse(read[8]), int.Parse(read[9]), 1f), // SCALE HARDCODED----------------------------------------------------------------- int.Parse(read[13]), int.Parse(read[14]))); } waves[w].Groups = waves[w].TempGroups.ToArray(); waves[w].Initialize(); } } #region OLD LOAD /*using (StreamReader reader = new StreamReader(filePath)) * { * * //--------Map size------------------------------------------ * for (int i = 0; i < 8; i++) * reader.ReadLine(); * columns = reader.ReadLine().Length; * while (reader.ReadLine() != "") * rows++; * layout = new char[rows + 1, columns]; // Y,X -----------!!!!! * * reader.DiscardBufferedData(); * reader.BaseStream.Position = 0; * //--------Map layout---------------------------------------- * for (int i = 0; i < 8; i++) * reader.ReadLine(); * for (int row = 0; row <= layout.GetUpperBound(0); row++) * { for (int col = 0; col <= layout.GetUpperBound(1); col++) * { * while (reader.Peek() < 32) reader.Read(); //run through whitespace characters, except space (32), which is the last of the whitespace in the ascii table * int ascii = reader.Peek(); * switch (ascii) * { * case 32: layout[row, col] = 0; break; // 32 = space -> empty (3) * case 39: layout[row, col] = 3; break; // 39 = ' -> path (1) * case 46: layout[row, col] = 3; break; // 46 = . -> path (1) (odd columns) * case 48: layout[row, col] = 1; break; // 48 = 0 -> wall (0) * case 49: layout[row, col] = 6; break; // 49 = 1 -> tower type 1 (6) * } * reader.Read(); * } * } * * * //--------Initial resources-------------------------------- * while (!reader.ReadLine().Contains("Life/Energy/Genes")) ; * initLife = byte.Parse(reader.ReadLine()); * initEnergy = int.Parse(reader.ReadLine()); * initUpgPoints = int.Parse(reader.ReadLine()); * * //--------Spawnpoints-------------------------------------- * while (!reader.ReadLine().Contains("SpawnPoints")) ; * read = reader.ReadLine().Split('\t'); * while (read.Length > 1) * { * spawnPoints.Add(new Point(int.Parse(read[0]), int.Parse(read[1]))); * read = reader.ReadLine().Split('\t'); * } * * //--------Goalpoints and openingtimes--------------------- * while (!reader.ReadLine().Contains("GoalPoints")) ; * read = reader.ReadLine().Split('\t'); * while (read.Length > 1) * { * goalPoints.Add(new Point(int.Parse(read[0]), int.Parse(read[1]))); * goalPointOpeningTimes.Add(int.Parse(read[2])); * read = reader.ReadLine().Split('\t'); * } * * loadedMap = new HexMap(ParentGame, layout, spawnPoints.ToArray(), goalPoints.ToArray(), goalPointOpeningTimes.ToArray(), ParentGame.players); * * while (!reader.ReadLine().Contains("Wave 1")) ; * * bool newWaveLine; * bool newSpawnGroupLine; * do * { * read = reader.ReadLine().Split(new string[] { "\t", " " }, StringSplitOptions.RemoveEmptyEntries); * //string[] av = read[5].Split(','); * spawnGroups.Add(new SpawnGroup(int.Parse(read[0]), //Number of creatures in group * new Creature(read[1], //Type * read[2], //Name * loadedMap, //Map * ParentGame.Content.Load<Texture2D>("Creatures\\" + read[3]), //Texture * int.Parse(read[4]), //SpawnPoint * Array.ConvertAll(read[5].Split(','), int.Parse), //GoalPoints----------COOL SH*T * int.Parse(read[6]), //InitHp * float.Parse(read[7]), //RRes * float.Parse(read[8]), //GRes * float.Parse(read[9]), //BRes * float.Parse(read[10], NumberFormatInfo.InvariantInfo), //DefSpd * float.Parse(read[11], NumberFormatInfo.InvariantInfo), //CellDmg * byte.Parse(read[12]), //LifeDmg * int.Parse(read[13]), //GeneBounty * 1f, // SCALE HARDCODED----------------------------------------------------------------- * read[3]), //TextureName -------------------------------------------not cool * int.Parse(read[14]), //Spawn rate * int.Parse(read[15])));//Wave duration * //Check next line * newWaveLine = reader.Peek() == 87; //87 = W (as in Wave) * newSpawnGroupLine = reader.Peek() == 9; //9 = tab (spawnGroup lines begin with a tab) * if (newWaveLine) * { * waves.Add(new Wave(loadedMap, spawnGroups.ToArray())); * spawnGroups.Clear(); * reader.ReadLine(); * } * else if (newSpawnGroupLine) * { * continue; * } * else waves.Add(new Wave(loadedMap, spawnGroups.ToArray())); * } while (newWaveLine || newSpawnGroupLine); * * loadedMap.Waves = waves.ToArray();*/ #endregion loadedMap.PlayerInitLife = initLife; loadedMap.PlayerInitEnergy = initEnergy; loadedMap.PlayerInitGenePoints = initGenePoints; loadedMap.Waves = waves.ToArray(); loadedMap.Pathfinder.InitializeTiles(); //-----------------------hmmmmmmmmm loadedMap.SpawnPoints = spawnPoints.ToArray(); loadedMap.GoalPoints = goalPoints.ToArray(); loadedMap.AvailableTowers = availableTowers; loadedMap.ResetMap(); CurrentGame.gameState = GameState.InGame; //} //catch (Exception) //{ // mapButton.Text += " (bad file!)"; // CurrentGame.gameState = GameState.MainMenu; //} } else { Debug.WriteLine("\"" + mapButton.Text + "\" doesn't exist"); } }