public void JoinCustom() { /* * There should be only number-inputs */ if (ChannelInput.text != "") { LocalUserData.SetUserName(InputName.text); Dictionary <string, string> data = new Dictionary <string, string> (); data ["name"] = InputName.text; data ["roomnumber"] = ChannelInput.text; /* * TODO: player position will be set from server-side */ Vector3 position = new Vector3(0f, 0f, 0f); data ["position"] = position.x + "," + position.y + "," + position.z; SocketIOComp.Emit("SERVER:JOINCUSTOM", new JSONObject(data)); HideChannelWindow(); GlobalGameState.DialogueUI.Show(DialogueUIController.DialogueTypes.JoiningRoom); } else { ChannelInputPlaceHolder.text = "Channel number is necessary!"; } }
public void LoadData() { if (SaveSystem.LoadUserData() != null) { LocalUserData data = SaveSystem.LoadUserData(); userID = data.userId; userHouse = data.userHouse; score = data.score; currentEventId = data.currentEventId; currentEventHouse = data.currentEventHouse; currentMutex = data.currentMutex; currentDefenderScore = data.currentDefenderScore; currentUserDefenderScore = data.currentUserDendenderScore; } else { userID = ""; userHouse = 0; score = 0; currentEventId = ""; currentDefenderScore = 0; currentUserDefenderScore = 0; currentEventHouse = 0; currentMutex = ""; } }
public void OnClickJoinBtn() { if (InputName.text != "") { LocalUserData.SetUserName(InputName.text); Dictionary <string, string> data = new Dictionary <string, string> (); data ["name"] = InputName.text; /* * TODO: player position will be set from server-side * probably send spawn area from here? */ Vector3 position = new Vector3(0f, 0f, 0f); data ["position"] = position.x + "," + position.y + "," + position.z; Vector3 rotation = new Vector3(0f, 0f, 0f); data ["rotation"] = rotation.x + "," + rotation.y + "," + rotation.z; SocketIOComp.Emit("SERVER:JOIN", new JSONObject(data)); GlobalGameState.DialogueUI.Show(DialogueUIController.DialogueTypes.JoiningRoom); } else { InputNamePlaceHolder.text = "Nickname is necessary!"; } }
// Use this for initialization void Start() { JoinBtn.onClick.AddListener(OnClickJoinBtn); JoinCustomBtn.onClick.AddListener(OnClickCustomChannelBtn); ChannelWindowOKBtn.onClick.AddListener(JoinCustom); ChannelWindowCancelBtn.onClick.AddListener(HideChannelWindow); InputName.text = LocalUserData.GetUserName(); }
public static void SaveUserData(LocalUser localUser) { BinaryFormatter formatter = new BinaryFormatter(); string path = Path.Combine(Application.persistentDataPath, "HarrySpotterLocalData"); FileStream stream = new FileStream(path, FileMode.Create); LocalUserData data = new LocalUserData(localUser); formatter.Serialize(stream, data); stream.Close(); }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Debug.LogWarning("[User.cs] - Multiple User(s) found!"); Destroy(gameObject); } _localData = new LocalUserData(); }
public static LocalUserData LoadUserData() { string path = Path.Combine(Application.persistentDataPath, "HarrySpotterLocalData"); Debug.Log(path); if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); LocalUserData data = formatter.Deserialize(stream) as LocalUserData; stream.Close(); return(data); } else { Debug.Log("Save File not found"); return(null); } }
internal static LocalUsers DeserializeLocalUsers(JsonElement element) { Optional <IReadOnlyList <LocalUserData> > value = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <LocalUserData> array = new List <LocalUserData>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(LocalUserData.DeserializeLocalUserData(item)); } value = array; continue; } } return(new LocalUsers(Optional.ToList(value))); }
public void LogOut() { _userData = null; _localData = null; }