Пример #1
0
        /// <summary>
        /// Create the start menu
        /// </summary>
        void CreateStartMenu()
        {
            //The background
            Entity background = new Entity(0, GameState.Start);
            SpriteComponent backgroundSprite = new SpriteComponent(new Rectangle(0, 0, screenWidth, screenHeight), collBackgroundTexture);
            backgroundSprite.OffsetRatio = new Vector2(0, 0);
            background.AddComponent(backgroundSprite);
            EntityManager.AddEntity(background);

            Entity pressStart = new Entity(8, GameState.Start);

            pressStartShade = new SpriteComponent(new Rectangle(400, 300, 200, 50), shadeTexture);
            pressStartShade.OffsetRatio = new Vector2(.5f, .5f);
            pressStart.AddComponent(pressStartShade);
            pressStartShade.IsGui = true;

            pressStartSprite = new TextSpriteComponent("PRESS START", TextAlignment.Center, new Vector2(400, 300), menuFont);
            pressStart.AddComponent(pressStartSprite);
            EntityManager.AddEntity(pressStart);
            pressStartSprite.IsGui = true;
        }
Пример #2
0
        /// <summary>
        /// Create the player lobby menus
        /// </summary>
        void CreatePlayerLobby()
        {
            for (int p = 0; p < 4; p++)
            {
                foreach (PlayerLobbyState lobby in Enum.GetValues(typeof(PlayerLobbyState)))
                {
                    playerLobbyStateSprites[p].Add(lobby, new List<DrawableComponent>());
                }
            }

            //Background
            Entity background = new Entity(0, GameState.PlayerLobby);
            SpriteComponent backgroundSprite = new SpriteComponent(new Rectangle(0, 0, screenWidth, screenHeight), collBackgroundTexture);
            backgroundSprite.OffsetRatio = new Vector2(0, 0);
            background.AddComponent(backgroundSprite);
            EntityManager.AddEntity(background);

            //What state are we in
            Entity gameStateIdentifier = new Entity(5, GameState.PlayerLobby);
            SpriteComponent titleSpriteBackground = new SpriteComponent(new Rectangle(400, 20, 200, 50), shadeTexture);
            titleSpriteBackground.OffsetRatio = new Vector2(.5f, .5f);
            gameStateIdentifier.AddComponent(titleSpriteBackground);
            gameStateIdentifier.AddComponent(new TextSpriteComponent("Pregame Lobby", TextAlignment.Center, Color.White, new Vector2(400, 20), menuFont));
            EntityManager.AddEntity(gameStateIdentifier);

            //Create our classweapons
            CreateWeapons();

            //Menu borders and sizes
            int classNameYSideBuffer = 75;
            int classNameXSideBuffer = -50;
            int classSpriteYBuffer = 150;

            int classIconWidth = 150;
            int classIconHeight = 150;

            //Create the name selection pinwheels
            CreateNamePinWheel(60, 400, 5, 3, 0);

            //Creating each players lobbystates
            for (int p = 0; p < 4; p++)
            {
                //Not connected
                Entity playerConnectionInstructions = new Entity(3, GameState.PlayerLobby);

                TextSpriteComponent playerConnectionInstructionsSprite = new TextSpriteComponent("  Press A\nTo Jack In!", TextAlignment.Center,
                    new Vector2((screenWidth - (classNameXSideBuffer * 2)) / 5 * (p + 1) + classNameXSideBuffer, classNameYSideBuffer), menuFont);
                playerLobbyStateSprites[p][PlayerLobbyState.NotConnected].Add(playerConnectionInstructionsSprite);
                playerConnectionInstructions.AddComponent(playerConnectionInstructionsSprite);
                EntityManager.AddEntity(playerConnectionInstructions);

                //Shade

                //Entity playerShade = new Entity(1, GameState.PlayerLobby);
                //int shadeWidth = screenWidth/4;
                //SpriteComponent shadeSprite = new SpriteComponent(new Rectangle(0 + (p * shadeWidth), 0, shadeWidth, screenHeight), shadeTexture);
                //shadeSprite.Color = Color.Black;
                //shadeSprite.Visible = false;
                //shadeSprite.OffsetRatio = new Vector2(0, 0);
                //playerShade.AddComponent(shadeSprite);
                //playerLobbyStateSprites[p][PlayerLobbyState.Class].Add(shadeSprite);
                //playerLobbyStateSprites[p][PlayerLobbyState.Name].Add(shadeSprite);
                //playerLobbyStateSprites[p][PlayerLobbyState.Ready].Add(shadeSprite);
                //EntityManager.AddEntity(playerShade);

                //Class
                Entity playerClassName = new Entity(3, GameState.PlayerLobby);

                playerClassText[p] = new TextSpriteComponent("Weapon:\n" + weapons[0].Name, TextAlignment.Center,
                    new Vector2((screenWidth - (classNameXSideBuffer * 2)) / 5 * (p + 1) + classNameXSideBuffer, classNameYSideBuffer), menuFont);
                playerLobbyStateSprites[p][PlayerLobbyState.Class].Add(playerClassText[p]);
                playerLobbyStateSprites[p][PlayerLobbyState.Name].Add(playerClassText[p]);
                playerLobbyStateSprites[p][PlayerLobbyState.Ready].Add(playerClassText[p]);
                playerClassName.AddComponent(playerClassText[p]);
                playerClassText[p].Visible = false;

                playerClassSprites[p] = new AnimatedSpriteComponent(new Rectangle((screenWidth - (classNameXSideBuffer * 2)) / 5 * (p + 1) + classNameXSideBuffer,
                                                                                classNameYSideBuffer + classSpriteYBuffer,
                                                                                classIconWidth*2,
                                                                                classIconWidth*2),
                                                                    weapons[0].Sprite);
                playerClassSprites[p].setCurrentRow(7);
                playerClassSprites[p].Visible = false;
                playerLobbyStateSprites[p][PlayerLobbyState.Class].Add(playerClassSprites[p]);
                playerLobbyStateSprites[p][PlayerLobbyState.Name].Add(playerClassSprites[p]);
                playerLobbyStateSprites[p][PlayerLobbyState.Ready].Add(playerClassSprites[p]);
                playerClassName.AddComponent(playerClassSprites[p]);
                EntityManager.AddEntity(playerClassName);

                Entity playerReadyIcon = new Entity(5, GameState.PlayerLobby);
                TextSpriteComponent readyText = new TextSpriteComponent("Ready!", TextAlignment.Left, new Vector2((screenWidth - (classNameXSideBuffer * 2)) / 5 * (p + 1) + classNameXSideBuffer
                                                                                                                   , 325), menuFont);
                readyText.Visible = false;
                readyText.TextAlighment = TextAlignment.Center;
                playerReadyIcon.AddComponent(readyText);
                playerLobbyStateSprites[p][PlayerLobbyState.Ready].Add(readyText);
                EntityManager.AddEntity(playerReadyIcon);
            }
        }
