Beispiel #1
0
        public void DrawShips(SpriteBatch spriteBatch)
        {
            int positionX = 5;

            spriteBatch.Draw(background, new Rectangle(0, 0, screenWidth, screenHeight), Color.White);
            if (!selected)
            {
                spriteBatch.DrawString(mediumFont, "Which ship do you want to purchase?", new Vector2(screenWidth / 15, screenHeight / 20), Color.White);
                spriteBatch.DrawString(mediumFont, "Back", new Vector2(screenWidth / 20, screenHeight - 50), Color.White);
                spriteBatch.Draw(box, new Vector2(screenWidth / 20 - 20, screenHeight - 70), Color.White);

                for (int j = 0; j < ships.Count; j++)
                {
                    positionX += 250;

                    if (j == 1)
                    {
                        Rectangle rectangle = new Rectangle((screenWidth / 2 - 600) + positionX, (screenHeight / 2) - 200, 100, 50);
                        ships[j].Rectangle = rectangle;
                        ships[j].healthBar = new Rectangle(rectangle.X, rectangle.Y + rectangle.Height + 5, rectangle.Width, 5);
                        spriteBatch.Draw(shipBox, new Vector2(ships[j].Rectangle.X - 70, ships[j].Rectangle.Y - 70), Color.White);
                        spriteBatch.DrawString(mediumFont, ships[j].Name, new Vector2(ships[j].Rectangle.X - ships[j].Rectangle.Width / 6, ships[j].Rectangle.Y - ships[j].Rectangle.Height / 2), Color.Red);
                        spriteBatch.DrawString(mediumFont, "Cost:" + ships[j].Price, new Vector2(ships[j].Rectangle.X, ships[j].Rectangle.Y + 120), Color.White);
                        ships[j].Draw(spriteBatch);
                    }
                    else
                    {
                        Rectangle rectangle = new Rectangle((screenWidth / 2 - 600) + positionX, (screenHeight / 2), 100, 100);
                        ships[j].Rectangle = rectangle;
                        ships[j].healthBar = new Rectangle(rectangle.X, rectangle.Y + rectangle.Height + 5, rectangle.Width, 5);
                        spriteBatch.Draw(shipBox, new Vector2(ships[j].Rectangle.X - 70, ships[j].Rectangle.Y - 70), Color.White);
                        spriteBatch.DrawString(mediumFont, ships[j].Name, new Vector2(ships[j].Rectangle.X - ships[j].Rectangle.Width / 6, ships[j].Rectangle.Y - ships[j].Rectangle.Height / 2), Color.Red);
                        ships[j].Draw(spriteBatch);
                        spriteBatch.DrawString(mediumFont, "Cost:" + ships[j].Price, new Vector2(ships[j].Rectangle.X, ships[j].Rectangle.Y + 120), Color.White);
                    }


                    if (HoverOverShip(ships[j].Rectangle) && Clicked())
                    {
                        selectedShip = ships[j];
                        selected     = true;
                    }
                    else if (HoveringOverText("Back", new Vector2(screenWidth / 20, screenHeight - 50), mediumFont) && Clicked())
                    {
                        selectionScreen = false;
                    }
                }
            }
            else
            {
                spriteBatch.DrawString(biggerFont, "Do you want to buy " + selectedShip.Name + "?", new Vector2(screenWidth / 2 - (screenWidth / 4), screenHeight / screenHeight + 30), Color.White);
                //spriteBatch.DrawString(biggerFont,"Cost: "+selectedShip.Price,new Vector2)
                spriteBatch.DrawString(mediumFont, "Ship stats" + "\n\n" + "Cost: " + selectedShip.Price + "\n" + "Attack:" + selectedShip.Attack + "\n" + "Defense:" + selectedShip.Defense + "\n" + "Name:" + selectedShip.Name + "\n" + "Bonus Speed:" + selectedShip.MoveSpeed + "\n" + "Level:" + selectedShip.Level + "\n" + "Rockets: " + selectedShip.Rockets, new Vector2(statsPosition.X, statsPosition.Y + statsBox.Height + 30), Color.White);
                spriteBatch.Draw(statsBox, new Rectangle((int)statsPosition.X - 20, (int)statsPosition.Y - 20, 270, 320), Color.White);
                spriteBatch.DrawString(mediumFont, "Enfinitum:" + player.Enfinitum + "\n" + "Credits: " + player.Credits + "\n" + "Attack:" + player.Ship.Attack + "\n" + "Defense:" + player.Ship.Defense + "\n" + "Name:" + player.Ship.Name + "\n" + "Bonus Speed:" + player.Ship.MoveSpeed + "\n" + "Level:" + player.Ship.Level + "\n" + "Experience: " + player.Experience + "\n" + "Rockets:" + player.Ship.Rockets, statsPosition, Color.White);
                spriteBatch.Draw(statsBox, new Rectangle((int)statsPosition.X - 20, (int)statsPosition.Y + 360, 240, 270), Color.White);
                //drawTip(spriteBatch);
                spriteBatch.DrawString(biggerFont, "Yes", new Vector2(screenWidth / 2 - 150, (screenHeight - 80)), Color.White);
                spriteBatch.Draw(yesNoBox, new Vector2(screenWidth / 2 - 170, (screenHeight - 80)), Color.White);
                spriteBatch.DrawString(biggerFont, "No", new Vector2(screenWidth / 2 + 150, (screenHeight - 80)), Color.White);
                spriteBatch.Draw(yesNoBox, new Vector2(screenWidth / 2 + 120, (screenHeight - 80)), Color.White);
                spriteBatch.Draw(shipBox, new Vector2(selectedShip.Rectangle.X - 70, selectedShip.Rectangle.Y - 70), Color.White);
                selectedShip.Draw(spriteBatch);
                if (TextClicked("Yes", new Vector2(screenWidth / 2 - 150, (screenHeight - 85)), biggerFont) && Clicked())
                {
                    if (player.Credits >= selectedShip.Price)
                    {
                        buyShip(player, selectedShip, spriteBatch);
                    }
                    else
                    {
                        spriteBatch.DrawString(biggerFont, "Not enough credits", new Vector2(screenWidth / 2, screenHeight / 2), Color.Red);
                    }
                }
                else if (TextClicked("No", new Vector2(screenWidth / 2 + 150, (screenHeight - 80)), biggerFont) && Clicked())
                {
                    selected = false;
                }
                else if (EscapePressed())
                {
                    selectionScreen = false;
                }
            }
        }