public void UpdateDragDirectionDisp() { LineRenderer lr = GetComponent <LineRenderer> (); bool bDragging = _DragRoter.IsDragging(); //print ("bDragging:" + bDragging); if (!bDragging) { lr.enabled = false; return; } int draggingDir = _DragRoter.GetDragingDir(); CellObjCtrl ctrl = CellObjCtrlUtils.GetNbCellObjCtrlInAbsDir(_CCtrl, draggingDir); if (ctrl == null) { lr.enabled = false; } else { lr.enabled = true; Vector3 p0 = _CCtrl.transform.position + new Vector3(0, 0, _zbias); Vector3 p1 = ctrl.transform.position + new Vector3(0, 0, _zbias); lr.SetPosition(0, p0); lr.SetPosition(1, p1); lr.useWorldSpace = true; } }
void OnMouseDrag() { if (!MiroPlayingStatus.bPlaying) { return; } if (CheckBlock()) { return; } if (enabled) { _bDragging = true; //Debug.Log (_cctrl.name + " OnMouseDrag" + " rotate"); Vector3 hitDir = GetHitDir(); int rightDir = _cctrl.GetDir(); float minAngle = 100000.0f; for (int dir = 0; dir < 6; dir++) { if (_banDirs.Contains(dir)) { continue; } CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrlInAbsDir(_cctrl, dir); if (nbCtrl == null) { continue; } Vector3 nbDir = nbCtrl.transform.position - _cctrl.transform.position; nbDir.Normalize(); float angle = Vector3.Angle(hitDir, nbDir); if (angle < minAngle) { minAngle = angle; rightDir = dir; } } if (rightDir != _cctrl.GetDir()) { _cctrl.SetDir(rightDir); _cctrl.ChangeDir(); //print ("ChangeDir" + rightDir); _RightDir = rightDir; _DirChanged.Invoke(rightDir); } } }