public IActionResult Registrar(string usuario, string password, int id_pass) { if (UsuarioDAO.getInstancia().devolverIdUsuario(usuario) == -1) { var psw = Hash(password); UsuarioDAO.getInstancia().add(new Usuario(usuario, psw, id_pass)); var id_user = UsuarioDAO.getInstancia().devolverIdUsuario(usuario); var passControler = new PassController(); passControler.UsarPass(id_pass, id_user); var usuarioJson = HttpContext.Session.GetString("usuario"); if (usuarioJson == null) { return(Login(usuario, password)); } return(View("../Home/Index")); } else { ViewBag.idPass = id_pass; ViewBag.msg = "Ya existe ese usuario"; return(View("../Home/Registrar")); } }
private void Awake() { dashController = GetComponent <DashController>(); passController = GetComponent <PassController>(); dunkController = GetComponent <DunkController>(); pawnController = GetComponent <PawnController>(); curvedCooldown = 0; if (passController) { passController.SetTargetedPawn(passTarget); } }
private void Start() { dunkState = DunkState.None; passController = GetComponent <PassController>(); pawnController = GetComponent <PawnController>(); playerController = GetComponent <PlayerController>(); if (playerController != null) { isPlayer = true; } currentDunkReadyPanel = Instantiate(Resources.Load <GameObject>("PlayerResource/DunkReadyPanel")); currentDunkReadyPanel.transform.SetParent(GameManager.mainCanvas.transform); }
public IActionResult ConfirmarEliminar(Boolean confirmacion) { var usuarioJson = HttpContext.Session.GetString("usuario"); var usuario = JsonConvert.DeserializeObject <dynamic>(usuarioJson); if (confirmacion) { UsuarioDAO.getInstancia().Eliminar((string)usuario.username); var passControler = new PassController(); passControler.EliminarPass((int)usuario.pass); return(Logout()); } else { ViewBag.usuario = usuario; return(View("../Home/Editar")); } }
PassController CreatePassController() { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "abcd") })); var passController = new PassController( _mockPassService.Object, _mapper, _mockLoggerService.Object) { ControllerContext = new ControllerContext() }; passController.ControllerContext.HttpContext = new DefaultHttpContext { User = user }; return(passController); }
public void IsDeletingPass() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: "database_to_delete_pass") .Options; var appDbContext = new AppDbContext(options); appDbContext.UserPermissions.Add(new UserPermission { Id = 1, UserName = "******", IdPrison = 1, Prison = new Prison { Id = 1, PrisonName = "prison_test" } }); var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "abcd"), })); var passRepository = new PassRepository(appDbContext); var passService = new PassService(passRepository); var loggerRepository = new LoggerRepository(appDbContext); var loggerService = new LoggerService(loggerRepository); var passController = new PassController(passService, _mapper, loggerService) { ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = user } } }; appDbContext.Passes.Add(new Pass { Id = 1, StartDate = default,
public void CurveShoot(PassController _passController, PawnController _thrower, PawnController _target, BallDatas _passDatas, Vector3 _lookDirection) //Shoot a curve ball to reach a point { if (ballCoroutine != null) { StopCoroutine(ballCoroutine); } startPosition = _passController.GetHandTransform().position; transform.SetParent(null, true); transform.localScale = Vector3.one; ballInformations.thrower = _thrower; ballInformations.moveSpeed = _passDatas.moveSpeed; ballInformations.maxDistance = Mathf.Infinity; ballInformations.ballDatas = _passDatas; ballInformations.bounceCount = 0; ballInformations.canBounce = true; ballInformations.canHitWalls = true; ballInformations.curve = _passController.GetCurvedPathCoordinates(startPosition, _target, _lookDirection, out float d); ballInformations.timeFlying = 0; ballInformations.initialLookDirection = _lookDirection; ballInformations.isTeleguided = false; hitGameObjects.Clear(); ChangeState(BallState.Flying); UpdateColor(); }
public virtual void Awake() { //Retrieve references rb = GetComponent <Rigidbody>(); animator = GetComponentInChildren <Animator>(); passController = GetComponent <PassController>(); navMeshAgent = GetComponent <NavMeshAgent>(); pawnStates = Resources.Load <PawnStates>("PawnStateDatas"); if (navMeshAgent == null) { navMeshAgent = GetComponentInChildren <NavMeshAgent>(); } if (navMeshAgent == null) { navMeshAgent = GetComponent <NavMeshAgent>(); } pushDatas = PushDatas.GetDatas(); //Init variables isInvincible = false; if (pawnMovementValues != null) { customGravity = pawnMovementValues.onGroundGravityMultiplier * -9.81f; customDrag = pawnMovementValues.idleDrag; effectiveSpeed = pawnMovementValues.moveSpeed; } currentHealth = maxHealth; targetable = true; if (GetComponent <PlayerController>() != null) { isPlayer = true; } UpdateNavMeshAgent(navMeshAgent); moveState = MoveState.Idle; currentPawnState = null; }
// Start is called before the first frame update private void Start() { playerController = GetComponentInParent <PlayerController>(); pawnController = GetComponentInParent <PawnController>(); passController = pawnController.passController; }
private void UpdateBallPosition() { switch (ballInformations.state) { case BallState.Flying: ballInformations.timeFlying += Time.deltaTime; if (ballInformations.isTeleguided) { PassController i_currentPassController = GetCurrentThrower().GetComponent <PassController>(); if (i_currentPassController != null) { ballInformations.direction = (i_currentPassController.GetTarget().GetCenterPosition() - transform.position).normalized; } } else if (ballInformations.curve != null) { PassController i_currentPassController = GetCurrentThrower().GetComponent <PassController>(); List <Vector3> i_pathCoordinates = i_currentPassController.GetCurvedPathCoordinates(startPosition, i_currentPassController.GetTarget(), ballInformations.initialLookDirection, out float d); float i_curveLength; if (i_currentPassController == null) { return; } ConvertCoordinatesToCurve(i_pathCoordinates, out curveX, out curveY, out curveZ, out i_curveLength); ballInformations.maxDistance = i_curveLength; float i_positionOnCurve = ballInformations.distanceTravelled / ballInformations.maxDistance; if (ballInformations.thrower.isPlayer) { LockManager.LockTargetsInPath(i_pathCoordinates, i_positionOnCurve); if (i_positionOnCurve >= 0.95f) { ChangeState(BallState.Grounded); LockManager.UnlockAll(); } } Vector3 i_nextPosition = new Vector3(curveX.Evaluate(i_positionOnCurve + 0.1f), curveY.Evaluate(i_positionOnCurve + 0.1f), curveZ.Evaluate(i_positionOnCurve + 0.1f)); ballInformations.direction = i_nextPosition - transform.position; } if (ballInformations.moveSpeed <= 0) { ballInformations.curve = null; ChangeState(BallState.Grounded); } else { //Ball is going to it's destination, checking for collisions RaycastHit[] i_hitColliders = Physics.RaycastAll(transform.position, ballInformations.direction, ballInformations.moveSpeed * Time.deltaTime); foreach (RaycastHit raycast in i_hitColliders) { /*EnemyShield i_selfRef = raycast.collider.GetComponentInParent<EnemyShield>(); * if (i_selfRef != null) * { * if (i_selfRef.shield.transform.InverseTransformPoint(transform.position).z > 0.0) * { * FeedbackManager.SendFeedback("event.ShieldHitByBall", this); * Vector3 i_newDirection = Vector3.Reflect(ballInformations.direction, i_selfRef.shield.transform.forward); * Bounce(i_newDirection, 1); * } * }*/ IHitable i_potentialHitableObjectFound = raycast.collider.GetComponent <IHitable>(); if (i_potentialHitableObjectFound != null && !hitGameObjects.Contains(i_potentialHitableObjectFound) && !isGhostBall) { hitGameObjects.Add(i_potentialHitableObjectFound); i_potentialHitableObjectFound.OnHit(this, ballInformations.direction * ballInformations.moveSpeed, ballInformations.thrower, GetCurrentDamages(), DamageSource.Ball); SlowTimeScale(); } if (raycast.collider.isTrigger || raycast.collider.gameObject.layer != LayerMask.NameToLayer("Environment")) { break; } FeedbackManager.SendFeedback("event.WallHitByBall", raycast.transform, raycast.point, ballInformations.direction, raycast.normal); if (!ballInformations.canHitWalls) { return; } if (ballInformations.bounceCount < ballInformations.ballDatas.maxBounces && ballInformations.canBounce) //Ball can bounce: Bounce { Analytics.CustomEvent("BallBounce", new Dictionary <string, object> { { "Zone", GameManager.GetCurrentZoneName() }, }); Vector3 i_hitNormal = raycast.normal; i_hitNormal.y = 0; Vector3 i_newDirection = Vector3.Reflect(ballInformations.direction, i_hitNormal); i_newDirection.y = -ballInformations.direction.y; Bounce(i_newDirection, ballInformations.ballDatas.speedMultiplierOnBounce); return; } else //Ball can't bounce: Stop { ChangeState(BallState.Grounded); MomentumManager.DecreaseMomentum(MomentumManager.datas.momentumLossWhenBallHitTheGround); return; } } } transform.position += ballInformations.direction.normalized * ballInformations.moveSpeed * Time.deltaTime * MomentumManager.GetValue(MomentumManager.datas.ballSpeedMultiplier) * GetCurrentSpeedModifier(); ballInformations.distanceTravelled += ballInformations.moveSpeed * Time.deltaTime * MomentumManager.GetValue(MomentumManager.datas.ballSpeedMultiplier) * GetCurrentSpeedModifier(); if (ballInformations.curve == null && !ballInformations.isTeleguided && ballInformations.distanceTravelled >= ballInformations.maxDistance) { ChangeState(BallState.Grounded); } break; } }
public void IsAddingNewPass() { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "abcd"), })); var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: "database_to_add_pass") .Options; var appDbContext = new AppDbContext(options); appDbContext.UserPermissions.Add(new UserPermission { Id = 1, UserName = "******", IdPrison = 1, Prison = new Prison { Id = 1, PrisonName = "prison_test" } }); var passRepository = new PassRepository(appDbContext); var passService = new PassService(passRepository); var loggerRepository = new LoggerRepository(appDbContext); var loggerService = new LoggerService(loggerRepository); var passController = new PassController(passService, _mapper, loggerService) { ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = user } } }; appDbContext.SaveChanges(); appDbContext.Prisoners.Add(new Prisoner { Id = 1, Name = "fdsafd", Forname = "dsdsa", Pesel = "12345678910", Address = "dsafa", Pass = false, Behavior = 2, Isolated = false, IdCell = 1, Cell = new Cell(), Isolations = new List <Isolation>(), Punishments = new List <Punishment>() }); appDbContext.SaveChanges(); passController.AddPass(new PassDTO { StartDate = DateTime.Today, EndDate = DateTime.Today.AddDays(1), IdPrisoner = 1 }); Assert.AreEqual(appDbContext.Passes.Count(), 1); }