private void OnHotspotClicked( HotspotWidget hotspotWidget, WidgetEvent widgetEvent) { if (m_currentNavRef.IsValid) { WidgetEvent.MouseClickEventParameters eventParameters = widgetEvent.EventParameters as WidgetEvent.MouseClickEventParameters; Point2d clickPoint = new Point2d(eventParameters.worldX, eventParameters.worldY); HotspotInfo hotspotInfo = hotspotWidget.Userdata as HotspotInfo; switch (hotspotInfo.hotspotType) { case eHotspotType.energy_tank: { EnergyTankData energyTankData = hotspotInfo.hotspotEntity as EnergyTankData; m_contextOverlayController.OnEnergyTankClicked(clickPoint, energyTankData); } break; case eHotspotType.portal: { RoomPortal portal = hotspotInfo.hotspotEntity as RoomPortal; m_contextOverlayController.OnPortalClicked(clickPoint, portal); } break; } } }
// Events public void OnWidgetEvent(WidgetEvent widgetEvent) { switch (widgetEvent.EventType) { case WidgetEvent.eEventType.buttonClick: { if (widgetEvent.EventSource == m_logoutButton) { GameWorldController.OnLogoutClicked(); } if (widgetEvent.EventSource == m_firstEventButton) { GameWorldController.OnFirstEventClicked(); } if (widgetEvent.EventSource == m_previousEventButton) { GameWorldController.OnPreviousEventClicked(); } if (widgetEvent.EventSource == m_playPauseEventButton) { GameWorldController.OnPlayPauseClicked(); } if (widgetEvent.EventSource == m_nextEventButton) { GameWorldController.OnNextEventClicked(); } if (widgetEvent.EventSource == m_lastEventButton) { GameWorldController.OnLastEventClicked(); } } break; case WidgetEvent.eEventType.mouseClick: { if (m_foregroundObjectTiles != null && widgetEvent.EventSource == m_foregroundObjectTiles) { WidgetEvent.MouseClickEventParameters eventParameters = widgetEvent.EventParameters as WidgetEvent.MouseClickEventParameters; GameWorldController.OnCharacterMoveToRequest(eventParameters.localX, eventParameters.localY); } } break; case WidgetEvent.eEventType.mouseOver: case WidgetEvent.eEventType.mouseOut: case WidgetEvent.eEventType.mouseMove: { // Forward mouse events on to the overlay view for cursor updates GameWorldController.OverlayController.View.OnWidgetEvent(widgetEvent); } break; } }
// Unity Mouse Event Handlers private void OnMouseUp() { m_mouseIsDragging = false; if (m_mouseOverIWidget != null) { { WidgetEvent.MouseUpEventParameters eventParameters = new WidgetEvent.MouseUpEventParameters { worldX = m_mousePosition.x, worldY = m_mousePosition.y, localX = m_mousePosition.x - m_mouseOverIWidget.WorldX, localY = m_mousePosition.y - m_mouseOverIWidget.WorldY }; if (LogEnabled) { Debug.Log("[MouseUp] on Widget " + m_mouseOverIWidget.GetType().Name); } // Notify the widget that the mouse was released (m_mouseOverIWidget as IWidgetEventListener).OnWidgetEvent( new WidgetEvent(WidgetEvent.eEventType.mouseUp, m_mouseOverIWidget, eventParameters)); } // Notify the widget if we clicked on it if (m_mouseOverIWidget == m_mouseDownIWidget) { WidgetEvent.MouseClickEventParameters eventParameters = new WidgetEvent.MouseClickEventParameters { worldX = m_mousePosition.x, worldY = m_mousePosition.y, localX = m_mousePosition.x - m_mouseOverIWidget.WorldX, localY = m_mousePosition.y - m_mouseOverIWidget.WorldY }; if (LogEnabled) { Debug.Log("[MouseClick] on Widget " + m_mouseOverIWidget.GetType().Name); } (m_mouseOverIWidget as IWidgetEventListener).OnWidgetEvent( new WidgetEvent(WidgetEvent.eEventType.mouseClick, m_mouseOverIWidget, eventParameters)); } } m_mouseDownIWidget = null; }