Ejemplo n.º 1
0
        public static bool Update()
        {
            uint enableColor  = 0xffffffff;
            uint disableColor = 0xff7f7f7f;

            playButton.ButtonColor   = disableColor;
            stopButton.ButtonColor   = disableColor;
            pauseButton.ButtonColor  = disableColor;
            resumeButton.ButtonColor = disableColor;

            if (bgmPlayer.Status == BgmStatus.Stopped)
            {
                playButton.ButtonColor = enableColor;
            }
            else if (bgmPlayer.Status == BgmStatus.Playing)
            {
                stopButton.ButtonColor  = enableColor;
                pauseButton.ButtonColor = enableColor;
            }
            else if (bgmPlayer.Status == BgmStatus.Paused)
            {
                stopButton.ButtonColor   = enableColor;
                resumeButton.ButtonColor = enableColor;
            }

            List <TouchData> touchDataList = Touch.GetData(0);

            if (playButton.ButtonColor == enableColor &&
                playButton.TouchDown(touchDataList))
            {
                bgmPlayer.Play();
            }
            if (stopButton.ButtonColor == enableColor &&
                stopButton.TouchDown(touchDataList))
            {
                bgmPlayer.Stop();
            }
            if (pauseButton.ButtonColor == enableColor &&
                pauseButton.TouchDown(touchDataList))
            {
                bgmPlayer.Pause();
            }
            if (resumeButton.ButtonColor == enableColor &&
                resumeButton.TouchDown(touchDataList))
            {
                bgmPlayer.Resume();
            }

            volumeSlider.Update(touchDataList);
            bgmPlayer.Volume = volumeSlider.Rate;

            return(true);
        }
Ejemplo n.º 2
0
            public void Update(List <TouchData> touchDataList)
            {
                if (playButton.TouchDown(touchDataList))
                {
                    soundPlayer.Play();
                }

                if (stopButton.TouchDown(touchDataList))
                {
                    soundPlayer.Stop();
                }

                volumeSlider.Update(touchDataList);
                soundPlayer.Volume = volumeSlider.Rate;
            }
Ejemplo n.º 3
0
        // check objects change state,
        private static bool CheckChangeState()
        {
            bool             changeState   = false;
            List <TouchData> touchDataList = Touch.GetData(0);

            // button.
            if (button0.ButtonColor == DISABLE_COLOR &&
                button0.TouchDown(touchDataList))
            {
                button0.SetText(BUTTON_PRESS);
                button0.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON0] = 1;
                changeState = true;
            }
            else if (button0.ButtonColor == ENABLE_COLOR &&
                     button0.TouchDown(touchDataList))
            {
                button0.SetText(BUTTON_RELEASE);
                button0.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON0] = 0;
                changeState = true;
            }

            if (button1.ButtonColor == DISABLE_COLOR &&
                button1.TouchDown(touchDataList))
            {
                button1.SetText(BUTTON_PRESS);
                button1.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON1] = 1;
                changeState = true;
            }
            else if (button1.ButtonColor == ENABLE_COLOR &&
                     button1.TouchDown(touchDataList))
            {
                button1.SetText(BUTTON_RELEASE);
                button1.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON1] = 0;
                changeState = true;
            }

            if (button2.ButtonColor == DISABLE_COLOR &&
                button2.TouchDown(touchDataList))
            {
                button2.SetText(BUTTON_PRESS);
                button2.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON2] = 1;
                changeState = true;
            }
            else if (button2.ButtonColor == ENABLE_COLOR &&
                     button2.TouchDown(touchDataList))
            {
                button2.SetText(BUTTON_RELEASE);
                button2.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON2] = 0;
                changeState = true;
            }

            if (button3.ButtonColor == DISABLE_COLOR &&
                button3.TouchDown(touchDataList))
            {
                button3.SetText(BUTTON_PRESS);
                button3.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON3] = 1;
                changeState = true;
            }
            else if (button3.ButtonColor == ENABLE_COLOR &&
                     button3.TouchDown(touchDataList))
            {
                button3.SetText(BUTTON_RELEASE);
                button3.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON3] = 0;
                changeState = true;
            }

            // slider.
            slider.Update(touchDataList);
            float curRate = slider.Rate;

            if (curRate != oldRate)
            {
                byte[] byteArray;
                byteArray = BitConverter.GetBytes(curRate);
                for (int i = 0; i < byteArray.Length; i++)
                {
                    persistentMemoryData[STATE_ADDR_SLIDER + i] = byteArray[i];
                }
                oldRate     = curRate;
                changeState = true;
            }

            // input dialog.
            if (inputTextButton.TouchDown(touchDataList))
            {
                if (dialog == null)
                {
                    dialog      = new TextInputDialog();
                    dialog.Text = inputTextButton.Label;
                    dialog.Open();
                }
                return(true);
            }

            if (dialog != null)
            {
                if (dialog.State == CommonDialogState.Finished)
                {
                    if (dialog.Result == CommonDialogResult.OK)
                    {
                        string setLabelStr;
                        int    i;

                        int len = dialog.Text.Length;

                        if (len > MAX_INPUT_CHARACTOR)
                        {
                            len = MAX_INPUT_CHARACTOR;
                        }

                        setLabelStr = dialog.Text.Substring(0, len);

                        inputTextButton.Label = setLabelStr;

                        byte[] byteArray0 = System.Text.Encoding.Unicode.GetBytes(setLabelStr);
                        for (i = 0; i < byteArray0.Length; i++)
                        {
                            persistentMemoryData[STATE_ADDR_STRING + i] = byteArray0[i];
                        }

                        byte[] byteArray1 = BitConverter.GetBytes(len);
                        for (i = 0; i < byteArray1.Length; i++)
                        {
                            persistentMemoryData[STATE_ADDR_STRING_NO + i] = byteArray1[i];
                        }

                        changeState = true;
                    }
                    dialog.Dispose();
                    dialog = null;
                }
            }

            return(changeState);
        }