public void DoubleClick() { DebugLog.DebugLogInfo("双击-----------------"); if (BlockManager.Instance.availableBaseCount > 0) { DebugLog.DebugLogInfo("availableBaseCount--- " + BlockManager.Instance.availableBaseCount); BlockManager.Instance.availableBaseCount--; TouchableObject tobj = GetComponent <TouchableObject>(); tobj.SetDraggable(false); tobj.SetRotatable(false); TweenRotation tween = TweenRotation.Begin(gameObject, 0.5f, targetRotation); DebugLog.DebugLogInfo("tween--- " + tween); tween.method = UITweener.Method.EaseInOut; UITweener tweener = TweenPosition.Begin(gameObject, 0.3f, targetPosition); DebugLog.DebugLogInfo("tweener--- " + tweener); tweener.method = UITweener.Method.EaseInOut; //TweenRotation tween = GetComponent<TweenRotation>(); tween.from = m_transform.localEulerAngles; tween.to = targetAngles; float y = tween.from.y; if (Mathf.Abs(360 - tween.from.y) < Mathf.Abs(tween.from.y - 0)) { //tween.from = new Vector3(tween.from.x, tween.from.y - 360, tween.from.z); tween.to = new Vector3(tween.to.x, tween.to.y + 360, tween.to.z); } DebugLog.DebugLogInfo("from:" + tween.from + "to:" + tween.to); tween.SetOnFinished(BlockManager.Instance.AddScore); //BlockManager.Instance.AddScore(); isFinished = true;//标志该结构已经归位 this.GetComponent <DraggableObject>().enabled = false; this.GetComponent <RotatableObject>().enabled = false; } }
private void checkCollison(float positionThreshold, float angleThreshold) { float distance = Vector3.Distance(m_transform.localPosition, targetPosition); if (distance <= positionThreshold) { print("position ok"); } if (distance <= positionThreshold && Vector3.Angle(m_transform.right, targetRight) < angleThreshold && Vector3.Angle(m_transform.up, targetUp) < angleThreshold && Vector3.Angle(m_transform.forward, targetForward) < angleThreshold )//判断为达到正确位置 { TouchableObject tobj = GetComponent <TouchableObject>(); tobj.SetDraggable(false); tobj.SetRotatable(false); TweenRotation tween = TweenRotation.Begin(gameObject, 0.5f, targetRotation); tween.method = UITweener.Method.EaseInOut; UITweener tweener = TweenPosition.Begin(gameObject, 0.5f, targetPosition); tweener.method = UITweener.Method.EaseInOut; //TweenRotation tween = GetComponent<TweenRotation>(); tween.from = m_transform.localEulerAngles; tween.to = targetAngles; float y = tween.from.y; if (Mathf.Abs(360 - tween.from.y) < Mathf.Abs(tween.from.y - 0)) { //tween.from = new Vector3(tween.from.x, tween.from.y - 360, tween.from.z); tween.to = new Vector3(tween.to.x, tween.to.y + 360, tween.to.z); } Debug.Log("from:" + tween.from + "to:" + tween.to); //tween.PlayForward(); //BlockManager.Instance.AddScore(); tween.SetOnFinished(BlockManager.Instance.AddScore); isFinished = true;//标志该结构已经归位 //targetRotation. } }