private void Awake() { Game = this; //Check if enemy is human if (PlayerPrefs.GetInt("IsHuman", 1) == 1) { Enemy.gameObject.SetActive(false); HumanEnemy.FromString(PlayerPrefs.GetString("EnemyStats")); Enemy = HumanEnemy; IsHuman = true; PlayerPrefs.SetInt("Music", 3 + PlayerPrefs.GetInt("IsBoss", 0)); } else { HumanEnemy.gameObject.SetActive(false); PlayerPrefs.SetInt("Music", 1 + PlayerPrefs.GetInt("IsBoss", 0)); } if (PlayerPrefs.GetInt("IsBoss", 0) == 1) { Color target = Enemy.Body.GetComponent <Renderer>().materials[0].color; foreach (var item in Enemy.Body.GetComponentsInChildren <Renderer>(true)) { if (item.materials[0].color == target) { item.materials[0].color = BossColor; } } } //Load enemy and player from prefs Enemy.FromString(PlayerPrefs.GetString("EnemyStats")); if (!PlayerPrefs.HasKey("PlayerStats")) { //Init stats Player.Name = "M43 (you)"; Player.MaxHealth = 10; Player.MaxEnergy = 10; Player.Power = 2; Player.Defense = 2; PlayerPrefs.SetString("PlayerStats", Player.ToString()); } Player.FromString(PlayerPrefs.GetString("PlayerStats")); }
private void OnTriggerEnter(Collider other) { if (!(PlayerPrefs.GetInt(ID) == 1)) { Debug.Log("Collided with " + ID + ", is " + PlayerPrefs.GetInt(ID) + " completed"); PlayerPrefs.SetInt("IsHuman", IsHuman ? 1 : 0); PlayerPrefs.SetInt("IsBoss", IsBoss ? 1 : 0); PlayerPrefs.SetString("EnemyStats", Stats.ToString()); PlayerPrefs.SetString("EnemyID", ID); PlayerPrefs.SetString("EnemyWeapon", WeaponName); PlayerPrefs.SetInt(ID, PlayerPrefs.GetInt(ID, 0)); PlayerPrefs.SetFloat("PlayerXPos", OverworldController.Instance.transform.position.x); PlayerPrefs.SetFloat("PlayerZPos", OverworldController.Instance.transform.position.z); SceneManager.LoadScene("Battle"); } }