Example #1
0
        private void GameScreen_Load(object sender, EventArgs e)
        {
            //adjusting label locations for various screen resolutions
            healthTwoLabel.Left       = healthTwoLabel.Location.X + this.Width - 1600;
            healthRegenTwoLabel.Left  = healthRegenTwoLabel.Location.X + this.Width - 1600;
            bodyDamageTwoLabel.Left   = bodyDamageTwoLabel.Location.X + this.Width - 1600;
            bulletSpeedTwoLabel.Left  = bulletSpeedTwoLabel.Location.X + this.Width - 1600;
            bulletHealthTwoLabel.Left = bulletHealthTwoLabel.Location.X + this.Width - 1600;
            reloadTwoLabel.Left       = reloadTwoLabel.Location.X + this.Width - 1600;
            speedTwoLabel.Left        = speedTwoLabel.Location.X + this.Width - 1600;
            bulletDamageTwoLabel.Left = bulletDamageTwoLabel.Location.X + this.Width - 1600;

            health1Label.Top = this.Height - 20;
            xp1Label.Top     = this.Height - 20;
            level1Label.Top  = this.Height - 20;
            health2Label.Top = this.Height - 20;
            xp2Label.Top     = this.Height - 20;
            level2Label.Top  = this.Height - 20;

            health2Label.Left = health2Label.Location.X + this.Width - 1600;
            xp2Label.Left     = xp2Label.Location.X + this.Width - 1600;
            level2Label.Left  = level2Label.Location.X + this.Width - 1600;

            //create mega square
            Square g = new Square(this.Width / 2 - 150, this.Height / 2 - 150, 300, 2500, 30);

            squareList.Add(g);

            //game start sound
            gameStart.Play();

            //reset variables
            keyCoolDown1          = keyCoolDown2 = attribute1 = attribute2 = healthRegenCounter = 0;
            squareGenerationSpeed = 300;

            //create bot objects with attributes and add them to botList
            p1 = new Bot(blueBrush, 1, 50, this.Height / 2 - 20, 40, baseMaxHealth, baseDamage, baseSpeed, "none", baseBulletHealth, baseBulletDamage, baseBulletSpeed, baseReload, baseRegen, baseMaxHealth, 1, 0, 0);
            botList.Add(p1);
            p2 = new Bot(redBrush, 2, this.Width - 90, this.Height / 2 - 20, 40, baseMaxHealth, baseDamage, baseSpeed, "none", baseBulletHealth, baseBulletDamage, baseBulletSpeed, baseReload, baseRegen, baseMaxHealth, 1, 0, 0);
            botList.Add(p2);

            //create 20 squares
            for (int i = 0; i <= 20; i++)
            {
                addShape = true;

                //random location
                shapeX    = randGen.Next(1, this.Width - squareSize - 1);
                shapeY    = randGen.Next(1, this.Height - squareSize - 1);
                newSquare = new Rectangle(shapeX, shapeY, squareSize, squareSize);

                //check to see if collision with a square
                foreach (Square s in squareList)
                {
                    r = new Rectangle(s.x - 1, s.y - 1, s.size + 1, s.size + 1);

                    if (r.IntersectsWith(newSquare))
                    {
                        addShape = false;
                    }
                }

                //if not colliding, add shape
                if (addShape == true)
                {
                    Square f = new Square(shapeX, shapeY, squareSize, squareHp, squareDamage);
                    squareList.Add(f);
                }
            }

            addShape = true;

            //create 5 hexagons
            for (int i = 0; i <= 5; i++)
            {
                shapeX    = randGen.Next(1, this.Width - hexagonSize - 1);
                shapeY    = randGen.Next(1, this.Height - hexagonSize - 1);
                newSquare = new Rectangle(shapeX, shapeY, hexagonSize, hexagonSize);

                //check to see if collision with a square
                foreach (Square s in squareList)
                {
                    r = new Rectangle(s.x - 1, s.y - 1, s.size + 1, s.size + 1);

                    if (r.IntersectsWith(newSquare))
                    {
                        addShape = false;
                    }
                }

                //check to see if collision with a hexagon
                foreach (Hexagon h in hexagonList)
                {
                    r = new Rectangle(h.x - 1, h.y - 1, h.size + 1, h.size + 1);

                    if (r.IntersectsWith(newSquare))
                    {
                        addShape = false;
                    }
                }

                if (addShape == true)
                {
                    Hexagon f = new Hexagon(shapeX, shapeY, hexagonSize, hexagonHp, hexagonDamage);
                    hexagonList.Add(f);
                }

                //start game
                gameLoop.Enabled = true;
            }
        }
