static public void Update(GameTime gameTime)
        {
            bool isCityClicked = false;

            //temp is used to check that a city has been pressed on and that it should display the associated
            //buttons and info and once somewhere else has been pressed on the screen that info should disappear


            foreach (Button button in cityButtons)
            {
                if (button.LeftClick())
                {
                    isCityClicked = true;
                }
            }

            if (!isCityClicked)
            {
                if (KMReader.LeftMouseClick())
                {
                    showText = false;
                }
            }

            foreach (Button tempButton in infoButtons)
            {
                if (tempButton.LeftClick())
                {
                    CityInfoMenu.Active   = true;
                    CityInfoMenu.Selected = tempButton.Name;
                }
            }

            foreach (Button button in cityButtons)
            {
                int counter = 0;
                foreach (City city in cities)
                {
                    if (button.LeftClick() && button.Name == city.Name)
                    {
                        showText  = true;
                        cityName  = city.Name;
                        cityCords = city.Coordinates;
                        cityInfo  = " ";
                        if (Player.VisitedCities[counter])
                        {
                            cityInfo = city.Information;
                        }
                    }
                    counter++;
                }
            }
        }
Esempio n. 2
0
 public bool RightClick()
 {
     if (KMReader.mouseState.RightButton == ButtonState.Pressed && KMReader.prevMouseState.RightButton == ButtonState.Released) //för att "hitta" exakt när kanppen trycks på
     {
         if (KMReader.RightMouseClick())
         {
             if (hitBox.Contains(KMReader.GetMousePoint()))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 3
0
        private void CheckDraggerChange()
        {
            if (KMReader.HeldMouseClick() && dragging == true)
            {
                dragging = true;
                fix      = false;
                if (KMReader.GetMouseVector2().X > disposeDragger.HitBox.X + (500 / 20) && disposeDragger.HitBox.X < 1211)
                {
                    Vector2 temp = KMReader.GetMouseVector2();
                    temp.Y = disposeDragger.HitBox.Y;
                    Rectangle temp2 = new Rectangle((int)temp.X, (int)temp.Y, disposeDragger.HitBox.Width, disposeDragger.HitBox.Height);
                    disposeDragger.HitBox = temp2;
                    numberToDispose       = 5 * ((disposeDragger.HitBox.X - 710) / (500 / 20));
                }
                else if (KMReader.GetMouseVector2().X < disposeDragger.HitBox.X - (500f / 20) && disposeDragger.HitBox.X > 710)
                {
                    Vector2 temp = KMReader.GetMouseVector2();
                    temp.Y = disposeDragger.HitBox.Y;
                    Rectangle temp2 = new Rectangle((int)temp.X, (int)temp.Y, disposeDragger.HitBox.Width, disposeDragger.HitBox.Height);
                    disposeDragger.HitBox = temp2;
                    numberToDispose       = 5 * ((disposeDragger.HitBox.X - 710) / (500 / 20));
                }

                if (disposeDragger.HitBox.X > 1211 && disposeDragger.HitBox.X > 710)
                {
                    disposeDragger.HitBox = new Rectangle(1211, disposeDragger.HitBox.Y, disposeDragger.HitBox.Width, disposeDragger.HitBox.Height);
                    numberToDispose       = 100;
                }

                if (disposeDragger.HitBox.X < 710 && disposeDragger.HitBox.X < 1211)
                {
                    disposeDragger.HitBox = new Rectangle(710, disposeDragger.HitBox.Y, disposeDragger.HitBox.Width, disposeDragger.HitBox.Height);
                    numberToDispose       = 0;
                }
            }
            else if (!fix)
            {
                dragging = false;
            }
        }
Esempio n. 4
0
 private void CheckSelect()
 {
     if (KMReader.LeftMouseClick())
     {
         int counter = 0;
         foreach (Rectangle tempRectangle in inventoryGrid)
         {
             if (tempRectangle.Contains(KMReader.GetMousePoint()) && !disposing)
             {
                 try
                 {
                     selected       = Player.Inventory.ItemList[counter];
                     selectedSquare = counter;
                 }
                 catch
                 {
                     //Mys 10/10 felhantering
                 }
             }
             counter++;
         }
     }
 }
Esempio n. 5
0
        //========================================================================
        //OM DU SKA ÄNDRA GAMESTATE ANVÄND METODERNA SOM FINNS EFTER DRAW METODEN
        //========================================================================
        protected override void Update(GameTime gameTime) // Too long
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Back))
            {
                Exit();
            }

            EndCredits.Update(gameTime.ElapsedGameTime.TotalMilliseconds); //////////////////////////////////////
            LevelUp.Update(gameTime.ElapsedGameTime.TotalMilliseconds);    ///////////////////////////////////////

            AchievementManager.Update();

            if (WorldEventManager.Update(random))
            {
                test = true;
            }
            else
            {
                test = false;
            }

            KMReader.Update();
            Calendar.Update();
            if (Calendar.CheckEventClick())
            {
                eventLog = !eventLog;
            }

            if (gameState == GameState.CityMenu)
            {
                UpdateCityMenu(gameTime);
            }
            else if (gameState == GameState.MapMenu)
            {
                UpdateMapMenu(gameTime);
            }
            else if (gameState == GameState.TradeMenu)
            {
                UpdateTradeMenu();
            }
            else if (gameState == GameState.InventoryMenu)
            {
                UpdateInventoryMenu(gameTime);
            }
            else if (gameState == GameState.TravelMenu)
            {
                UpdateTravelMenu(gameTime);
            }
            else if (gameState == GameState.MainMenu)
            {
                UpdateMainMenu();
            }
            else if (gameState == GameState.CharacterCreationMenu)
            {
                UpdateCharacterCreationMenu();
            }
            else if (gameState == GameState.Debug)
            {
                UpdateDebugMenu();
            }

            if (KMReader.prevKeyState.IsKeyUp(Keys.F6) && KMReader.keyState.IsKeyDown(Keys.F6))
            {
                ChangeGameState(GameState.Debug);
            }
            if (KMReader.prevKeyState.IsKeyUp(Keys.F11) && KMReader.keyState.IsKeyDown(Keys.F11))
            {
                LoadSave();
            }
            if (KMReader.prevKeyState.IsKeyUp(Keys.F12) && KMReader.keyState.IsKeyDown(Keys.F12))
            {
                SaveGame();
            }

            if (options)
            {
                UpdateOptionsMenu();
            }
            if (OptionsMenu.CheckMenuToggle())
            {
                options = !options;
            }

            WorldMapMenu.CheckPlayerEventLog();
            WorldMapMenu.UpdateCities();
            Player.Update();
            if (CityInfoMenu.Update())
            {
                CityInfoMenu.Active = false;
                ChangeGameState(GameState.TravelMenu);
            }

            base.Update(gameTime);
        }
Esempio n. 6
0
 public bool RightClicked()
 {
     return(KMReader.OverRectangle(hitbox));
 }