protected override void OnPointerUp() { base.OnPointerUp(); NodeProperties nodeBehaviour = this.GetComponent <NodeProperties>(); if (nodeBehaviour.m_nodeType == NodeProperties.NodeType.Simple) { if (m_attachedAnchor == null) { if (m_snappedAnchor != null) { m_attachedAnchor = m_snappedAnchor; m_snappedAnchor.Spread(); Destroy(nodeBehaviour.m_deactivatedGUIItem); } else { Destroy(this.gameObject); nodeBehaviour.m_deactivatedGUIItem.SetActive(true); } } } else if (nodeBehaviour.m_nodeType == NodeProperties.NodeType.TargetIndicator) { if (m_snappedAnchor != null) { this.m_parentNode.GetComponent <NodeMovement>().MoveParentNodeToAnchor(m_snappedAnchor); } Destroy(this.gameObject); //destroy the target indicator node Destroy(m_parentNode.GetComponent <NodeTouchHandler>().m_targetIndicatorBridge); //destroy the target indicator node } }
void Update() { if (m_isGUIItem) { return; } float dt = Time.deltaTime; if (m_moving) { Vector2 positionVec2 = transform.position; Vector2 direction = (m_moveEndAnchor.m_position - m_moveStartAnchor.m_position); float fTotalSqrDistance = direction.sqrMagnitude; direction.Normalize(); positionVec2 += (direction * NODE_MOVE_SPEED * dt); float fCoveredSqrDistance = (positionVec2 - m_moveStartAnchor.m_position).sqrMagnitude; float fZValue = GetComponent <NodeProperties>().GetZValue(); if (fCoveredSqrDistance > fTotalSqrDistance) { transform.position = new Vector3(m_moveEndAnchor.m_position.x, m_moveEndAnchor.m_position.y, fZValue); m_moving = false; m_moveEndAnchor.Spread(); this.GetComponent <NodeTouchHandler>().m_attachedAnchor = m_moveEndAnchor; InvalidateMovementPointsTextMeshValue(); } else { transform.position = new Vector3(positionVec2.x, positionVec2.y, fZValue); } } }