public Level(string fileName, Game1 game) { this.game = game; builder = new LevelBuilder(this); player = builder.Build(fileName); collision = new CollisionDetection(player, game); }
public Camera(Viewport viewport, Game1 game) { this.viewport = viewport; this.game = game; Zoom = 2f; CenterScreen = new Vector2(viewport.Width / 2, viewport.Height / 2); }
public PauseMenuGameState(Game1 game) { this.game = game; menu = new UniversalGUI(game); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new IndexMenuCommand(), "Monster Index")); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new MonsterMenuCommand(game), "Monsters")); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new BagMenuCommand(), "Bag")); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new GearMenuCommand(), "Gear")); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new CharacterMenuCommand(), "Character")); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new SaveMenuCommand(), "Save")); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new OptionsMenuCommand(), "Options")); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new ExitMenuCommand(game), "Exit")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new IndexMenuCommand(), "Monster Index")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new MonsterMenuCommand(game), "Monsters")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new BagMenuCommand(), "Bag")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new GearMenuCommand(), "Gear")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new CharacterMenuCommand(), "Character")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new SaveMenuCommand(), "Save")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new OptionsMenuCommand(), "Options")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new ExitMenuCommand(game), "Exit")); menu.currentCommand = menu.columnOne[0].Key; menu.Column1StartingPosition.X = game.level.player.position.X + 90; menu.Column1StartingPosition.Y = game.level.player.position.Y - 110; menu.arrowStartingPosition.X = game.level.player.position.X + 80; menu.arrowStartingPosition.Y = game.level.player.position.Y - 110; game.keyboard = new MenuController(menu); menu.graphicHolder.Add(new KeyValuePair<Texture2D, Rectangle>(Game1.gameContent.Load<Texture2D>("GUI Sprites/menuBorder"), new Rectangle((int)game.level.player.position.X + 70, (int)game.level.player.position.Y - 120, 130, 200))); }
public CollisionDetection(Player player, Game1 game) { this.game = game; grassResponse = new GrassCollisionResponse(game); tileResponse = new TileCollisionResponse(game); ledgeResponse = new LedgeCollisionResponse(game); buildingResponse = new BuildingCollisionResponse(game); enemyResponse = new EnemyCollisionResponse(game); exitResponse = new ExitCollisionResponse(game); }
public KeyboardController(Player currentPlayer, Game1 game) { player = currentPlayer; commandLibrary = new Dictionary<Keys, ICommands>(); commandLibrary.Add(Keys.W, currentCommand = new UpCommand(player)); commandLibrary.Add(Keys.A, currentCommand = new LeftCommand(player)); commandLibrary.Add(Keys.S, currentCommand = new DownCommand(player)); commandLibrary.Add(Keys.D, currentCommand = new RightCommand(player)); commandLibrary.Add(Keys.Space, currentCommand = new InteractCommand(player)); commandLibrary.Add(Keys.Enter, currentCommand = new PauseCommand(game)); }
public UniversalGUI(Game1 game) { this.game = game; columnOne = new List<KeyValuePair<ICommands, string>>(); columnTwo = new List<KeyValuePair<ICommands, string>>(); defaultOne = new List<KeyValuePair<ICommands, string>>(); defaultTwo = new List<KeyValuePair<ICommands, string>>(); graphicHolder = new List<KeyValuePair<Texture2D, Rectangle>>(); font = Game1.gameContent.Load<SpriteFont>("Fonts/guiFont"); factory = new SpriteFactory(); arrow = factory.builder(SpriteFactory.sprites.arrow); }
public EncounterGameState(Game1 game) { font = Game1.gameContent.Load<SpriteFont>("Fonts/guiFont"); this.game = game; game.background = Color.White; menu = new UniversalGUI(game); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new FightMenuCommand(this, game), "FIGHT")); menu.columnOne.Add(new KeyValuePair<ICommands, string>(new MonsterMenuCommand(game), "MONSTERS")); menu.columnTwo.Add(new KeyValuePair<ICommands, string>(new BagMenuCommand(), "BAG")); menu.columnTwo.Add(new KeyValuePair<ICommands, string>(new RunAwayCommand(game), "RUN")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new FightMenuCommand(this, game), "FIGHT")); menu.defaultOne.Add(new KeyValuePair<ICommands, string>(new MonsterMenuCommand(game), "MONSTERS")); menu.defaultTwo.Add(new KeyValuePair<ICommands, string>(new BagMenuCommand(), "BAG")); menu.defaultTwo.Add(new KeyValuePair<ICommands, string>(new RunAwayCommand(game), "RUN")); menu.currentCommand = menu.columnOne[0].Key; menu.Column1StartingPosition = new Vector2(550, 350); menu.Column2StartingPosition = new Vector2(650, 350); menu.arrowStartingPosition = new Vector2(540, 350); menu.CameraPointer = new Vector2(530, 270); game.keyboard = new EncounterController(menu); menu.graphicHolder.Add(new KeyValuePair<Texture2D, Rectangle>(Game1.gameContent.Load<Texture2D>("GUI Sprites/encounterWindow"), new Rectangle(330, 342, 400, 47))); menu.graphicHolder.Add(new KeyValuePair<Texture2D, Rectangle>(Game1.gameContent.Load<Texture2D>("GUI Sprites/encounterSelectWindow"), new Rectangle(530, 342, 200, 47))); faderTexture = new Texture2D(game.GraphicsDevice, 1, 1); var colors = new Color[] { Color.White }; faderTexture.SetData<Color>(colors); faderStart = true; dmg = new Damage(); enemyMon = game.level.player.monsterBuilder.monsterList["Pikachu"]; //enemyMon = new Monster("Pikachu", "Electric", 25, 25, 25, 25, 25, 25, "MonsterSprites/jigglypuff"); }
public ExitCollisionResponse(Game1 game) { this.game = game; }
public BuildingCollisionResponse(Game1 game) { this.game = game; }
public FightMenuCommand(EncounterGameState enc, Game1 game) { this.game = game; this.enc = enc; }
public RunAwayCommand(Game1 game) { this.game = game; }
public Player Build(string fileName) { float xCoord = 0, yCoord = 0; StreamReader sr; sr = File.OpenText(Game1.GetInstance().Content.RootDirectory + "\\" + fileName); string line; int reference = 0; // LEVEL DESTINATIONS int currDest = 0; List <string> destinations = new List <string>(); // LEVEL TILES List <TileFactory.TileType> tileChoices = new List <TileFactory.TileType>(); tileChoices.Add(TileFactory.TileType.grass); tileChoices.Add(TileFactory.TileType.pokePlainFloor); int tileNumber = 0; // LEVEL DATA line = sr.ReadLine(); string[] initialWords = line.Split(','); try { tileNumber = Int32.Parse(initialWords[0]); } catch { } for (int i = 0; i < initialWords.Length; i++) { if (initialWords[i].Contains("Levels")) { destinations.Add(initialWords[i]); } } // MAIN LEVEL while ((line = sr.ReadLine()) != null) { xCoord = 0; string[] words = line.Split(','); for (int i = 0; i < words.Length; i++) { if (words[i].Length > 1) { try { string tmp = words[i].Remove(1); reference = Int32.Parse(words[i][1].ToString()); words[i] = tmp; } catch { // exception here } } if (xCoord % 32 == 0 && yCoord % 32 == 0) { Tile tile = tileFactory.builder(tileChoices[tileNumber], new Vector2(xCoord, yCoord)); level.levelBackground.Add(tile); } if (words[i] == "P") { player = new Player(new Vector2(xCoord, yCoord)); } if (tileDictionary.ContainsKey(words[i])) { Tile tile = tileFactory.builder(tileDictionary[words[i]], new Vector2(xCoord, yCoord)); if (words[i] == "0" || words[i] == "q") { tile.collision = false; } if (words[i] == "q") { tile.position.X += 8f; tile.position.Y += 4f; } if (words[i] == "p") { tile.sign = true; tile.signTex = factory.builder(SpriteFactory.sprites.instructions); } level.levelTiles.Add(tile); } if (grassDictionary.ContainsKey(words[i])) { Grass grass = grassFactory.builder(grassDictionary[words[i]], new Vector2(xCoord, yCoord)); level.levelGrass.Add(grass); } if (ledgeDictionary.ContainsKey(words[i])) { Ledge ledge = ledgeFactory.builder(ledgeDictionary[words[i]], new Vector2(xCoord, yCoord)); level.levelLedges.Add(ledge); } if (buildingDictionary.ContainsKey(words[i])) { Building building = buildingFactory.builder(buildingDictionary[words[i]], new Vector2(xCoord, yCoord)); if (words[i] == "I") { building.isDoor = true; building.destination = destinations[currDest]; building.source = fileName; currDest++; } level.levelBuildings.Add(building); } if (exitDictionary.ContainsKey(words[i])) { Exit exit = new Exit(factory.builder(exitDictionary[words[i]]), new Vector2(xCoord, yCoord)); exit.destination = destinations[currDest]; currDest++; level.levelExits.Add(exit); } if (enemyDictionary.ContainsKey(words[i])) { Enemy enemy = enemyFactory.builder(enemyDictionary[words[i]], new Vector2(xCoord, yCoord), reference); level.levelEnemies.Add(enemy); } xCoord += spacingIncrement; } yCoord += spacingIncrement; } return(player); }
public PlayingGameState(Game1 game) { this.game = game; game.background = Color.Black; game.keyboard = new KeyboardController(game.level.player, game); }
public PauseCommand(Game1 game) { this.game = game; }
public EnemyCollisionResponse(Game1 game) { this.game = game; }
static void Main() { using (var game = new Game1()) game.Run(); }
public LedgeCollisionResponse(Game1 game) { this.game = game; }
public TileCollisionResponse(Game1 game) { this.game = game; }
public GrassCollisionResponse(Game1 game) { rnd = new Random(); this.game = game; }