Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            // TODO: Add your update logic here
            m_focusManager.UpdateFocus();

            foreach (ButtonSprite button in m_buttons)
            {
                if (button == m_focusManager.SelectedButton)
                {
                    button.ButtonTexture = button.ButtonActive;
                }
                else
                {
                    button.ButtonTexture = button.ButtonInactive;
                }
            }

            m_focusManager.UpdatePauseFocus(BtnPause);

            base.Update(gameTime);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            // touch exception property to avoid killing app
            if (null != TaskRequestProducts)
            {
                AggregateException exception = TaskRequestProducts.Exception;
                if (null != exception)
                {
                    m_debugText = string.Format("Request Products has exception. {0}", exception);
                    TaskRequestProducts.Dispose();
                    TaskRequestProducts = null;
                }
            }

            // touch exception property to avoid killing app
            if (null != TaskRequestPurchase)
            {
                AggregateException exception = TaskRequestPurchase.Exception;
                if (null != exception)
                {
                    m_debugText = string.Format("Request Purchase has exception. {0}", exception);
                    TaskRequestPurchase.Dispose();
                    TaskRequestPurchase = null;
                    ClearPurchaseId();
                }
            }

            // touch exception property to avoid killing app
            if (null != TaskRequestReceipts)
            {
                AggregateException exception = TaskRequestReceipts.Exception;
                if (null != exception)
                {
                    m_debugText = string.Format("Request Receipts has exception. {0}", exception);
                    TaskRequestReceipts.Dispose();
                    TaskRequestReceipts = null;
                }
            }

            // touch exception property to avoid killing app
            if (null != TaskRequestGamer)
            {
                AggregateException exception = TaskRequestGamer.Exception;
                if (null != exception)
                {
                    m_debugText = string.Format("Request Gamer UUID has exception. {0}", exception);
                    TaskRequestGamer.Dispose();
                    TaskRequestGamer = null;
                }
            }

            // TODO: Add your update logic here
            m_focusManager.UpdateFocus();

            foreach (ButtonSprite button in m_buttons)
            {
                if (button == m_focusManager.SelectedButton)
                {
                    button.ButtonTexture = button.ButtonActive;
                }
                else
                {
                    button.ButtonTexture = button.ButtonInactive;
                }
            }

            if (m_focusManager.SelectedButton == BtnGetReceipts)
            {
                if (null != TaskRequestReceipts)
                {
                    if (TaskRequestReceipts.IsCanceled)
                    {
                        m_debugText = "Request Receipts has cancelled.";
                    }
                    else if (TaskRequestReceipts.IsCompleted)
                    {
                        m_debugText = "Request Receipts has completed.";
                    }
                }

                if (null != TaskRequestReceipts &&
                    null == TaskRequestReceipts.Exception &&
                    !TaskRequestReceipts.IsCanceled &&
                    TaskRequestReceipts.IsCompleted &&
                    null != TaskRequestReceipts.Result)
                {
                    m_focusManager.UpdateReceiptFocus(TaskRequestReceipts.Result.Count);
                }
            }
            else if (m_focusManager.SelectedButton == BtnGetUUID)
            {
                if (null != TaskRequestGamer)
                {
                    if (TaskRequestGamer.IsCanceled)
                    {
                        m_debugText = "Request Gamer UUID has cancelled.";
                    }
                    else if (TaskRequestGamer.IsCompleted)
                    {
                        m_debugText = string.Format("Request Gamer UUID: {0}", TaskRequestGamer.Result);
                    }
                }

                if (null != TaskRequestReceipts &&
                    null == TaskRequestReceipts.Exception &&
                    !TaskRequestReceipts.IsCanceled &&
                    TaskRequestReceipts.IsCompleted &&
                    null != TaskRequestReceipts.Result)
                {
                    m_focusManager.UpdateReceiptFocus(TaskRequestReceipts.Result.Count);
                }
            }
            else
            {
                if (m_focusManager.SelectedButton == BtnPurchase)
                {
                    if (null != TaskRequestPurchase)
                    {
                        if (TaskRequestPurchase.IsCanceled)
                        {
                            m_debugText = "Request Purchase has cancelled.";
                            ClearPurchaseId(); //clear the purchase id
                        }
                        else if (TaskRequestPurchase.IsCompleted)
                        {
                            if (TaskRequestPurchase.Result)
                            {
                                m_debugText = "Request Purchase has completed succesfully.";
                            }
                            else
                            {
                                m_debugText = "Request Purchase has completed with failure.";
                            }
                            ClearPurchaseId(); //clear the purchase id
                        }
                    }
                }
                else if (m_focusManager.SelectedButton == BtnGetProducts)
                {
                    if (null != TaskRequestProducts)
                    {
                        if (TaskRequestProducts.IsCanceled)
                        {
                            m_debugText = "Request Products has cancelled.";
                        }
                        else if (TaskRequestProducts.IsCompleted)
                        {
                            if (TaskRequestProducts.Result.Count > 0)
                            {
                                m_debugText = "Request Products has completed with results.";
                            }
                            else
                            {
                                m_debugText = "Request Products has completed without results.";
                            }
                        }
                    }
                }

                if (null != TaskRequestProducts &&
                    null == TaskRequestProducts.Exception &&
                    !TaskRequestProducts.IsCanceled &&
                    TaskRequestProducts.IsCompleted)
                {
                    m_focusManager.UpdateProductFocus(TaskRequestProducts.Result.Count);
                }
            }

            m_focusManager.UpdatePauseFocus(BtnPause);

            base.Update(gameTime);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //Log.Info(TAG, string.Format("BUTTON_O is {0}", OuyaInput.GetButton(OuyaController.BUTTON_O)));

            if (OuyaInput.GetButtonUp(0, OuyaController.BUTTON_A))
            {
                Exit();
            }

            // TODO: Add your update logic here
            m_focusManager.UpdateFocus();

            foreach (ButtonSprite button in m_buttons)
            {
                // button is active if the selected button is true
                button.m_isActive = (button == m_focusManager.SelectedButton);
            }

            if (OuyaInput.GetButtonUp(OuyaController.BUTTON_MENU))
            {
                m_debugText = "Pause button detected.";
                m_focusManager.SelectedButton = BtnPause;
            }

            if (OuyaInput.GetButtonUp(OuyaController.BUTTON_O))
            {
                if (m_focusManager.SelectedButton == BtnRequestProducts)
                {
                    s_productIndex = 0;
                    s_products.Clear();
                    m_debugText = "Requesting products...";
                    Activity1.RequestProducts();
                }
                else if (m_focusManager.SelectedButton == BtnRequestPurchase)
                {
                    if (s_productIndex < s_products.Count)
                    {
                        Purchasable purchasable = new Purchasable(s_products [s_productIndex].Identifier);
                        m_debugText = "Requesting purchase...";
                        Activity1.RequestPurchase(purchasable);
                    }
                    else
                    {
                        m_debugText = "Be sure to request products to select a purchase...";
                    }
                }
                else if (m_focusManager.SelectedButton == BtnRequestReceipts)
                {
                    m_debugText = "Requesting receipts...";
                    Activity1.RequestReceipts();
                }
                else if (m_focusManager.SelectedButton == BtnRequestGamerInfo)
                {
                    m_debugText = "Requesting GamerInfo...";
                    Activity1.RequestGamerInfo();
                }
                else if (m_focusManager.SelectedButton == BtnExit)
                {
                    m_debugText = "Exiting...";
                    Activity1.Quit();
                }
                else if (m_focusManager.SelectedButton == BtnPause)
                {
                    m_debugText = "Pause button detected...";
                    m_focusManager.SelectedButton = BtnPause;
                }
            }

            if (m_focusManager.SelectedButton == BtnRequestProducts ||
                m_focusManager.SelectedButton == BtnRequestPurchase)
            {
                if (OuyaInput.GetButtonUp(OuyaController.BUTTON_DPAD_UP))
                {
                    if (s_productIndex > 0)
                    {
                        --s_productIndex;
                    }
                }
                if (OuyaInput.GetButtonUp(OuyaController.BUTTON_DPAD_DOWN))
                {
                    if ((s_productIndex + 1) < s_products.Count)
                    {
                        ++s_productIndex;
                    }
                }
            }

            base.Update(gameTime);

            OuyaInput.ClearButtonStates();
        }