Esempio n. 1
0
        public AllGui(Camera cam, MainPlayer will, Texture2D hud, Texture2D trans, Texture2D charactersForHud
                                                                   , Texture2D titleScreen, Texture2D menuScreen, Texture2D life
                                                                   , Texture2D selectionScreen, Texture2D playerMenu,Texture2D transBack)
        {
            //initiate the camera and the position, place texture and have title screen and menu
            this.life = life;
            this.cam = cam;
            this.titleScreen = titleScreen;
            this.trans = trans;
            this.characters = charactersForHud;
            this.playerGui = hud;
            this.menuStuff = menuScreen;
            this.selectionScreen = selectionScreen;
            this.playerMenu = playerMenu;
            this.transBack = transBack;

            //This is the source rectangle to do the transformation animations
            sourceRect = new Rectangle(0, 0, 71 * 2, 71 * 2);

            //These lines set up the images that are to be drawn on the selection screen
            pressEnterTextSource = new Rectangle(6, 10, 420, 30);
            loadSaveBoxSource = new Rectangle(261, 50, 728, 192);
            loadSaveBox2Source = new Rectangle(261, 255, 728, 192);
            fingerSource = new Rectangle(18, 320, 48, 40);
            newGameSource = new Rectangle(18, 52, 172, 48);
            loadGameSource = new Rectangle(18, 112, 192, 48);
            optionsSource = new Rectangle(18, 241, 172, 48);
            testRoomSource = new Rectangle(18, 176, 192, 48);
        }
Esempio n. 2
0
        //This tests to see if the sprite is on this sprite;
        public bool onThis(MainPlayer player)
        {
            //Players collision info
            float pX = player.footArea.X;
            float pY = player.footArea.Y;
            float pWidth = player.footArea.Width;
            float pHeight = player.footArea.Height;

            //this info
            float tX = this.destRect.X;
            float tY = this.destRect.Y;
            float tWidth = this.destRect.Width;
            float tHeight = this.destRect.Height;

            //returns if the player is touching this square revealing he is "techniqually" on this.
            return ((tX <= pX && pX <= (tX + tWidth) || (tX <= (pX + pWidth) && (pX + pWidth) <= (tX + tWidth))) &&
               ((tY <= pY && pY <= (tY + tHeight)) || (tY <= (pY + pHeight) && (pY + pHeight) <= (tY + tHeight)))) ;
        }
Esempio n. 3
0
        //The update loop that gets called constantly
        public int update(GameTime time, int state, char characterChange, MainPlayer player, KeyboardState currentKey, KeyboardState prevKey)
        {
            this.state = state;
            //check to see if the character has different hp
            //add additional items if the exist,
            //see if we are in the titlescreen
            //update to the according states
            //if game playing update
            this.maxHealth = player.maxHealth;
            this.maxMana = player.maxMana;
            this.health = player.health;
            this.mana = player.mana;
            this.playerID = player.playerID;

            //This updates the corresponding GUI/HUD depending on the right
            //state
            switch (state)
            {

                //This is for working on the title screen
                case 0:
                    if (prevKey.IsKeyDown(Keys.Enter) && currentKey.IsKeyUp(Keys.Enter))
                        state = 1;

                    animationTimer += time.ElapsedGameTime.Milliseconds;
                    flashingText += time.ElapsedGameTime.Milliseconds;

                    if (animationTimer > 50)
                    {
                        animateSprite();
                        animationTimer = 0;
                    }

                    if (flashingText > 300 && textOn)
                    {
                        textOn = false;
                        flashingText = 0f;

                    }
                    else if (flashingText > 100 && !textOn)
                    {
                        textOn = true;
                        flashingText = 0f;
                    }
                    break;

                //This is for loading,starting a new game or going to the test room
                case 1:

                    if (prevKey.IsKeyUp(Keys.Up) && currentKey.IsKeyDown(Keys.Up))
                    {
                        fingerPositionY -= 60;
                        if (fingerPositionY < 0)
                            fingerPositionY = 180;
                        fingerPositionY = fingerPositionY % 240;
                        sounds.playSound(0);
                    }

                    if (prevKey.IsKeyUp(Keys.Down) && currentKey.IsKeyDown(Keys.Down))
                    {

                        fingerPositionY += 60;
                        fingerPositionY = fingerPositionY % 240;
                        sounds.playSound(0);
                    }
                    if (prevKey.IsKeyDown(Keys.Enter) && currentKey.IsKeyUp(Keys.Enter))
                        switch (fingerPositionY)
                        {
                            case 0: state = 3; sounds.playSound(1); break;
                            case 60: state = 4; sounds.playSound(1); break;
                            case 120: state = 5; sounds.playSound(1); break;
                            case 180: state = 6; sounds.playSound(1); break;

                        }
                    break;

                //This is for the menu for the player
                case 2:
                    //Displays the players stats according to the player
                    menuData = player.currLvl + "\n" + player.maxHealth + "\n"
                               + player.maxMana + "\n0\n" + player.strength
                               + "\n" + player.defense + "\n" + player.intelligence +
                               "\n" + player.currEXP;

                    //Check to see what keys were pressed and move the finger accordingly
                    if (prevKey.IsKeyUp(Keys.Up) && currentKey.IsKeyDown(Keys.Up))
                    {
                        fingerPosition2Y -= 47;
                        if (fingerPosition2Y < 0)
                            fingerPosition2Y = 282;
                        fingerPosition2Y = fingerPosition2Y % 329;
                        sounds.playSound(0);
                    }

                    if (prevKey.IsKeyUp(Keys.Down) && currentKey.IsKeyDown(Keys.Down))
                    {

                        fingerPosition2Y += 47;
                        fingerPosition2Y = fingerPosition2Y % 329;
                        sounds.playSound(0);
                    }
                        if (prevKey.IsKeyUp(Keys.Left) && currentKey.IsKeyDown(Keys.Left))
                    {
                        fingerPosition2X -= 63;
                        if (fingerPosition2X < 0)
                            fingerPosition2X = 378;
                        fingerPosition2X = fingerPosition2X % 441 ;
                        sounds.playSound(0);
                    }

                    if (prevKey.IsKeyUp(Keys.Right) && currentKey.IsKeyDown(Keys.Right))
                    {

                        fingerPosition2X += 63;
                        fingerPosition2X = fingerPosition2X % 441;
                        sounds.playSound(0);
                    }
                    //We unpause the game and move to the next available gamestate
                    if (prevKey.IsKeyUp(Keys.RightShift) && currentKey.IsKeyDown(Keys.RightShift))
                        state = 3;

                    //Change what the character looks like on the sprite sheet making sure its the standing still image
                    if(!player.attacking)
                        currentPlayer = player.spriteSheet;
                    playerRectangle = new Rectangle(0, 0, player.width, player.height);
                    break;

                    //This is when the game is running and if this button is pressed, the
                    //menu screen pops up
                case 3:
                case 4:
                case 5:
                case 6:
                    //these keys are pressed means that the game is paused into the players menu
                  if (prevKey.IsKeyUp(Keys.RightShift) && currentKey.IsKeyDown(Keys.RightShift))
                    state = 2;
                    break;
                case 7:
                    //do transitions
                    if (!transitionDone()){
                        transition(time);
                    }else{
                        transDone = false;
                        map.setChange();
                        state = 3;
                    }
                    break;
            }

            return state;
        }
