public static void Login(UserData user) { isLoggedIn = true; LogUserInput.LogMessage(user.userName + " has logged on"); currUserData = user; UnpackModelData(); }
void AdjustScale() { if (!validSelection) { return; } string userAction; float scrollValue = Input.GetAxis("Mouse ScrollWheel"); if (scrollValue > 0f) { mouseSelectedPrimitive.transform.localScale *= scaleMultipler; userAction = "Enlarging "; } else if (scrollValue < 0f) { mouseSelectedPrimitive.transform.localScale /= scaleMultipler; userAction = "Shrinking "; } else { return; } //Log User Input string logMessage = userAction + mouseSelectedPrimitive.name.Split('_')[0]; LogUserInput.LogMessage(logMessage); }
void Update() { validSelection = mouseSelectedPrimitive.name != gameObject.name; if (Input.GetMouseButton(1) && validSelection) { AdjustRotation(); } else if (Input.GetMouseButton(0) && validSelection) { AdjustPosition(); } else if (Input.GetMouseButtonUp(0) && isDragging) { //Log User Drag Action string actionOnModel = "Dragged " + mouseSelectedPrimitive.name.Split('_')[0]; string dataFromAction = " to new position " + mouseSelectedPrimitive.transform.position.ToString(); LogUserInput.LogMessage(actionOnModel + dataFromAction); isDragging = false; } else { HoverMouseSelect(); AdjustScale(); isDragging = false; } }
public static void LogMessage(string message) { if (LogUserInput.GetLastMessage() == message) { return; } GameObject textlog; if (m_transform.childCount < maxMessageCount) { textlog = Instantiate(textPrefab, m_transform); } else { textlog = m_transform.GetChild(0).gameObject; } textlog.GetComponent <Text>().text = message; textlog.transform.SetAsLastSibling(); lastMessage = message; using (StreamWriter w = File.AppendText("log.txt")) { Log(message, w); } }
void AdjustRotation() { mouseSelectedPrimitive.transform.Rotate(new Vector3(Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0) * Time.deltaTime * -rotateSpeed); //Log User Input string logMessage = "Rotating " + mouseSelectedPrimitive.name.Split('_')[0]; LogUserInput.LogMessage(logMessage); }
public void LoginButton() { bool UN = false; bool PW = false; if (Username != "") { if (System.IO.File.Exists(Username + ".txt")) { UN = true; Lines = System.IO.File.ReadAllLines(Username + ".txt"); } else { LogUserInput.LogMessage("Username Invaild"); } } else { LogUserInput.LogMessage("Username Field Empty"); } if (Password != "") { if (System.IO.File.Exists(Username + ".txt")) { currLogUser = JsonUtility.FromJson <UserData>(Lines[0]); DecryptedPass = SimpleEncryptString(currLogUser.encryptedPassword); if (Password == DecryptedPass) { PW = true; } else { LogUserInput.LogMessage("Password Is invalid"); } } else { LogUserInput.LogMessage("Password Is invalid"); } } else { LogUserInput.LogMessage("Password Field Empty"); } if (UN == true && PW == true) { usernameHolder.GetComponent <InputField>().text = ""; passwordHolder.GetComponent <InputField>().text = ""; LogUserInput.LogMessage("Login Sucessful"); loginSuccess.SetActive(true); UserDataManager.Login(currLogUser); gameObject.SetActive(false); } }
public void RegisterButton() { bool UN = false; bool PW = false; if (Username != "") { if (!System.IO.File.Exists(Username + ".txt")) { UN = true; } else { LogUserInput.LogMessage("Username Taken"); } } else { LogUserInput.LogMessage("Username field Empty"); } if (Password != "") { if (Password.Length > 5) { PW = true; } else { LogUserInput.LogMessage("Password Must Be atleast 6 Characters long"); } } else { LogUserInput.LogMessage("Password Field Empty"); } if (UN == true && PW == true) { Password = SimpleDecryptString(Password); UserData newRegisteredUser = new UserData(Username, Password); string form = JsonUtility.ToJson(newRegisteredUser); System.IO.File.WriteAllText(Username + ".txt", form); usernameHolder.GetComponent <InputField>().text = ""; passwordHolder.GetComponent <InputField>().text = ""; LogUserInput.LogMessage("Registration Complete"); } }
public void MoveCameraToSelected(GameObject primitive) { SelectedPrimitive = GameObject.Find(primitive.name); if (SelectedPrimitive == null) { Vector3 position = new Vector3(Random.Range(-10.0f, 10.0f), 0, Random.Range(-10.0f, 10.0f)); SelectedPrimitive = Instantiate(primitive, position, Quaternion.identity, workEnvironment); SelectedPrimitive.name = primitive.name; } Camera.main.transform.position = SelectedPrimitive.transform.position - cameraOffset; Camera.main.transform.LookAt(SelectedPrimitive.transform.position); LogUserInput.LogMessage("Viewing " + SelectedPrimitive.name.Split('_')[0] + " Model"); }
public void Logout() { isLoggedIn = false; LogUserInput.LogMessage(currUserData.userName + " has logged off"); //Save data to local string form = JsonUtility.ToJson(currUserData); processModelData(currUserData.models, form); LogUserInput.LogMessage(currUserData.userName + " data saved"); //Reset runtime Data currUserData = null; labelModel.text = ""; labelPosition.text = ""; labelRotation.text = ""; labelScale.text = ""; }