Пример #1
0
        public override void Update()
        {
            //update all ui items
            for (i = 0; i < aui_instances.Count; i++)
            {
                aui_instances[i].Update();
            }

            #region Screen Display States

            if (displayState == DisplayState.Opening)
            {
                if (button_back.displayState == DisplayState.Opened)
                {
                    displayState = DisplayState.Opened;
                }
            }
            else if (displayState == DisplayState.Opened)
            {
                //handle main input here

                if (Input.IsLeftMouseBtnPress())
                {
                    //back button
                    if (Functions.Contains(
                            button_back.window.rec_bkg.openedRec,
                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        Close(ExitAction.Title);
                    }
                }
            }
            else if (displayState == DisplayState.Closing)
            {
                //ensure all aui items are closed
                Boolean allClosed = true; //assume true, prove false
                for (i = 0; i < aui_instances.Count; i++)
                {
                    if (aui_instances[i].displayState != DisplayState.Closed)
                    {
                        allClosed = false;
                    }
                }
                if (allClosed)
                {
                    displayState = DisplayState.Closed;
                }
            }
            else if (displayState == DisplayState.Closed)
            {
                if (exitAction == ExitAction.Title)
                {
                }
                //this screen only closes one way
                ScreenManager.ExitAndLoad(new Screen_Title());
            }

            #endregion
        }
Пример #2
0
        public override void Update()
        {
            button.Update();

            if (wiggleChildren)
            {
                AnimateChildren();
            }

            for (i = 0; i < aui_crown_children.Count; i++)
            {
                aui_crown_children[i].Update();
            }

            //ui display states
            if (displayState == DisplayState.Opening)
            {
                if (button.displayState == DisplayState.Opened)
                {
                    displayState = DisplayState.Opened;
                }
            }
            else if (displayState == DisplayState.Opened)
            {
                //open/close crown children
                if (Input.IsLeftMouseBtnPress())
                {
                    if (Functions.Contains(
                            button.window.rec_bkg.openedRec,
                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        //open/close crown's children
                        if (childOpen == false)
                        {
                            OpenChildren();
                        }
                        else
                        {
                            CloseChildren();
                        }
                    }
                }
            }
            else if (displayState == DisplayState.Closing)
            {
                if (button.displayState == DisplayState.Closed)
                {
                    displayState = DisplayState.Closed;
                }
            }
            else if (displayState == DisplayState.Closed)
            {
            }
        }
Пример #3
0
        public override void Update()
        {
            button.Update();
            for (i = 0; i < 8; i++)
            {
                lines[i].Update();
            }

            //miniphysics: apply friction to magnitude per axis
            magnitude.X = magnitude.X * friction;
            magnitude.Y = magnitude.Y * friction;

            //display states
            if (displayState == DisplayState.Opening)
            {
                if (button.displayState == DisplayState.Opened)
                {
                    displayState = DisplayState.Opened;
                }
            }
            else if (displayState == DisplayState.Opened)
            {
                //randomly spring to life
                if (Functions.Random.Next(0, 101) > 97)
                {
                    wandering = true;
                    Open();
                    ChooseDirection();
                }

                //limit button to screen (kill otherwise)
                if (button.window.rec_bkg.openedRec.X > Assets.GDM.PreferredBackBufferWidth)
                {
                    Close();
                }
                if (button.window.rec_bkg.openedRec.X < 0)
                {
                    Close();
                }
                if (button.window.rec_bkg.openedRec.Y > Assets.GDM.PreferredBackBufferHeight)
                {
                    Close();
                }
                if (button.window.rec_bkg.openedRec.Y < 0)
                {
                    Close();
                }


                #region Button Click Input

                //on click, spider wanders around
                if (Input.IsLeftMouseBtnPress())
                {
                    if (Functions.Contains(
                            button.window.rec_bkg.openedRec,
                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        Close();
                    }
                }

                #endregion

                #region Wandering Routine

                //if spider is wandering around, the legs should be
                //open and wiggling about
                if (wandering)
                {   //randomly choose a target to move button to
                    button.MoveTo(
                        (int)(button.window.rec_bkg.openedRec.X + magnitude.X),
                        (int)(button.window.rec_bkg.openedRec.Y + magnitude.Y));

                    //count wandering frames
                    wanderCounter++;
                    if (wanderCounter > wanderTotal)
                    {   //goto resting state
                        wanderCounter = 0;
                        wandering     = false;
                        //close all legs
                        for (i = 0; i < 8; i++)
                        {
                            lines[i].Close();
                        }
                    }

                    //randomly modify moving direction
                    if (Functions.Random.Next(0, 101) > 98)
                    {
                        ChooseDirection();
                    }
                }

                #endregion
            }
            else if (displayState == DisplayState.Closing)
            {
                if (button.displayState == DisplayState.Closed)
                {
                    displayState = DisplayState.Closed;
                }
            }
            else if (displayState == DisplayState.Closed)
            {   //remove bug from aui instances list, gc() will get it
                Kill();
            }


            //place legs onto button (after button has moved)
            if (displayState != DisplayState.Closed)
            {
                #region Anchor legs to button

                //top of button
                lines[0].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 0,
                    button.window.rec_bkg.openedRec.Y);
                lines[1].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 5,
                    button.window.rec_bkg.openedRec.Y);
                lines[2].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 9,
                    button.window.rec_bkg.openedRec.Y);
                lines[3].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 15,
                    button.window.rec_bkg.openedRec.Y);
                //bottom of button
                lines[4].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 1,
                    button.window.rec_bkg.openedRec.Y + 16);
                lines[5].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 6,
                    button.window.rec_bkg.openedRec.Y + 16);
                lines[6].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 10,
                    button.window.rec_bkg.openedRec.Y + 16);
                lines[7].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 16,
                    button.window.rec_bkg.openedRec.Y + 16);
                #endregion

                #region Place legs away from body like spider

                //top of button
                lines[0].SetTarget(
                    button.window.rec_bkg.openedRec.X + 0,
                    button.window.rec_bkg.openedRec.Y - 4);
                lines[1].SetTarget(
                    button.window.rec_bkg.openedRec.X + 4,
                    button.window.rec_bkg.openedRec.Y - 4);
                lines[2].SetTarget(
                    button.window.rec_bkg.openedRec.X + 8,
                    button.window.rec_bkg.openedRec.Y - 4);
                lines[3].SetTarget(
                    button.window.rec_bkg.openedRec.X + 12,
                    button.window.rec_bkg.openedRec.Y - 4);
                //bottom of button
                lines[4].SetTarget(
                    button.window.rec_bkg.openedRec.X + 0,
                    button.window.rec_bkg.openedRec.Y + 16 + 4);
                lines[5].SetTarget(
                    button.window.rec_bkg.openedRec.X + 4,
                    button.window.rec_bkg.openedRec.Y + 16 + 4);
                lines[6].SetTarget(
                    button.window.rec_bkg.openedRec.X + 8,
                    button.window.rec_bkg.openedRec.Y + 16 + 4);
                lines[7].SetTarget(
                    button.window.rec_bkg.openedRec.X + 12,
                    button.window.rec_bkg.openedRec.Y + 16 + 4);

                #endregion

                if (wandering)
                {
                    //sort button over other buttons
                    button.window.rec_bkg.zDepth  = Assets.Layer_WindowFront;
                    button.window.rec_fore.zDepth = Assets.Layer_WindowFront;

                    //modify leg positions each frame as if moving
                    for (i = 0; i < 8; i++)
                    {
                        lines[i].SetTarget(
                            lines[i].Xa + Functions.Random.Next(-3, 4),
                            lines[i].Ya + Functions.Random.Next(-3, 4));
                        lines[i].zDepth = Assets.Layer_WindowFront;
                    }
                }
                else
                {   //set button and lines on lower layers (behind)
                    button.window.rec_bkg.zDepth  = Assets.Layer_WindowBack;
                    button.window.rec_fore.zDepth = Assets.Layer_WindowBack;
                    for (i = 0; i < 8; i++)
                    {
                        lines[i].zDepth = Assets.Layer_Lines;
                    }
                }
            }
        }
