Exemplo n.º 1
0
 private void SelectMenuItem(int itemNumber, InputManager inputManager)
 {
     optionNumber = (int)variable[itemNumber];
         if (axis == 2)
         {
             if (inputManager.KeyPressed(Keys.Right, Keys.D) && limits.Y > optionNumber)
             {
                 //System.Diagnostics.Debug.WriteLine("Option" + limits.X + "," + limits.Y);
                 variable[itemNumber]++;
             }
             else if (inputManager.KeyPressed(Keys.Left, Keys.A) && limits.X < optionNumber)
                 variable[itemNumber]--;
         }
         else
         {
             if (inputManager.KeyPressed(Keys.Down, Keys.S) && limits.Y > optionNumber)
                 variable[itemNumber]++;
             else if (inputManager.KeyPressed(Keys.Up, Keys.W) && limits.X < optionNumber)
                 variable[itemNumber]--;
         }
 }
Exemplo n.º 2
0
        public void Update(GameTime gameTime, InputManager inputManager)
        {
            if (axis == 1)
            {
                if (inputManager.KeyPressed(Keys.Right, Keys.D))
                    itemNumber++;
                else if (inputManager.KeyPressed(Keys.Left, Keys.A))
                    itemNumber--;
            }
            else
            {
                if (inputManager.KeyPressed(Keys.Down, Keys.S))
                    itemNumber++;
                else if (inputManager.KeyPressed(Keys.Up, Keys.W))
                    itemNumber--;
            }

            if (itemNumber != null)
            {
                if (linkType[itemNumber] == "Screen")
                {
                    Type newClass = Type.GetType("TM2." + linkID[itemNumber]);
                    ScreenManager.Instance.AddScreen((GameScreen)Activator.CreateInstance(newClass), inputManager);
                }
                else if (linkType[itemNumber] == "Option")
                {
                    SelectMenuItem(itemNumber, inputManager);
                }
            }

            if (itemNumber < 0)
                itemNumber = optionsItems.Count - 1;
            else if (itemNumber > optionsItems.Count - 1)
                itemNumber = 0;

            for (int i = 0; i < animation.Count; i++)
            {
                for (int j = 0; j < animation[i].Count; j++)
                {
                    if (itemNumber == i)
                        animation[i][j].IsActive = true;
                    else
                        animation[i][j].IsActive = false;

                    animation[i][j].Update(gameTime);
                }

            }
        }