public void HandleUserEvent (UserBody userBody) { //userBody.pauseUpdate = true; //userBody.RotateToInitialPosition(); foreach (ClothingButton button in currentSelections){ //clothingManager.RemoveAllClothing(); clothingManager.ToggleClothing(button.label); button.currentSelectionTime = 0.0F; } currentSelections.Clear(); //userBody.pauseUpdate = false; userEvent = false; }
public override void Start() { base.Start(); UserBody userBody = user.GetTrackedUserBody(); currentRoom = virtualEnvironment.CurrentRoom; wallTranslateGain = new float[5]; wallTranslateGain[0] = 0.8f; wallTranslateGain[1] = 0.9f; wallTranslateGain[2] = 1.0f; wallTranslateGain[3] = 1.1f; wallTranslateGain[4] = 1.2f; direction = new Vector2[4]; direction[0] = Vector2.up; direction[1] = Vector2.left; direction[2] = Vector2.down; direction[3] = Vector2.right; grid = 0.5f; answer = new Dictionary <DistanceType, List <List <bool> > >(); answer.Add(DistanceType.Short, new List <List <bool> >()); answer.Add(DistanceType.Middle, new List <List <bool> >()); answer.Add(DistanceType.Long, new List <List <bool> >()); for (int i = 0; i < totalTrial; i++) { answer[DistanceType.Short].Add(new List <bool>(new bool[5])); answer[DistanceType.Middle].Add(new List <bool>(new bool[5])); answer[DistanceType.Long].Add(new List <bool>(new bool[5])); } // PrintResult(); gainSample = new Queue <int> [3]; for (int i = 0; i < gainSample.Length; i++) { gainSample[i] = new Queue <int>(); } distSample = new Queue <int>(); targetPosition = Vector2.zero; float userInitRotation = Utility.sampleUniform(0, 360); userBody.Rotation = userInitRotation; userBody.AddClickEvent(GenerateTarget, 0); userBody.AddClickEvent(userUI.DisableUI, 0); userBody.AddClickEvent(userPointer.HidePointer, 0); userBody.AddReachTargetEvent(DestroyTarget); userBody.AddReachTargetEvent(GenerateTurnTarget); userBody.AddDetachTargetEvent(DestroyTurnTarget); userBody.AddDetachTargetEvent(MoveOppositeWall); userBody.AddDetachTargetEvent(userPointer.ShowPointer); userBody.AddDetachTargetEvent(userUI.PopUPOK2Paragraph); userBody.AddClickEvent(userUI.PopUpChoiceParagraph, 1); userBody.AddClickEvent(userUI.DisableUI, 1); userBody.AddClickEvent(CheckAnswerYes, 2); userBody.AddClickEvent(GenerateTarget, 2); userBody.AddClickEvent(userUI.DisableUI, 2); userBody.AddClickEvent(userPointer.HidePointer, 2); userBody.AddClickEvent(CheckAnswerNo, 3); userBody.AddClickEvent(GenerateTarget, 3); userBody.AddClickEvent(userUI.DisableUI, 3); userBody.AddClickEvent(userPointer.HidePointer, 3); // userPointer.ShowPointer(); userUI.PopUpOkParagraph(); }
/// <summary> /// login existing user /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="appId">ID of app</param> /// <param name="body">request body</param> /// <returns>Task of ApiResponse (CloudUser)</returns> public async System.Threading.Tasks.Task<ApiResponse<CloudUser>> LoginAsyncWithHttpInfo (string appId, UserBody body) { // verify the required parameter 'appId' is set if (appId == null) throw new ApiException(400, "Missing required parameter 'appId' when calling Login"); // verify the required parameter 'body' is set if (body == null) throw new ApiException(400, "Missing required parameter 'body' when calling Login"); var localVarPath = "user/{app_id}/login"; var localVarPathParams = new Dictionary<String, String>(); var localVarQueryParams = new Dictionary<String, String>(); var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary<String, String>(); var localVarFileParams = new Dictionary<String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (appId != null) localVarPathParams.Add("app_id", Configuration.ApiClient.ParameterToString(appId)); // path parameter if (body.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter } else { localVarPostBody = body; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int) localVarResponse.StatusCode; if (localVarStatusCode >= 400) throw new ApiException (localVarStatusCode, "Error calling Login: "******"Error calling Login: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); return new ApiResponse<CloudUser>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (CloudUser) Configuration.ApiClient.Deserialize(localVarResponse, typeof(CloudUser))); }
/// <summary> /// login existing user /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="appId">ID of app</param> /// <param name="body">request body</param> /// <returns>Task of CloudUser</returns> public async System.Threading.Tasks.Task<CloudUser> LoginAsync (string appId, UserBody body) { ApiResponse<CloudUser> localVarResponse = await LoginAsyncWithHttpInfo(appId, body); return localVarResponse.Data; }
/// <summary> /// login existing user /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="appId">ID of app</param> /// <param name="body">request body</param> /// <returns>CloudUser</returns> public CloudUser Login (string appId, UserBody body) { ApiResponse<CloudUser> localVarResponse = LoginWithHttpInfo(appId, body); return localVarResponse.Data; }
public async Task <IActionResult> Register([FromBody] UserBody user) { if (!ModelState.IsValid) { return(ModelError()); } if (!Regex.IsMatch(user.UserName, @"^[A-Za-z0-9_\-\.\@]+$")) { return(Error("Tên đăng nhập không hợp lệ")); } if (user.UserName == "admin") { return(Error("Xin lỗi, bạn không thể sử dụng admin làm username")); } var roles = await db.Roles.Where(item => user.RoleIds.Contains(item.Id)).Select(item => item.Name) .ToListAsync(); if (roles.Any(r => r == "Admin")) { return(Error("Xin lỗi, bạn không thể hack hệ thống")); } var appUser = new ApplicationUser { UserName = user.UserName, Email = user.Email, PhoneNumber = user.Phone, JoinDate = DateTime.Now, Status = IdentityStatus.Active, FullName = user.FullName, FirstName = user.Firstname, LastName = user.Lastname }; var createResult = await userManager.CreateAsync(appUser, user.Password); if (roles.Contains("Recruitment")) { var recruiment = new Recruitment { CompanyName = user.CompanyName, Position = user.Position, WorkingTypes = user.WorkingTypes, WorkAddress = user.WorkAddress, UserId = appUser.Id }; await db.Recruitments.AddAsync(recruiment); } else { var candidate = new Candidate { WorkAddress = user.WorkAddress, UserId = appUser.Id }; await db.Candidates.AddAsync(candidate); } await db.SaveChangesAsync(); if (!createResult.Succeeded) { return(IdentityError(createResult)); } if (user.RoleIds != null) { await userManager.AddToRolesAsync(appUser, roles); } return(Ok(await FormatUser(db.Users.Where(item => item.Id == appUser.Id)).FirstOrDefaultAsync())); }
void Start () { niteController = new NiteController(new NiteController.NewUserCallback(this.OnNewUser)); gui = new DressingRoomGUI(niteController); userBody = new UserBody(); }
private void Awake() { userBody = GameObject.FindGameObjectWithTag("Player").GetComponent <User>().GetTrackedUserBody(); interactable = this.GetComponent <Interactable>(); }
public HttpResponseMessage CreateKmsAccount([FromBody] CreateKmsAccountPost dataPost) { // --- Validar que API-Key tenga autorización de crear cuentas -- if (!OAuth.ConsumerKey.AccuntCreateEnabled) { throw new HttpUnauthorizedException( "107 " + ControllerStrings.Warning107_ConsumerNotAllowed ); } // --- Validar que se tenga un Request Token --- if (!OAuth.IsRequestToken) { throw new HttpUnauthorizedException( "104 " + ControllerStrings.Warning104_RequestTokenInvalid ); } // --- Validar que no haya un usuario con el mismo Email --- User userSearch = Database.UserStore.GetFirst( f => f.Email == dataPost.Email.ToLower() ); if (userSearch != null) { throw new HttpConflictException( "206 " + ControllerStrings.Warning206_CannotCreateUserWithEmail ); } // --- Crear cuenta de Usuario --- User user = new User() { Name = dataPost.Name, LastName = dataPost.LastName, BirthDate = dataPost.Birthdate, Email = dataPost.Email.ToLower(CultureInfo.InvariantCulture), PreferredCultureCode = dataPost.CultureCode, RegionCode = dataPost.RegionCode, UtcOffset = dataPost.UtcOffset }; user.SetPassword(dataPost.Password); // --- Crear perfil Físico del Usuario --- UserBody userBody = new UserBody() { Height = dataPost.Height, Weight = dataPost.Weight, Sex = dataPost.Gender.ToString().ToUpper(CultureInfo.InvariantCulture), User = user }; // Calcular zancada a partir del género y altura if (userBody.Sex == "F") { userBody.StrideLengthWalking = (int)(userBody.Height * 0.413d); userBody.StrideLengthRunning = (int)(userBody.Height * 0.613d); } else if (userBody.Sex == "M") { userBody.StrideLengthWalking = (int)(userBody.Height * 0.415d); userBody.StrideLengthRunning = (int)(userBody.Height * 0.615d); } // --- Crear un Data Point en 0 --- var data = new Data[] { new Data { Timestamp = DateTime.UtcNow, Steps = 0, Activity = DataActivity.Running, StrideLength = 0, EqualsKcal = 0, EqualsCo2 = 0, EqualsCash = 0, User = user }, new Data { Timestamp = DateTime.UtcNow, Steps = 0, Activity = DataActivity.Walking, StrideLength = 0, EqualsKcal = 0, EqualsCo2 = 0, EqualsCash = 0, User = user }, new Data { Timestamp = DateTime.UtcNow, Steps = 0, Activity = DataActivity.Sleep, StrideLength = 0, EqualsKcal = 0, EqualsCo2 = 0, EqualsCash = 0, User = user } }; // --- Crear MotionLevelHistory --- MotionLevel motionLevel = Database.MotionLevelStore.GetFirst( orderBy: o => o.OrderBy(b => b.DistanceThresholdStart) ); UserMotionLevelHistory motionLevelHistory = new UserMotionLevelHistory { User = user, MotionLevel = motionLevel }; // --- Crear Token OAuth --- Token token = new Token() { ApiKey = OAuth.ConsumerKey, Guid = Guid.NewGuid(), Secret = Guid.NewGuid(), User = user, ExpirationDate = DateTime.UtcNow.AddMonths(3) }; // --- Integrar cambios a BD --- Database.UserStore.Add(user); Database.UserBodyStore.Add(userBody); Database.UserMotionLevelStore.Add(motionLevelHistory); foreach (var d in data) { Database.DataStore.Add(d); } Database.TokenStore.Add(token); Database.TokenStore.Delete(OAuth.Token); var triggers = new RewardTipTrigger(user, Database); triggers.TriggerRewardsByDistance(); triggers.TriggerTipsByDays(); Database.SaveChanges(); // --- Devolver respuesta --- HttpResponseMessage response = new HttpResponseMessage() { RequestMessage = Request, StatusCode = HttpStatusCode.OK, Content = new StringContent( string.Format( CultureInfo.CurrentCulture, "oauth_token={0}&oauth_token_secret={1}&x_expiration_date={2}", token.Guid.ToString("N"), token.Secret.ToString("N"), token.ExpirationDate.ToString() ) ) }; response.Headers.TryAddWithoutValidation( "Warning", "000 " + ControllerStrings.Warning108_RequestTokenExchanged ); return(response); }
public void Initialize(UserBody localBodyInstance) { //PlayerBody playerBody = PlayerBody.FindUnclaimedPlayerBody(); //playerBody.StartControlling(fakeController); }
public void Init() { instance = new UserBody(); }
public async Task <ActionResult <CouchDbCreateDocumentResult> > CreateServiceUser([FromBody] UserBody body) { CouchDbCreateDocumentResult postUser; try { if (string.IsNullOrEmpty(body.name) || string.IsNullOrEmpty(body.email) || string.IsNullOrEmpty(body.password)) { return(StatusCode(StatusCodes.Status409Conflict, $"Unable to create user. \n\nDue to missing parameters")); } postUser = await ManagementService.PostServiceUser(body); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Internal Server no issue, from \nUser: {body}. \n\nException: {e.Message}")); } return(Ok(postUser.IsSuccessful)); }
public bool[] CheckWallMovable(VirtualEnvironment virtualEnvironment, Room currentRoom, UserBody userBody, float[] translate) // translate은 xx,y 좌표계 기준으로 부호가 결정 { bool[] isMovable = new bool[4]; for (int i = 0; i < 4; i++) { isMovable[i] = true; // i와 i+1 사이 wall } // 벽이 사용자와 충분히 멀리 있는지를 판단 for (int i = 0; i < 4; i++) { Vector2 wallPosition = currentRoom.GetEdge2D(i, Space.World); if (i % 2 == 0 && Mathf.Abs(wallPosition.y - userBody.Position.y) < 0.4f) // 현재 벽 i가 0, 2번 벽이고 user와 너무 가까운 경우, 0.1f는 여유 boundary , user.Size.y / 2 { isMovable[i] = false; } else if (i % 2 != 0 && Mathf.Abs(wallPosition.x - userBody.Position.x) < 0.4f) // user.Size.x / 2 { isMovable[i] = false; } } // 벽이 사용자 시야에 있는지를 판단 for (int i = 0; i < 4; i++) { Vector2 vertexPosition = currentRoom.GetVertex2D(i, Space.World); Vector2 wallPosition = currentRoom.GetEdge2D(i, Space.World); if (userBody.IsTargetInUserFov(vertexPosition)) { isMovable[Utility.mod(i, 4)] = false; isMovable[Utility.mod(i - 1, 4)] = false; } if (userBody.IsTargetInUserFov(wallPosition)) { isMovable[Utility.mod(i, 4)] = false; } } return(isMovable); }
void NetworkingController.LocalUserObjects.Initialize(UserBody localUserBody) { userMain.SetupUserBody(localUserBody); userMain.Setup(); }