void ShootPlayer() { RopeSriptes m_RopeSripts = curHook.GetComponent <RopeSriptes> (); List <GameObject> nodes = m_RopeSripts.nodes; Transform player = m_RopeSripts.player.transform; LineRenderer lr = m_RopeSripts.lr; StartCoroutine(TakeBackRope(nodes, player, lr)); }
// Use this for initialization void Start() { hookRig2D = GetComponent <Rigidbody2D> (); ropeScritpes = GetComponent <RopeSriptes> (); }
// Update is called once per frame void Update() { if (isStart) { if (gameState == GameState.isInSky) { //if(Input.GetTouch) if (Input.GetMouseButtonDown(0)) { if (curRocket) { gameState = GameState.isShooting; //Vector2 destiny = Camera.main.ScreenToWorldPoint (Input.mousePosition); Vector2 destiny = (Vector2)curRocket.transform.position; curHook = (GameObject)Instantiate(hook, transform.position, Quaternion.LookRotation(Vector3.forward, destiny - (Vector2)transform.position)); curHook.GetComponent <RopeSriptes> ().destiny = destiny; ropeSriptes = curHook.GetComponent <RopeSriptes> (); if (drawCircleObj) { StopCoroutine("CircleFollowPlayer"); Destroy(drawCircleObj); } } } } if (gameState == GameState.isHooking) { //if (Input.GetKeyUp (KeyCode.A)) { if (Input.GetMouseButtonUp(0)) { gameState = GameState.isTakeBacking; hookTarget.DORotate(new Vector3(0, 0, 0), 0.2f, RotateMode.Fast); ShootPlayer(); } } if (gameState == GameState.isHooking) { if (Input.GetMouseButton(0)) { if (hookTarget) { float mouseDetal = mousePos.x - Camera.main.ScreenToViewportPoint(Input.mousePosition).x; if (mouseDetal > 0.001f) { hookTarget.position += Vector3.left * hookTargerSpeed * Time.deltaTime; hookTarget.DORotate(new Vector3(0, 0, 30), 0.2f, RotateMode.Fast); } else if (mouseDetal < -0.001f) { hookTarget.position -= Vector3.left * hookTargerSpeed * Time.deltaTime; hookTarget.DORotate(new Vector3(0, 0, -30), 0.2f, RotateMode.Fast); } else { hookTarget.DORotate(new Vector3(0, 0, 0), 0.2f, RotateMode.Fast); } } } } mousePos = Camera.main.ScreenToViewportPoint(Input.mousePosition); } }