Пример #4
0
        public override void Update()
        {
            window.Update(); text.Update();

            if (displayState == DisplayState.Opening)
            {
                window.Open();
                if (window.displayState == DisplayState.Opened)
                {
                    text.Open();
                    if (text.displayState == DisplayState.Opened)
                    {
                        displayState = DisplayState.Opened;
                    }
                }
            }
            else if (displayState == DisplayState.Opened)
            {
                //handle user focusing/hovering over button via cursor
                if (Functions.Contains(
                        window.rec_bkg.openedRec,
                        Input.cursorPos.X, Input.cursorPos.Y))
                {
                    window.rec_bkg.color = color_over;
                    text.color           = color_over_text;
                    //pulse text alpha
                    if (text.alpha >= 1.1f)
                    {
                        text.alpha = 0.7f;
                    }
                    else
                    {
                        text.alpha += 0.01f;
                    }
                    //pickup button
                    if (Input.IsLeftMouseBtnPress())
                    {   //check for new left click, start dragging state
                        if (draggable)
                        {
                            beingDragged = true;
                        }
                    }
                }
                else
                {
                    window.rec_bkg.color = color_normal;
                    text.color           = color_normal_text;
                }

                //if button was picked up, match cursor's pos
                if (Input.currentMouseState.LeftButton == ButtonState.Pressed)
                {
                    if (draggable & beingDragged)
                    {
                        MoveTo(
                            (int)Input.cursorPos.X - window.rec_bkg.openedRec.W / 2,
                            (int)Input.cursorPos.Y - window.rec_bkg.openedRec.H / 2);
                    }
                }
                //drop button to screen
                if (Input.currentMouseState.LeftButton == ButtonState.Released)
                {
                    if (draggable & beingDragged)
                    {
                        beingDragged = false;
                    }
                }
            }
            else if (displayState == DisplayState.Closing)
            {
                if (window.displayState == DisplayState.Closed)
                {
                    displayState = DisplayState.Closed;
                }
            }
            else if (displayState == DisplayState.Closed)
            {
            }

            //Debug.WriteLine("obj ds: " + displayState);
            //Debug.WriteLine("window ds: " + window.displayState);
            //Debug.WriteLine("text ds: " + text.displayState);
        }
