public SelectorPannel(Screen parent, ContentManager c,GuideBlock g) { this.ParentScreen = parent; this.GameResolution = parent.GameResolution; this.WindowResolution = parent.WindowResolution; this.contentManager = c; this.guide = g; this.IsDrawn = true; this.IsUpdated = true; this.ChildScreens = null; this.state = States.showing; this.currentButton = null; this.Color = new Color(200, 200, 200, 255); this.PositionBox = new Rectangle(0, -300, 1920, 400); addButtons(); }
public override void update(Utilities.GameTime time) { Vector2i mouse = Game1.getMousePosition(); switch (state) { case States.showing: this.PositionBox.y += 25; if (PositionBox.y > 0) { PositionBox.y = 0; state = States.shown; onStateChanged(); } break; case States.hiding: this.PositionBox.y -= 25; if (PositionBox.y < -400) { PositionBox.y = -400; state = States.hidden; onStateChanged(); this.IsDrawn = false; } break; } foreach (SelectorButton b in buttons) { b.update(); if (currentButton != null) { if (Utils.checkMouseCollision(mouse.X, mouse.Y, b.positionBox) && !b.Equals(currentButton)) { currentButton.onMouseLeave(); b.onMouseOver(); currentButton = b; } } else if (Utils.checkMouseCollision(mouse.X, mouse.Y, b.positionBox)) { b.onMouseOver(); currentButton = b; } } if (currentButton != null && !Utils.checkMouseCollision(mouse.X, mouse.Y, currentButton.positionBox)) { currentButton.onMouseLeave(); currentButton = null; } }
public override void Dispose() { foreach (SelectorButton b in buttons) b.Dispose(); this.buttons.Clear(); this.buttons = null; this.currentButton = null; this.guide = null; this.ParentScreen = null; }