private void CreateDurationEvent(String state, float startTime, float endTime) { state = Regex.Replace(state, " ", ""); String enemyData = state.Substring(0, 1); String movementData = state.Substring(1, 2); String eventData = state.Substring(3, 1); SortedDictionary <string, int> settings = new SortedDictionary <string, int>(); MatchCollection matches = Regex.Matches(state, @"([A-Z])(\d+)"); foreach (Match match in matches) { String letter = match.Groups[1].Value; String valueString = match.Groups[2].Value; int value = Convert.ToInt32(valueString); settings.Add(letter, value); } //String enemy = SaveLoadStringLibrary.GetEnemyTypeFromSaveString(enemyData); String enemy = enemyData; EnemyType identifier = DataConversionLibrary.GetEnemyEnumFromString(enemy); Movement movement = DataConversionLibrary.GetMovementEnumFromString(movementData); switch (eventData) { case "E": { int density = settings["D"]; LevelEvent lvEv = new EvenSwarm(Game, player, spriteSheet, this, identifier, 1000 * startTime, 1000 * (endTime - startTime), density); SetMovement(lvEv, movement); untriggeredEvents.Add(lvEv); break; } case "G": { int startDensity = settings["S"]; int peakDensity = settings["P"]; int peakTime = settings["T"]; LevelEvent lvEv = new GradientSwarm(Game, player, spriteSheet, this, identifier, 1000 * startTime, 1000 * (endTime - startTime), peakTime, startDensity, peakDensity); SetMovement(lvEv, movement); untriggeredEvents.Add(lvEv); break; } } }
private void CreatePointEvent(String state, float pos, float time) { //To prevent enemies at position 0 from being removed if (pos == 0) { pos = 1; } // String enemyData = state.Substring(0, 1); String movementData = state.Substring(1, 2); String eventData = state.Substring(3, 1); SortedDictionary <string, int> settings = new SortedDictionary <string, int>(); MatchCollection matches = Regex.Matches(state, @"([XYWHD])(\d+)"); foreach (Match match in matches) { String letter = match.Groups[1].Value; String valueString = match.Groups[2].Value; int value = Convert.ToInt32(valueString); settings.Add(letter, value); } //String enemy = SaveLoadStringLibrary.GetEnemyTypeFromSaveString(enemyData); String enemy = enemyData; EnemyType identifier = DataConversionLibrary.GetEnemyEnumFromString(enemy); Movement movement = DataConversionLibrary.GetMovementEnumFromString(movementData); #region switchEventData switch (eventData) { case "0": { LevelEvent lvEv = new SingleEnemy(Game, player, spriteSheet, this, identifier, time, pos); SetMovement(lvEv, movement); untriggeredEvents.Add(lvEv); break; } // The horizontal event forces a horizontal movement case "h": { int direction = settings["D"]; int yPos = settings["Y"]; LevelEvent lvEv = new SingleHorizontalEnemy(Game, player, spriteSheet, this, identifier, time, direction, yPos); if (direction == 1) { SetMovement(lvEv, Movement.RightHorizontal); } else { SetMovement(lvEv, Movement.LeftHorizontal); } untriggeredEvents.Add(lvEv); break; } case "l": { int width = settings["W"]; int xspacing = settings["X"]; LevelEvent lvEv = new LineFormation(Game, player, spriteSheet, this, identifier, time, width, xspacing, pos); SetMovement(lvEv, movement); untriggeredEvents.Add(lvEv); break; } case "s": { int width = settings["W"]; int xspacing = settings["X"]; int height = settings["H"]; int yspacing = settings["Y"]; LevelEvent lvEv = new SquareFormation(Game, player, spriteSheet, this, identifier, time, width, height, xspacing, yspacing, pos); SetMovement(lvEv, movement); untriggeredEvents.Add(lvEv); break; } case "t": { int height = settings["H"]; int xspacing = settings["X"]; int yspacing = settings["Y"]; LevelEvent lvEv = new VFormation(Game, player, spriteSheet, this, identifier, time, height, xspacing, yspacing, pos); SetMovement(lvEv, movement); untriggeredEvents.Add(lvEv); break; } } #endregion }
protected void SetEnemy(String enemyString) { enemyType = DataConversionLibrary.GetEnemyEnumFromString(enemyString); }