public playerdata(SimpleSampleCharacterControl player) { health = player.currentHealth; position = new float[3]; position[0] = player.transform.position.x; position[1] = player.transform.position.y; position[2] = player.transform.position.z; }
public static void SavePlayer(SimpleSampleCharacterControl player) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/SaveGameData.hehe"; FileStream stream = new FileStream(path, FileMode.Create); playerdata data = new playerdata(player); formatter.Serialize(stream, data); stream.Close(); }
public void LoadGame() { //current loads players position playerdata data = SaveSystem.Loadplayer(); SimpleSampleCharacterControl play = new SimpleSampleCharacterControl(); play.currentHealth = data.health; Vector3 position; position.x = data.position[0]; position.y = data.position[1]; position.z = data.position[2]; transform.position = position; }
void PlayerFound() { if (Vector3.Distance(transform.position, Player.transform.position) >= MinDis) { transform.LookAt(Player.transform); // enemy moves forward transform.position += transform.forward * Speed * Time.deltaTime; if (Vector3.Distance(transform.position, Player.transform.position) <= MaxDis) { SimpleSampleCharacterControl characterControl = new SimpleSampleCharacterControl(); characterControl.TakeDamage(damage); Anim.Attack(); } } }