Exemple #1
0
 public virtual void select(InputHandlerComponent i)
 {
     if (i.getButton("Select", true))
     {
         if (Selected != null)
         {
             Selected(this, new EventArgs());
         }
     }
 }
        public MediaLibraryComponent(Game game, MenuComponent m)
            : base(game)
        {
            menus    = m;
            input    = new InputHandlerComponent(game);
            playList = new List <Song>();
            random   = new Random();

            spriteBatch = new SpriteBatch(game.GraphicsDevice);
        }
        public void update(InputHandlerComponent input)
        {
            movement(input);

            for (int i = top; i < bottom; i++)
            {
                options[i].update(input);
            }

            counter++;
        }
        public void update(InputHandlerComponent i)
        {
            movement(i);

            foreach (OptionType option in options)
            {
                option.update(i);
            }

            counter++;
        }
 public override void update(InputHandlerComponent i, ref string state)
 {
     if (activeSubMenu)
     {
         subMenu.update(i, ref state);
     }
     else
     {
         base.update(i, ref state);
     }
 }
 public MenuComponent(Game game)
     : base(game)
 {
     spriteBatch       = new SpriteBatch(game.GraphicsDevice);
     input             = new InputHandlerComponent(game);
     transitionManager = new TransitionManager();
     menus             = new Dictionary <string, MenuType>();
     systems           = new Dictionary <string, SystemType>();
     menuStack         = new Stack <string>();
     gameStack         = new Stack <string>();
 }
        public override void select(InputHandlerComponent i, ref string state)
        {
            if (i.getButton("Select", true))
            {
                if (Selected != null)
                {
                    Text = "Press any key";

                    Selected(this, new EventArgs());
                }
            }
        }
