private void CreateActor_Clicked(object sender, RoutedEventArgs e) { ActorInput actorInput = new ActorInput(); actorInput.Subscribe(this); actorInput.Show(); }
private void GetMovement(ref ActorInput actorInput) { if (actorInput.movement.x <= deadPoint && actorInput.movement.x >= -deadPoint && actorInput.movement.z <= deadPoint && actorInput.movement.z >= -deadPoint) { actorInput.movement = Vector3.zero; } }
private void UpdateAsAI(Entity entity, ref ActorInput actorInput) { if (EntityManager.HasComponent(entity, typeof(ActorPlayer))) { return; } }
public ActionResult DoCreate(HttpPostedFileBase file, ActorInput input) { var actor = input.CreateActor(file, CountriesDao, FilmsDao); ActorsDao.Add(actor); return(RedirectToAction("Index")); }
public async Task <IActionResult> Post([FromBody] ActorInput input) { var item = await _actorAppService .InsertAsync(input) .ConfigureAwait(false); return(CreatedContent("", item)); }
public static void CopyToData(this ActorInput input, Actor data, HttpPostedFileBase photo, IDaoCountry daoCountry, IDaoFilm daoFilm) { if (data.ID != input.ID) { throw new Exception("Cannot copy from foreign view to data"); } data.Name = input.Name; data.Surname = input.Surname; data.Birth = input.Birth; data.Death = input.Death; data.Biography = input.Biography; if (input.CountryId != null) { data.Country = daoCountry.Find(input.CountryId); } data.RemoveAllFilms(); if (input.FilmsStared != null) { foreach (var id in input.FilmsStared) { var film = daoFilm.Find(id); data.AddFilm(film); } } data.Gender = (Data.Models.Gender)input.Gender; if (photo != null && photo.ContentLength > 0) { try { if (photo.ContentType.Contains("image")) { var filename = Guid.NewGuid().ToString() + Path.GetExtension(photo.FileName); var path = Path.Combine(PathUtils.GetProjectDirectory(), "Cinematheque.WebSite\\images\\actors\\", filename); photo.SaveAs(path); data.PhotoFileName = filename; } else { throw new Exception("ERROR: Uploaded file is not image"); } } catch (Exception ex) { throw new Exception("ERROR:" + ex.Message.ToString()); } } }
public ActionResult DoEdit(Guid id, HttpPostedFileBase file, ActorInput newView) { var data = ActorsDao.GetActorWithFilms(id); newView.CopyToData(data, file, CountriesDao, FilmsDao); ActorsDao.Update(data); return(RedirectToAction("Index")); }
public static Actor CreateActor(this ActorInput input, HttpPostedFileBase photo, IDaoCountry daoCountry, IDaoFilm daoFilm) { var actor = new Actor { Name = input.Name, Surname = input.Surname, Birth = input.Birth, Death = input.Death, Country = daoCountry.Find(input.CountryId), Biography = input.Biography, Gender = (Data.Models.Gender)input.Gender }; if (photo != null && photo.ContentLength > 0) { try { if (photo.ContentType.Contains("image")) { var filename = Guid.NewGuid().ToString() + Path.GetExtension(photo.FileName); var path = Path.Combine(PathUtils.GetProjectDirectory(), "Cinematheque.WebSite\\images\\actors\\", filename); photo.SaveAs(path); actor.PhotoFileName = filename; } else { throw new Exception("ERROR: Uploaded file is not image"); } } catch (Exception ex) { throw new Exception("ERROR:" + ex.Message.ToString()); } } else { actor.PhotoFileName = "default.jpg"; } if (input.FilmsStared != null) { foreach (var id in input.FilmsStared) { var film = daoFilm.Find(id); actor.AddFilm(film); } } return(actor); }
public async Task <Actor> InsertAsync(ActorInput actorInput) { var genre = await _genreRepository .GetGenreByIdAsync(actorInput.GenresId) .ConfigureAwait(false); var actor = new Actor(genre, actorInput.Sex, actorInput.Salary, actorInput.UserId, actorInput.Ranking); if (!actor.IsValid()) { _notification.NewNotificationBadRequest("Os dados são obrigatórios"); return(default);
void Awake() { playerInput = GetComponent <ActorInput>(); animator = model.GetComponent <Animator>(); sm = GetComponent <StateManager>(); characterController = GetComponent <CharacterController>(); if (neckPos == null) { neckPos = animator.GetBoneTransform(HumanBodyBones.Neck); } if (!cc) { cc = new CameraController(); } }
private void UpdateAsPlayer(Entity entity, ref ActorInput actorInput) { if (!EntityManager.HasComponent(entity, typeof(ActorPlayer))) { return; } //Get Player Input { //AXIS actorInput.movement.x = GInput.GetAxisRaw(GAxis.LEFTHORIZONTAL); actorInput.movement.z = GInput.GetAxisRaw(GAxis.LEFTVERTICAL); //Reset actorInput.actionToDo = 0; //BUTTONS if (GInput.GetButtonDown(GButton.RIGHT)) { actorInput.actionToDo = 1; } if (GInput.GetButtonDown(GButton.BOTTOM)) { actorInput.actionToDo = 2; } if (GInput.GetButtonDown(GButton.LEFT)) { actorInput.actionToDo = 3; } if (GInput.GetButtonDown(GButton.L3)) { actorInput.crouch = (byte)(actorInput.crouch == 1 ? 0 : 1); } actorInput.sprint = (byte)(GInput.GetButton(GButton.TOP) ? 1 : 0); actorInput.strafe = (byte)(GInput.GetButton(GButton.L2) ? 1 : 0); } //Convert Actor Movement to Camera { var cameraForward = (Camera.main.transform.TransformDirection(Vector3.forward).normalized); cameraForward.y = 0; var camreaRight = new Vector3(cameraForward.z, 0, -cameraForward.x); actorInput.movement = actorInput.movement.x * camreaRight + actorInput.movement.z * cameraForward; actorInput.movement.Normalize(); } }
public void OnEdit_Clicked(object sender, RoutedEventArgs e) { currentOperation = Operations.EDIT; if (currentState == States.NONE) { return; } switch (currentState) { case States.FILMS: Film film = new Film( Int32.Parse(((DataRowView)DataGrid.SelectedItem).Row["fid"].ToString()), ((DataRowView)DataGrid.SelectedItem).Row["title"].ToString(), Int32.Parse(((DataRowView)DataGrid.SelectedItem).Row["budget"].ToString()), ((DataRowView)DataGrid.SelectedItem).Row["script"].ToString(), Int32.Parse(((DataRowView)DataGrid.SelectedItem).Row["did"].ToString()) ); FilmInput filmInput = new FilmInput(film); filmInput.Subscribe(this); filmInput.Show(); break; case States.ACTORS: Actor actor = new Actor( Int32.Parse(((DataRowView)DataGrid.SelectedItem).Row["aid"].ToString()), ((DataRowView)DataGrid.SelectedItem).Row["firstname"].ToString(), ((DataRowView)DataGrid.SelectedItem).Row["secondname"].ToString(), Int32.Parse(((DataRowView)DataGrid.SelectedItem).Row["experience"].ToString()) ); ActorInput actorInput = new ActorInput(actor); actorInput.Subscribe(this); actorInput.Show(); break; case States.DIRECTORS: Director director = new Director( Int32.Parse(((DataRowView)DataGrid.SelectedItem).Row["did"].ToString()), ((DataRowView)DataGrid.SelectedItem).Row["firstname"].ToString(), ((DataRowView)DataGrid.SelectedItem).Row["secondname"].ToString(), ((DataRowView)DataGrid.SelectedItem).Row["isCertified"].ToString().ToLower() ); DirectorInput directorInput = new DirectorInput(director); directorInput.Subscribe(this); directorInput.Show(); break; } }
protected override void OnUpdate() { Entities.WithAll <Transform, ActorInventory, ActorInput>().ForEach((Entity inventoryEntity, Transform inventoryTransform, ref ActorInventory actorInventory, ref ActorInput actorInput) => { newActorInventory = actorInventory; newInventoryActorInput = actorInput; attemptToPickUp = false; if (actorInput.actionToDo == 1 && actorInput.action == 0) { Entities.WithAll <Transform, ActorItem>().ForEach((Entity itemEntity, Transform itemTransform) => { //Get Item shared component var actorItem = EntityManager.GetSharedComponentData <ActorItem>(itemEntity); //Check if were in distance and not already picked up if (!attemptToPickUp && Vector3.Distance(inventoryTransform.position, itemTransform.position) <= 1f && !EntityManager.HasComponent(itemEntity, typeof(Parent))) { //Set that we attempted to pick a item up attemptToPickUp = true; //Get Target Socket var targetSocket = ActorUtilities.GetFirstEmptyTransform(inventoryTransform, actorItem.sockets); //Do Pickup | Set action to 0 if (targetSocket != null) { ActorUtilities.PickupItem(PostUpdateCommands, EntityManager, targetSocket, itemTransform, itemEntity, actorItem, inventoryTransform, inventoryEntity, ref newActorInventory); newInventoryActorInput.action = 0; } } }); } //Drop | Set Action to 0 if (actorInput.actionToDo == 1 && actorInput.action == 0 && attemptToPickUp == false && newActorInventory.isEquipped == 1) { ActorUtilities.DropItem(PostUpdateCommands, EntityManager, newActorInventory.equippedEntiy, inventoryTransform, inventoryEntity, ref newActorInventory); newInventoryActorInput.action = 0; } actorInventory = newActorInventory; actorInput = newInventoryActorInput; }); }
public async Task Validar_Metodo_Insert_Sem_Dados_Obrigatorios(double salary, char sex, int ranking, int userId) { //Arrange var input = new ActorInput(); input.Salary = salary; input.Sex = sex; input.Ranking = ranking; input.UserId = userId; //Act var result = await this.ActorAppServices .InsertAsync(input) .ConfigureAwait(false); //Assert result .Should() .Be(default(Actor)); domainNotificationHandler .GetNotifications() .Should() .HaveCount(1); domainNotificationHandler .GetNotifications() .FirstOrDefault() .DomainNotificationType .Should() .Be(DomainNotificationType.BadRequest); domainNotificationHandler .GetNotifications() .FirstOrDefault() .Value .Should() .Be("Os dados são obrigatórios"); }
void Awake() { movement = GetComponent <ActorMovement>(); input = GetComponent <ActorInput>(); combat = GetComponent <ActorCombat>(); animation = GetComponent <Animation>(); TextMesh[] textMeshes = GetComponentsInChildren <TextMesh>(); foreach (TextMesh textMesh in textMeshes) { if (textMesh.transform.name == "DebugText") { debugTextMesh = textMesh; } if (textMesh.transform.name == "LifeCounter") { lifeCounterTextMesh = textMesh; } } }
private void OnFallMovement(Transform transform, AnimationEventManager animationEventManager, Animator animator, Rigidbody rigidbody, Entity entity, Actor actor, ref ActorInput actorInput, ActorCharacter actorCharacter) { //set Animators in air previoius animator.SetBool("inAirPrevious", animator.GetBool("inAir")); if (!isGrounded) { var newMovement = rigidbody.velocity; newMovement.y -= actorCharacter.fallForce * dt; rigidbody.velocity = newMovement; if (actorInput.crouch == 1) { ActorUtilities.UpdateCollider(actor, transform, "Standing"); actorInput.crouch = 0; } animator.SetBool("inAir", true); } else { animator.SetBool("inAir", false); } }
private void OnWallHugMovement(Transform transform, AnimationEventManager animationEventManager, Animator animator, Rigidbody rigidbody, Entity entity, Actor actor, ref ActorInput actorInput, ActorCharacterWallHug actorCharacterWallHug) { // start wall hugging if (actorInput.actionToDo == 1 && actorInput.crouch == 0 && actorInput.action == 0) { // get all surrounding walls | Get first hit as our main hit var hits = Physics.SphereCastAll(transform.position, 0.5f, Vector3.one * 0.5f, 0.5f, actorCharacterWallHug.wallHugMask); if (hits.Length >= 1) { var hit = hits[0]; var directionToWall = (hit.transform.position - transform.position).normalized; var distanceToWall = Vector3.Distance(hit.transform.position, transform.position); RaycastHit wallHit; if (Physics.Raycast(transform.position + new Vector3(0, 0.5f, 0), directionToWall, out wallHit, distanceToWall, actorCharacterWallHug.wallHugMask)) { wallHuggingDirections[entity.Index] = Quaternion.LookRotation(GetMeshColliderNormal(wallHit)).eulerAngles; Debug.DrawLine(transform.position + new Vector3(0, 0.5f, 0), wallHit.point, Color.red, 1); Debug.DrawRay(wallHit.point, GetMeshColliderNormal(wallHit) * 5, Color.red, 1); actorInput.actionToDo = 0; actorInput.action = 99; } } } //Stop wall hugging if (actorInput.actionToDo == 1 && actorInput.action == 99) { actorInput.actionToDo = 0; actorInput.action = 0; } //Update Wall hugging if (actorInput.action == 99) { bool forceStop = false; //Move if (actorInput.movement.magnitude >= deadPoint) { //Movement var movement = actorInput.movement; var movementToRightDotProduct = Vector3.Dot(movement, transform.right); rigidbody.velocity = transform.right * movementToRightDotProduct * actorCharacterWallHug.speed; //Check if there is wall ahead of where we are going if not than force a stop { //Do it var raycastPoint = transform.position; raycastPoint += Vector3.up * 0.1f; raycastPoint += (transform.right * movementToRightDotProduct).normalized * 0.5f; forceStop = !Physics.Raycast(raycastPoint, -transform.forward, 0.5f, actorCharacterWallHug.wallHugMask); //Debug Debug.DrawRay(raycastPoint, -transform.forward * 0.5f, forceStop ? Color.red : Color.green, 0); } //Animation if (!forceStop) { animator.SetFloat("movementX", movementToRightDotProduct * deadPoint, animationTransitionRate, dt); animator.SetFloat("movementY", 0, animationTransitionRate, dt); } } //Stop Move if (actorInput.movement.magnitude <= deadPoint || forceStop) { //Movement rigidbody.velocity = Vector3.zero; //Animation animator.SetFloat("movementX", 0, animationTransitionRate, dt); animator.SetFloat("movementY", 0, animationTransitionRate, dt); } //Rotate to face wall normal transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, wallHuggingDirections[entity.Index], Time.deltaTime * 6); //Sound if (animationEventManager.RequestEvent("footStep") && actorCharacterWallHug.footStepAudioEvent != null && actorInput.movement.magnitude != 0) { actorCharacterWallHug.footStepAudioEvent.Play(transform.position); } } }
private void OnGroundMovement(Transform transform, AnimationEventManager animationEventManager, Animator animator, Rigidbody rigidbody, Entity entity, Actor actor, ref ActorInput actorInput, ActorCharacter actorCharacter) { //Return if doing diffrent action | Not Grounded if (actorInput.action != 0 || !isGrounded || actorInput.isJumping == 1) { return; } //Get movement type { if (!isHeadFree && actorInput.crouchPreviousFrame == 1) { actorInput.crouch = 1; } if (actorInput.movement.magnitude == 0 || actorInput.crouch == 1 && !isHeadFree) { actorInput.sprint = 0; } if (actorInput.sprint == 1) { actorInput.crouch = 0; } if (actorInput.walk == 1 && actorInput.sprint == 0 && actorInput.crouch == 0) { actorInput.movement *= deadPoint; } } //Move { //Set Velocity var velocity = actorInput.movement; velocity *= actorInput.sprint == 1 ? actorCharacter.sprintSpeed : actorInput.crouch == 1 ? actorCharacter.crouchSpeed : actorCharacter.runSpeed; velocity.y = -1; rigidbody.velocity = velocity; } //Collider { //Set Collider if (actorInput.crouch == 1 && actorInput.crouchPreviousFrame == 0) { ActorUtilities.UpdateCollider(actor, transform, "Crouching"); } else if (actorInput.crouch == 0 && actorInput.crouchPreviousFrame == 1) { ActorUtilities.UpdateCollider(actor, transform, "Standing"); } } //Rotate { if (actorInput.movement.magnitude != 0 && actorInput.strafe == 0 || actorInput.movement.magnitude != 0 && actorInput.sprint == 1) { var lookRotation = Quaternion.LookRotation(actorInput.movement); transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, dt * actorCharacter.rotationSpeed); } } //Animate { //Is Sprinting if (actorInput.sprint == 1) { actorInput.movement = new float3(0, 0, 2f); } //Strafing else if (actorInput.strafe == 1) { actorInput.movement = transform.InverseTransformDirection(actorInput.movement); } //Not Strafing else { actorInput.movement = new float3(0, 0, Mathf.Abs(actorInput.movement.magnitude)); } //Set Animator Properties animator.SetBool("crouch", actorInput.crouch == 1 && actorInput.sprint == 0); animator.SetFloat("movementX", actorInput.movement.x, animationTransitionRate, dt); animator.SetFloat("movementY", actorInput.movement.z, animationTransitionRate, dt); animator.SetFloat("movementAmount", actorInput.movement.magnitude, animationTransitionRate, dt); } //Sound if (animationEventManager.RequestEvent("footStep") && actorCharacter.footStepAudioEvent != null && actorInput.movement.magnitude != 0) { actorCharacter.footStepAudioEvent.Play(transform.position); } }
private void OnJumpMovement(Transform transform, AnimationEventManager animationEventManager, Animator animator, Rigidbody rigidbody, Entity entity, Actor actor, ref ActorInput actorInput, ActorCharacter actorCharacter) { //Save Jump Data if (!jumpIntervals.ContainsKey(entity.Index)) { jumpIntervals.Add(entity.Index, jumpInterval); } //Decrease jump interval if goruned if (isGrounded && rigidbody.velocity.y <= 0) { jumpIntervals[entity.Index] -= 1 * dt; actorInput.isJumping = 0; } //If were not grounded reset jump interval else { jumpIntervals[entity.Index] = jumpInterval; } //Do Jump if (actorInput.action == 0 && actorInput.actionToDo == 2 && isGrounded && actorCharacter.jumpForce != 0 && isHeadFree && jumpIntervals[entity.Index] <= 0) { var velocity = rigidbody.velocity; velocity.y = actorCharacter.jumpForce; rigidbody.velocity = velocity; animator.SetTrigger("jump"); actorInput.isJumping = 1; if (actorInput.crouch == 1) { ActorUtilities.UpdateCollider(actor, transform, "standing"); } if (actorInput.movement.magnitude != 0) { transform.forward = actorInput.movement; } } //Sound { if (animationEventManager.RequestEvent("jumpGrunt") && actorCharacter.jumpGruntAudioEvent != null) { actorCharacter.jumpGruntAudioEvent.Play(transform.position); } else if (animationEventManager.RequestEvent("jumpStart") && actorCharacter.jumpStartAudioEvent != null) { actorCharacter.jumpStartAudioEvent.Play(transform.position); } else if (animationEventManager.RequestEvent("jumpLand") && actorCharacter.jumpLandAudioEvent != null) { actorCharacter.jumpLandAudioEvent.Play(transform.position); } } }