void OnDrag(DragGesture gesture) { ContinuousGesturePhase phase = gesture.Phase; Vector3 UIPos = Game.gesturePos2UIPos(gesture.StartPosition); trails[0].transform.position = UIPos; trails[0].particleSystem.enableEmission = true; if (phase.ToString() == "Ended") { trails[0].particleSystem.enableEmission = false; } }
void OnDrag(DragGesture gesture) { if (Game.state != fixState) { return; } ContinuousGesturePhase phase = gesture.Phase; Debug.Log("phase" + phase.ToString()); // // Vector3 creaPos = gesture.Position; // // creaPos.x -= Screen.width / 2; // creaPos.y -= Screen.height / 2 ; // creaPos.x *= Camera.main.fieldOfView / ( Screen.height / 2 ) * touchScaleX ; // creaPos.y *= Camera.main.fieldOfView / ( Screen.height / 2 ) * touchScaleY ; // creaPos.z = 1f; // // creaCursor.transform.position = creaPos; if (ifPress) { Vector3 UIPos = Game.gesturePos2UIPos(gesture.StartPosition); float dis = Vector3.Distance(UIPos, initPos); Debug.Log("ifPressed " + dis.ToString()); Debug.Log("size " + (spriteWidth / 2)); //check if drag if (dis < spriteWidth / 2) { Debug.Log("distanced "); // Debug.Log ( "move " + gesture.DeltaMove.ToString() ); // transform.position += new Vector3 (gesture.DeltaMove.x * dragScale , gesture.DeltaMove.y * dragScale , 0); transform.position = Game.gesturePos2UIPos(gesture.Position); } // if (!newdown) { // //GameObject newo = Instantiate (fireballdown, new Vector3 (x, y, z), Quaternion.identity) as GameObject; // //down = newo; // //newdown = true; // } } if (phase.ToString().Equals("Started")) { Debug.Log("ges" + gesture.Position + gesture.StartPosition); Vector3 UIPos = Game.gesturePos2UIPos(gesture.Position); Debug.Log("began drag " + Vector3.Distance(UIPos, initPos) + " < " + (spriteWidth / 2)); // Ray ray = new Ray( Game.mainCamera.transform.position , UIPos - Game.mainCamera.transform.position ); // RaycastHit raycastHit = new RaycastHit(); // if ( Physics.Raycast( ray , out raycastHit ) && raycastHit.collider.gameObject == gameObject ) // { if (Vector3.Distance(UIPos, initPos) < spriteWidth / 2 && num > 0) { touchEffect.Emit(30); ifPress = true; } } if (phase.ToString().Equals("Ended") && ifPress) { ifPress = false; // DestroyObject(down, 0.1f); // newdown = false; //Debug.Log (gesture.Position); // logic.SendMessage("destoryLife", new Vector2(x + gesture.TotalMove.x / 150f, y + gesture.TotalMove.y / 150f)); HOTween.To(transform , resetTime , "position" , initPos , false , resetEase , 0); logic.SendMessage("destoryLife", Game.gesturePos2CreaPos(gesture.Position)); num--; text.text = num.ToString(); Color col = text.color; col.a = 0; text.color = col; col.a = 1; HOTween.To(text , textTime , new TweenParms() .Prop("color", col, false) .Loops(2, LoopType.YoyoInverse) ); Vector3 gesPos = Game.gesturePos2CreaPos(gesture.Position); GameObject exp = Instantiate(exposionPrefab) as GameObject; exp.transform.position = new Vector3(gesPos.x, gesPos.y, exp.transform.position.z); } creaCursor.transform.position = Game.gesturePos2CreaPos(gesture.Position); UICursor.transform.position = Game.gesturePos2UIPos(gesture.Position); }