public bool IADefense(Vector3 _position, float _efecto) { // obtener la probabilidad base de parada float baseProb = DifficultyService.GetProbabilidadBaseDeParada();//ServiceLocator.Request<IDifficultyService>().GetFase(), GameplayService.modoJuego.tipoModo); if (PowerupService.instance.IsPowerActive(Powerup.Destello)) { baseProb -= 0.2f; } if (PowerupService.instance.IsPowerActive(Powerup.Phase)) { baseProb -= 0.2f; } if (Habilidades.IsActiveSkill(Habilidades.Skills.Mago_balon) && Mathf.Abs(_efecto) > 0.65f) { baseProb -= 0.2f; } // modificador en la horizontal float hBonus = Mathf.Clamp01(Mathf.Abs(_position.x) / 3.5f); baseProb -= 0.05f * hBonus; // modificador en la vertical float vBonus = Mathf.Clamp01(Mathf.Abs(_position.y - 1.2f) / 1.1f); baseProb -= 0.05f * vBonus; // modificador por efecto baseProb -= 0.05f * Mathf.Abs(_efecto); baseProb = Mathf.Clamp01(baseProb); Debug.Log("Probabilidad de parada: " + baseProb + "(X " + hBonus + " Y " + vBonus + " E " + _efecto + ")"); //aqui se decidiria si el portero coge o no la pelota (tirada de dado para resolver si la parada es efectiva) float rand = Random.Range(0f, 1f); bool success = rand < baseProb; //m_forcedResult = success ? GKResult.Good : GKResult.Fail; // forcedResult if (success) { m_forcedResult = (Random.Range(0f, 1f) < 0.25f) ? GKResult.Perfect : GKResult.Good; } else { m_forcedResult = GKResult.Fail; } return(success); }
public void setFase(int _fase) { if (!m_showingPhase && !GameplayService.networked && DifficultyService.FaseToName(_fase) != "") { // si la ayuda esta oculta => asegurarse de que se muestra la pastilla de multiplicador if (ifcBase.activeIface != ifcAyudaInGame.instance) { transform.FindChild("pastilla_nivel_multiplicador").gameObject.SetActive(true); } m_showingPhase = true; } //setMultiplicador(ServiceLocator.Request<IDifficultyService>().GetMultiplier()); }
public void GetAll_ShouldCallRepository() { var repository = new Mock <IDifficultyRepository>(); repository.Setup(x => x.GetAll()) .Returns(new List <Difficulty>()) .Verifiable(); var service = new DifficultyService(repository.Object); var result = service.GetAll(); Assert.IsNotNull(result); repository.Verify(x => x.GetAll(), Times.Once); }
public FiltersPage() { InitializeComponent(); categories = new List <string> { "Empty" }; categories.AddRange(CategoryService.GetCategories()); Pick.ItemsSource = categories; // mettere la source delle difficoltà difficulties = new List <string> { "Empty" }; difficulties.AddRange(DifficultyService.GetDifficulties()); Pick_Diff.ItemsSource = difficulties; BindingContext = filtri; }
public TeamDetailPage(Team t) { if (t == null) { throw new ArgumentNullException(nameof(t)); } InitializeComponent(); MessagingCenter.Subscribe <LocationSearchPage, string>(this, "LocationTeam", SetLocation); MessagingCenter.Subscribe <LocationSearchPage, (double, double)>(this, "LocationDetails", SetLocationDetails); _categories = CategoryService.GetCategories(); Category_Picker.ItemsSource = _categories; Difficulty_Picker.ItemsSource = DifficultyService.GetDifficulties(); team = new Team { Id = t.Id, Name = t.Name, CreatorID = t.CreatorID, City = t.City, Description = t.Description, MaxMembers = t.MaxMembers, NumOfMembers = t.NumOfMembers, PlaceDetails = t.PlaceDetails, CreationDate = t.CreationDate, Difficulty = t.Difficulty, TerminationDate = t.TerminationDate }; BindingContext = team; if (TS.GetTeam(t.Id) != null) { PageTitle_Label.Text = "Edit your team"; Category_Picker.SelectedIndex = TCS.GetCategories(t.Id)[0] - 1; old_teamCategory_ID = Category_Picker.SelectedIndex + 1; Remove_button.IsVisible = true; Difficulty_Picker.SelectedIndex = t.Difficulty - 1; } }
public void TryShotResult(ShotResult shotResult) { bool playingGoalkeeper = GameplayService.IsGoalkeeper(); if (playingGoalkeeper) { Habilidades.EndRound(shotResult.Result == Result.Goal); } if (!GameplayService.networked) { if (!playingGoalkeeper) { if (shotResult.Result == Result.Goal || shotResult.Result == Result.Target) { if (shotResult.Perfect && attempts < maxAttempts) { GeneralSounds.instance.vidaExtra(); kickEffects.instance.ExtraLife(shotResult.Point); this.attempts++; if (Habilidades.IsActiveSkill(Habilidades.Skills.VIP) && (attempts < maxAttempts)) { this.attempts++; kickEffects.instance.ExtraLife(shotResult.Point + (Vector3.up * -1f)); } } /*if (this.attempts >= maxAttempts && shotResult.Perfect) * { * if (perfects > 1 || Habilidades.IsActiveSkill(Habilidades.Skills.VIP)) * { * if (this.attempts != 3) * { * GeneralSounds.instance.vidaExtra(); * kickEffects.instance.ExtraLife(shotResult.Point); * this.attempts = 3; * } * } * } * if(this.attempts < maxAttempts) this.attempts = maxAttempts;*/ } else { ShotFailed(); } } else { if (shotResult.Result == Result.Goal) { ShotFailed(); } else { if (shotResult.Perfect && attempts < maxAttempts) { GeneralSounds.instance.vidaExtra(); kickEffects.instance.ExtraLife(shotResult.Point); this.attempts++; if (Habilidades.IsActiveSkill(Habilidades.Skills.VIP) && (attempts < maxAttempts)) { this.attempts++; kickEffects.instance.ExtraLife(shotResult.Point + (Vector3.up * -0.5f)); } } //else if (this.attempts < maxAttempts && shotResult.Result != Result.OutOfBounds) this.attempts = maxAttempts; } } SumarDineroPorPrimas(); } else if (GameplayService.networked) { bool isPlayer1 = GameplayService.initialGameMode != GameMode.Shooter; if (playingGoalkeeper) { cntPastillaMultiplayer.marcadorRemoto.Lanzamientos++; } else { cntPastillaMultiplayer.marcadorLocal.Lanzamientos++; } if (newState) { Debug.Log("APPLYING"); cntPastillaMultiplayer.marcadorLocal.SetEstado(GetSimpleState(serverState, isPlayer1)); cntPastillaMultiplayer.marcadorRemoto.SetEstado(GetSimpleState(serverState, !isPlayer1)); newState = false; } else { Debug.Log("CALCULATING"); MatchState tempstate = serverState; if ((isPlayer1 == playingGoalkeeper)) { tempstate.rounds++; } if (playingGoalkeeper) { MatchStateSimple state = cntPastillaMultiplayer.marcadorRemoto.AddResult(shotResult.Result == Result.Goal); if (isPlayer1) { tempstate.marker_2 = state.marker; tempstate.score_2 = state.score; } else { tempstate.marker_1 = state.marker; tempstate.score_1 = state.score; } } else { MatchStateSimple stateF = cntPastillaMultiplayer.marcadorLocal.AddResult(shotResult.Result == Result.Goal); if (isPlayer1) { tempstate.marker_1 = stateF.marker; tempstate.score_1 = stateF.score; } else { tempstate.marker_2 = stateF.marker; tempstate.score_2 = stateF.score; } } serverState = tempstate; if (!playingGoalkeeper) { Debug.Log("SENDING"); MsgSendState msg = Shark.instance.mensaje <MsgSendState>(); msg.state = tempstate; msg.defense = MsgDefend.ToDefenseInfoNet(Vector3.zero, shotResult.DefenseResult); msg.send(); } newState = false; } if (isPlayer1 == playingGoalkeeper) //fin de ronda { if (serverState.rounds > 4 && serverState.score_1 != serverState.score_2) //fin de partida { gameOver = true; bool winner = isPlayer1 ? (serverState.score_1 > serverState.score_2) : (serverState.score_2 > serverState.score_1); bool perfect = isPlayer1 ? (serverState.score_2 == 0) : (serverState.score_1 == 0); perfect = perfect && (isPlayer1 ? (serverState.score_1 >= 5) : (serverState.score_2 >= 5)); if (winner) { Interfaz.MonedasSoft += recompensaMultijugadorWin; } else { Interfaz.MonedasSoft += recompensaMultijugadorFail; } PersistenciaManager.instance.GuardarPartidaMultiPlayer(winner, perfect); } } } int points = shotResult.ScorePoints + shotResult.EffectBonusPoints; // actualizar la informacion de cada ronda RoundInfoManager.instance.AcumularRonda(shotResult.Result, points, shotResult.Perfect);//, GameplayService.IsGoalkeeper() ? (shotResult.DefenseResult == GKResult.Perfect) : (shotResult.Perfect)); // acumular la recompensa // DINERO! MONEDAS! int monedas = Mathf.FloorToInt((float)points * DifficultyService.GetRatioRecompensa()); Interfaz.recompensaAcumulada += monedas; Interfaz.MonedasSoft += monedas; if (gameOver && !GameplayService.networked) { //ifcGameOver.instance.resultTime = FieldControl.instance.seconds; Mission mission = MissionManager.instance.GetMission(); if (attempts > 0) { // persistir la mision que se acaba de superar PersistenciaManager.instance.ActualizarUltimoNivelDesbloqueado(mission.indexMision + 1); // comprobar si la en mision que se acaba de superar desbloquea algun jugador Jugador jugadorDesbloqueado = InfoJugadores.instance.GetJugadorDesbloqueableEnFase(mission.indexMision); if (jugadorDesbloqueado != null) { // registrar el dialogo para mostrar el aviso de que se ha obtenido un nuevo jugador y actualizar su estado jugadorDesbloqueado.estado = Jugador.Estado.DISPONIBLE; DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.JUGADOR_DESBLOQUEADO, jugadorDesbloqueado)); } // comprobar si en la mision que se acaba de superar se desbloquea alguna equipacion Equipacion equipacionDesbloqueada = EquipacionManager.instance.GetEquipacionDesbloqueableEnFase(mission.indexMision); if (equipacionDesbloqueada != null) { // registrar el dialogo para mostrar el aviso de que se ha obtenido una nueva equipacion y actualizar su estado equipacionDesbloqueada.estado = Equipacion.Estado.DISPONIBLE; DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.EQUIPACION_DESBLOQUEADA, equipacionDesbloqueada)); } // comprobar si en la mision que se acaba de superar se ha desbloqueado algun escudo Debug.Log(">>> Compruebo escudo => fase "); Escudo escudoDesbloqueado = EscudosManager.instance.GetEscudoDesbloqueableEnFase(mission.indexMision); if (escudoDesbloqueado != null) { // registrar el dialogo para mostrar el aviso de que se ha obtenido un nuevo escudo y desbloquearlo escudoDesbloqueado.bloqueado = false; DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.ESCUDO_DESBLOQUEADO, escudoDesbloqueado)); } } } if (firstShot) { firstShot = false; } UpdateEvent(); }
public TeamPage(Team t) { InitializeComponent(); BindingContext = t; PS = new PropertyService(); NS = new NotificationService(); TCS = new TeamCategoryService(); TMS = new TeamMemberService(); TS = new TeamService(); US = new UserService(); _userID = PS.GetUser().Id; if (IsAdmin(t.CreatorID)) { Edit_button.IsVisible = true; } else { if (NS.ExistsNotification(_userID, t.Id) || TMS.IsTeamMember(t.Id, _userID) || t.NumOfMembers == t.MaxMembers || TMS.GetRequests(t.Id, _userID) > 3) { SendRequest_button.IsVisible = false; } else { SendRequest_button.IsVisible = true; } if (TMS.IsTeamMember(t.Id, _userID)) { RemoveUser_button.IsVisible = true; } } //Ho assegnato il riferimento alle categorie del team team_categories = TCS.GetCategories(t.Id); CategoryLabel.Text = CategoryService.GetCategory(team_categories[0]) + " - " + DifficultyService.GetDifficulty(t.Difficulty); teamImage.Source = CategoryService.GetImage(team_categories[0]).Item1; foreach (TeamMemberButton b in CreateTMButtons(t)) { if (t.CreatorID == b._user.Id) { b.ChangeButtonColor(Color.FromHex("#A1A1A1"), Color.White); } teamMembersStack.Children.Add(b); } creationDateLabel.Text = "Created on " + t.CreationDate.Date.ToString("dd MMMM yyyy"); terminationDateLabel.Text = "Subscriptions end on " + t.TerminationDate.Date.ToString("dd MMMM yyyy"); }