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) { } }
public override void Update() { button.Update(); //match the target to the button each frame line.SetTarget( button.window.rec_bkg.openedRec.X + offsetX, button.window.rec_bkg.openedRec.Y + offsetY); //insta match the line's length (bypass animation) if (displayState == DisplayState.Opened) { line.line.animLength = line.line.length; } //else we allow the lines to close line.Update(); //wait for line to complete opening before opening button if (line.displayState == DisplayState.Opened) { button.Open(); } //set display state based on instances if (button.displayState == DisplayState.Opening || line.displayState == DisplayState.Opening) { displayState = DisplayState.Opening; } else if (button.displayState == DisplayState.Opened & line.displayState == DisplayState.Opened) { displayState = DisplayState.Opened; } else if (button.displayState == DisplayState.Closing || line.displayState == DisplayState.Closing) { displayState = DisplayState.Closing; } else if (button.displayState == DisplayState.Closed & line.displayState == DisplayState.Closed) { displayState = DisplayState.Closed; } }
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; } } } }
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 } }