// Methods public virtual new void OnPointerDown(PointerEventData _eventData) { //Check for null Transform if (_eventData.button == PointerEventData.InputButton.Left) { if (m_rectTransform == null || m_canvas == null || m_visualGate == null || m_visualGridManager == null || m_gameplayManager == null || m_wireManager == null || m_infoPopup == null) { m_rectTransform = GetComponent <RectTransform>(); m_visualGate = GetComponent <VisualGate>(); m_canvas = FindObjectOfType <Canvas>(); m_visualGridManager = FindObjectOfType <VisualGridManager>(); m_gameplayManager = FindObjectOfType <GameplayManager>(); m_wireManager = FindObjectOfType <WireManager>(); m_infoPopup = FindObjectOfType <InfoPopup>(); } if (m_rectTransform != null && m_canvas != null && m_visualGate != null && m_visualGridManager != null && m_gameplayManager != null && m_wireManager != null) { if (!m_wireManager.IsInWireEditMode()) { DoStateTransition(SelectionState.Pressed, false); m_isBeingDragged = true; m_rectTransform.SetParent(m_gameplayManager.gridParent); StartCoroutine(OnDrag()); } } } }
private void Update() { //Update UI Elements if (isPlaying) { if (timerText != null) { timerText.text = (timeLeft > 0 ? (timeLeft < 100 ?Mathf.Floor(timeLeft) + 1 : 100) : 0).ToString(); } if (wave >= 0 && waveText != null) { waveText.text = "Wave " + (wave + 1); } } if (wireManager.IsInWireEditMode() != isGridModeIndicatorHidden && !isGridModeIndicatorAnimating) { isGridModeIndicatorAnimating = true; isGridModeIndicatorHidden = wireManager.IsInWireEditMode(); StartCoroutine(FadeInText(gridModeIndicator.GetComponent <Text>(), wireManager.IsInWireEditMode())); if (isGridModeIndicatorHidden) { backgroundColour = Color.Lerp(orginalBackgroundColour, Color.black, 0.5f); } else { backgroundColour = orginalBackgroundColour; } } if (actualBackgroundColour != backgroundColour && !isBackgroundFading) { isBackgroundFading = true; StartCoroutine(FadeBackground(actualBackgroundColour, backgroundColour, background)); StartCoroutine(TurnOffAfterFade(backgroundColour)); } }
// Update is called once per frame void Update() { if (wireManager.IsInWireEditMode()) { if (!isShowingLocalWire) { //Start showing a local wire isShowingLocalWire = true; } } else { if (isShowingLocalWire) { Reset(); } } //Draw the Wire if (isShowingLocalWire) { List <CellCoordinates> wirePath = wireManager.GetCurrentPath(); if (localWire == null || localWire.Count != wirePath.Count) { //We've changed somewhere GenerateWire(wirePath); } else { for (int i = 0; i < wirePath.Count; i++) { //Check for changes if (localWire[i].X != wirePath[i].X || localWire[i].Y != wirePath[i].Y) { //We've changed somewhere GenerateWire(wirePath); } } } } }