/// <summary> /// Crates the name selection tool /// </summary> void CreateNamePinWheel(int myTopLeftX, int myTopLeftY, int myMaxLength, int myOddColumnHeight, int myPlayer) { int middleRow = myOddColumnHeight / 2; //Creating the spinning name selector for (int x = 0; x < myMaxLength; x++) { for (int y = 0; y < myOddColumnHeight; y++) { Entity letter = new Entity(9, GameState.PlayerLobby); SpriteSheetComponent letterSprite; if (y == middleRow) { letterSprite = new SpriteSheetComponent(new Rectangle(myTopLeftX + (x * 30), myTopLeftY + y * 40, 40, 50), alphabetTextureFramed); } else { letterSprite = new SpriteSheetComponent(new Rectangle(myTopLeftX + (x * 30), myTopLeftY + y * 40, 20, 20), alphabetTextureFramed); } letterSprite.Visible = false; playerLobbyStateSprites[myPlayer][PlayerLobbyState.Name].Add(letterSprite); playerLobbyStateSprites[myPlayer][PlayerLobbyState.Ready].Add(letterSprite); playerNameLetterSprites[myPlayer][x, y] = letterSprite; letter.AddComponent(letterSprite); EntityManager.AddEntity(letter); } } }
public MapProcessor(string filename) { // catch IO exceptions try { input = new StreamReader(filename); // read each line string line = ""; // initialize 2D array // = new char[rows, columns]; int lineCount = 0; // run this code for each line in the file, one line at a time while ((line = input.ReadLine()) != null) { string noSpaces = ""; for (int i = 0; i < line.Length; i++) // might be removed depending on format of map { if (line[i] != ' ') { noSpaces += line[i]; } } columns = noSpaces.Length; for (int c = 0; c < noSpaces.Length; c++) // could also be used with line { Entity tile = new Entity(5, GameState.Ingame); SpriteSheetComponent sprite = new SpriteSheetComponent( new Rectangle((c * tileWidth) + (c * tileSpacing), (lineCount * tileHeight) + (lineCount * tileSpacing), tileWidth, tileHeight), Game1.tileSheet); sprite.OffsetRatio = (Vector2.Zero); tile.AddComponent(sprite); //handle map editor input switch (noSpaces[c]) { case 'l': sprite.setCurrentRow(2); // wall stops movement break; case 't': sprite.setCurrentRow(1); //stops and damages break; case 'f': sprite.setCurrentRow(0); // just display break; case 's': // for enemy spawns enemySpawnLocations.Add(new Vector2((c * tileWidth) + (c * tileSpacing), (lineCount * tileHeight) + (lineCount * tileSpacing))); break; case 'p': // for player spawns playerSpawnLocations.Add(new Vector2((c * tileWidth) + (c * tileSpacing), (lineCount * tileHeight) + (lineCount * tileSpacing))); break; default: sprite.setCurrentRow(0); break; } tile.AddComponent(new TileComponent(noSpaces[c])); EntityManager.AddEntity(tile); // adds character to tiles list } // for lineCount++; } // while rows = lineCount; } catch (FileNotFoundException fnfe) { Console.WriteLine(filename + " was not found." + fnfe.Message); return; } finally { if (input != null) { input.Close(); } } }