void OnMouseEnter() { if (fieldTeam.ConvertActualTimeToSimulatedTime(actualTime) <= fieldTeam.simulatedTimeLastOnline && fieldTeam.fieldTeamAppearStatus == FieldTeam.FieldTeamAppearStatus.Showing && fieldTeam.mainController.fullscreenView == null && !fieldTeam.mainController.mouseHoveringOverIcon) { //this.HighlightPathPoint(); string imagePath = fieldTeam.GetPhotoThumbnailPathFromActualTime(actualTime); GameObject wholeScreenUiObj = fieldTeam.mainController.wholeScreenUiObj; _mapFrameDisplayObj = Instantiate(fieldTeam.mapFrameDisplayPrefab, wholeScreenUiObj.transform); _mapFrameDisplayObj.transform.Find("Background").GetComponent <Image>().color = fieldTeam.teamColor; _mapFrameDisplayObj.transform.Find("Arrow").GetComponent <Image>().color = fieldTeam.teamColor; _mapFrameDisplayObj.transform.Find("Time").GetComponent <Text>().text = fieldTeam.ConvertActualTimeToSimulatedTime(actualTime).ToString("MM/dd/yyyy HH:mm:ss"); _mapFrameDisplay = _mapFrameDisplayObj.GetComponent <MapFrameDisplay>(); _mapFrameDisplay.fieldTeam = fieldTeam; _mapFrameDisplay.DisplayImage(imagePath); Camera sceneCamera = fieldTeam.mainController.sceneCameraObj.GetComponent <Camera>(); RectTransform canvasRect = wholeScreenUiObj.GetComponent <RectTransform>(); Vector2 viewportPos = sceneCamera.WorldToViewportPoint(this.transform.position); Vector2 worldObjScreenPos = new Vector2( ((viewportPos.x * canvasRect.sizeDelta.x * 0.75f) - (canvasRect.sizeDelta.x * 0.5f)), ((viewportPos.y * canvasRect.sizeDelta.y * 0.8f) - (canvasRect.sizeDelta.y * 0.5f) + (canvasRect.sizeDelta.y * 0.2f)) ); _mapFrameDisplayObj.GetComponent <RectTransform>().anchoredPosition = worldObjScreenPos; fieldTeam.HighlightActualTimeOnTimeline(actualTime); } }
public void Update() { if (fieldTeam) { /* Update icon colour if team's colour changed */ if (fieldTeam.teamColor != _lastTeamColor) { _lastTeamColor = fieldTeam.teamColor; Image img = line.GetComponent <Image>(); img.color = fieldTeam.teamColor; _offlineLineImg.color = fieldTeam.teamColor; } /* Update name if team's name changed */ if (fieldTeam.teamName != _lastTeamName) { _lastTeamName = fieldTeam.teamName; Text txt = this.transform.Find("Label").GetComponent <Text>(); txt.text = this.fieldTeam.teamName; } /* Draw/update timeline markings */ if (fieldTeam.mainController.currentSimulatedTime.dateTime < fieldTeam.simulatedEndTime.dateTime) { _endTimeOfTimeline = fieldTeam.simulatedTimeLastOnline.dateTime; } else { _endTimeOfTimeline = fieldTeam.simulatedEndTime.dateTime; } RectTransform lineTransform = line.GetComponent <RectTransform>(); _scaleX = (float)(_endTimeOfTimeline.Ticks - fieldTeam.simulatedStartTime.dateTime.Ticks) / (float)(fieldTeam.mainController.currentSimulatedTime.dateTime.Ticks - fieldTeam.mainController.earliestSimulatedStartTime.dateTime.Ticks); _n = (float)(fieldTeam.simulatedStartTime.dateTime.Ticks - fieldTeam.mainController.earliestSimulatedStartTime.dateTime.Ticks) / (float)(fieldTeam.mainController.currentSimulatedTime.dateTime.Ticks - fieldTeam.mainController.earliestSimulatedStartTime.dateTime.Ticks); if (_scaleX == 1.0f) { _pivotX = 0.0f; } else { _pivotX = _n + _n / (1.0f - _scaleX) * _scaleX; } lineTransform.pivot = new Vector2(_pivotX, lineTransform.pivot.y); lineTransform.localScale = new Vector3(_scaleX, lineTransform.localScale.y, lineTransform.localScale.z); lineTransform.SetLeft(0.0f); lineTransform.SetRight(0.0f); _beginPos = _n * (_timelineUiCanvasRect.sizeDelta.x - 25.0f) + 5.0f; _endPos = (_n + _scaleX) * (_timelineUiCanvasRect.sizeDelta.x - 25.0f) + 5.0f; /* Draw/update offline timeline markings */ if (fieldTeam.isInRadioDeadZone) { offlineLine.SetActive(true); if (fieldTeam.mainController.currentSimulatedTime.dateTime < fieldTeam.simulatedEndTime.dateTime) { _endTimeOfOfflineTimeline = fieldTeam.mainController.currentSimulatedTime; } else { _endTimeOfOfflineTimeline = fieldTeam.simulatedEndTime.dateTime; } RectTransform offlineLineTransform = offlineLine.GetComponent <RectTransform>(); _offlineLineScaleX = (float)(_endTimeOfOfflineTimeline.Ticks - fieldTeam.simulatedTimeLastOnline.dateTime.Ticks) / (float)(fieldTeam.mainController.currentSimulatedTime.dateTime.Ticks - fieldTeam.mainController.earliestSimulatedStartTime.dateTime.Ticks); _offlineLineN = (float)(fieldTeam.simulatedTimeLastOnline.dateTime.Ticks - fieldTeam.mainController.earliestSimulatedStartTime.dateTime.Ticks) / (float)(fieldTeam.mainController.currentSimulatedTime.dateTime.Ticks - fieldTeam.mainController.earliestSimulatedStartTime.dateTime.Ticks); if (_offlineLineScaleX == 1.0f) { _offlineLinePivotX = 0.0f; } else { _offlineLinePivotX = _offlineLineN + _offlineLineN / (1.0f - _offlineLineScaleX) * _offlineLineScaleX; } offlineLineTransform.pivot = new Vector2(_offlineLinePivotX, offlineLineTransform.pivot.y); offlineLineTransform.localScale = new Vector3(_offlineLineScaleX, offlineLineTransform.localScale.y, offlineLineTransform.localScale.z); offlineLineTransform.SetLeft(0.0f); offlineLineTransform.SetRight(0.0f); Material mat = Instantiate(_offlineLineImg.material); mat.SetFloat("_RepeatCount", 400.0f * _offlineLineScaleX); _offlineLineImg.material = mat; } else { offlineLine.SetActive(false); } /* Display team footage thumbnail preview if cursor hovering over timeline */ // Set up the new Pointer Event _pointerEventData = new PointerEventData(_eventSystem); // Set the Pointer Event Position to that of the cursor position _pointerEventData.position = Input.mousePosition; // Create a list of Raycast Results List <RaycastResult> results = new List <RaycastResult>(); // Raycast using the Graphics Raycaster and cursor position _raycaster.Raycast(_pointerEventData, results); RaycastResult result = new RaycastResult(); bool prevHoveringOverLine = _hoveringOverLine; _hoveringOverLine = false; foreach (RaycastResult res in results) { if (res.gameObject == line && fieldTeam.mainController.fullscreenView == null) // cursor is hovering over line { _hoveringOverLine = true; result = res; break; } } if (fieldTeam.mainController.sideUi.selectedFieldTeam == null) { if (prevHoveringOverLine == false && _hoveringOverLine == true) { fieldTeam.ShowThisFieldTeamOnly(); } else if (prevHoveringOverLine == true && _hoveringOverLine == false) { fieldTeam.ShowAllFieldTeams(); } } if (_hoveringOverLine) { _hoveringOverLineOnLastFrame = true; Vector2 referencePosition = new Vector2( result.screenPosition.x / _wholeScreenUiObj.GetComponent <Canvas>().pixelRect.size.x *_wholeScreenUiObj.GetComponent <CanvasScaler>().referenceResolution.x, result.screenPosition.y / _wholeScreenUiObj.GetComponent <Canvas>().pixelRect.size.y *_wholeScreenUiObj.GetComponent <CanvasScaler>().referenceResolution.y ); float placeHighlighted = (referencePosition.x - _beginPos) / (_endPos - _beginPos); if (placeHighlighted < 0) { placeHighlighted = 0; } else if (placeHighlighted > 1) { placeHighlighted = 1; } long ticks = fieldTeam.simulatedStartTime.dateTime.Ticks + (long)(placeHighlighted * (_endTimeOfTimeline.Ticks - fieldTeam.simulatedStartTime.dateTime.Ticks)); DateTime simulatedTimeHighlighted = new DateTime(ticks); string imagePath = fieldTeam.GetPhotoThumbnailPathFromSimulatedTime(simulatedTimeHighlighted); if (!_mapFrameDisplayShowing) { _mapFrameDisplayObj = Instantiate(fieldTeam.mapFrameDisplayPrefab, _wholeScreenUiObj.transform); _mapFrameDisplayObj.transform.Find("Background").GetComponent <Image>().color = fieldTeam.teamColor; _mapFrameDisplayObj.transform.Find("Arrow").GetComponent <Image>().color = fieldTeam.teamColor; _mapFrameDisplay = _mapFrameDisplayObj.GetComponent <MapFrameDisplay>(); _mapFrameDisplay.fieldTeam = fieldTeam; _mapFrameDisplayShowing = true; } _mapFrameDisplay.DisplayImage(imagePath); _mapFrameDisplayObj.transform.Find("Time").GetComponent <Text>().text = simulatedTimeHighlighted.ToString("MM/dd/yyyy HH:mm:ss"); Vector2 pos = new Vector2( referencePosition.x - 0.5f * _wholeScreenUiCanvasRect.sizeDelta.x, referencePosition.y - 0.5f * _wholeScreenUiCanvasRect.sizeDelta.y); float halfMapFrameWidth = _mapFrameDisplayObj.transform.Find("Background").GetComponent <RectTransform>().rect.width * 0.5f; RectTransform arrowTransform = _mapFrameDisplayObj.transform.Find("Arrow").GetComponent <RectTransform>(); if (pos.x - halfMapFrameWidth < -0.5f * _wholeScreenUiCanvasRect.sizeDelta.x) { float originalPos = pos.x; pos.x = -0.5f * _wholeScreenUiCanvasRect.sizeDelta.x + halfMapFrameWidth; arrowTransform.localPosition = new Vector3(originalPos - pos.x, arrowTransform.localPosition.y, arrowTransform.localPosition.z); //float arrowWidth = arrowTransform.rect.width; //if (arrowTransform.localPosition.x - 0.5f * arrowWidth < -halfMapFrameWidth) //{ // float newWidth = arrowWidth - (halfMapFrameWidth - (arrowTransform.localPosition.x - 0.5f * arrowWidth)); // arrowTransform.localScale = new Vector3(newWidth, arrowTransform.localScale.y, arrowTransform.localScale.z); //} //else //{ // arrowTransform.localScale = new Vector3(25.0f, arrowTransform.localScale.y, arrowTransform.localScale.z); //} } else { arrowTransform.localPosition = new Vector3(0.0f, arrowTransform.localPosition.y, arrowTransform.localPosition.z); } _mapFrameDisplayObj.GetComponent <RectTransform>().anchoredPosition = pos; fieldTeam.UnhighlightPath(); fieldTeam.HighlightPathAtSimulatedTime(simulatedTimeHighlighted); // Check for click if (Input.GetMouseButtonDown(0)) { fieldTeam.mainController.fullscreenViewObj = GameObject.Instantiate(fieldTeam.mainController.footageFullscreenViewPrefab, fieldTeam.mainController.wholeScreenUiObj.transform); fieldTeam.mainController.footageFullscreenView = fieldTeam.mainController.fullscreenViewObj.GetComponent <FootageFullscreenView>(); fieldTeam.mainController.footageFullscreenView.mainController = fieldTeam.mainController; fieldTeam.mainController.footageFullscreenViewShowingLive = false; fieldTeam.mainController.footageFullscreenView.DisplayFullscreenImage( fieldTeam.GetPhotoPathFromSimulatedTime(simulatedTimeHighlighted), fieldTeam.GetPhotoThumbnailPathFromSimulatedTime(simulatedTimeHighlighted) ); } } else if (_hoveringOverLineOnLastFrame) { GameObject.Destroy(_mapFrameDisplayObj); _mapFrameDisplayShowing = false; fieldTeam.UnhighlightPath(); _hoveringOverLineOnLastFrame = false; } } }