Example #2
0
        private void LevelUp(Bot p, int attribute)
        {
            //upgrade attribute for specific player
            if (p.playerNumber == 1)
            {
                //upgrade selected attribute
                if (attribute == 0)
                {
                    //cannot upgrade if label forecolour is red
                    if (healthLabel.ForeColor != Color.Red)
                    {
                        p.hp        += 50;
                        p.maxHealth += 50;
                        p.boost++;

                        //if max upgrade make label forecolour red
                        if (p.maxHealth > 375)
                        {
                            healthLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 1)
                {
                    if (healthRegenLabel.ForeColor != Color.Red)
                    {
                        p.healthRegen += 4;
                        p.boost++;
                        if (p.healthRegen > 24)
                        {
                            healthRegenLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 2)
                {
                    if (bodyDamageLabel.ForeColor != Color.Red)
                    {
                        p.damage += 10;
                        p.boost++;
                        if (p.damage > 58)
                        {
                            bodyDamageLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 3)
                {
                    if (bulletSpeedLabel.ForeColor != Color.Red)
                    {
                        p.bulletSpeed += 8;
                        p.boost++;
                        if (p.bulletSpeed > 44)
                        {
                            bulletSpeedLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 4)
                {
                    if (bulletHealthLabel.ForeColor != Color.Red)
                    {
                        p.bulletHealth += 13;
                        p.boost++;
                        if (p.bulletHealth > 69)
                        {
                            bulletHealthLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 5)
                {
                    if (bulletDamageLabel.ForeColor != Color.Red)
                    {
                        p.bulletDamage += 17;
                        p.boost++;
                        if (p.bulletDamage > 93)
                        {
                            bulletDamageLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 6)
                {
                    if (reloadLabel.ForeColor != Color.Red)
                    {
                        p.reload -= 4;
                        p.boost++;
                        if (p.reload < 6)
                        {
                            reloadLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else
                {
                    if (speedLabel.ForeColor != Color.Red)
                    {
                        p.speed += 2;
                        p.boost++;
                        if (p.speed > 13)
                        {
                            speedLabel.ForeColor = Color.Red;
                        }
                    }
                }
            }
            else
            {
                if (attribute == 0)
                {
                    if (healthTwoLabel.ForeColor != Color.Red)
                    {
                        p.hp        += 50;
                        p.maxHealth += 50;
                        p.boost++;
                        if (p.maxHealth > 375)
                        {
                            healthTwoLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 1)
                {
                    if (healthRegenTwoLabel.ForeColor != Color.Red)
                    {
                        p.healthRegen += 4;
                        p.boost++;
                        if (p.healthRegen > 24)
                        {
                            healthRegenTwoLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 2)
                {
                    if (bodyDamageTwoLabel.ForeColor != Color.Red)
                    {
                        p.damage += 10;
                        p.boost++;
                        if (p.damage > 58)
                        {
                            bodyDamageTwoLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 3)
                {
                    if (bulletSpeedTwoLabel.ForeColor != Color.Red)
                    {
                        p.bulletSpeed += 8;
                        p.boost++;
                        if (p.bulletSpeed > 44)
                        {
                            bulletSpeedTwoLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 4)
                {
                    if (bulletHealthTwoLabel.ForeColor != Color.Red)
                    {
                        p.bulletHealth += 13;
                        p.boost++;
                        if (p.bulletHealth > 69)
                        {
                            bulletHealthTwoLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 5)
                {
                    if (bulletDamageTwoLabel.ForeColor != Color.Red)
                    {
                        p.bulletDamage += 17;
                        p.boost++;
                        if (p.bulletDamage > 93)
                        {
                            bulletDamageTwoLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else if (attribute == 6)
                {
                    if (reloadTwoLabel.ForeColor != Color.Red)
                    {
                        p.reload -= 4;
                        p.boost++;
                        if (p.reload < 6)
                        {
                            reloadTwoLabel.ForeColor = Color.Red;
                        }
                    }
                }
                else
                {
                    if (speedTwoLabel.ForeColor != Color.Red)
                    {
                        p.speed += 2;
                        p.boost++;
                        if (p.speed > 13)
                        {
                            speedTwoLabel.ForeColor = Color.Red;
                        }
                    }
                }
            }
        }