private void OnMouseUp() { theBall.isKinematic = false; isPressed = false; if (startScreen.activeSelf == false) { GetComponent <AudioSource>().Play(); LevelTracker.ShotCounter(); StartCoroutine(ReleaseBall()); } }
private void OnMouseUp() { theBall.isKinematic = false; isPressed = false; if (startScreen.activeSelf == false) { for (int i = 0; i < number; i++) { Destroy(trajectoryDots[i]); } GetComponent <AudioSource>().Play(); LevelTracker.ShotCounter(); StartCoroutine(ReleaseBall()); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { canShoot = true; } if (canShoot == true) { if (Input.GetMouseButtonDown(0) && launchable == true) //click { startPos = rockLauncher.transform.position; for (int i = 0; i < number; i++) { trajectoryDots[i] = Instantiate(trajectoryDot, rockLauncher.transform); } } if (Input.GetMouseButton(0) && LevelTracker.canLoad == true && launchable == true) //drag { endPos = Camera.main.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0, 0, 10); //Debug.Log(endPos); if (Vector3.Distance(endPos, startPos) > distance) { rockLauncher.transform.position = startPos + (endPos - startPos).normalized * distance; forceAtPlayer = endPos - startPos; } else { rockLauncher.transform.position = endPos; forceAtPlayer = endPos - startPos; } //gameObject.transform.position = endPos; //forceAtPlayer = endPos - startPos; for (int i = 0; i < number; i++) { trajectoryDots[i].transform.position = calculatePosition(i * 0.1f); } } if (Input.GetMouseButtonUp(0) && LevelTracker.canLoad == true && launchable == true) //leave { GetComponent <AudioSource>().Play(); theRB.gravityScale = 1; theRB.velocity = new Vector2(-forceAtPlayer.x * forceFactor, -forceAtPlayer.y * forceFactor); for (int i = 0; i < number; i++) { Destroy(trajectoryDots[i]); } Attaractor.beAttracted = true; LevelTracker.ShotCounter(); canShoot = false; launchable = false; if (PlayerPrefs.GetInt("DemoComplete") == 0) { DemoLevel.gblLaunchExp.SetActive(false); } StartCoroutine(RockSpawn()); } /*if(Input.GetKey(KeyCode.Space)) { * if(((transform.position.y < -7 || (transform.position.x < -9.5f) || (transform.position.x > 9.5f)) && LevelTracker.enemyCounter != 0) || blackHoled == true && LevelTracker.enemyCounter != 0) * { * canReload = true; * } else { * canReload = false; * } * if(canReload == true){ * LaunchController.SpawnRock(); * var skin = Random.Range(0,3); * spriteRenderer.sprite = rockSkins[skin]; * theRB.gravityScale = 0; * theRB.velocity = Vector2.zero; * gameObject.transform.position = initPos; * canReload = false; * Attaractor.beAttracted = false; * blackHoled = false; * //canShoot = true; * } * * }*/ } }