Пример #5
0
        public override void Update()
        {
            text.Update();
            bkgLineWindow.Update();

            //put the text over the handle each frame
            text.position.X = handle.X - 4;
            text.position.Y = handle.Y - 16;

            if (displayState == DisplayState.Opening)
            {
                if (bkgLineWindow.displayState == DisplayState.Opened)
                {
                    displayState = DisplayState.Opened;
                }
            }
            else if (displayState == DisplayState.Opened)
            {
                //click line always follows clickX each frame
                clickLine.X = clickX;
                //fade click line out overtime
                if (clickLineAlpha > 0.0f)
                {
                    clickLineAlpha -= 0.01f;
                }
                else
                {
                    clickLineAlpha = 0.0f;
                }


                #region Increment currValue, which is what text draws

                if (currValue < value)
                {
                    currValue += 0.01f;
                }
                else if (currValue > value)
                {
                    currValue -= 0.01f;
                }
                else
                {
                    currValue = value;
                }

                #endregion

                #region Move handle to click position over time

                if (handle.X + 2 < clickX)
                {
                    handle.X++;
                    value += 0.01f;
                    //limit value max
                    if (value > 1.0f)
                    {
                        value = 1.0f;
                    }
                    //check for right boundary, limit
                    if (handle.X > bkgLineWindow.rec_bkg.openedRec.X + Width - 2)
                    {
                        handle.X = bkgLineWindow.rec_bkg.openedRec.X + Width - 2;
                        value    = 1.0f; //max
                    }
                    UpdateHandleValue();
                }
                else if (handle.X + 2 > clickX)
                {
                    handle.X--;
                    value -= 0.01f;
                    //limit value min
                    if (value < 0.01f)
                    {
                        value = 0.01f;
                    }
                    //check for left boundary, limit
                    if (handle.X < bkgLineWindow.rec_bkg.openedRec.X)
                    {
                        handle.X = bkgLineWindow.rec_bkg.openedRec.X;
                        value    = 0.01f; //min
                    }
                    UpdateHandleValue();
                }

                #endregion


                //add in user input to move value/handle
                if (Input.IsLeftMouseBtnPress())
                {
                    //user must click inside hitbox to move slider/handle
                    if (!Functions.Contains(hitbox,
                                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        return;
                    }

                    //else, store click position, display click line
                    clickX         = (int)Input.cursorPos.X;
                    clickLineAlpha = 1.0f;
                }
            }
            else if (displayState == DisplayState.Closing)
            {
                if (bkgLineWindow.displayState == DisplayState.Closed)
                {
                    displayState = DisplayState.Closed;
                }
            }
            else if (displayState == DisplayState.Closed)
            {
            }
        }
Пример #6
0
        public override void Update()
        {
            button.Update();
            for (i = 0; i < 8; i++)
            {
                lines[i].Update();
            }

            //miniphysics: apply friction to magnitude per axis
            magnitude.X = magnitude.X * friction;
            magnitude.Y = magnitude.Y * friction;

            //display states
            if (displayState == DisplayState.Opening)
            {
                if (button.displayState == DisplayState.Opened)
                {
                    displayState = DisplayState.Opened;
                }
            }
            else if (displayState == DisplayState.Opened)
            {
                #region Button Click Input

                //on click, spider wanders around
                if (Input.IsLeftMouseBtnPress())
                {
                    if (Functions.Contains(
                            button.window.rec_bkg.openedRec,
                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        if (wandering == false)
                        {
                            //open all legs start wandering around
                            for (i = 0; i < 8; i++)
                            {
                                lines[i].Open();
                            }
                            wandering = true;
                            ChooseDirection();
                        }
                        //spawn a child as feedback
                        SpawnChildren();
                        //change text as well
                        button.text.ChangeText("XXXXXXXXXXXXX");
                        button.CenterText();
                    }
                }

                #endregion

                #region Wandering Routine

                //if spider is wandering around, the legs should be
                //open and wiggling about
                if (wandering)
                {   //randomly choose a target to move button to
                    button.MoveTo(
                        (int)(button.window.rec_bkg.openedRec.X + magnitude.X),
                        (int)(button.window.rec_bkg.openedRec.Y + magnitude.Y));

                    //count wandering frames
                    wanderCounter++;
                    if (wanderCounter > wanderTotal)
                    {   //goto resting state
                        wanderCounter = 0;
                        wandering     = false;
                        //close all legs
                        for (i = 0; i < 8; i++)
                        {
                            lines[i].Close();
                        }
                        //change text
                        //change text as well
                        button.text.ChangeText("hmm...");
                        button.CenterText();
                    }

                    //randomly modify moving direction
                    if (Functions.Random.Next(0, 101) > 98)
                    {
                        ChooseDirection();
                    }
                }

                #endregion
            }
            else if (displayState == DisplayState.Closing)
            {
                if (button.displayState == DisplayState.Closed)
                {
                    displayState = DisplayState.Closed;
                }
            }
            else if (displayState == DisplayState.Closed)
            {
            }



            //work that happens when button isn't closed
            if (displayState != DisplayState.Closed)
            {
                #region Anchor legs to button

                //top of button
                lines[0].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 8,
                    button.window.rec_bkg.openedRec.Y);
                lines[1].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 24,
                    button.window.rec_bkg.openedRec.Y);
                lines[2].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 40,
                    button.window.rec_bkg.openedRec.Y);
                lines[3].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 56,
                    button.window.rec_bkg.openedRec.Y);
                //bottom of button
                lines[4].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 8,
                    button.window.rec_bkg.openedRec.Y + 16);
                lines[5].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 24,
                    button.window.rec_bkg.openedRec.Y + 16);
                lines[6].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 40,
                    button.window.rec_bkg.openedRec.Y + 16);
                lines[7].SetAnchor(
                    button.window.rec_bkg.openedRec.X + 56,
                    button.window.rec_bkg.openedRec.Y + 16);
                #endregion

                #region Place legs away from body like spider

                //top of button
                lines[0].SetTarget(
                    button.window.rec_bkg.openedRec.X + 5,
                    button.window.rec_bkg.openedRec.Y - 8);
                lines[1].SetTarget(
                    button.window.rec_bkg.openedRec.X + 21,
                    button.window.rec_bkg.openedRec.Y - 8);
                lines[2].SetTarget(
                    button.window.rec_bkg.openedRec.X + 43,
                    button.window.rec_bkg.openedRec.Y - 8);
                lines[3].SetTarget(
                    button.window.rec_bkg.openedRec.X + 60,
                    button.window.rec_bkg.openedRec.Y - 8);
                //bottom of button
                lines[4].SetTarget(
                    button.window.rec_bkg.openedRec.X + 5,
                    button.window.rec_bkg.openedRec.Y + 16 + 8);
                lines[5].SetTarget(
                    button.window.rec_bkg.openedRec.X + 21,
                    button.window.rec_bkg.openedRec.Y + 16 + 8);
                lines[6].SetTarget(
                    button.window.rec_bkg.openedRec.X + 43,
                    button.window.rec_bkg.openedRec.Y + 16 + 8);
                lines[7].SetTarget(
                    button.window.rec_bkg.openedRec.X + 60,
                    button.window.rec_bkg.openedRec.Y + 16 + 8);

                #endregion

                #region leg animation routine

                if (wandering)
                {
                    //sort button over other buttons
                    button.window.rec_bkg.zDepth  = Assets.Layer_WindowFront;
                    button.window.rec_fore.zDepth = Assets.Layer_WindowFront;

                    //modify leg positions each frame as if moving
                    for (i = 0; i < 8; i++)
                    {
                        lines[i].SetTarget(
                            lines[i].Xa + Functions.Random.Next(-4, 5),
                            lines[i].Ya + Functions.Random.Next(-4, 5));
                        lines[i].zDepth = Assets.Layer_WindowFront;
                    }
                }

                #endregion

                else
                {   //set button and lines on lower layers (behind)
                    button.window.rec_bkg.zDepth  = Assets.Layer_WindowBack;
                    button.window.rec_fore.zDepth = Assets.Layer_WindowBack;
                    for (i = 0; i < 8; i++)
                    {
                        lines[i].zDepth = Assets.Layer_Lines;
                    }
                }

                #region Keep button onscreen (push back to center)

                if (button.window.rec_bkg.openedRec.X > Assets.GDM.PreferredBackBufferWidth)
                {
                    magnitude.X = -3;
                }
                if (button.window.rec_bkg.openedRec.X < 0)
                {
                    magnitude.X = 3;
                }
                if (button.window.rec_bkg.openedRec.Y > Assets.GDM.PreferredBackBufferHeight)
                {
                    magnitude.Y = -3;
                }
                if (button.window.rec_bkg.openedRec.Y < 0)
                {
                    magnitude.Y = 3;
                }

                #endregion
            }
        }
