예제 #1
0
    /*
     * this funtion is used to login the player
     * login posts the data entered to the login input field
     * to the game server to validate/add the user to the db
     * and get the profile of the user from the server
     * set is_online flag to true in the db
     */
    public void GameLogin()
    {
        user_name = user_name_field.text;
        password  = password_field.text;

        //checking if fields blank
        if (user_name != "" && password != "")
        {
            player.username = user_name;
            player.password = password;

            string response = new WebClient().UploadString("http://192.168.43.10:8000/lobby/login", JsonUtility.ToJson(player));
            print(response);
            player = JsonUtility.FromJson <Player>(response);

            if (player.username != null && player.password == "")
            {
                NotificationLogger.Load("username taken");
            }
            else if (player.username != null && player.letters_typed != 0)
            {
                LocalPlayer.local_player = player;
                NotificationLogger.Load("welcome back " + LocalPlayer.local_player.username);
                FindObjectOfType <GameManager>().Login();
            }
            else
            {
                LocalPlayer.local_player = player;
                NotificationLogger.Load("loggend in as " + LocalPlayer.local_player.username);
                FindObjectOfType <GameManager>().Login();
            }
        }
    }
예제 #2
0
        public void ShowNotification(NotificationType pNotificationType)
        {
            switch (pNotificationType)
            {
            case NotificationType.Info:
                NotificationToastService.ShowInfo(NotificationMessage, NotificationTitle);
                if (String.IsNullOrEmpty(NotificationTitle))
                {
                    NotificationLogger.LogInfo($"Info: {NotificationMessage}");
                }
                else
                {
                    NotificationLogger.LogInfo($"{NotificationTitle}: {NotificationMessage}");
                }
                break;

            case NotificationType.Success:
                NotificationToastService.ShowSuccess(NotificationMessage, NotificationTitle);
                if (String.IsNullOrEmpty(NotificationTitle))
                {
                    NotificationLogger.LogInfo($"Success: {NotificationMessage}");
                }
                else
                {
                    NotificationLogger.LogInfo($"{NotificationTitle}: {NotificationMessage}");
                }
                break;

            case NotificationType.Warning:
                NotificationToastService.ShowWarning(NotificationMessage, NotificationTitle);
                if (String.IsNullOrEmpty(NotificationTitle))
                {
                    NotificationLogger.LogWarn($"Warning: {NotificationMessage}");
                }
                else
                {
                    NotificationLogger.LogWarn($"{NotificationTitle}: {NotificationMessage}");
                }
                break;

            case NotificationType.Error:
                NotificationToastService.ShowError(NotificationMessage, NotificationTitle);
                if (String.IsNullOrEmpty(NotificationTitle))
                {
                    NotificationLogger.LogError($"Error: {NotificationMessage}");
                }
                else
                {
                    NotificationLogger.LogError($"{NotificationTitle}: {NotificationMessage}");
                }
                break;

            default:         // assume this is debug
                NotificationToastService.ShowToast(ToastLevel.Info, NotificationMessage, NotificationTitle);
                if (String.IsNullOrEmpty(NotificationTitle))
                {
                    NotificationLogger.LogDebug($"Debug: {NotificationMessage}");
                }
                else
                {
                    NotificationLogger.LogDebug($"{NotificationTitle}: {NotificationMessage}");
                }
                break;
            }
        }
 public void Then_Returns_Expected_Errors()
 {
     NotificationLogger.Received(1).LogWarning(Arg.Any <EventId>(), _errorMessage);
 }