// Use this for initialization void Awake() { // Set texture name. shaderOffsetTextureName = ConstantsManager.GetShaderTextureOffSetName(); // Set assertion. Assert.IsNotNull(skyDome); Assert.IsNotNull(skyDomeMaterial); }
// Use this for initialization void Start() { // Get animator. anim = GetComponent <Animator>(); // Get rigid body. rigidBody = GetComponent <Rigidbody>(); // Get audio source. audioSource = GetComponent <AudioSource>(); // Get obstacle tag. obstacleTag = ConstantsManager.GetTag(ObjectTags.obstacle); // Get jump animation name. jumpAnimationName = ConstantsManager.GetAnimationName(Animations.jump); // Play jump animation. anim.Play(ConstantsManager.GetAnimationName(Animations.fly)); }
/******************** PUBLIC METHODS **********************/ public void PlayerCollided() { /// Check if camera shake is enabled. // if (shakeCameraEnabled) // { // StartCoroutine(Shake()); // } gameOver = true; playerActive = false; gameReplay = true; // Save score. ConstantsManager.SetTopScore(currentScore); /// Display hit smoke effect. hitSmokeEffect = Instantiate(hitSmokeEffectPrefab); hitSmokeEffect.transform.position = player.transform.position; /// Wait for player animation to finish. StartCoroutine(Delay(2.0f)); }
private void SetAfterPlayerCollidedState() { /// Set main menu state. MenuManager.instance.Game(GameState.replayScreen); /// Show main menu. mainMenu.SetActive(true); /// Show main menu. mainMenuPrefab.SetActive(true); /// Hide scene GUI. sceneGUI.SetActive(false); /// Reset rock position. GameObject obstacle = GameObject.FindGameObjectWithTag(ConstantsManager.GetTag(ObjectTags.obstacle)); if (obstacle != null) { Rock rockScript = obstacle.GetComponent <Rock>(); if (rockScript != null) { /// Get random starting position coordinates. float randomX = Random.Range(3.75f, 4.0f); float randomY = Random.Range(2.0f, 8.0f); /// Set new starting position. rockScript.setStart(new Vector3(randomX, randomY, -3.2f)); } } /// Destroy player prefab. Destroy(player); /// Destroy hit smoke effect. Destroy(hitSmokeEffect); /// Destroy scene prefab. Destroy(currentScene); }
// Update best score from player prefs. void updateBestScore() { /// Update and set top score. topScore.text = "Best score: " + ConstantsManager.GetTopScore().ToString(); }