/// ------------------------------------------------------------------------------------
        /// <summary>
        /// Move the mouse cursor to the center of the current button.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void MoveMouseCursorToDefaultButton()
        {
            Point pt = new Point(CurrentButton.Width / 2,
                                 CurrentButton.Height / 2);

            Cursor.Position = CurrentButton.PointToScreen(pt);
        }
Beispiel #2
0
        void InitRotator()
        {
            transform.localEulerAngles = Vector3.zero;

            Color fadedColor = ViveSR_Experience_Demo.instance.DisableColor;

            for (int i = 1; i < IncludedBtns.Count; i++)         // set default transparency. not changing depth image button.
            {
                IncludedBtns[i].SetIconColor(fadedColor);
            }

            //Rotate the Buttons and then expands them to form a circle.
            for (int i = 0; i < IncludedBtns.Count; i++)
            {
                //Add 90 degrees to match the controller's orientation.
                if (i == 0)
                {
                    rotateAngle = 90;
                }

                //Rotate the Buttons.
                IncludedBtns[i].gameObject.transform.localEulerAngles += new Vector3(0, rotateAngle, 0);

                //Extend the Button from the geo center of all Buttons.
                IncludedBtns[i].gameObject.transform.GetChild(0).transform.localPosition += new Vector3(distToCenter, 0, 0);

                //Accumulate the degree number for the next button.
                rotateAngle += 360 / IncludedBtns.Count;

                IncludedBtns[i].rotatorIdx = i;
            }

            //Move the UI to Attachpoint.
            SetRotatorTransform();

            if (distToCenter >= 0)
            {
                transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
            }
            else
            {
                transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, -transform.localScale.z);
            }

            //Assign & Enlarge the current Button.
            CurrentButton = IncludedBtns[0];
            CurrentButton.gameObject.transform.GetChild(0).transform.localScale *= 1.2f;
            CurrentButton.gameObject.transform.localScale = Vector_Enlarged;
            CurrentButton.SetFrameColor(ViveSR_Experience_Demo.instance.BrightFrameColor);

            //Push & scale down non-current buttons
            AdjustUITransform();

            //Display of included buttons
            RenderButtons(true);
        }
Beispiel #3
0
 void ActOnButton()
 {
     //Toggle on and off. Some Buttons do not allow toggling off.
     if ((CurrentButton.isOn && CurrentButton.allowToggle) || !CurrentButton.isOn)
     {
         if (!CurrentButton.disabled)
         {
             CurrentButton.isOn = !CurrentButton.isOn;
             CurrentButton.ActOnRotator(CurrentButton.isOn);
         }
     }
 }
Beispiel #4
0
        IEnumerator Rotate(bool isTouchPositive)
        {
            SetRotator(false);

            /*---The Old Button---*/
            CurrentButton.isEnlarging = false;
            Shirnk(CurrentButton);

            if (CurrentButton.isOn && CurrentButton.disableWhenRotatedAway)
            {
                CurrentButton.ActOnRotator(false);
            }

            ViveSR_Experience_IButton oldBtn = CurrentButton;

            /*--------------------*/

            /*---The New Button---*/
            CurrentButton = GetButtons(isTouchPositive, 1);

            //Enlarge
            CurrentButton.isShrinking = false;
            Enlarge(CurrentButton);

            //Set the target degree.
            targetY = localY + (360 / (int)MenuButton.MaxNum) * (isTouchPositive ? 1 : -1);

            CurrentButton.gameObject.transform.GetChild(0).transform.localScale *= 1.2f;

            while (isTouchPositive ? localY <targetY : localY> targetY)
            {
                localY += (isTouchPositive ? 1 : -1) * rotateSpeed * Time.deltaTime;
                transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, localY, transform.localEulerAngles.z);

                yield return(new WaitForEndOfFrame());
            }

            targetY = localY = (360 / IncludedBtns.Count) * CurrentButton.rotatorIdx;
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, targetY, transform.localEulerAngles.z);

            oldBtn.gameObject.transform.GetChild(0).transform.localScale = Vector3.one * 0.03f;

            AdjustUITransform();
            SetRotator(true);

            /*--------------------*/
        }