Пример #3
0
        /// <summary>
        /// Creates the main menu and its options
        /// </summary>
        void CreateMainMenu()
        {
            Entity mainMenuBackground = new Entity(0, GameState.MainMenu);
            SpriteComponent mainMenuSprite = new SpriteComponent(new Rectangle(0, 0, screenWidth, screenHeight), collBackgroundTexture);
            mainMenuSprite.OffsetRatio = new Vector2(0, 0);
            mainMenuBackground.AddComponent(mainMenuSprite);
            EntityManager.AddEntity(mainMenuBackground);

            Entity menuPointer = new Entity(6, GameState.MainMenu);
            pointerSprite = new SpriteComponent(new Rectangle(300, 250, 50, 25), arrowTexture);
            pointerSprite.Effect = SpriteEffects.FlipHorizontally;
            menuPointer.AddComponent(pointerSprite);
            EntityManager.AddEntity(menuPointer);

            menuOptionSprites = new TextSpriteComponent[3];

            Entity playSelection = new Entity(5, GameState.MainMenu);

            SpriteComponent playShade = new SpriteComponent(new Rectangle(400, 250, 150, 50), shadeTexture);
            playShade.OffsetRatio = new Vector2(.5f, .5f);
            playSelection.AddComponent(playShade);
            pressStartShade.IsGui = true;

            TextSpriteComponent playText = new TextSpriteComponent("Play", TextAlignment.Center, Color.White, new Vector2(400, 250), menuFont);
            menuOptionSprites[0] = playText;
            playSelection.AddComponent(playText);
            EntityManager.AddEntity(playSelection);

            Entity instructionsSelection = new Entity(5, GameState.MainMenu);

            SpriteComponent intructionsShade = new SpriteComponent(new Rectangle(400, 300, 150, 50), shadeTexture);
            intructionsShade.OffsetRatio = new Vector2(.5f, .5f);
            instructionsSelection.AddComponent(intructionsShade);
            pressStartShade.IsGui = true;

            instructionsText = new TextSpriteComponent("Instructions", TextAlignment.Center, Color.White, new Vector2(400, 300), menuFont);
            menuOptionSprites[1] = instructionsText;
            instructionsSelection.AddComponent(instructionsText);
            EntityManager.AddEntity(instructionsSelection);

            Entity quitSelection = new Entity(5, GameState.MainMenu);

            SpriteComponent quitShade = new SpriteComponent(new Rectangle(400, 350, 150, 50), shadeTexture);
            quitShade.OffsetRatio = new Vector2(.5f, .5f);
            quitSelection.AddComponent(quitShade);
            pressStartShade.IsGui = true;

            TextSpriteComponent quitText = new TextSpriteComponent("Quit", TextAlignment.Center, Color.White, new Vector2(400, 350), menuFont);
            menuOptionSprites[2] = quitText;
            quitSelection.AddComponent(quitText);
            EntityManager.AddEntity(quitSelection);
        }
