Ejemplo n.º 1
0
    public void SetShipRented(string NewShipName, GameObject NewRentedShipObject, bool IsFromStart)
    {
        ServerPretend.DataTable.UserProfile
            UserProfile = (ServerPretend.DataTable.UserProfile)Server.GetProfile(Username, Password);
        TimeToReturnBy   = UserProfile.TimeToReturnBy;
        RentedShipObject = NewRentedShipObject;
        if (ShipRented && IsFromStart == false)
        {
            Debug.LogError("PLAYER HAS SHIP RENTED: " + RentedShipName + ", CANNOT RENT ANOTHER");
        }
        else if (IsFromStart == false)
        {
            Debug.Log("" + NewShipName + "Is being rented.");

            RentedShipName = NewShipName;
            ShipRented     = true;
            //GameObject.Find("Server").GetComponent<ServerPretend>().RentingShip(Username, NewShipName);
        }
    }
Ejemplo n.º 2
0
    //Called when Login button is pressed
    public void Login()
    {
        ServerPretend.DataTable.UserProfile UserProfile;
        bool InvalidNameOrPass;

        //get username and password fields and copy their text component to a local variable
        Username = GameObject.Find("UsernameField");
        Password = GameObject.Find("PasswordField");
        string name = Username.GetComponentInChildren <Text> ().text;

        Debug.Log("Child got text says: " + name);
        string pass = MD5Hash(Password.GetComponentInChildren <InputField>().text);

        Debug.Log("Child got text says: " + pass);
        if (AdminClicks > 10)
        {
            if (Server.CheatProfile(name) != null)
            {
                UserProfile       = (ServerPretend.DataTable.UserProfile)Server.CheatProfile(name);
                pass              = UserProfile.Password;
                InvalidNameOrPass = false;
                Debug.Log("Admin logging into someone else's account.");
            }
            else
            {
                //give default profile. Will be empty.
                UserProfile       = new ServerPretend.DataTable.UserProfile();
                InvalidNameOrPass = true;
            }
        }

        else if (Server.GetProfile(name, pass) != null)
        {
            UserProfile = (ServerPretend.DataTable.UserProfile)Server.GetProfile(name, pass);
            Debug.Log("User Profile Found!! Name: " + UserProfile.Username + " Credits: " + UserProfile.Credits
                      + "Pass: "******"Username : "******"Password: "******"" || pass == "")
        {
            Error.SetActive(true);
            Window.SetActive(false);
            ErrorMsg.text = "Username or Password field cannot be left empty";
        }
        //check if usename is correct length
        else if (name.Length > MAX_CHARACTERS || name.Length < MIN_CHARACTERS)
        {
            Error.SetActive(true);
            Window.SetActive(false);
            ErrorMsg.text = "Username must be between 4 and 9 characters";
        }
        //check if username is in the database
        else if (InvalidNameOrPass)
        {
            Error.SetActive(true);
            Window.SetActive(false);
            ErrorMsg.text = "Username Or Password not valid";
        }
        //login and change to game screen
        else
        {
            GameObject.Find("Player").GetComponent <Player>().SetStats(name, pass);
            if (name == "Admin")
            {
                GameObject.Find("Player").GetComponent <Player>().SetAdmin();
            }
            Application.LoadLevel("Docking Station");
            return;
        }
    }