Esempio n. 1
0
 public PC(Vector2 vector, CharGraphics graphics, int moveSpeed, List <Animation> animation, Rectangle rectangle)
 {
     this.vector     = vector;
     this.graphics   = graphics;
     this.moveSpeed  = moveSpeed;
     this.animation  = animation;
     hitbox          = rectangle;
     latestTexture   = graphics.texture;
     latestAnimation = animation[0];
 }
Esempio n. 2
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            charHitboxTexture = Content.Load <Texture2D>("Character/Medium/charHitboxTexture");
            black             = Content.Load <Texture2D>("Background/black");
            gridTexture       = Content.Load <Texture2D>("Misc/gridSquare");
            debug             = Content.Load <SpriteFont>("debug");

            switch (world.CurrentLoadState)
            {
            case LoadStates.FirstRun:     // TODO: Move this to initialize. Probably smarter than this solution. That way you dont have to LoadContent inside firstrun
                ui = new UI();

                ballGraphics    = new CharGraphics(charFrontTexture);
                zoneGraphics    = new ZoneGraphics(rumTexture, resX, resY);
                hallwayGraphics = new ZoneGraphics(hallwayTexture, resX, resY);
                menu            = new Menu(menuTexture);
                settings        = new Settings(settingsMenuTexture);


                // PC animation textures getting loaded
                frontAnimation = new Animation(new List <Texture2D> {
                    charFrontTexture
                }, "front");
                frontAnimation.AddTexture(charFrontAnimation1);
                frontAnimation.AddTexture(charFrontAnimation2);


                backAnimation = new Animation(new List <Texture2D> {
                    charBackTexture
                }, "back");
                backAnimation.AddTexture(charBackAnimation1);
                backAnimation.AddTexture(charBackAnimation2);

                rightSideAnimation = new Animation(new List <Texture2D> {
                    charRightTexture
                }, "rightSide");
                rightSideAnimation.AddTexture(charRightAnimation1);
                rightSideAnimation.AddTexture(charRightTexture);
                rightSideAnimation.AddTexture(charRightAnimation2);
                rightSideAnimation.AddTexture(charRightTexture);

                leftSideAnimation = new Animation(new List <Texture2D> {
                    charLeftTexture
                }, "leftSide");
                leftSideAnimation.AddTexture(charLeftAnimation1);
                leftSideAnimation.AddTexture(charLeftTexture);
                leftSideAnimation.AddTexture(charLeftAnimation2);
                leftSideAnimation.AddTexture(charLeftTexture);



                // Creation of the first rooms grid
                roomGrid.CreateHitBoxes();
                roomGrid.LoadGrid();

                hallwayGrid.CreateHitBoxes();
                hallwayGrid.LoadGrid();

                // PC gets created and animations gets added.
                character = new PC(ballvector, ballGraphics, pcMovementSpeed, new List <Animation> {
                    frontAnimation
                },
                                   new Rectangle((int)ballvector.X, (int)ballvector.Y, (int)(charHitboxTexture.Width), (int)(charHitboxTexture.Height)));

                currentCharacters.Add(character);
                character.AddAnimation(backAnimation);
                character.AddAnimation(rightSideAnimation);
                character.AddAnimation(leftSideAnimation);


                zone                 = new Zone(contentHandler, testZoneVector, zoneGraphics, currentCharacters, character, roomGrid);
                zone.StartVector     = new Vector2(915, 470);
                zone.ZoneStartVector = new Vector2(-280, -20);
                zone.setState(LoadStates.BedRoom);

                hallwayBackground = new Background(hallwayBackgroundLarge, new Vector2(-200, -330), new Vector2(-200, -330), 3);
                hallwayZone       = new Zone(contentHandler, new Vector2(0, -456), hallwayGraphics, currentCharacters,
                                             character, hallwayGrid, hallwayBackground, new Vector2(846, 456 + 65));
                hallwayZone.ZoneStartVector = new Vector2(0, -456);
                hallwayZone.setState(LoadStates.Hallway);

                // -280

                world.CurrCharacters.Add(character);
                world.CurrentZone       = zone;
                world.PlayableCharacter = character;
                for (int i = 97; i < 109; i++)
                {
                    roomGrid.hitBoxArray[37, i].connectedZone = hallwayZone;
                }
                for (int i = 68; i < 78; i++)
                {
                    hallwayGrid.hitBoxArray[55, i].connectedZone = zone;
                }
                ui.latestKeyPressed    = Keys.S;
                world.CurrentLoadState = LoadStates.TitleScreen;
                LoadContent();
                break;

            case LoadStates.TitleScreen:

                testZone         = Content.Load <Texture2D>("game1testpic");
                menu.menuTexture = Content.Load <Texture2D>("UI/Large/menu");
                startTexture     = Content.Load <Texture2D>("UI/Large/start");
                settingsTexture  = Content.Load <Texture2D>("UI/Large/settings");
                exitTexture      = Content.Load <Texture2D>("UI/Large/exit");
                break;

            case LoadStates.Settings:
                settings.settingsTexture = Content.Load <Texture2D>("UI/Large/settingsTexture");
                returnTexture            = Content.Load <Texture2D>("UI/Large/return");
                devToggleTexture         = Content.Load <Texture2D>("UI/Large/enableDev");
                break;

            case LoadStates.BedRoom:
                zone.graphics.texture = Content.Load <Texture2D>("Zone/Large/rumstor3");
                break;

            case LoadStates.Hallway:
                hallwayZone.graphics.texture = Content.Load <Texture2D>("Zone/Large/hallwayv2");
                tree1LargeTexture            = Content.Load <Texture2D>("Background/tree1large");
                tree1SmallTexture            = Content.Load <Texture2D>("Background/tree1");
                hallwayBackground.Texture    = Content.Load <Texture2D>("Background/hallwayBackgroundLarge");
                break;
            }

            character.Animation[0].textureList[0] = Content.Load <Texture2D>("Character/Medium/charfront");
            character.Animation[0].textureList[1] = Content.Load <Texture2D>("Character/Medium/charfronanimation1");
            character.Animation[0].textureList[2] = Content.Load <Texture2D>("Character/Medium/charfronanimation2");

            character.Animation[1].textureList[0] = Content.Load <Texture2D>("Character/Medium/charback");
            character.Animation[1].textureList[1] = Content.Load <Texture2D>("Character/Medium/charbackanimation1");
            character.Animation[1].textureList[2] = Content.Load <Texture2D>("Character/Medium/charbackanimation2");

            character.Animation[2].textureList[0] = Content.Load <Texture2D>("Character/Medium/charRight");
            character.Animation[2].textureList[1] = Content.Load <Texture2D>("Character/Medium/charRightAnimation1");
            character.Animation[2].textureList[2] = Content.Load <Texture2D>("Character/Medium/charRight");
            character.Animation[2].textureList[3] = Content.Load <Texture2D>("Character/Medium/charRightAnimation2");
            character.Animation[2].textureList[4] = Content.Load <Texture2D>("Character/Medium/charRight");

            character.Animation[3].textureList[0] = Content.Load <Texture2D>("Character/Medium/charLeft");
            character.Animation[3].textureList[1] = Content.Load <Texture2D>("Character/Medium/charLeftAnimation1");
            character.Animation[3].textureList[2] = Content.Load <Texture2D>("Character/Medium/charLeft");
            character.Animation[3].textureList[3] = Content.Load <Texture2D>("Character/Medium/charLeftAnimation2");
            character.Animation[3].textureList[4] = Content.Load <Texture2D>("Character/Medium/charLeft");

            character.Graphics.texture = Content.Load <Texture2D>("Character/Medium/charback");
            string[] tmp = { "Character/Medium/charback",  "Character/Medium/charLeft",
                             "Character/Medium/charfront", "Character/Medium/charRight" };

            Keys[] key = { Keys.W, Keys.A, Keys.S, Keys.D };

            for (int i = 0; i < tmp.Length; i++)
            {
                if (ui.latestKeyPressed == key[i])
                {
                    character.LatestTexture = Content.Load <Texture2D>(tmp[i]);
                }
            }
            testSprite = Content.Load <Texture2D>("Character/Tiny/charfrontSmall");
        }