Пример #4
0
        /// <summary>
        /// Create the level select menu
        /// </summary>
        void CreateLevelSelect()
        {
            Entity background = new Entity(0, GameState.LevelSelect);
            SpriteComponent backgroundSprite = new SpriteComponent(new Rectangle(0, 0, screenWidth, screenHeight), collBackgroundTexture);
            backgroundSprite.OffsetRatio = new Vector2(0, 0);
            background.AddComponent(backgroundSprite);
            EntityManager.AddEntity(background);

            Entity levelSelectTitle = new Entity(5, GameState.LevelSelect);
            levelSelectSpritePointer = new SpriteComponent(new Rectangle(400, 20, 200, 50), shadeTexture);
            levelSelectSpritePointer.OffsetRatio = new Vector2(.5f, .5f);
            levelSelectTitle.AddComponent(levelSelectSpritePointer);
            TextSpriteComponent selectLevelText = new TextSpriteComponent("Select a level!", TextAlignment.Left, new Vector2(400, 20), menuFont);
            selectLevelText.TextAlighment = TextAlignment.Center;
            levelSelectTitle.AddComponent(selectLevelText);
            EntityManager.AddEntity(levelSelectTitle);

            int numberTilesX = 3;
            int numberTilesY = 3;

            int xSideBuffer = 50;
            int ySideBuffer = 50;

            int xBuffer = 10;
            int yBuffer = 10;

            int previewWidth = (screenWidth - (xSideBuffer * 2) - (xBuffer * 2)) / numberTilesX;
            int previewHeight = (screenHeight - (ySideBuffer * 2) - (yBuffer * 2)) / numberTilesY;

            //Loading all maps!
            if (Directory.Exists("Content/Maps/MapFiles"))
            {
                string[] fileEntries = Directory.GetFiles("Content/Maps/MapFiles");
                foreach (string fileName in fileEntries)
                    mapNames.Add(fileName);
            }
            if (Directory.Exists("Content/Maps/MapPreviews"))
            {
                string[] fileEntries = Directory.GetFiles("Content/Maps/MapPreviews");
                foreach (string fileName in fileEntries)
                {
                    string finalFileName = "";
                    for (int c = 8; c < fileName.Length; c++)
                    {
                        finalFileName += fileName[c];
                    }
                    mapPreviewNames.Add(finalFileName);
                }
            }
            //Done Loading maps!

            levelPreviews = new Entity[numberTilesX, numberTilesY];
            int numberOfPreviews = 0;
            for (int y = 0; y < numberTilesY; y++)
            {
                for (int x = 0; x < numberTilesX; x++)
                {
                    if (numberOfPreviews < mapNames.Count)
                    {

                        Entity preview = new Entity(8, GameState.LevelSelect);
                        levelPreviews[x, y] = preview;
                        SpriteComponent previewSprite = new SpriteComponent(new Rectangle(xSideBuffer + (x * (previewWidth + xBuffer)),
                                                                                          ySideBuffer + (y * (previewHeight + yBuffer)),
                                                                                          previewWidth,
                                                                                          previewHeight),
                                                                                          Content.Load<Texture2D>(mapPreviewNames[numberOfPreviews]));
                        previewSprite.OffsetRatio = Vector2.Zero;
                        preview.AddComponent(previewSprite);
                        EntityManager.AddEntity(preview);

                        numberOfPreviews++;
                    }
                    else //We are out of previews
                    {
                        levelPreviews[x, y] = null;
                    }
                }
            }

            for (int y = 0; y < numberTilesY; y++)
            {
                for (int x = 0; x < numberTilesX; x++)
                {
                    if (mapNames.Count < (y * numberTilesX) + x)
                    {
                        mapNames.Add(null);
                    }
                }
            }
            //Creating the glow of being selected
            SpriteComponent selectedPreviewSprite = (SpriteComponent)levelPreviews[0, 0].GetComponent("Sprite");

            Entity selectedLevelHighlight = new Entity(9, GameState.LevelSelect);
            levelSelectSpritePointer = new SpriteComponent(selectedPreviewSprite.Position, selectedGraphic);
            levelSelectSpritePointer.OffsetRatio = Vector2.Zero;
            selectedLevelHighlight.AddComponent(levelSelectSpritePointer);
            EntityManager.AddEntity(selectedLevelHighlight);
        }
