/* * public void TakeDamage(int damageAmount){ * health-=damageAmount; * UpdateHealthUI(health); * hurtAnim.SetTrigger("hurt"); * if (health<=0){ * Destroy(gameObject); * screenTransition.LoadScene("Lose"); * } * } */ public void TakeDamage(int damageAmount) { health -= damageAmount; UpdateHealthUI(health); hurtAnim.SetTrigger("hurt"); if (health <= 0) { //GameObject smallplayer=GameObject.FindGameObjectWithTag("smalldevilplayer"); //Instantiate(smallplayer.GetComponent<smallplayer>().bloodsplash,smallplayer.transform.position,smallplayer.transform.rotation); //Destroy(smallplayer); Destroy(gameObject); //Instantiate(soundObject,transform.position,transform.rotation); ScreenTransition screenTransition = GameObject.FindGameObjectWithTag("transitionpanel").GetComponent <ScreenTransition>(); if (scene.name == "Level2") { screenTransition.LoadScene("Lose2"); } else { screenTransition.LoadScene("Lose"); } // screenTransition.LoadScene("Lose"); } }
public void Call() { PlaytimeData.Reset(); ScreenTransition screenTransition = ScreenTransition.instance; if (screenTransition) { screenTransition.Call(scenePath); } else { ScreenTransition.LoadScene(scenePath); } }
private void Update() { if (Input.GetKeyDown(KeyCode.Alpha3)) { string sceneName = "DevScene"; ScreenTransition screenTransition = ScreenTransition.instance; if (screenTransition) { screenTransition.Call(sceneName); } else { ScreenTransition.LoadScene(sceneName); } } }
public void RestartScene() { PlaytimeData.numberOfDeaths++; PlayerHealth.ResetSavedHealth(); ScreenTransition screenTransition = ScreenTransition.instance; string sceneName = SceneManager.GetActiveScene().path; if (screenTransition) { screenTransition.Call(sceneName); } else { ScreenTransition.LoadScene(sceneName); } }
public void CallNextStage() { UpdateData(); ScreenTransition screenTransition = ScreenTransition.instance; string scenePath = SceneManager.GetActiveScene().path; int currentIndex = int.Parse(scenePath.Substring(scenePath.Length - 7, 1)); scenePath = scenePath.Substring(0, scenePath.Length - 7) + (currentIndex + 1) + ".unity"; if (screenTransition) { screenTransition.Call(scenePath); } else { ScreenTransition.LoadScene(scenePath); } }
private IEnumerator WinSequence() { yield return(new WaitForSeconds(.5f)); WinScreen winScreen = WinScreen.instance; if (winScreen) { winScreen.Show(); } yield return(new WaitForSeconds(2)); ScreenTransition screenTransition = ScreenTransition.instance; string scenePath = scenePath = "Assets/Scenes/WorldsScene.unity"; if (screenTransition) { screenTransition.Call(scenePath); } else { ScreenTransition.LoadScene(scenePath); } }
public void LoadbyIndex(int sceneIndex) { StartCoroutine(transition.LoadScene()); }
//to detect collision..with enemy private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Enemy" && GameObject.FindGameObjectWithTag("Player") != null) { //Changes being made WaveSpawnnerScript = GameObject.FindGameObjectWithTag("wave").GetComponent <WaveSpawnner>(); wavenumber = WaveSpawnnerScript.currentWaveIndex; if (collision.GetComponent <OurEnemy>().transform.name == "smallDevil(Clone)" && GameObject.FindGameObjectWithTag("Player") != null) { if (GameObject.FindGameObjectWithTag("devil") == null) { if (GameObject.FindGameObjectsWithTag("Enemy").Length != 0) { GameObject[] allsmalldevils = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject child in allsmalldevils) { child.GetComponent <OurEnemy>().smallDevilHit(damage, collision, gameObject); } DestroyProjectile(); StartCoroutine(Order()); if (scene.name == "Level2") { screenTransition.LoadScene("Win2"); } else { screenTransition.LoadScene("Win"); } } if (scene.name == "Level2") { screenTransition.LoadScene("Win2"); } else { screenTransition.LoadScene("Win"); } } else { collision.GetComponent <OurEnemy>().smallDevilHit(damage, collision, gameObject); DestroyProjectile(); } } /* * collision.GetComponent<OurEnemy>().smallDevilHit(damage,collision,gameObject); * if(GameObject.FindGameObjectWithTag("devil")==null){ * if(GameObject.FindGameObjectsWithTag("Enemy").Length==0){ * * StartCoroutine(Order()); * screenTransition.LoadScene("Win"); * } * } * else{ * collision.GetComponent<OurEnemy>().smallDevilHit(damage,collision,gameObject); * DestroyProjectile(); * } * }*/ if (wavenumber >= 1) { if ((collision.GetComponent <OurEnemy>().transform.name == "Sphere(Clone)" || collision.GetComponent <OurEnemy>().transform.name == "Sphere2(Clone)") && GameObject.FindGameObjectWithTag("Weapon").transform.name != "gun" ) { //damage=1; collision.GetComponent <OurEnemy>().YellowBoost(damage); DestroyProjectile(); } else { collision.GetComponent <OurEnemy>().TakeDamage(damage); //collision.GetComponent<Enemy> loads the enemy script on //collision object and call the TakeDamage function of Enemy.cs DestroyProjectile(); } } else { if (!(collision.GetComponent <OurEnemy>().transform.name == "smallDevil(Clone)" && GameObject.FindGameObjectWithTag("Player") != null)) { collision.GetComponent <OurEnemy>().TakeDamage(damage); //collision.GetComponent<Enemy> loads the enemy script on //collision object and call the TakeDamage function of Enemy.cs DestroyProjectile(); } } } if (collision.tag == "devil" && GameObject.FindGameObjectWithTag("Player") != null) { collision.GetComponent <Devil>().TakeDamage(damage); prefab = (GameObject)Resources.Load("ToonExplosion/Prefabs/smallDevil", typeof(GameObject)); Instantiate(prefab, transform.position, Quaternion.identity); DestroyProjectile(); } if (collision.tag == "bomb" && GameObject.FindGameObjectWithTag("Player") != null) { explosion = (GameObject)Resources.Load("ToonExplosion/Prefabs/Explosion", typeof(GameObject)); Collider2D[] colliders = Physics2D.OverlapCircleAll(collision.gameObject.transform.position, 4.0f); foreach (Collider2D col in colliders) { if (col.tag == "Enemy") { Destroy(col.gameObject); } } Destroy(collision.gameObject); Instantiate(explosion, transform.position, Quaternion.identity); } }