Пример #1
0
        public Shop(Player player, Random rng, SpriteFont largeFont, SpriteFont mediumFont, SpriteFont smallFont, Texture2D cursor, Texture2D moneyCounter, Level waveManager)
        {
            nacho    = player;
            this.rng = rng;

            transitionAlpha = 255;
            fadeIn          = true;
            fadeOut         = false;

            this.largeFont    = largeFont;
            this.mediumFont   = mediumFont;
            this.smallFont    = smallFont;
            this.cursor       = cursor;
            this.moneyCounter = moneyCounter;

            cursorX = 1050;
            cursorY = 480;

            shopState = ShopMenuState.Options;
            WelcomeTextGenerator();

            this.waveManager = waveManager;

            healthPrice = HealthPrice;
            weaponPrice = 500;
            bombPrice   = BombPrice;

            menuSelection = 0;
            shopSelection = 0;
        }
Пример #2
0
        public virtual void Initialize()
        {
            missionHelper = new MissionHelper(Game, this);
            missionHelper.Initialize();

            objectives            = new List <Objective>();
            objectiveDescriptions = new List <string>();

            rewardItems = new List <Item>();

            OverviewMenuState = Game.stateManager.planetState.SubStateManager.OverviewMenuState;
            MissionMenuState  = Game.stateManager.planetState.SubStateManager.MissionMenuState;
            RumorsMenuState   = Game.stateManager.planetState.SubStateManager.RumorsMenuState;
            ShopMenuState     = Game.stateManager.planetState.SubStateManager.ShopMenuState;

            eventBuffer    = MissionManager.MissionEventBuffer;
            responseBuffer = MissionManager.MissionResponseBuffer;
            acceptText     = new string[1];

            LoadMissionData();

            SetMissionType();
        }
Пример #3
0
        public virtual void Initialize()
        {
            textBoxes        = new List <TextBox>();
            tempTextList     = new List <string>();
            tempVariableList = new List <string>();

            portraitTextRectangle = new Rectangle((int)(Game1.ScreenSize.X / 2 - PortraitOverlaySize.X / 2 + PortraitTextOffset.X),
                                                  (int)(Game1.ScreenSize.Y / 2 - PortraitOverlaySize.Y / 2 + PortraitTextOffset.Y),
                                                  (int)(PortraitOverlaySize.X - PortraitTextOffset.X - 20),
                                                  (int)(PortraitOverlaySize.Y / 2 - PortraitTextOffset.Y - 20));

            normalTextRectangle = new Rectangle((int)(Game1.ScreenSize.X / 2 - TextOverlaySize.X / 2 + NormalTextOffset.X),
                                                (int)(Game1.ScreenSize.Y / 2 - TextOverlaySize.Y / 2 + NormalTextOffset.Y),
                                                (int)(TextOverlaySize.X - NormalTextOffset.X - 20),
                                                (int)(TextOverlaySize.Y / 2 - NormalTextOffset.Y - 20));

            responseTextRectangle = new Rectangle((int)(Game1.ScreenSize.X / 2 - ResponseOverlaySize.X / 2 + ResponseTextOffset.X),
                                                  (int)(Game1.ScreenSize.Y / 2 - ResponseOverlaySize.Y / 2 + ResponseTextOffset.Y),
                                                  (int)(ResponseOverlaySize.X - ResponseTextOffset.X - 20),
                                                  (int)(ResponseOverlaySize.Y / 2 - ResponseTextOffset.Y - 20));

            responseRectangles = new List <Rectangle>();

            responseRectangle1 = new Rectangle((Game1.ScreenSize.X / 2 + (int)ResponseOverlaySize.X / 6) - 10,
                                               Game1.ScreenSize.Y / 2 + 30,
                                               (int)ResponseOverlaySize.X - 20,
                                               10);

            responseRectangles.Add(responseRectangle1);

            responseRectangle2 = new Rectangle((Game1.ScreenSize.X / 2 + (int)ResponseOverlaySize.X / 6) - 10,
                                               Game1.ScreenSize.Y / 2 + 30 + 24,
                                               (int)ResponseOverlaySize.X - 20,
                                               10);

            responseRectangles.Add(responseRectangle2);

            responseRectangle3 = new Rectangle((Game1.ScreenSize.X / 2 + (int)ResponseOverlaySize.X / 6) - 10,
                                               Game1.ScreenSize.Y / 2 + 30 + 48,
                                               (int)ResponseOverlaySize.X - 20,
                                               10);

            responseRectangles.Add(responseRectangle3);

            responseRectangle4 = new Rectangle((Game1.ScreenSize.X / 2 + (int)ResponseOverlaySize.X / 6) - 10,
                                               Game1.ScreenSize.Y / 2 + 30 + 72,
                                               (int)ResponseOverlaySize.X - 20,
                                               10);

            responseRectangles.Add(responseRectangle4);

            allButtons      = new List <MenuDisplayObject>();
            buttonsToRemove = new List <MenuDisplayObject>();

            menuStates = new List <MenuState>();

            rumorsMenuState = new RumorsMenuState(this.Game, "Rumors", this, baseState);
            rumorsMenuState.Initialize();

            overviewMenuState = new OverviewMenuState(this.Game, "Overview", this, baseState);
            overviewMenuState.Initialize();

            missionMenuState = new MissionMenuState(this.Game, "Mission", this, baseState);
            missionMenuState.Initialize();

            shopMenuState = new ShopMenuState(this.Game, "Shop", this, baseState);
            shopMenuState.Initialize();

            menuStates.Add(overviewMenuState);
            menuStates.Add(missionMenuState);
            menuStates.Add(shopMenuState);
            menuStates.Add(rumorsMenuState);
        }