Пример #5
0
        /// <summary>
        /// instructions state for the game
        /// </summary>
        void CreateInstructions()
        {
            //string containing whatever the directions are (press enter to be changed i dont have a controller)
            string textToDisplay = "Instructions:\nCreate your gladiator team and enter the arena\nto fight off waves of enemies!\n\nControls:\nLeft Thumbstick to move\nA to attack"
                + "\n\nPress B to Return...";

            //same background
            Entity background = new Entity(0, GameState.Instructions);
            SpriteComponent backgroundSprite = new SpriteComponent(new Rectangle(0, 0, screenWidth, screenHeight), collBackgroundTexture);
            backgroundSprite.OffsetRatio = new Vector2(0, 0);
            background.AddComponent(backgroundSprite);
            EntityManager.AddEntity(background);

            //What state are we in
            Entity gameStateIdentifier = new Entity(5, GameState.Instructions);
            gameStateIdentifier.AddComponent(new TextSpriteComponent("Instructions", TextAlignment.Left, Color.White, new Vector2(600, 0), menuFont));
            EntityManager.AddEntity(gameStateIdentifier);

            //make entity for text
            Entity instructionsTextEntity = new Entity(3, GameState.Instructions);
            instructionsText = new TextSpriteComponent(textToDisplay, TextAlignment.Left, Color.White, new Vector2(0, 100), menuFont);

            instructionsText.IsGui = true;
            instructionsTextEntity.AddComponent(instructionsText);
            EntityManager.AddEntity(instructionsTextEntity);
        }
