private void moveShot() { QRegion region = new QRegion(shotRect()); timerCount++; QRect shotR = shotRect(); if (shotR.Intersects(targetRect())) { autoShootTimer.Stop(); Emit.hit(); } else if (shotR.X() > Width() || shotR.Y() > Height()) { autoShootTimer.Stop(); Emit.missed(); } else { region = region.Unite(new QRegion(shotR)); } Update(region); }
public void SetGameOver() { if (gameEnded) { return; } if (IsShooting) { autoShootTimer.Stop(); } gameEnded = true; Update(); }
void UpdateHoverItem() { var oldItem = m_HoverItem; var pos = this.MapFromGlobal(QCursor.Pos()); var item = this.ItemAt(pos); // Since we map the point to scene coords, we could accidently // focus items outside the visible viewport. if (m_SuppressTooltips || !this.Viewport().Geometry.Contains(pos) || !this.IsVisible()) { m_TooltipTimer.Stop(); m_HoverItem = null; m_InfoPopup.Item = null; } else { if (item is RosterItem <T> ) { m_HoverItem = (RosterItem <T>)item; m_HoverItem.Update(); if (m_InfoPopup.Item != m_HoverItem) { if (m_InfoPopup.IsVisible()) { m_InfoPopup.Item = m_HoverItem; } else { m_TooltipTimer.Stop(); m_InfoPopup.Item = m_HoverItem; m_TooltipTimer.Start(); } } } else { m_TooltipTimer.Stop(); m_HoverItem = null; // Allow a buffer around the active item so that the tooltip // can change items without having to be closed/re-opened. if (m_InfoPopup.Item != null) { var itemRect = m_InfoPopup.Item.SceneBoundingRect(); var itemPos = this.MapFromScene(itemRect.X(), itemRect.Y()); QRectF rect = new QRectF(itemPos.X() - IconPadding, itemPos.Y() - IconPadding, itemRect.Width() + IconPadding + IconPadding, itemRect.Height() + IconPadding + IconPadding); if (!rect.Contains(pos)) { m_InfoPopup.Item = null; } } } } if (oldItem != null && oldItem != m_HoverItem) { oldItem.Update(); } }