Пример #4
0
        public void UpdateShop()
        {
            KeyboardState KBnow = Keyboard.GetState();

            switch (shopState)
            {
            case ShopMenuState.Options:
                if (fadeIn == true)    // plays fade in effects
                {
                    transitionAlpha -= 5;
                    if (transitionAlpha <= 0)
                    {
                        transitionAlpha = 0;
                        fadeIn          = false;
                    }
                }

                if (fadeOut == true)    // plays fade out effects
                {
                    transitionAlpha += 3;
                    if (transitionAlpha >= 255)
                    {
                        transitionAlpha = 255;
                        fadeIn          = true;
                        fadeOut         = false;

                        shopState = ShopMenuState.Leave;
                    }
                }

                // moves cursor down & changes selection
                if (KBnow.IsKeyDown(Keys.Down) && KBprev != KBnow &&
                    fadeIn == false && fadeOut == false)
                {
                    cursorY += 95;
                    menuSelection++;
                }

                // moves the cursor up & changes selection
                if (KBnow.IsKeyDown(Keys.Up) && KBprev != KBnow &&
                    fadeIn == false && fadeOut == false)
                {
                    cursorY -= 95;
                    menuSelection--;
                }

                // facilitates screen wrapping of cursor
                if (menuSelection < 0)
                {
                    menuSelection = 2;
                    cursorY      += 285;
                }
                // facilitates screen wrapping of cursor
                if (menuSelection > 2)
                {
                    menuSelection = 0;
                    cursorY      -= 285;
                }

                //moves to shop screen (where player can actually buy items)
                if (KBnow.IsKeyDown(Keys.Z) && KBprev != KBnow && menuSelection == 0 &&
                    transitionAlpha == 0)
                {
                    BuyTextGenerator();
                    shopState     = ShopMenuState.Buy;
                    shopSelection = 0;
                    cursorX       = 850;
                    cursorY       = 405;
                }
                // prints out random text from Talulah's Diolauge (below)
                else if (KBnow.IsKeyDown(Keys.Z) && KBprev != KBnow && menuSelection == 1 &&
                         transitionAlpha == 0)
                {
                    TalkTextGenerator();
                }
                // exits the shop
                else if (KBnow.IsKeyDown(Keys.Z) && KBprev != KBnow && menuSelection == 2 &&
                         transitionAlpha == 0)
                {
                    fadeIn  = false;
                    fadeOut = true;
                }

                break;

            // moves cursor and displays text for selected item
            case ShopMenuState.Buy:
                if (KBnow.IsKeyDown(Keys.Down) && KBprev != KBnow)
                {
                    cursorY += 65;
                    shopSelection++;
                    BuyTextGenerator();
                }

                if (KBnow.IsKeyDown(Keys.Up) && KBprev != KBnow)
                {
                    cursorY -= 65;
                    shopSelection--;
                    BuyTextGenerator();
                }

                if (shopSelection < 0)
                {
                    shopSelection = 3;
                    cursorY      += 255;
                    BuyTextGenerator();
                }

                if (shopSelection > 3)
                {
                    shopSelection = 0;
                    cursorY      -= 255;
                    BuyTextGenerator();
                }

                // buying health
                if (KBnow.IsKeyDown(Keys.Z) && KBprev != KBnow && shopSelection == 0)
                {
                    if (nacho.Coincount >= HealthPrice && nacho.Health <= 28)    // subtracts coins equal to health price and adds one health
                    {
                        nacho.Coincount -= HealthPrice;

                        nacho.Health += 1;
                    }
                    // When the maximum health has been reached, health cannot be bought
                    else if (nacho.Coincount >= HealthPrice)
                    {
                        shopKeepText = "You're a healthy man Nacho." +
                                       "\nEat a doughnut once in a while.";
                    }
                    else     // runs if player cannot afford health
                    {
                        BrokeTextGenerator();
                    }
                }
                // buying damage upgrade
                else if (KBnow.IsKeyDown(Keys.Z) && KBprev != KBnow && shopSelection == 1)
                {
                    if (nacho.Coincount >= weaponPrice)     // subtracts coins equal to damage price and increases damage
                    {
                        nacho.Coincount -= weaponPrice;

                        nacho.Damage += 10;
                        weaponPrice  += 500;
                    }
                    else     // runs if player cannot afford upgrade
                    {
                        BrokeTextGenerator();
                    }
                }
                // buying bombs
                else if (KBnow.IsKeyDown(Keys.Z) && KBprev != KBnow && shopSelection == 2)
                {
                    if (nacho.Coincount >= BombPrice)     // subtracts coins equal to bomb price and adds bomb
                    {
                        nacho.Coincount -= BombPrice;

                        nacho.NumBombs++;
                    }
                    else     // runs if player cannot afford bomb
                    {
                        BrokeTextGenerator();
                    }
                }
                // moves player back to main shop screen
                else if (KBnow.IsKeyDown(Keys.Z) && KBprev != KBnow && shopSelection == 3)
                {
                    WelcomeTextGenerator();
                    shopState     = ShopMenuState.Options;
                    menuSelection = 0;
                    cursorX       = 1050;
                    cursorY       = 415;
                }

                break;

            case ShopMenuState.Leave:
                // When the shop menu state enters the leave state,
                // the gameState changes back to the Game state

                break;
            }

            KBprev = KBnow;
        }