Beispiel #5
0
        public void SetCurrentButton(int index)
        {
            int lastIndex = currentButtonIndex < 0 ? 0 : currentButtonIndex;

            lastIndex = index >= 0 ? lastIndex : -1;

            if (CurrentButton != null)
            {
                CurrentButton.Unselect();
            }

            currentButtonIndex = allSecionButtons.GetClampedIndex(index);
            bool available = index >= 0;

            if (available)
            {
                if (CurrentButton == null || !CurrentButton.Active)
                {
                    currentButtonIndex = lastIndex;
                    available          = false;
                    int dir = (index - currentButtonIndex);
                    dir = (int)Mathf.Sign(dir);
                    SectionButton testbutton = null;
                    for (int i = 1; i < allSecionButtons.Length; i++)
                    {
                        testbutton = allSecionButtons.GetLoop(currentButtonIndex + (dir * i));
                        if (testbutton != null && testbutton.Active)
                        {
                            available          = true;
                            currentButtonIndex = allSecionButtons.GetIndexOf(testbutton);
                            break;
                        }
                    }
                }
            }

            if (!available)
            {
                currentButtonIndex = lastIndex;
            }

            if (CurrentButton != null && CurrentButton.Active)
            {
                CurrentButton.Select();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
            //Load Profils
            ProfilProperties profile = new ProfilProperties();

            for (int i = 1; i <= 5; i++)
            {
                profile = ProfilProperties.Load("Profils\\Profil" + i + ".xml");
                ProfilXml.Add(profile);
            }

            //Is there an active Profil at beginning
            int test = 0;

            foreach (ProfilProperties i in ProfilXml)
            {
                if (i.Active == true)
                {
                    test += 1;
                    if (test == 1)
                    {
                        CurrentNumber = i.ProfilNummer;
                    }
                }
            }
            if (test == 0)
            {
                CurrentNumber = 1;
                Menü          = true;
            }
            CurrentProfil = ProfilXml[CurrentNumber - 1];

            //StartButton if there is an active Profil
            if (CurrentProfil.Active == true)
            {
                while (!CurrentButton.getButtonName().Equals("Ok"))
                {
                    CurrentList.Next();
                }
            }
        }
Beispiel #7
0
        private void CoreWindow_PointerReleased(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.PointerEventArgs args)
        {
            var under = VisualTreeHelper.FindElementsInHostCoordinates(args.CurrentPoint.Position, Window.Current.Content);

            var allowed = true;

            foreach (UIElement elem in under)
            {
                if (elem is MenuBarButton)
                {
                    allowed = false;
                    break;
                }
            }

            if (CurrentButton != null && allowed)
            {
                CurrentButton.ToggleMenu();
            }
        }
Beispiel #8
0
        public override void ApplyAction(GameState g, float dt)
        {
            if (CurrentButton != null)
            {
                // If The Unit Is Still Being Produced
                if (QueueTimer != float.MaxValue && QueueTimer > 0)
                {
                    QueueTimer -= dt;
                }
                // If Finished Building The Unit
                if (QueueTimer <= 0 && CurrentButton.CanFinish(g))
                {
                    CurrentButton.OnQueueFinished(g);
                    QueueTimer    = float.MaxValue;
                    CurrentButton = null;
                }
            }

            // Add New Buttons To The Queue
            for (int i = 0; i < building.ButtonControllers.Count; i++)
            {
                int ec = building.ButtonControllers[i].GetEnqueueCount();
                while (ec > 0)
                {
                    ButtonQueue.Enqueue(building.ButtonControllers[i]);
                    ec--;
                }
            }

            // Get New Button
            if (CurrentButton == null && ButtonQueue.Count > 0)
            {
                CurrentButton = ButtonQueue.Dequeue();
                QueueTimer    = CurrentButton.QueueTime;
            }
        }
Beispiel #9
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            #region Hauptmenü
            if (scoring)
            {
                if (this.startscoring && this.score != null)
                {
                    SaveScore();
                    prompt.LoadContent(game);
                    this.startscoring = false;
                }
            }
            if (Visiblity && isActive)
            {
                if (Action)
                {
                    #region Mouse
                    //Auswahl tätigen
                    if (steuerung.isMouseInShift() &&
                        new Vector2(game.Input.MousePosition.X, game.Input.MousePosition.Y) != game.GameStates.Menu.Mouse)
                    {
                    }
                    if (game.Input.HasKeyJustBeenPressed("Menu.Select"))
                    {
                        if (steuerung.isMouseInShift())
                        {
                            steuerung.changeButton();
                        }
                        else if (steuerung.isMouseInBox() && CurrentButton.getPosition() == MouseInRec)
                        {
                            steuerung.selection();
                            LoadContent();
                        }
                    }
                    #endregion

                    #region Keyboard
                    if (game.Input.HasKeyJustBeenPressed("Menu.Left"))
                    {
                        steuerung.changeButton(Keys.Left);
                    }

                    else if (game.Input.HasKeyJustBeenPressed("Menu.F2"))
                    {
                        game.HasSpaceMouse = !game.HasSpaceMouse;
                    }

                    else if (game.Input.HasKeyJustBeenPressed("Menu.Right"))
                    {
                        steuerung.changeButton(Keys.Right);
                    }
                    else if (game.Input.HasKeyJustBeenPressed("Menu.Ok"))
                    {
                        Shifts.LeftShift.resetActive();
                        Shifts.RightShift.resetActive();
                        steuerung.selection();
                        LoadContent();
                    }
                    else if (game.Input.HasKeyJustBeenPressed("Game.Menu"))
                    {
                        Shifts.LeftShift.resetActive();
                        Shifts.RightShift.resetActive();
                        steuerung.Back(CurrentMenu);
                        LoadContent();
                    }
                    #endregion
                }
            }
            #endregion

            else if (HighscoreMenu != null && HighscoreMenu.Visiblity)
            {
                HighscoreMenu.Update(gameTime, SpriteBatch);
            }
            else if (OptionMenu != null && OptionMenu.Visiblity)
            {
                OptionMenu.Update(gameTime, SpriteBatch);
            }

            if (prompt != null)
            {
                prompt.Update(gameTime);
            }

            if (mousepos != MousePosition)
            {
                mouseMovement = MousePosition;
            }
        }
