public void Draw(SpriteBatch batch, SpaceShip ship)
 {
     if (active)
     {
         Rectangle rectangle = ship.getUnitRectangle();
         Vector2 location = Unit.WorldPosToScreenPos(ship.GetPosition());
         Rectangle animationFrame = new Rectangle(0, 0, graphic.Width, graphic.Height);
         batch.Draw(graphic, location, animationFrame, Color.White, 0f,
             new Vector2(animationFrame.Width/2, animationFrame.Height/2),
             (float)rectangle.Width/animationFrame.Width, SpriteEffects.None, 1f);
     }
 }
Exemple #2
0
        public void HandleShopInput(KeyboardState newState, GameTime gameTime, SpaceShip ship)
        {
            switch (ship.GetShopWindow())
            {
                case "main":

                    if (newState.IsKeyDown(Keys.Z)) // Repair
                    {
                        if (currency >= 1 && ship.Repair(gameTime)) currency -= 1;
                    }
                    else if (newState.IsKeyDown(Keys.X) && !oldState.IsKeyDown(Keys.X)) // Engine window
                    {
                        ship.SetShopWindow("engine");
                    }
                    else if (newState.IsKeyDown(Keys.C) && !oldState.IsKeyDown(Keys.C)) // Abilities window
                    {
                        ship.SetShopWindow("abilities1");
                    }
                    else if (newState.IsKeyDown(Keys.V) && !oldState.IsKeyDown(Keys.V)) // Weapons window
                    {
                        ship.SetShopWindow("weapons1");
                    }
                    else if (newState.IsKeyDown(Keys.B) && !oldState.IsKeyDown(Keys.B)) // Armor window
                    {
                        ship.SetShopWindow("armor");
                    }
                    else if (newState.IsKeyDown(Keys.N) && !oldState.IsKeyDown(Keys.N)) //
                    {

                    }
                    break;
                case "abilities1":
                    if (newState.IsKeyDown(Keys.Z) && !oldState.IsKeyDown(Keys.Z)) // Shield 500
                    {
                        int price = 500;
                        if (currency >= price && ship.BuyAbility("shield")) Purchase(price);
                    }
                    else if (newState.IsKeyDown(Keys.X) && !oldState.IsKeyDown(Keys.X)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.C) && !oldState.IsKeyDown(Keys.C)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.V) && !oldState.IsKeyDown(Keys.V)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.B) && !oldState.IsKeyDown(Keys.B)) // Next abilities page
                    {
                        ship.SetShopWindow("abilities2");
                    }
                    else if (newState.IsKeyDown(Keys.N) && !oldState.IsKeyDown(Keys.N)) // Exit
                    {
                        ship.SetShopWindow("main");
                    }
                    break;
                case "abilities2":
                    if (newState.IsKeyDown(Keys.Z) && !oldState.IsKeyDown(Keys.Z)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.X) && !oldState.IsKeyDown(Keys.X)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.C) && !oldState.IsKeyDown(Keys.C)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.V) && !oldState.IsKeyDown(Keys.V)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.B) && !oldState.IsKeyDown(Keys.B)) // Next abilities window
                    {
                        ship.SetShopWindow("abilities1");
                    }
                    else if (newState.IsKeyDown(Keys.N) && !oldState.IsKeyDown(Keys.N)) // Exit
                    {
                        ship.SetShopWindow("main");
                    }
                    break;
                case "weapons1":
                    if (newState.IsKeyDown(Keys.Z) && !oldState.IsKeyDown(Keys.Z)) // Standard Gun 200
                    {
                        int price = 200;
                        if (currency >= price && ship.BuyWeapon("gun")) Purchase(price);
                    }
                    else if (newState.IsKeyDown(Keys.X) && !oldState.IsKeyDown(Keys.X)) // Rapid gun 600
                    {
                        int price = 600;
                        if (currency >= price && ship.BuyWeapon("rapidgun")) Purchase(price);
                    }
                    else if (newState.IsKeyDown(Keys.C) && !oldState.IsKeyDown(Keys.C)) // Laser 1000
                    {
                        int price = 1000;
                        if (currency >= price && ship.BuyWeapon("laser")) Purchase(price);
                    }
                    else if (newState.IsKeyDown(Keys.V) && !oldState.IsKeyDown(Keys.V)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.B) && !oldState.IsKeyDown(Keys.B)) // Next weapons window
                    {
                        ship.SetShopWindow("weapons2");
                    }
                    else if (newState.IsKeyDown(Keys.N) && !oldState.IsKeyDown(Keys.N)) // Exit
                    {
                        ship.SetShopWindow("main");
                    }
                    break;
                case "weapons2":
                    if (newState.IsKeyDown(Keys.Z) && !oldState.IsKeyDown(Keys.Z)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.X) && !oldState.IsKeyDown(Keys.X)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.C) && !oldState.IsKeyDown(Keys.C)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.V) && !oldState.IsKeyDown(Keys.V)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.B) && !oldState.IsKeyDown(Keys.B)) // Next weapons window
                    {
                        ship.SetShopWindow("weapons1");
                    }
                    else if (newState.IsKeyDown(Keys.N) && !oldState.IsKeyDown(Keys.N)) // Exit
                    {
                        ship.SetShopWindow("main");
                    }
                    break;
                case "armor":
                    if (newState.IsKeyDown(Keys.Z) && !oldState.IsKeyDown(Keys.Z)) // Buy Armor 100
                    {
                        if (Purchase(100)) ship.BuyArmor();
                    }
                    else if (newState.IsKeyDown(Keys.X) && !oldState.IsKeyDown(Keys.X)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.C) && !oldState.IsKeyDown(Keys.C)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.V) && !oldState.IsKeyDown(Keys.V)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.B) && !oldState.IsKeyDown(Keys.B)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.N) && !oldState.IsKeyDown(Keys.N)) // Exit
                    {
                        ship.SetShopWindow("main");
                    }
                    break;
                case "engine":
                    if (newState.IsKeyDown(Keys.Z) && !oldState.IsKeyDown(Keys.Z)) // Thrust 150
                    {
                        if (Purchase(150)) ship.BuyThrust();
                    }
                    else if (newState.IsKeyDown(Keys.X) && !oldState.IsKeyDown(Keys.X)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.C) && !oldState.IsKeyDown(Keys.C)) // Turn speed 150
                    {
                        if(Purchase(150)) ship.BuyTurnSpeed();
                    }
                    else if (newState.IsKeyDown(Keys.V) && !oldState.IsKeyDown(Keys.V)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.B) && !oldState.IsKeyDown(Keys.B)) //
                    {

                    }
                    else if (newState.IsKeyDown(Keys.N) && !oldState.IsKeyDown(Keys.N)) // Exit
                    {
                        ship.SetShopWindow("main");
                    }
                    break;

            }
        }