Пример #6
0
        /// <summary>
        /// Load the map and create the player
        /// </summary>
        void CreateIngame()
        {
            // brings in map data and gives two lists of spawn locations
            mapProcessor = new MapProcessor(chosenMapFileName);
            enemySpawnsLoc = MapProcessor.enemySpawnLocations;
            playerSpawnLoc = MapProcessor.playerSpawnLocations;

            Vector2 spawnLocation = Vector2.Zero;

            //isPlayerPlaying[0] = true; // T E M P OR A R I LY populates array - this should toggle when a player clicks into the main lobby to select a weapon/ leaves

            float healthBarHalfWidth = ((healthBarWidth * healthBarNumber) + (healthBarSpacing * (healthBarNumber - 1))) / 2;
            float healthBarPosXRatio = 0.20f;//Percents of the screen
            float healthBarPosYRatio = 0.80f;

            float namePosYRatio = 0.75f;

            //Wave counter
            Entity waveCounterEntity = new Entity(6, GameState.Ingame);
            SpriteComponent titleSpriteBackground = new SpriteComponent(new Rectangle(400, 20, 200, 50), shadeTexture);
            titleSpriteBackground.OffsetRatio = new Vector2(.5f, .5f);
            waveCounterEntity.AddComponent(titleSpriteBackground);
            titleSpriteBackground.IsGui = true;
            waveCounterTextSprite = new TextSpriteComponent("Wave Counter: 1", TextAlignment.Center, new Vector2(400, 20), menuFont);
            waveCounterTextSprite.Color = Color.White;
            waveCounterTextSprite.IsGui = true;
            waveCounterEntity.AddComponent(waveCounterTextSprite);
            EntityManager.AddEntity(waveCounterEntity);

            wave = 1;

            //CREATING ALL THE PLAYERS
            for (int p = 0; p < 4; p++)
            {
                if (isPlayerPlaying[p])
                {
                    //Creating teh palyer
                    playerEntities[p] = new Entity(6, GameState.Ingame);

                    //Pulling spawn
                    if (playerSpawnLoc.Count != 0)
                    {
                        int spawnLocationUsed = randell.Next(0, playerSpawnLoc.Count);
                        spawnLocation = playerSpawnLoc[spawnLocationUsed];
                        playerSpawnLoc.RemoveAt(spawnLocationUsed);
                    }

                    //Shadow
                    playerShadows[p] = new SpriteComponent(new Rectangle(0, 0, 50, 30), shadeTexture);
                    playerShadows[p].OffsetRatio = new Vector2(.5f, .5f);
                    playerEntities[p].AddComponent(playerShadows[p]);

                    //Player Graphoc
                    playerSprites[p] = new AnimatedSpriteComponent(new Rectangle((int)spawnLocation.X, (int)spawnLocation.Y, 120, 75), swordTexture);
                    playerSprites[p].OffsetRatio = new Vector2(0.5f, .9f);
                    playerEntities[p].AddComponent(playerSprites[p]);

                    //Player Player
                    playerPlayers[p] = new PlayerComponent(chosenPlayerNames[p], 100, 5, 1f, 5, playerSprites[p]);        // 20 makes him move way too quickly
                    playerEntities[p].AddComponent(playerPlayers[p]);
                    EntityManager.AddEntity(playerEntities[p]);

                    playerPlayers[p].Equip(weapons[playerCurrentWeaponIndex[p]]);

                    //Create Name
                    Entity nameEntity = new Entity(8, GameState.Ingame);
                    SpriteComponent nameShade = new SpriteComponent(new Rectangle((int)(screenWidth * healthBarPosXRatio * (p + 1)), (int)(screenHeight * namePosYRatio), 150, 50), shadeTexture);
                    nameShade.OffsetRatio = new Vector2(.5f, .5f);
                    nameShade.IsGui = true;
                    nameEntity.AddComponent(nameShade);

                    TextSpriteComponent nameText = new TextSpriteComponent(chosenPlayerNames[p], TextAlignment.Center, new Vector2((int)(screenWidth * healthBarPosXRatio * (p + 1)), screenHeight * namePosYRatio), menuFont);
                    nameText.IsGui = true;
                    nameEntity.AddComponent(nameText);
                    playerNameUI[p] = nameText;
                    EntityManager.AddEntity(nameEntity);

                    //Creating the health bar
                    for (int i = 0; i < healthBarNumber; i++)
                    {
                        Entity healthBarEntity = new Entity(8, GameState.Ingame);
                        SpriteComponent healthBarSprite = new SpriteComponent(new Rectangle(
                                                                             (int)(screenWidth * healthBarPosXRatio * (p + 1)) + (healthBarWidth * i) + (healthBarSpacing * i) - (int)healthBarHalfWidth,
                                                                             (int)(screenHeight * healthBarPosYRatio),
                                                                             healthBarWidth, healthBarHeight),
                                                                             healthBarTexture);

                        healthBarSprite.IsGui = true;
                        healthBarEntity.AddComponent(healthBarSprite);
                        playerHealthBars[p][i] = healthBarSprite;
                        EntityManager.AddEntity(healthBarEntity);

                        Entity healthBarMissingEntity = new Entity(7, GameState.Ingame);
                        SpriteComponent healthBarMissingSprite = new SpriteComponent(new Rectangle(
                                                                             (int)(screenWidth * healthBarPosXRatio * (p + 1)) + (healthBarWidth * i) + (healthBarSpacing * i) - (int)healthBarHalfWidth,
                                                                             (int)(screenHeight * healthBarPosYRatio),
                                                                             healthBarWidth, healthBarHeight),
                                                                             healthBarMissingTexture);
                        healthBarMissingSprite.IsGui = true;
                        healthBarMissingEntity.AddComponent(healthBarMissingSprite);
                        playerHealthBarsBase[p][i] = healthBarMissingSprite;
                        EntityManager.AddEntity(healthBarMissingEntity);
                    }

                    //AttackBoxes
                    if (attackBoxesDrawn)
                    {
                        Entity attackBox = new Entity(9, GameState.Ingame);
                        attackBoxSprites[p] = new AnimatedSpriteComponent(playerPlayers[p].AttackBox[0], swordAttackAnimation);
                        attackBoxSprites[p].OffsetRatio = Vector2.Zero;

                        attackBox.AddComponent(attackBoxSprites[p]);
                        EntityManager.AddEntity(attackBox);

                    }
                }
            }
        }