public AutoMoveProjectile(int playerNumber, TextureObj obj, float seconds, float speed, float angle)
 {
     this.playerNumber = playerNumber;
     this.obj = obj;
     timeLeft = seconds;
     this.speed = speed;
     calculateToAdd(angle);
 }
        public Player(int playerNumber, TextureObj textureObj, float movementSpeed, float rotateSpeed, Vector2 healthBarLocation, Input entityInput)
        {
            this.playerNumber = playerNumber;
            base.textureObj = textureObj;
            base.movementSpeed = movementSpeed;
            base.rotateSpeed = rotateSpeed;
            this.healthBarLocation = healthBarLocation;
            base.entityInput = entityInput;

            //create and add the healthbar to active textures.
            String objName = "Life-" + (int)(((health + (maxHealth / 3.0 - 1)) / maxHealth) * 3) + ".png";
            Texture2D healthBar = Main.imageList.Find(obj => obj.Name == objName);
            Main.addAsActive(new TextureObj(playerNumber, healthBar, healthBarLocation, new Rectangle(0, 0, healthBar.Width, healthBar.Height), Color.White, 0, new Vector2(healthBar.Width / 2, healthBar.Height / 2), 1.0f, SpriteEffects.None, 1, "Healthbar"));
        }
        public Player(int playerNumber, TextureObj textureObj, float movementSpeed, float rotateSpeed, Keys up, Keys left, Keys down, Keys right, Keys shoot, Vector2 healthBarLocation)
        {
            this.playerNumber = playerNumber;
            this.textureObj = textureObj;
            this.movementSpeed = movementSpeed;
            this.rotateSpeed = rotateSpeed;
            this.up = up;
            this.left = left;
            this.down = down;
            this.right = right;
            this.shoot = shoot;
            this.healthBarLocation = healthBarLocation;
            controller = false;

            String objName = "Life-" + (int)((health / maxHealth) * 3) + ".png";
            Texture2D healthBar = Main.imageList.Find(obj => obj.Name == objName);
            Main.addAsActive(new TextureObj(playerNumber, healthBar, healthBarLocation, new Rectangle(0, 0, healthBar.Width, healthBar.Height), Color.White, 0, new Vector2(healthBar.Width / 2, healthBar.Height / 2), 1.0f, SpriteEffects.None, 1, "Healthbar"));
        }
        public Player(int playerNumber, TextureObj textureObj, float movementSpeed, float rotateSpeed, PlayerIndex playerIndex, Vector2 healthBarLocation)
        {
            this.playerNumber = playerNumber;
            this.textureObj = textureObj;
            this.movementSpeed = movementSpeed;
            this.rotateSpeed = rotateSpeed;
            this.playerIndex = playerIndex;
            this.healthBarLocation = healthBarLocation;

            //Temporary code till a main screen is added.
            //This way we can still control players and test if we dont have a controller at hand.
            if (GamePad.GetState(playerIndex).IsConnected)
            {
                controller = true;
            }
            else
            {
                if(playerNumber == 2)
                {
                    controller = false;
                    this.up = Keys.Up;
                    this.left = Keys.Left;
                    this.down = Keys.Down;
                    this.right = Keys.Right;
                    this.shoot = Keys.RightShift;
                }
                else if(playerNumber == 3)
                {
                    controller = false;
                    this.up = Keys.I;
                    this.left = Keys.J;
                    this.down = Keys.K;
                    this.right = Keys.L;
                    this.shoot = Keys.RightAlt;
                }
            }
            /////////////////////////////////////////////////////////////////////////////////////

            String objName = "Life-" + (int)((health / maxHealth) * 3) + ".png";
            Texture2D healthBar = Main.imageList.Find(obj => obj.Name == objName);
            Main.addAsActive(new TextureObj(playerNumber, healthBar, healthBarLocation, new Rectangle(0, 0, healthBar.Width, healthBar.Height), Color.White, 0, new Vector2(healthBar.Width / 2, healthBar.Height / 2), 1.0f, SpriteEffects.None, 1, "Healthbar"));
        }
 public bool checkCollision(TextureObj obj)
 {
     if (this.hitboxBL.X >= obj.hitboxBL.X && this.hitboxBL.X <= obj.hitboxBR.X)
     {
         if (this.hitboxBL.Y <= obj.hitboxBL.Y && this.hitboxBL.Y >= obj.hitboxTL.Y)
         {
             return true;
         }
         else if (this.hitboxTL.Y <= obj.hitboxBL.Y && this.hitboxTL.Y >= obj.hitboxTL.Y)
         {
             return true;
         }
     }
     else if (this.hitboxBR.X >= obj.hitboxBL.X && this.hitboxBR.X <= obj.hitboxBR.X)
     {
         if (this.hitboxBL.Y <= obj.hitboxBL.Y && this.hitboxBL.Y >= obj.hitboxTL.Y)
         {
             return true;
         }
         else if (this.hitboxTL.Y <= obj.hitboxBL.Y && this.hitboxTL.Y >= obj.hitboxTL.Y)
         {
             return true;
         }
     }
     return false;
 }
 public static void removeAsActive(TextureObj obj)
 {
     toDeactivateObjects.Add(obj);
     changeInActives = true;
     changeInLists = true;
 }
 public static void addAsActive(TextureObj obj)
 {
     toActivateObjects.Add(obj);
     changeInActives = true;
     changeInLists = true;
 }
        private void createPlayer(Texture2D playerImage, int x, int y, float movementSpeed, float rotateSpeed, PlayerIndex playerIndex, Vector2 healthBarLocation)
        {
            playerAmount++;
            TextureObj playerObj = new TextureObj(playerAmount, playerImage, new Vector2(x, y), new Rectangle(0, 0, playerImage.Width, playerImage.Height), Color.White, 0, new Vector2(playerImage.Width / 2, playerImage.Height / 2), 1.0f, SpriteEffects.None, 1, "Player");

            addAsActive(playerObj);
            playerList.Add(new Player(playerAmount, playerObj, movementSpeed, rotateSpeed, playerIndex, healthBarLocation));
        }
 public AutoMoveMeatball(TextureObj obj, float speed, float angle)
 {
     this.obj = obj;
     this.speed = speed;
     calculateToAdd(angle);
 }
        private Player createPlayer(Texture2D playerImage, int x, int y, float movementSpeed, 
            float rotateSpeed, Vector2 healthBarLocation, Input playerInput)
        {
            playerAmount++;
            System.Diagnostics.Debug.WriteLine("Making a player: " + playerAmount);
            TextureObj playerObj = new TextureObj(playerAmount, playerImage, new Vector2(x, y),
                new Rectangle(0, 0, playerImage.Width, playerImage.Height), Color.White, 0,
                new Vector2(playerImage.Width / 2, playerImage.Height / 2), 1.0f, SpriteEffects.None, 1, "Player");

            addAsActive(playerObj);
            Player newPlayer = new Player(playerAmount, playerObj, movementSpeed, rotateSpeed, healthBarLocation, playerInput);
            playerList.Add(newPlayer);
            return newPlayer;
        }
        public void createMeatball()
        {
            Texture2D meatballImage = imageList.Find(name => name.Name == "Meatball.png");

            Vector2 location = new Vector2(0, 0);
            float angle = 0;
            float speed = (float)(random.NextDouble() * 20) + 1.0f;
            float scale = (float)(random.NextDouble() * 4) + 1.0f;

            int n = random.Next(4);
            if(n == 0)
            {
                location = new Vector2((float)(random.NextDouble() * screenWidth), (float)(0 - ((meatballImage.Height / 2) * scale)));
                angle = (float)(random.NextDouble() * 140 + 110);
            }
            else if(n == 1)
            {
                location = new Vector2((float)(screenWidth + ((meatballImage.Width / 2) * scale)), (float)(random.NextDouble() * screenHeight));
                angle = (float)(random.NextDouble() * 140 + 200);
            }
            else if (n == 2)
            {
                location = new Vector2((float)(random.NextDouble() * screenWidth), (float)(screenHeight + ((meatballImage.Height / 2) * scale)));
                angle = (float)(random.NextDouble() * 140 + - 70);
                //To make sure you dont pass on negative angles.
                if (angle < 0)
                {
                    angle += 359;
                }
            }
            else if (n == 3)
            {
                location = new Vector2((float)(0 - ((meatballImage.Width / 2) * scale)), (float)(random.NextDouble() * screenHeight));
                angle = (float)(random.NextDouble() * 140 + 20);
            }

            TextureObj projectileObj = new TextureObj(meatballImage, location, new Rectangle(0, 0, meatballImage.Width, meatballImage.Height), Color.White, angle, new Vector2(meatballImage.Width / 2, meatballImage.Height / 2), scale, SpriteEffects.None, 1.0f, "Meatball");
            addAsActive(projectileObj);
            addAsMeatball(new AutoMoveMeatball(projectileObj, speed, angle));
        }
 public bool checkCollision(TextureObj obj)
 {
     //System.Diagnostics.Debug.WriteLine("Checking for Collision");
     //System.Diagnostics.Debug.WriteLine("This BL X: " + this.hitboxBL.X + ", collision BL X: " + obj.hitboxBL.X + ", collision BR X: " + obj.hitboxBR.X);
     //System.Diagnostics.Debug.WriteLine("This BL X: " + this.hitboxBL.X + ", collision BR X: " + obj.hitboxBR.X);
     if (this.hitboxBL.X >= obj.hitboxBL.X && this.hitboxBL.X <= obj.hitboxBR.X)
     {
         //System.Diagnostics.Debug.WriteLine("BL left in image1");
         //System.Diagnostics.Debug.WriteLine("This BL Y: " + this.hitboxBL.Y + ", collision BL Y: " + obj.hitboxBL.Y + ", collision TL Y: " + obj.hitboxTL.Y);
         //System.Diagnostics.Debug.WriteLine("This BL Y: " + this.hitboxBL.Y + ", collision TL Y: " + obj.hitboxTL.Y);
         if (this.hitboxBL.Y <= obj.hitboxBL.Y && this.hitboxBL.Y >= obj.hitboxTL.Y)
         {
             return true;
         }
         else if (this.hitboxTL.Y <= obj.hitboxBL.Y && this.hitboxTL.Y >= obj.hitboxTL.Y)
         {
             return true;
         }
     }
     else if (this.hitboxBR.X >= obj.hitboxBL.X && this.hitboxBR.X <= obj.hitboxBR.X)
     {
         if (this.hitboxBL.Y <= obj.hitboxBL.Y && this.hitboxBL.Y >= obj.hitboxTL.Y)
         {
             return true;
         }
         else if (this.hitboxTL.Y <= obj.hitboxBL.Y && this.hitboxTL.Y >= obj.hitboxTL.Y)
         {
             return true;
         }
     }
     return false;
 }