//The function to end the current session when the enemy is dead IEnumerator EnemDead() { dead = true; enem_atk = false; finished = false; if (stat.CurEXP + enem_stat.monster.EXP >= stat.BaseEXP) { yield return(new WaitForSeconds(1.5f)); lvlup = true; dead = false; stat.Player.LVL++; stat.CurEXP += enem_stat.monster.EXP; stat.CurEXP -= stat.BaseEXP; stat.statPoint += 3; yield return(null); PlayerPrefs.SetInt("statPoint", stat.statPoint); print(statPoint); yield return(null); stat.StatUpdate(); } else { stat.CurEXP += enem_stat.monster.EXP; } anim = OurEnemy.GetComponent <Animator> (); yield return(null); anim.SetBool("Dead", true); yield return(null); anim.SetBool("Dead", false); Debug.Log("You kill the enemy"); yield return(new WaitForSeconds(2f)); PlayerPrefs.SetInt("HP", stat.CurHP); PlayerPrefs.SetInt("MP", stat.CurMP); PlayerPrefs.SetInt("EXP", stat.CurEXP); PlayerPrefs.SetInt("LVL", stat.Player.LVL); PlayerPrefs.SetInt("BEXP", stat.BaseEXP); yield return(null); Application.LoadLevel(Application.loadedLevel); }
//initilisation before starting the game void Awake() { stat = Player.GetComponent <PStats>(); Enemy = All_Enemy[Random.Range(0, All_Enemy.Length)]; OurEnemy = (GameObject)Instantiate(Enemy, new Vector2(-1.22f, 0), Quaternion.identity); enem_stat = OurEnemy.GetComponent <Monsters> (); if (!PlayerPrefs.HasKey("init")) { PlayerPrefs.SetInt("STR", stat.Player.STR); PlayerPrefs.SetInt("AGI", stat.Player.AGI); PlayerPrefs.SetInt("INT", stat.Player.INT); PlayerPrefs.SetInt("init", 1); } stat.StatUpdate(); enem_stat.StatUpdate(); }
//initilisation before starting the game void Awake() { stat = Player.GetComponent<PStats>(); Enemy = All_Enemy[Random.Range (0, All_Enemy.Length)]; OurEnemy = (GameObject) Instantiate(Enemy,new Vector2(-1.22f, 0), Quaternion.identity); enem_stat = OurEnemy.GetComponent<Monsters> (); if (!PlayerPrefs.HasKey("init")) { PlayerPrefs.SetInt ("STR", stat.Player.STR); PlayerPrefs.SetInt ("AGI", stat.Player.AGI); PlayerPrefs.SetInt ("INT", stat.Player.INT); PlayerPrefs.SetInt ("init", 1); } stat.StatUpdate (); enem_stat.StatUpdate (); }