Exemple #8
0
        public void update(InputHandlerComponent i)
        {
            arrows.update(i);

            if (i.getButton("Select", true))
            {
                if (Selected != null)
                {
                    Selected(this, new EventArgs());
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Checks to see if the user has pressed the back button, and if so, raises the Back event and resets the menu data.
        /// </summary>
        /// <param name="i">The game's menu input handler.</param>
        public virtual void back(InputHandlerComponent i)
        {
            if (i.getButton("Back", true))
            {
                if (Back != null)
                {
                    Back(this, new EventArgs());
                }

                reset();
            }
        }
Exemple #10
0
        public virtual void select(InputHandlerComponent i, ref string state)
        {
            if (i.getButton("Select", true))
            {
                if (Selected != null)
                {
                    Selected(this, new EventArgs());
                }

                state = menuLink;
            }
        }
        public /*override*/ void movement(InputHandlerComponent i)
        {
            if (i.getButton("Left", true) && !left.selected && !right.selected && level > 1)
            {
                level--;
                left.selected = true;
            }

            if (i.getButton("Right", true) && !left.selected && !right.selected && level < levelMax)
            {
                level++;
                right.selected = true;
            }
        }
Exemple #12
0
        public Snakez()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.PreferredBackBufferWidth  = 240;
            graphics.PreferredBackBufferHeight = 320;

            graphics.ApplyChanges();

            input = new InputHandlerComponent(this);

            Components.Add(input);
        }
Exemple #13
0
        /// <summary>
        /// Updates all of the menu's components, as well as checking if the user has pressed the back button.
        /// </summary>
        /// <param name="i">The game's menu input handler.</param>
        public virtual void update(InputHandlerComponent i)
        {
            switch (transitionState)
            {
            case TransitionState.menu:
                foreach (IComponent component in components.Values)
                {
                    component.update(i);
                }

                back(i);

                break;
            }
        }
Exemple #14
0
        private void rotate(InputHandlerComponent input, Vector2 sourceVector)
        {
            //Get the vector of the touch pad
            Vector2 inputVector = input.getVector(vector - sourceVector);

            //If the y coordinate is positive, invert the rotation
            if (inputVector.Y > 0)
            {
                rotation = -(float)(Math.Acos(inputVector.X));
            }
            else
            {
                rotation = (float)Math.Acos(inputVector.X);
            }
        }
        public override void update(InputHandlerComponent i)
        {
            base.update(i);

            left.update(ref counter, counterMax);
            right.update(ref counter, counterMax);

            select(i);

            counter++;

            if (counter > counterMax)
            {
                counter = 0;
            }
        }
Exemple #16
0
        public override void update(GameTime gameTime, InputHandlerComponent input, Vector2 moveVector)
        {
            vector = moveVector;

            if (input.getButton(ButtonType.b, true))
            {
                reload();
            }

            if (input.getButton(ButtonType.a, true))
            {
                shoot(gameTime);
            }

            bullet.update(gameTime, vector);
        }
 public void scroll(InputHandlerComponent i)
 {
     if (i.getButton("Left", true) && leftState != "None")
     {
         if (leftState != "None")
         {
             Scroll(this, new DirectionArgs(Direction.left));
         }
     }
     else if (i.getButton("Right", true) && rightState != "None")
     {
         if (rightState != "None")
         {
             Scroll(this, new DirectionArgs(Direction.right));
         }
     }
 }
Exemple #18
0
        /// <summary>
        /// Updates the snake, based upon user input and level design.
        /// </summary>
        /// <param name="i">The game's input handler.</param>
        /// <param name="level">The current level the snake is in.</param>
        public void update(InputHandlerComponent i, LevelType level)
        {
            //If the snake needs to progress forward, check collision and react accordingly
            if (counter == interval)
            {
                switch (collision(level))
                {
                //If the potential cell is empty or a portal, move the snake there.
                case CellContent.empty:
                case CellContent.portal:
                    move(level);
                    break;

                //If the cell is filled with a food item, move there and eat the food.
                case CellContent.food:
                    move(level);
                    EatFood(this, level.LevelFood.getArgs());
                    break;

                //If the cell is filled with a level item, i.e. a key, move there and activate the item.
                case CellContent.item:
                    move(level);
                    ActivateObject(this, new EventArgs());
                    break;

                //If the cell is a wall or a part of the snake, raise the game over event.
                case CellContent.snake:
                case CellContent.wall:
                    GameOver(this, new EventArgs());
                    break;
                }

                counter = 0;
                canTurn = true;
            }

            //If a turn has not already been activated, allow the snake to attempt to turn
            if (canTurn)
            {
                turn(i);
            }

            //Update the counter
            counter++;
        }
Exemple #19
0
        public virtual void update(InputHandlerComponent i)
        {
            switch (state)
            {
            case OptionState.standard:
                option.update();
                break;

            case OptionState.highlighted:
                highlighted.update();
                select(i);
                break;

            case OptionState.pressed:
                hit.update();
                break;
            }
        }
 public void movement(InputHandlerComponent i)
 {
     if (i.getButton("Down", false) && index < options.Count - 1 && counter > interval)
     {
         options[index].State = OptionState.standard;
         index++;
         options[index].State = OptionState.highlighted;
         counter = 0;
         return;
     }
     else if (i.getButton("Up", false) && index > 0 && counter > interval)
     {
         options[index].State = OptionState.standard;
         index--;
         options[index].State = OptionState.highlighted;
         counter = 0;
         return;
     }
 }
Exemple #21
0
        public void update(InputHandlerComponent i)
        {
            movement(i);

            foreach (SlideType slide in slides)
            {
                slide.update(i);
            }

            calculateColor();

            preview.changeColor(color);

            preview.update(i);

            option.update(i);

            counter++;
        }
Exemple #22
0
        public override void update(GameTime gameTime, InputHandlerComponent input, Vector2 moveVector)
        {
            vector = moveVector;

            bullet.update(gameTime, moveVector);

            if (input.getButton(ButtonType.b, true))
            {
                reload();
            }

            if (input.getButton(ButtonType.a, false))
            {
                shoot(gameTime);
            }
            else if (input.getReleased(ButtonType.a, true))
            {
                bullet.deactivate();
            }
        }
Exemple #23
0
        public void movement(InputHandlerComponent i)
        {
            if (i.getButton("Left", false) && number > minimum)
            {
                number--;

                if (slider != null)
                {
                    slider.move(number, maximum);
                }
            }

            if (i.getButton("Right", false) && number < maximum)
            {
                number++;

                if (slider != null)
                {
                    slider.move(number, maximum);
                }
            }
        }
Exemple #24
0
        /// <summary>
        /// Turns the snake based on the input from the user.
        /// </summary>
        /// <param name="i">The game's input handler</param>
        private void turn(InputHandlerComponent i)
        {
            //The new orientation of the snake
            OrientationType newOrientation = head.Orientation;

            //Get the new orientation based on the input
            if (i.getButton("Right", true) && head.Orientation != OrientationType.left)
            {
                newOrientation = OrientationType.right;
            }
            else if (i.getButton("Up", true) && head.Orientation != OrientationType.down)
            {
                newOrientation = OrientationType.up;
            }
            else if (i.getButton("Down", true) && head.Orientation != OrientationType.up)
            {
                newOrientation = OrientationType.down;
            }
            else if (i.getButton("Left", true) && head.Orientation != OrientationType.right)
            {
                newOrientation = OrientationType.left;
            }

            //If there has been a change in the orientation, add a curve and change the snake
            if (newOrientation != head.Orientation)
            {
                CurveType curve = new CurveType();
                curve.deepCopy(temp);

                curve.Vector      = head.Vector;
                curve.Orientation = newOrientation;
                curve.Rotation    = MovementFunctions.calculateCurveRotation(head.Orientation, newOrientation);
                curves.Add(curve.Vector, curve);

                head.Orientation = newOrientation;

                canTurn = false;
            }
        }
Exemple #25
0
        public void update(InputHandlerComponent i)
        {
            ArrowDirection direction = ArrowDirection.left;

            foreach (ArrowType arrow in arrows.Values)
            {
                arrow.update();
            }

            if (i.getButton("Left", true))
            {
                direction = ArrowDirection.left;
            }
            else if (i.getButton("Right", true))
            {
                direction = ArrowDirection.right;
            }
            else if (i.getButton("Up", true))
            {
                direction = ArrowDirection.up;
            }
            else if (i.getButton("Down", true))
            {
                direction = ArrowDirection.down;
            }
            else
            {
                return;
            }

            try
            {
                getArrow(direction).press();
            }
            catch
            {
            }
        }
Exemple #26
0
 public override void update(InputHandlerComponent input)
 {
 }
 public override void update(InputHandlerComponent i)
 {
     scroll(i);
 }
 public void update(InputHandlerComponent i)
 {
 }
 public void updateInput(InputHandlerComponent i)
 {
     input = i;
 }
Exemple #30
0
 public virtual void update(InputHandlerComponent i)
 {
     getMenu(current).update(i);
 }