Exemplo n.º 1
0
        public override void Update(GameTime gameTime, TouchCollection touchCollection)
        {
            if (touchCollection.Count() > 0)
            {
                //get the first touch
                TouchLocation touch = touchCollection.ElementAt(0);
                if (touch.State == TouchLocationState.Pressed)
                {
                    String command = Helper.GetFirstButtonPressCommand(listButtons, (int)touch.Position.X, (int)touch.Position.Y);

                    if (command.Equals("returnToSolarSystem"))
                    {
                        NextScreen = game.screenSolarSystem;
                    }
                    else if (command.Equals("nasa"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureMarsNASAInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                    else if (command.Equals("moon"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureMarsMoonInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                    else if (command.Equals("storm"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureMarsStormInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                }
            }
        }
        public override void Update(GameTime gameTime, TouchCollection touchCollection)
        {
            if (touchCollection.Count() > 0)
            {
                //get the first touch
                TouchLocation touch = touchCollection.ElementAt(0);
                if (touch.State == TouchLocationState.Pressed)
                {
                    String command = Helper.GetFirstButtonPressCommand(listButtons, (int)touch.Position.X, (int)touch.Position.Y);

                    if (command.Equals("volcano"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureVenusVolcanoInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                    else if (command.Equals("rotate"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureVenusRotateInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                    else if (command.Equals("nasa"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureVenusNASAInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                    else if (command.Equals("earth"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureVenusEarthInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates the state and location of the touch
        /// </summary>
        public virtual void Update()
        {
            TouchCollection touchCollection = TouchPanel.GetState();

            if (touchCollection.Count() > 0)
            {
                touchLocation = touchCollection[0];
                touchChanged  = true;
            }
            else if (touchChanged)
            {
                touchChanged = false;
            }
        }
Exemplo n.º 4
0
        public override void Update(GameTime gameTime, TouchCollection touchCollection)
        {
            if (touchCollection.Count() > 0)
            {
                //get the first touch
                TouchLocation touch = touchCollection.ElementAt(0);
                if (touch.State == TouchLocationState.Pressed)
                {
                    String command = Helper.GetFirstButtonPressCommand(listButtons, (int)touch.Position.X, (int)touch.Position.Y);

                    if (command.Equals("back"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureMercury, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = prevScreen;
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// The main update method for the game loop. Calls all the lower level update methods
        /// </summary>
        /// <param name="gameTime">snapshot of the game timing state</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

#if MEASURE_FPS
            elapsedTime += gameTime.ElapsedGameTime;

            if (elapsedTime > TimeSpan.FromSeconds(1))
            {
                elapsedTime -= TimeSpan.FromSeconds(1);
                frameRate    = frameCounter;
                frameCounter = 0;
            }
#endif
            if (view != null)
            {
                level.disableBikeControls();
                view.Update();
            }
            else if (!editorOpen)
            {
                TouchCollection touchCollection = TouchPanel.GetState();
                if (touchCollection.Count() > 0)
                {
                    optionsButton.Update(touchCollection[0]);
                    exitButton.Update(touchCollection[0]);
                    leftButton.Update(touchCollection[0]);
                    rightButton.Update(touchCollection[0]);
                }
            }
            if (!paused)
            {
                level.Update();
            }

            clockTime = String.Format("{0:d2}:{1:d2}", stopwatch.Elapsed.Minutes, stopwatch.Elapsed.Seconds);
        }
        public override void Update(GameTime gameTime, TouchCollection touchCollection)
        {
            if (touchCollection.Count() > 0)
            {
                //get the first touch
                TouchLocation touch = touchCollection.ElementAt(0);
                if (touch.State == TouchLocationState.Pressed)
                {
                    String command = Helper.GetFirstButtonPressCommand(listButtons, (int)touch.Position.X, (int)touch.Position.Y);

                    if (command.Equals("moon"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureUranusMoonInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                    else if (command.Equals("ring"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureUranusRingInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                    else if (command.Equals("wind"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureUranusWindInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                    else if (command.Equals("ocean"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureUranusOceanInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                    else if (command.Equals("nasa"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureUranusNASAInfo, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                }
            }
        }
Exemplo n.º 7
0
        public override void Update(GameTime gameTime, TouchCollection touchCollection)
        {
            if (touchCollection.Count() > 0)
            {
                //get the first touch
                TouchLocation touch = touchCollection.ElementAt(0);
                if (touch.State == TouchLocationState.Pressed)
                {
                    String command = Helper.GetFirstButtonPressCommand(listButtons, (int)touch.Position.X, (int)touch.Position.Y);

                    if (command.Equals("play"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureMercury, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = game.GetNewScreenSolarSystem();
                    }

                    else if (command.Equals("about"))
                    {
                        AnimationFixed background = new AnimationFixed(game.textureAboutBackground, 1, 0, 800, 480, 0, 0, 0);
                        NextScreen = new ScreenInfo(game, new Background(background, null), null, this);
                    }
                }
            }
        }
Exemplo n.º 8
0
 public static bool TouchReleased()
 {
     return(lastTouchState.Count() > 0 &&
            touchState.Count() == 0);
 }
Exemplo n.º 9
0
        private Enumeration.Input GetTouchInput(TouchCollection touchState)
        {
            Enumeration.Input lastInput = Enumeration.Input.none;
            bool shiftInput             = false;
            int  pixelToX = 0;
            int  pixelToY = 0;

#if ANDROID
            pixelToX = 50;
            pixelToY = 50;
#elif WINDOWS
            pixelToX = 50;
#endif

            Vector2 touchDepth = Vector2.Zero;

            if (touchState.Count() == 0)
            {
                touchPositionRect = Rectangle.Empty;
                return(lastInput);
            }

            for (int x = 0; x < touchState.Count; x++)
            {
                touchPositionRect = new Rectangle((int)touchState[x].Position.X - pixelToX, (int)touchState[x].Position.Y - pixelToY, 60, 60);

                touchDepth = PoP.CntShiftZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    shiftInput = true;
                    lastInput  = Enumeration.Input.shift;
                    continue;
                }

                touchDepth = PoP.CntUpZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    lastInput = Enumeration.Input.up;
                    continue;
                }
                touchDepth = PoP.CntUpLeftZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    lastInput = Enumeration.Input.leftup;
                    continue;
                }
                touchDepth = PoP.CntUpRightZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    lastInput = Enumeration.Input.rightup;
                    continue;
                }
                touchDepth = PoP.CntLeftZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    lastInput = Enumeration.Input.left;
                    continue;
                }
                touchDepth = PoP.CntLeftZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    if (PoP.CntCenterZone.Contains((int)touchState[x].Position.X, (int)touchState[x].Position.Y))
                    {
                        //lastInput = Enumeration.Input.none;
                        continue;
                    }
                }
                touchDepth = PoP.CntRightZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    lastInput = Enumeration.Input.right;
                    continue;
                }
                touchDepth = PoP.CntDownLeftZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    lastInput = Enumeration.Input.leftdown;
                    continue;
                }
                touchDepth = PoP.CntDownZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    lastInput = Enumeration.Input.down;
                    continue;
                }
                touchDepth = PoP.CntDownRightZone.GetIntersectionDepth(touchPositionRect);
                if (touchDepth.X > 0 | touchDepth.Y > 0)
                {
                    lastInput = Enumeration.Input.righdown;
                    continue;
                }
            }

            if (shiftInput == false)
            {
                return(lastInput);
            }

            switch (lastInput)
            {
            case Enumeration.Input.left: return(Enumeration.Input.leftshift);

            case Enumeration.Input.right: return(Enumeration.Input.rightshift);

            case Enumeration.Input.down: return(Enumeration.Input.downshift);

            case Enumeration.Input.up: return(Enumeration.Input.upshift);

            default:
                return(lastInput);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Handle user touch events: Pressed, Moved, Released
        /// </summary>
        private void handleTouch()
        {
            // Handle all touch here
            TouchCollection touchCollection = TouchPanel.GetState();

            if (touchCollection.Count() > 0)
            {
                TouchLocation tl = touchCollection.First();

                if (tl.State == TouchLocationState.Pressed)
                {
                    // Handle deck touch and find active card
                    Card ret = null;
                    for (int di = 0; di < m_deckList.Count; di++)
                    {
                        ret = m_deckList[di].HandleTouch(tl);
                        if (ret != null)
                        {
                            break;
                        }
                    }
                    // Accept to select cards?
                    if (ret != null && ret.OwnerDeck.Type() != Deck.DeckType.ESourceDeck)
                    {
                        // Turn card and activate
                        if (!ret.IsTurned())
                        {
                            if (ret.ParentCard == null)
                            {
                                ret.setTurned(true);
                                p_activeCard = ret;
                            }
                        }
                        // Car is turned
                        // Set active card under move
                        else
                        {
                            p_activeCard = ret;
                        }
                    }
                }
                else if (tl.State == TouchLocationState.Moved)
                {
                    // If active card, move it
                    if (p_activeCard != null)
                    {
                        p_activeCard.handleTouch(tl);
                    }
                }
                else if (tl.State == TouchLocationState.Released)
                {
                    // Where active card was released?
                    if (p_activeCard != null)
                    {
                        // Accept moving cards only from target and source decks
                        Deck fromDeck = p_activeCard.OwnerDeck;
                        if (fromDeck != null && (fromDeck.Type() == Deck.DeckType.EUserDeck ||
                                                 fromDeck.Type() == Deck.DeckType.EWasteDeck))
                        {
                            // Find deck where card was released, accept target and source decks only
                            Deck toDeck = GetDeckUnderTouch(tl);
                            if (toDeck != null && (toDeck.Type() == Deck.DeckType.EUserDeck ||
                                                   toDeck.Type() == Deck.DeckType.ETargetDeck))
                            {
                                if (toDeck == fromDeck)
                                {
                                    // cancel move
                                    p_activeCard.cancelMove();
                                }
                                else
                                {
                                    // Check is this card move acceptable
                                    if (isAcceptedMove(p_activeCard, toDeck))
                                    {
                                        // Accept move
                                        fromDeck.RemoveCard(p_activeCard);
                                        toDeck.AddCard(p_activeCard);
                                    }
                                    else
                                    {
                                        // Cancel move
                                        p_activeCard.cancelMove();
                                    }
                                }
                            }
                            else
                            {
                                // Trying to move card between not acceptable decks
                                p_activeCard.cancelMove();
                            }
                        }
                        else
                        {
                            // Trying to move card between not acceptable decks
                            p_activeCard.cancelMove();
                        }
                        // Reset active card, no moving ongoing
                        p_activeCard = null;
                    }


                    int count = 0;
                    for (int i = 0; i < m_deckList.Count(); i++)
                    {
                        count += m_deckList[i].CardCount();
                    }
                }
            }
        }