// Start is called before the first frame update void Start() { leftTipPanel = leftStickCanvas.gameObject.GetComponentInChildren <TipPanelControl>(); rightTipPanel = rightStickCanvas.gameObject.GetComponentInChildren <TipPanelControl>(); rewardedAdEndScale = Vector3.one; startScale = Vector3.zero; endScale = new Vector3(3f, 3f, 3f); gameManager = GetComponent <GameManagerScript>(); musicToggle.onValueChanged.AddListener(delegate { toggleMusic(); }); soundToggle.onValueChanged.AddListener(delegate { toggleSound(); }); swapControls.onValueChanged.AddListener(delegate { toggleFlipControl(); }); resume.onClick.AddListener(unpause); retry.onClick.AddListener(retryGame); pauseButton.onClick.AddListener(togglePause); restartButton.onClick.AddListener(restart); returnToMenu.onClick.AddListener(returnToMain); pauseReturnToMain.onClick.AddListener(returnToMain); rewardedAdNoButton.onClick.AddListener(rewardedAdPanelNoButton); soundToggle.isOn = PlayerPersistence.GetSoundStatus() == 1 ? true : false; musicToggle.isOn = PlayerPersistence.GetMusicStatus() == 1 ? true : false; swapControls.isOn = PlayerPersistence.GetFlipControlStatus() == 1 ? true : false; }
// Start is called before the first frame update void Start() { Screen.autorotateToPortrait = false; Screen.orientation = ScreenOrientation.AutoRotation; Screen.SetResolution(Screen.width, Screen.height, true); helpButton.onClick.AddListener(OpenHelpPanel); closeHelpMenu.onClick.AddListener(CloseHelpPanel); playButton.onClick.AddListener(StartGame); achievementsButton.onClick.AddListener(OpenAchievementsPanel); leaderboardButton.onClick.AddListener(OpenLeaderboardPanel); settingsButton.onClick.AddListener(ToggleSettingsPanel); scoreText.text = PlayerPersistence.GetHighScore().ToString(); musicToggle.onValueChanged.AddListener(delegate { toggleMusic(); }); soundToggle.onValueChanged.AddListener(delegate { toggleSound(); }); swapControls.onValueChanged.AddListener(delegate { toggleFlipControl(); }); soundToggle.isOn = PlayerPersistence.GetSoundStatus() == 1 ? true : false; musicToggle.isOn = PlayerPersistence.GetMusicStatus() == 1 ? true : false; swapControls.isOn = PlayerPersistence.GetFlipControlStatus() == 1 ? true : false; }
// Method which handles player jumping private void jump() { if (!isJumping) { isJumping = true; //isGrounded = false; playerRigidbody.AddForce(new Vector3(0.0f, jumpForce, 0.0f), ForceMode.Impulse); if (PlayerPersistence.GetSoundStatus() == 1) { audioSource.Play(); } } }
// Update is called once per frame private void OnTriggerEnter(Collider hoopTrigger) { BallGoalColliderControl ballCollider = hoopTrigger.gameObject.GetComponent <BallGoalColliderControl>(); if (ballCollider) { // Ensures points are only given if the ball goes through the top of the hoop if (spherePhysics.getMovementDirection().y > 0) { // More points given if the sides of the hoop aren't touched if (!spherePhysics.getTouchedRim()) { // iscolliding is required so it doesn't trigger multiple times isColliding = true; if (PlayerPersistence.GetSoundStatus() == 1) { audioSource.clip = swishSound; audioSource.Play(); } scoreManager.scoreSwish(); confetti.Play(); wait(.5f); } // if hoop was touched else { isColliding = true; if (PlayerPersistence.GetSoundStatus() == 1) { audioSource.clip = nonSwishSound; audioSource.Play(); } scoreManager.scoreHoop(); confetti.Play(); spherePhysics.SetTouchedRim(false); wait(.5f); } spherePhysics.centreBall(); } } }
private void OnCollisionEnter(Collision collision) { PlayerControl player = collision.gameObject.GetComponent <PlayerControl>(); //If the ball collides with player if (player) { //And if the ball has reached the height required to get another point if (scoreManager && allowPoint) { if (PlayerPersistence.GetSoundStatus() == 1) { audioSource.clip = scorePoint; audioSource.Play(); } scoreManager.addToScore(1); allowPoint = false; } //This resets every time the player hits the ball. //It might be possible to get 10 points for a swish, if the ball bounces off //one hoop, and swishes into another. if (touchedRim) { touchedRim = false; } } else if (gameManagerScript.getGameState() && PlayerPersistence.GetSoundStatus() == 1) { audioSource.clip = ballHitSound; audioSource.Play(); } if (collision.gameObject.name == "Torus" || collision.gameObject.name == "Backboard") { SetTouchedRim(true); } }
private void OnCollisionEnter(Collision collision) { BallController ball = collision.gameObject.GetComponent <BallController>(); if (ball) { if (ball.getBallDrops() > 0) { ball.ballDropped(); gameManagerScript.resetPlayerLocation(); ball.centreBall(); if (PlayerPersistence.GetSoundStatus() == 1) { audioSource.clip = loseLifeSound; audioSource.Play(); } } else if (gameManagerScript.GetOfferAdState()) { gameManagerScript.RewardedAdPanelDisplayed(); if (PlayerPersistence.GetSoundStatus() == 1) { audioSource.clip = loseLifeSound; audioSource.Play(); } StartCoroutine(uiManager.OpenRewardedAdPanel()); } else { gameManagerScript.lostGame(); if (PlayerPersistence.GetSoundStatus() == 1) { audioSource.clip = gameOver; audioSource.Play(); } } } }