public void checkPlayersScore() { players = GameObject.FindGameObjectsWithTag("Player"); //Debug.Log("playersCount= " + players.Length); if (players.Length == 0) { return; } bool hasWinningPlayer = false; foreach (GameObject p in players) { playerdata pdata = p.GetComponent <playerdata>(); if (pdata.scoref >= 100) { winnedPlayer = p; hasWinningPlayer = true; } if (winnedPlayer == null) { if (questCount == 0) { pdata.RpcUpdateText("collect the balls"); } else if (questCount == 1) { pdata.RpcUpdateText("find the hidden ball"); } else if (questCount == 2) { pdata.RpcUpdateText("kill any player"); } else { pdata.RpcUpdateText("game completed"); } } else { if (winnedPlayer == p) { pdata.RpcUpdateText("you won"); } else { pdata.RpcUpdateText("you lost"); } } if (!hasWinningPlayer) { winnedPlayer = null; } // pdata.RpcUpdateScore(p.transform.position.x); } }
public void ResetPlayersScore() { foreach (GameObject p in players) { playerdata pdata = p.GetComponent <playerdata>(); pdata.RpcUpdateScore(0); } }
public void loadplayer() { playerdata data = savesystem.loadplayer(); level = data.level; health = data.health; score = data.score; hscore = data.hscore; }
public static void savedata(gamemanager gm) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/player.fun"; FileStream stream = new FileStream(path, FileMode.Create); playerdata data = new playerdata(gm); formatter.Serialize(stream, data); stream.Close(); }
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 CheckCurQuests() { foreach (Quest q in activeQuests) { if (q.isComplete) { foreach (GameObject g in q.winners) { playerdata pd = g.GetComponent <playerdata>(); pd.RpcUpdateScore(pd.scoref + q.reward); } } } }
void loadplayer() { playerdata data = savesystem.Loadplayer(); levelname = data.levelname; n = data.n; coin = data.coin; // if (levelname == null) // { // levelname = SceneManager.GetActiveScene().name; // } // SceneManager.LoadScene(levelname); }
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; }
public void Load() { if (File.Exists(Application.persistentDataPath + "/playerInfo.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open); playerdata data = (playerdata)bf.Deserialize(file); file.Close(); // Change this data to... health = data.health; experience = data.experience; Debug.Log("File Loaded"); } }
// Save and Load data to file (Cant be used on web builds) public void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/playerInfo.dat"); playerdata data = new playerdata(); data.health = health; data.experience = experience; bf.Serialize(file, data); file.Close(); Debug.Log(Application.persistentDataPath); Debug.Log("File Saved"); }
public static playerdata Loadplayer() { string path = Application.persistentDataPath + "/player.fun"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); playerdata data = formatter.Deserialize(stream) as playerdata; stream.Close(); return(data); } else { Debug.LogError("save file is not found " + path); return(null); } }
// Start is called before the first frame update void Start() { playerdata data = savesystem.Loadplayer(); if (data == null) { levelname = 1; Debug.Log(" level start hua inside start nulladata set " + levelname); } else { levelname = data.levelname; Debug.Log(" level start hua inside start " + levelname); } if (levelname == 0) { levelname = levelname + 1; } }
public static void SavePlayer() { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/PlayerData.data"; FileStream stream = new FileStream(path, FileMode.Create); playerdata data = new playerdata(); if (File.Exists(path)) { Debug.Log($"exported to {path}"); } else { Debug.Log("iets ging mis"); } formatter.Serialize(stream, data); stream.Close(); }
public static playerdata loadPlayer() { string path = Application.persistentDataPath + "/PlayerData.data"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); Debug.Log($"successfully loaded from {path}"); playerdata data = formatter.Deserialize(stream) as playerdata; stream.Close(); Debug.Log($"this is data {data.Coins}"); return(data); } Debug.LogError($"save file not found at {path}"); return(null); }
public void checkPlayersScore() { //Debug.Log("playersCount= " + players.Length); if (players.Count == 0) { return; } foreach (GameObject p in players) { playerdata pdata = p.GetComponent <playerdata>(); if (pdata.scoref >= 100 && questCount != 3) { winnedPlayer = p; } else if (questCount == 3) { if (!lockResults) { if (pdata.hasDied) { pdata.RpcUpdateText("you lost"); } else if (timeOut) { pdata.RpcUpdateText("you Survived"); lockResults = true; } else if (!timeOut) { pdata.RpcUpdateText("survive"); } } } } }