void OnTriggerEnter(Collider other) { // x = gameController.Health(); //xl = boos.fanhui(); // Debug.Log("boos.fanhui" + boos.fanhui()); if (xl == 1) { Destroy(gameObject); } else { if (other.tag == "Boundary" || other.tag == "Enemy" || other.tag == "asteroid" || other.tag == "Enemybullet" || other.tag == "aaa" || other.tag == "terrian" || other.tag == "Pick up" || other.tag == "PUSuoXiao") { //Debug.Log(other.tag); return; } else { if (other.tag == "Player") { life.hurt(); if (life.hp() >= 0) { Instantiate(playerExplosion, other.transform.position, other.transform.rotation); life.test(); //Destroy(other.gameObject); Destroy(gameObject); other.gameObject.transform.position = new Vector3(0, 0, -2); other.gameObject.SetActive(true); } if (life.hp() < 0) { Instantiate(playerExplosion, other.transform.position, other.transform.rotation); other.gameObject.SetActive(false); Destroy(gameObject); PlayerPrefs.SetFloat("scorethisgame", 0); gameController.GameOver(); } } if (other.tag == "wudi" || other.tag == "Shield") { //Instantiate(playerExplosion, other.transform.position, other.transform.rotation); Destroy(gameObject); } // else { i = i + 1; Destroy(other.gameObject); } } } }
void Update() { if (booos.wait() != 0) { shot11.GetComponent <MeshCollider>().enabled = false; jk = 1; if (Time.time - booos.wait() > 4 && nextlevel != null) { PlayerPrefs.SetFloat("scorethisgame", score); PlayerPrefs.SetFloat("life", player.hp()); PlayerPrefs.SetFloat("powerup", player.jimoValue1); PlayerPrefs.SetString("nextlevel", nextlevel1); Application.LoadLevel(nextlevel); } } AsteroidHPText.text = "xg : " + Health();; angle = angle2 * 180 / Mathf.PI; //Debug.Log("2" + angle); if (Time.time > xgtime) { boss.SetActive(true); } //enter story mode /*if (boss.activeSelf) { * if (isStory == 0) { * isStory = 1; * gameOverText.text = "press \"Y\" to continue talking"; * //Shield.gameObject.SetActive (true); * Time.timeScale = 0.0f; * mainCamera.gameObject.SetActive (false); * storyCamera.gameObject.SetActive (true); * storyText.gameObject.SetActive (true); * scoreText.gameObject.SetActive(false); * restartText.gameObject.SetActive(false); * highscoreText.gameObject.SetActive(false); * AsteroidHPText.gameObject.SetActive (false); * } else { * * if (Input.GetKeyDown (KeyCode.Y)) { * if (storyIndex < storyContent.Length) { * storyText.text = storyContent [storyIndex]; * storyIndex = storyIndex + 1; * } else { * gameOverText.text = ""; * mainCamera.gameObject.SetActive (true); * storyCamera.gameObject.SetActive (false); * storyText.gameObject.SetActive (false); * isStory = 2; // story end * storyEndTime = Time.realtimeSinceStartup; * scoreText.gameObject.SetActive(true); * restartText.gameObject.SetActive(true); * highscoreText.gameObject.SetActive(true); * AsteroidHPText.gameObject.SetActive (true); * //Shield.gameObject.SetActive (false); * } * } * } * if (isStory == 2) * { * //Debug.Log(Time.realtimeSinceStartup); Debug.Log("story"+storyEndTime); * if (Time.realtimeSinceStartup - storyEndTime < 1.5f) * { * gameOverText.text = "get ready!"; * } * else if (Time.realtimeSinceStartup - storyEndTime < 2) * { * gameOverText.text = "Go!"; * } else { * gameOverText.text = ""; * isStory = 3; * Time.timeScale = 1.0f; * } * } * }*/ //stop game if (Input.GetKeyDown(KeyCode.P) && !orderInput.IsActive()) { if (isPause == 0) { Time.timeScale = 0.0f; isPause = 1; botton2.SetActive(true); botton3.SetActive(true); botton4.SetActive(true); } else if (isPause == 1) { botton2.SetActive(false); botton3.SetActive(false); botton4.SetActive(false); Time.timeScale = 1.0f; isPause = 0; } } if (Input.GetKeyDown(KeyCode.Return)) { if (isInput == 0) { orderInput.gameObject.SetActive(true); Time.timeScale = 0.0f; isInput = 1; orderInput.ActivateInputField(); } else if (isInput == 1) { inputText = orderInput.text; if (inputText == "whosyourdaddy") { if (wudidesi.gameObject.activeInHierarchy) { wudidesi.gameObject.SetActive(false); } else { wudidesi.gameObject.SetActive(true); } } orderInput.text = ""; orderInput.gameObject.SetActive(false); Time.timeScale = 1.0f; isInput = 0; } } if (hs) { if (score > highscore) { highscore = score; } highscoreText.text = "highscore:" + highscore; } if (restart) { if (Input.GetKeyDown(KeyCode.R)) { // xgtime = xgtime + Time.realtimeSinceStartup; Application.LoadLevel(Application.loadedLevel); } } bossji = boss.GetComponent <Rigidbody> ().position; ziji = shot11.GetComponent <Rigidbody> ().position; }