Esempio n. 1
0
 public Goal(Texture2D texture, int x, int y, int width, int height, Game1 game1, GameScreen gs)
 {
     game        = game1;
     ls          = new LevelScreen(game);
     theGame     = game;
     save        = new SaveInfo();
     state       = new GameState(game);
     rect        = new Rectangle(x, y, width, height);
     xPostion    = x;
     yPostion    = y;
     this.width  = width;
     this.height = height;
     goalTexture = texture;
     gameScreen  = gs;
 }
Esempio n. 2
0
 //Constructor
 public OptionScreen(Game1 game1)
 {
     game         = game1;
     gameState    = new GameState(game);                     // creates new gamestate object and assigns it to gameState
     font1        = game.Content.Load <SpriteFont>("Font1"); //loads Font1
     back         = game.Content.Load <Texture2D>("back");
     soundOn1     = game.Content.Load <Texture2D>("soundOn1");
     soundOn2     = game.Content.Load <Texture2D>("soundOn2");
     soundOff1    = game.Content.Load <Texture2D>("soundOff1");
     soundOff2    = game.Content.Load <Texture2D>("soundOff2");
     levelUnlock1 = game.Content.Load <Texture2D>("levelUnlock1");
     levelUnlock2 = game.Content.Load <Texture2D>("levelUnlock2");
     resetHS1     = game.Content.Load <Texture2D>("resetHS1");
     resetHS2     = game.Content.Load <Texture2D>("resetHS2");
     info         = new SaveInfo();
     count        = 0;
 }
Esempio n. 3
0
        //Constructor
        public LevelScreen(Game1 game1)
        {
            save      = new SaveInfo();
            game      = game1;
            gameState = new GameState(game);                     // creates new gamestate object and assigns it to gameState
            font1     = game.Content.Load <SpriteFont>("Font1"); // loads Font1
            lastState = Keyboard.GetState();
            levels    = save.ReadUnlock();

            back = game.Content.Load <Texture2D>("back");
            lvl1 = game.Content.Load <Texture2D>("level1");
            lvl2 = game.Content.Load <Texture2D>("level2");
            lvl3 = game.Content.Load <Texture2D>("level3");
            lvl4 = game.Content.Load <Texture2D>("level4");
            lvl5 = game.Content.Load <Texture2D>("level5");
            lvl6 = game.Content.Load <Texture2D>("level6");

            currentLvl = "level1.txt";
            nextLvl    = "level2.txt";
        }
Esempio n. 4
0
        //basic game screen constructor
        public GameScreen(Game1 game)
        {
            this.game = game;
            gameState = new GameState(game);                     //creates new gameState object and assigns it to game screen
            font1     = game.Content.Load <SpriteFont>("Font1"); //loads Font1

            drawList          = new List <GameObject>();
            enemyList         = new List <Enemy>();
            timeSinceLastMove = 0;
            enemyPathList     = new List <EnemyPathEnd>();
            colList           = new List <Rectangle>();
            gemsList          = new List <Gold>();
            bulletList        = new List <Bullet>();
            platformList      = new List <Platform>();

            SaveInfo info = new SaveInfo();
            Dictionary <string, int> highscoreDict = info.ReadHighScore();

            highScore = highscoreDict[levelName];
            // reading in the file
            StreamReader input = null;

            input = new StreamReader(levelFile); // this will load in whatever level the player picks
            string text = "";

            level = input.ReadLine();            // brings in the level name
            text  = input.ReadLine();            // brings in the high score as a string
            //int.TryParse(text, out highScore); // now its an int
            text = input.ReadLine();             // brings in the best time as a string
            double.TryParse(text, out bestTime); // now its a double

            text = input.ReadLine();             // read in width
            int.TryParse(text, out gameWidth);

            text = input.ReadLine(); // read in height
            int.TryParse(text, out gameHeight);

            int xPos = game.screenWidth / gameWidth;

            //int yPos = game.screenHeight / gameHeight;

            grappleableObjectList = new List <GameObject>();
            int y = -gameHeight + 8;

            while ((text = input.ReadLine()) != null)
            {
                int      x         = 0;
                string[] gamePiece = text.Split();
                foreach (string piece in gamePiece)
                {
                    if (piece == "w")
                    {
                        Platform block = new Platform(game.wallSprite, xPos * x + x, xPos * y + y, xPos, xPos);
                        drawList.Add(block);
                        colList.Add(block.rect);
                        platformList.Add(block);
                        grappleableObjectList.Add(block);
                    }
                    else if (piece == "c")
                    {
                        player = new Player(game.playerSprite, xPos * x + x, xPos * y + y, game.playerSprite.Width * 4, game.playerSprite.Height * 4, colList, game, this, enemy, block);
                    }
                    else if (piece == "f")
                    {
                        endGoal = new Goal(game.goalSprite, xPos * x + x, xPos * y + y, xPos, xPos, game, this);
                    }
                    else if (piece == "g")
                    {
                        gem = new Gold(game.gemSprite, xPos * x + 25, xPos * y + 35, game.gemSprite.Width, game.gemSprite.Height, this, game.coinS);
                        gemsList.Add(gem);
                    }
                    else if (piece == "e")
                    {
                        enemy = new Enemy(game.enemySprite, xPos * x, xPos * y + y, game.enemySprite.Width, game.enemySprite.Height, game, this, true, bulletList);
                        enemyList.Add(enemy);
                        bulletList.Add(enemy.MyBullet);
                    }
                    else if (piece == "t")
                    {
                        epe = new EnemyPathEnd(xPos * x + x, xPos * y + y, game.wallSprite.Width, 1, true, game);
                        enemyPathList.Add(epe);
                    }

                    // will add code later for all the other objects that are going to be shown

                    x++;
                }
                y++;
            }
            input.Close();
            input.Close();
            y--;
            lavaRect = new Rectangle(0, game.screenHeight - game.lavaBack.Height, game.screenWidth, game.lavaBack.Height);
        } // is not updated to current