Beispiel #10
0
 /// <summary>
 /// Deselects the current button, if not null. In RadioSwitch mode, this leaves the RadioSwitch with no buttons selected.
 /// </summary>
 public void DeselectCurrent()
 {
     CurrentButton?.SetValue(false);
     CurrentButton = null;
 }
Beispiel #11
0
        /// <summary>
        /// Called when the DrawableGameComponent needs to be drawn.  Override this method
        /// with component-specific drawing code.
        /// </summary>
        /// <parameters>
        /// gameTime:
        ///     Time passed since the last call to
        ///     Microsoft.Xna.Framework.DrawableGameComponent.Draw(Microsoft.Xna.Framework.GameTime).
        /// </parameters>
        public override void Draw(GameTime gameTime)
        {
            if (!Menü && CurrentProfil.OnlineQuestion)
            {
                if (SpriteBatch != null)
                {
                    SpriteBatch.Begin();
                    SpriteBatch.GraphicsDevice.Clear(Color.Black);
                    SpriteBatch.End();
                }
            }
            else
            {
                if (Visible)
                {
                    if (SpriteBatch != null)
                    {
                        SpriteBatch.Begin();
                        SpriteBatch.Draw(background, new Rectangle(0, 0,
                                                                   game.Graphics.Device.Viewport.Width, game.Graphics.Device.Viewport.Height),
                                         Color.White);
                        SpriteBatch.Draw(textback, BildXml.TextbackRec, Color.White);
                        SpriteBatch.Draw(buttonback, new Rectangle(game.Graphics.Device.Viewport.Width - 40
                                                                   - BildXml.ButtonBackRec.Width, BildXml.ButtonBackRec.Y, BildXml.ButtonBackRec.Width,
                                                                   BildXml.ButtonBackRec.Height), Color.White);

                        #region Draw Bars
                        switch (CurrentButton.getButtonName())
                        {
                        case "Erstellen":
                        {
                            SpriteBatch.Draw(buttonbackbarCreate, new Rectangle(game.Graphics.Device.Viewport.Width
                                                                                - 50 - BildXml.barRec.Width, BildXml.barRec.Y, BildXml.barRec.Width,
                                                                                BildXml.barRec.Height), Color.White);
                            break;
                        }

                        case "Löschen":
                        {
                            SpriteBatch.Draw(buttonbackbarDelete, new Rectangle(game.Graphics.Device.Viewport.Width
                                                                                - 50 - BildXml.barRec.Width, BildXml.barRec.Y, BildXml.barRec.Width,
                                                                                BildXml.barRec.Height), Color.White);
                            break;
                        }

                        case "Ok":
                        {
                            SpriteBatch.Draw(buttonbackbarOk, new Rectangle(game.Graphics.Device.Viewport.Width
                                                                            - 50 - BildXml.barRec.Width, BildXml.barRec.Y, BildXml.barRec.Width,
                                                                            BildXml.barRec.Height), Color.White);
                            break;
                        }

                        default:
                            break;
                        }
                        #endregion

                        CurrentList.Draw(gameTime, SpriteBatch);

                        #region Profilnamen und Marker

                        foreach (ProfilProperties j in ProfilXml)
                        {
                            if (j.ProfilNummer == CurrentNumber)
                            {
                                SpriteBatch.Draw(marker, new Rectangle(j.ActionrecX, j.ActionrecY, j.ActionrecWidth,
                                                                       j.ActionrecHeigth), Color.White);
                            }
                            SpriteBatch.DrawString(font, j.ProfilName, new Vector2(j.PositionX, j.PositionY),
                                                   Color.Black);
                        }

                        #endregion

                        SpriteBatch.DrawString(font, "Please select: ", new Vector2(50, 104), Color.Black);

                        #region Eingabe
                        if (Writing)
                        {
                            SpriteBatch.Draw(textfield, new Rectangle(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2,
                                                                      game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2,
                                                                      textfield.Width, textfield.Height), Color.White);
                            if (!CurrentProfil.Active)
                            {
                                if (counter == 20)
                                {
                                    SpriteBatch.DrawString(font, "Please enter profilename:\n\n" + profilname,
                                                           new Vector2(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2 + 30,
                                                                       game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2 + 40),
                                                           Color.White);
                                }
                                else
                                {
                                    SpriteBatch.DrawString(font, "Please enter profilename:\n\n" + profilname + "_",
                                                           new Vector2(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2 + 30,
                                                                       game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2 + 40),
                                                           Color.White);
                                }
                            }
                            else
                            {
                                SpriteBatch.DrawString(font, "No changes to a existing \nprofile \n" +
                                                       "Press any Key to return...",
                                                       new Vector2(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2 + 30,
                                                                   game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2 + 40),
                                                       Color.White);
                            }
                        }
                        #endregion
                        else if (question)
                        {
                            SpriteBatch.Draw(textfield, new Rectangle(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2,
                                                                      game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2,
                                                                      textfield.Width, textfield.Height), Color.White);
                            if (counter == 1)
                            {
                                SpriteBatch.DrawString(font, "Would you like to send\n" +
                                                       "your score to the Online \nHighscore? (y - yes/n - no)\n" + answer,
                                                       new Vector2(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2 + 30,
                                                                   game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2 + 40),
                                                       Color.White);
                            }
                            else
                            {
                                SpriteBatch.DrawString(font, "Would you like to send\n" +
                                                       "your score to the Online \nHighscore? (y - yes/n - no)\n" + answer + "_",
                                                       new Vector2(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2 + 30,
                                                                   game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2 + 40),
                                                       Color.White);
                            }
                        }
                        else if (player)
                        {
                            SpriteBatch.Draw(textfield, new Rectangle(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2,
                                                                      game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2,
                                                                      textfield.Width, textfield.Height), Color.White);
                            if (counter == 15)
                            {
                                SpriteBatch.DrawString(font, "Please insert playername\n\n" + pname,
                                                       new Vector2(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2 + 30,
                                                                   game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2 + 40),
                                                       Color.White);
                            }
                            else
                            {
                                SpriteBatch.DrawString(font, "Please insert playername\n\n" + pname + "_",
                                                       new Vector2(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2 + 30,
                                                                   game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2 + 40),
                                                       Color.White);
                            }
                        }
                        else if (Wahl)
                        {
                            SpriteBatch.Draw(textfield, new Rectangle(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2,
                                                                      game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2,
                                                                      textfield.Width, textfield.Height), Color.White);
                            SpriteBatch.DrawString(font, "Please create a profile \nor select one.\n" +
                                                   "Press any Key to return...",
                                                   new Vector2(game.Graphics.Device.Viewport.Width / 2 - textfield.Width / 2 + 30,
                                                               game.Graphics.Device.Viewport.Height / 2 - textfield.Height / 2 + 40), Color.White);
                        }
                        else
                        {
                            SpriteBatch.Draw(mouse, MousePosition, Color.White);
                        }
                        SpriteBatch.End();
                    }
                }
            }
        }
Beispiel #12
0
 void Start()
 {
     CuC = GM.GetComponent <CurrentColor> ();
     CuB = GM.GetComponent <CurrentButton> ();
 }