//constructor
 public CombatantComponent(int myHealth, int myAttackDamage, float myAttackCooldownSeconds, float mvSp, AnimatedSpriteComponent mySprite)
 {
     attackCoolDownMax = myAttackCooldownSeconds;
     currentHealth = myHealth;
     maxHealth = myHealth;
     attackDmg = myAttackDamage;
     movementSpeed = mvSp;
     sprite = mySprite;
 }
Beispiel #2
0
        public List<EnemyComponent> CreateEnemiesWithDifficulty(int difficulty)
        {
            if (wave % 5 != 0)
            {
                int numberEnemies = 1;

                int damage = 1;
                int health = 10;
                int speed = 100;
                float attackSpeed = 2000;
                float spawnTime = 2000;

                // used to change difficulty of enemies being spawned
                for (int i = difficulty; i >= 0; i--)
                {
                    int dieroll = randell.Next(0, 101);

                    if (dieroll < 50)
                    {
                        numberEnemies++;
                    }
                    else if (dieroll < 60)
                    {
                        damage++;
                    }
                    else if (dieroll < 70)
                    {
                        speed += 5;
                    }
                    else if (dieroll < 80)
                    {
                        health++;
                    }
                    else if (dieroll < 90)
                    {
                        attackSpeed -= 5;
                    }
                    else
                    {
                        speed -= 5;
                    }
                }

                List<EnemyComponent> enemies = new List<EnemyComponent>();
                for (int i = 0; i < numberEnemies; i++)
                {
                    Entity enemy = new Entity(6, GameState.Ingame);

                    // spawn enemies
                    Vector2 spawnLocation = Vector2.Zero;           // if no spawn points, spawn location is zero
                    if (enemySpawnsLoc.Count != 0)
                    {
                        spawnLocation = enemySpawnsLoc[randell.Next(0, enemySpawnsLoc.Count)];
                    }

                    AnimatedSpriteComponent enemySprite = new AnimatedSpriteComponent(new Rectangle((int)spawnLocation.X, (int)spawnLocation.Y, 50, 50), enemyTexture);

                    enemySprite.OffsetRatio = new Vector2(0.5f, 1f);
                    EnemyComponent enemyGuy = new EnemyComponent(health, damage, 100, 50, attackSpeed, speed, enemySprite);
                    enemy.AddComponent(enemySprite);
                    enemy.AddComponent(enemyGuy);
                    enemies.Add(enemyGuy);
                    EntityManager.AddEntity(enemy);
                }
                return enemies;
            }
            else //BEHOLD A BOSS WAVE!
            {
                int numberEnemies = 1;

                int damage = 1;
                int health = 10;
                int speed = 100;
                float attackSpeed = 2000;

                // used to change difficulty of enemies being spawned
                for (int i = difficulty; i >= 0; i--)
                {
                    int dieroll = randell.Next(0, 101);
                    if (dieroll < 50)
                    {
                        health++;
                    }
                    else if (dieroll < 60)
                    {
                        speed += 5;
                    }
                    else if (dieroll < 70)
                    {
                        damage++;
                    }
                    else if (dieroll < 90)
                    {
                        attackSpeed -= 5;
                    }
                    else
                    {
                        speed -= 5;
                    }
                }

                List<EnemyComponent> enemies = new List<EnemyComponent>();
                for (int i = 0; i < numberEnemies; i++)
                {
                    Entity enemy = new Entity(6, GameState.Ingame);

                    // spawn enemies
                    Vector2 spawnLocation = Vector2.Zero;           // if no spawn points, spawn location is zero
                    if (enemySpawnsLoc.Count != 0)
                    {
                        spawnLocation = enemySpawnsLoc[randell.Next(0, enemySpawnsLoc.Count)];
                    }

                    AnimatedSpriteComponent enemySprite = new AnimatedSpriteComponent(new Rectangle((int)spawnLocation.X, (int)spawnLocation.Y, 100, 100), enemyTexture);

                    enemySprite.OffsetRatio = new Vector2(0.5f, 1f);
                    EnemyComponent enemyGuy = new EnemyComponent(health, damage, 100, 50, attackSpeed, speed, enemySprite);
                    enemy.AddComponent(enemySprite);
                    enemy.AddComponent(enemyGuy);
                    enemies.Add(enemyGuy);
                    EntityManager.AddEntity(enemy);
                }
                return enemies;
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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);

                    }
                }
            }
        }
Beispiel #5
0
 //constructor that CURRENTLY just uses the base constructor
 public EnemyComponent(int myHealth, int myAttackDamage, int myAttackRange, int myAttackBreadth, float myAttackCooldownSeconds, float mvSp, AnimatedSpriteComponent mySprite)
     : base(myHealth, myAttackDamage, myAttackCooldownSeconds, mvSp, mySprite)
 {
     attackRange = myAttackRange;
     attackBreadth = myAttackBreadth;
 }
 public PlayerComponent(string myName, int myHealth, int myAttackDamage, float myAttackCooldownSeconds, float mvSp, AnimatedSpriteComponent mySprite)
     : base(myHealth, myAttackDamage, myAttackCooldownSeconds, mvSp, mySprite)
 {
     playerName = myName;
 }