Пример #7
0
        public override void Update()
        {
            //update all ui items
            for (i = 0; i < aui_instances.Count; i++)
            {
                aui_instances[i].Update();
            }

            #region Screen Display States

            if (displayState == DisplayState.Opening)
            {
                if (button_screen1.displayState == DisplayState.Opened)
                {
                    displayState = DisplayState.Opened;
                }
            }
            else if (displayState == DisplayState.Opened)
            {
                //handle main input here
                if (Input.IsLeftMouseBtnPress())
                {
                    //button 1
                    if (Functions.Contains(
                            button_screen1.window.rec_bkg.openedRec,
                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        Close(ExitAction.Example1);
                    }
                    //button 2
                    if (Functions.Contains(
                            button_screen2.window.rec_bkg.openedRec,
                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        Close(ExitAction.StressTest);
                    }
                    //button 3
                    if (Functions.Contains(
                            button_screen3.window.rec_bkg.openedRec,
                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        Close(ExitAction.Spider);
                    }
                    //button 4
                    if (Functions.Contains(
                            button_screen4.window.rec_bkg.openedRec,
                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        Close(ExitAction.Example1);
                    }
                    //button 5
                    if (Functions.Contains(
                            button_screen5.window.rec_bkg.openedRec,
                            Input.cursorPos.X, Input.cursorPos.Y))
                    {
                        Close(ExitAction.Example1);
                    }
                }
            }
            else if (displayState == DisplayState.Closing)
            {
                //ensure all aui items are closed
                Boolean allClosed = true; //assume true, prove false
                for (i = 0; i < aui_instances.Count; i++)
                {
                    if (aui_instances[i].displayState != DisplayState.Closed)
                    {
                        allClosed = false;
                    }
                }
                if (allClosed)
                {
                    displayState = DisplayState.Closed;
                }
            }
            else if (displayState == DisplayState.Closed)
            {
                if (exitAction == ExitAction.Title)
                {
                    ScreenManager.ExitAndLoad(new Screen_Title());
                }
                else if (exitAction == ExitAction.Example1)
                {
                    ScreenManager.ExitAndLoad(new Screen_Example1());
                }
                else if (exitAction == ExitAction.StressTest)
                {
                    ScreenManager.ExitAndLoad(new Screen_StressTest());
                }
                else if (exitAction == ExitAction.Spider)
                {
                    ScreenManager.ExitAndLoad(new Screen_Spider());
                }
            }

            #endregion
        }