public GameplayState(Game game, GameStateManager manager, EntityProperties properties) : base(game, manager) { loadedGame = true; loadedProps = properties == null ? new EntityProperties() : properties; hud = new HUD(this); }
public void LoadFromData(EntityProperties props) { Name = props.Name; Position = props.Position; dir = props.Direction; godMode = props.GodMode; noClip = props.NoClip; superSpeed = props.SuperSpeed; }
/// <summary> /// Saves the player's data /// </summary> /// <param name="properties"></param> public static bool SavePlayerData(EntityProperties properties) { try { var stream = File.Create(absolutePath + properties.Name + ".dat"); serializer.Serialize(stream, properties); stream.Close(); return(true); } catch (IOException ex) { Debug.WriteLine(ex.StackTrace); return(false); } }
/// <summary> /// Loads the data from a given player /// </summary> /// <param name="name">Name of the player</param> public static EntityProperties LoadPlayerData(string name) { EntityProperties results = new EntityProperties(); try { if (File.Exists(absolutePath + name + ".dat")) { // The load file was found --> continue var stream = File.Open(absolutePath + name + ".dat", FileMode.Open); results = (EntityProperties)serializer.Deserialize(stream); stream.Close(); } else { throw new Exception("That load file was not found!\nFile: " + absolutePath + name + ".dat"); } } catch (IOException ex) { Debug.WriteLine(ex.StackTrace); } return(results); }
/// <summary> /// Loads the data from a given player /// </summary> /// <param name="name">Name of the player</param> public static EntityProperties LoadPlayerData(string name) { EntityProperties results = new EntityProperties(); try { if (File.Exists(absolutePath + name + ".dat")) { // The load file was found --> continue var stream = File.Open(absolutePath + name + ".dat", FileMode.Open); results = (EntityProperties)serializer.Deserialize(stream); stream.Close(); } else { throw new Exception("That load file was not found!\nFile: " + absolutePath + name + ".dat"); } } catch (IOException ex) { Debug.WriteLine(ex.StackTrace); } return results; }
/// <summary> /// Saves the player's data /// </summary> /// <param name="properties"></param> public static bool SavePlayerData(EntityProperties properties) { try { var stream = File.Create(absolutePath + properties.Name + ".dat"); serializer.Serialize(stream, properties); stream.Close(); return true; } catch (IOException ex) { Debug.WriteLine(ex.StackTrace); return false; } }