Esempio n. 4
0
 public void Follow(MainPlayer source)
 {
     this.source = source.center;
 }
Esempio n. 5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            rand = new Random();
            mediaPlayer = new MediaPlayerGaia();
            soundPlayer = new SoundPlayerGaia();

            //Load the main player
            player = new MainPlayer(Content.Load<Texture2D>("Sprites/Will"),Content.Load<Texture2D>("Sprites/WillAttackingSheet")
                                     ,Content.Load<Texture2D>("Sprites/freedan"),null,new Vector2(160, 120),64,84);
            skeleton = new Enemy(20, 5, 4, new Vector2(60, 50), 72, 120, false, Content.Load<Texture2D>("Sprites/Enemy/Skeleton"),true,rand,false);
            bat = new Enemy(14,9, 3, new Vector2(70, 70), 80, 80, true, Content.Load<Texture2D>("Sprites/Enemy/Bat"),true,rand,false);
            powerHitter= new Enemy(100, 20, 25, new Vector2(700, 300), 72, 120, false, Content.Load<Texture2D>("Sprites/Enemy/Skeleton"), true, rand,false);
            lance = new Enemy(10, 10, 10, new Vector2(600, 200), 64, 64, false, Content.Load<Texture2D>("Sprites/NPC/NPCSheet"), true, rand,true);
            //startUpMapBuilder
            mapDesigner = new MapReader(Content.Load<Texture2D>("Maps/GTILES32"));
            //This tells the camera to follow the player as well as setting up the camera
            cam = new Camera(graphics.GraphicsDevice.Viewport, Vector2.Zero);
            cam.Follow(player);

            //load font and set position
            informFont = Content.Load <SpriteFont>("Text2");
            informFont2 = Content.Load<SpriteFont>("Text");

            mediaPlayer.init(Content);
            soundPlayer.init(Content);

            //Load first level
            mapDesigner.init();
            mapDesigner.buildMap("Content/Maps/level",0);

            //Connect the map to the main player and temporary enemies
            player.connectMap(mapDesigner,rand,soundPlayer);
            skeleton.connectMap(mapDesigner,cam,soundPlayer);
            bat.connectMap(mapDesigner,cam,soundPlayer);
            powerHitter.connectMap(mapDesigner,cam,soundPlayer);
            lance.connectMap(mapDesigner, cam,soundPlayer);
            enemyHolder[0] = skeleton;
            enemyHolder[1] = bat;
            enemyHolder[2] = powerHitter;

            //sets the game state to opening screen
            //stats - '0' for title
            //        '1' for openingScreen
            //        '2' for player menu
            gameState = 0;
            lance.addText("Hello there, this is just a test to make sure that NPC is ");
            lance.addText("working correctly. This is another test run because ");
            lance.addText("we will be reading line by line or max characters. Not ");
            lance.addText("100% sure what will be done with this yet");
            lance.color = Color.LightGreen;
            lance.textBox = Content.Load<Texture2D>("Sprites/Gui/TextBox");
            //sets up the Hud and all the graphics any menu
            allGui = new AllGui(cam, player, Content.Load<Texture2D>("Sprites/Gui/PlayerGui")
                                                  , Content.Load<Texture2D>("Sprites/Gui/Transformation2")
                                                  , Content.Load<Texture2D>("Sprites/Gui/characters2"),
                                                  Content.Load<Texture2D>("Sprites/Gui/TitleScreen"),
                                                  Content.Load<Texture2D>("Sprites/Gui/IntroScreenSetup")
                                                  , Content.Load<Texture2D>("Sprites/Gui/life")
                                                  , Content.Load<Texture2D>("Sprites/Gui/SelectionScreen"),
                                                  Content.Load<Texture2D>("Sprites/Gui/PlayerMenu")
                                                  ,Content.Load<Texture2D>("Sprites/Gui/transitionBackground"));

            allGui.connect(soundPlayer,Content.Load<SpriteFont>("Text"),mapDesigner);

            // TODO: use this.Content to load your game content here
        }