void earthwatcherRequest_LandReassignedByPlayingRegion(object sender, EventArgs e) { Land land = sender as Land; try { if (land != null) { //Cambios en memoria de lands var oldLand = Current.Instance.Lands.Where(x => x.Id == Current.Instance.Earthwatcher.Lands.FirstOrDefault().Id).FirstOrDefault(); if (oldLand != null) { //Si no está en amarillo o en verde la saco if (oldLand.LandStatus != LandStatus.Alert && oldLand.LandStatus != LandStatus.Ok) { Current.Instance.Lands.Remove(oldLand); Current.Instance.LandInView.Remove(oldLand); } else { //Si es amarilla o verde la paso a greenpeace oldLand.EarthwatcherId = Configuration.GreenpeaceId; oldLand.EarthwatcherName = Configuration.GreenpeaceName; oldLand.IsPowerUser = true; } //Saco del current instance del Ew la land que quiero cambiar var oldEarthwatcherLand = Current.Instance.Earthwatcher.Lands.Where(x => x.Id == oldLand.Id).FirstOrDefault(); Current.Instance.Earthwatcher.Lands.Remove(oldEarthwatcherLand); } //si la land que me asignaron no esta en el current instance de lands, la agrega y se la agrega al Ew if (!Current.Instance.Lands.Any(x => x.Id == land.Id)) { Current.Instance.Lands.Add(land); Current.Instance.Earthwatcher.Lands.Add(land); } //Actualizo en memoria la nueva region Current.Instance.Region = _selectedRegion; var hexagonLayer = Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername) as Earthwatchers.UI.Layers.HexagonLayer; if (hexagonLayer != null) { hexagonLayer.AddHexagon(land); } if (land.IsTutorLand) //Is Tutor Land - All region is complete { //Muestro el mensaje, Deshabilito mi parcela NotificationsWindow notificationsWindow = new NotificationsWindow(ActionPoints.Action.RegionCompleted.ToString()); notificationsWindow.Show(); } } } catch (Exception ex) { } finally { //Traigo nuevamente las lands para el pais que estoy jugando landRequests.GetAll(Current.Instance.Earthwatcher.Id, Current.Instance.Earthwatcher.PlayingRegion); Earthwatcher earthwatcher = Current.Instance.Earthwatcher; if (land == null) { MessageBox.Show(Labels.NoMoreLands); ChangeCompleted(this, EventArgs.Empty); } else { //Logueo el cambio de pais de juego MapHelper.ZoomToHexagon(Current.Instance.MapControl, land.GeohexKey); Current.Instance.AddScore.Add(new Score(earthwatcher.Id, ActionPoints.Action.PlayingRegionChanged.ToString(), ActionPoints.Points(ActionPoints.Action.PlayingRegionChanged), earthwatcher.PlayingRegion, Current.Instance.PrecisionScore, earthwatcher.Lands.FirstOrDefault().Id)); // Recibe el evento en mainpage y le asigna el puntaje ChangeCompleted(this, EventArgs.Empty); } } }
void earthwatcherRequest_LandReassignedByPlayingRegion(object sender, EventArgs e) { Land land = sender as Land; try { if (land != null) { //Cambios en memoria de lands var oldLand = Current.Instance.Lands.Where(x => x.Id == Current.Instance.Earthwatcher.Lands.FirstOrDefault().Id).FirstOrDefault(); if (oldLand != null) { //Si no está en amarillo o en verde la saco if (oldLand.LandStatus != LandStatus.Alert && oldLand.LandStatus != LandStatus.Ok) { Current.Instance.Lands.Remove(oldLand); Current.Instance.LandInView.Remove(oldLand); } else { //Si es amarilla o verde la paso a greenpeace oldLand.EarthwatcherId = Configuration.GreenpeaceId; oldLand.EarthwatcherName = Configuration.GreenpeaceName; oldLand.IsPowerUser = true; } //Saco del current instance del Ew la land que quiero cambiar var oldEarthwatcherLand = Current.Instance.Earthwatcher.Lands.Where(x => x.Id == oldLand.Id).FirstOrDefault(); Current.Instance.Earthwatcher.Lands.Remove(oldEarthwatcherLand); } //si la land que me asignaron no esta en el current instance de lands, la agrega y se la agrega al Ew if (!Current.Instance.Lands.Any(x => x.Id == land.Id)) { Current.Instance.Lands.Add(land); Current.Instance.Earthwatcher.Lands.Add(land); } //Actualizo en memoria la nueva region Current.Instance.Region = _selectedRegion; var hexagonLayer = Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername) as Earthwatchers.UI.Layers.HexagonLayer; if (hexagonLayer != null) hexagonLayer.AddHexagon(land); if (land.IsTutorLand) //Is Tutor Land - All region is complete { //Muestro el mensaje, Deshabilito mi parcela NotificationsWindow notificationsWindow = new NotificationsWindow(ActionPoints.Action.RegionCompleted.ToString()); notificationsWindow.Show(); } } } catch (Exception ex) { } finally { //Traigo nuevamente las lands para el pais que estoy jugando landRequests.GetAll(Current.Instance.Earthwatcher.Id, Current.Instance.Earthwatcher.PlayingRegion); Earthwatcher earthwatcher = Current.Instance.Earthwatcher; if (land == null) { MessageBox.Show(Labels.NoMoreLands); ChangeCompleted(this, EventArgs.Empty); } else { //Logueo el cambio de pais de juego MapHelper.ZoomToHexagon(Current.Instance.MapControl, land.GeohexKey); Current.Instance.AddScore.Add(new Score(earthwatcher.Id, ActionPoints.Action.PlayingRegionChanged.ToString(), ActionPoints.Points(ActionPoints.Action.PlayingRegionChanged), earthwatcher.PlayingRegion, Current.Instance.PrecisionScore, earthwatcher.Lands.FirstOrDefault().Id)); // Recibe el evento en mainpage y le asigna el puntaje ChangeCompleted(this, EventArgs.Empty); } } }
//SignalR Handlers void signalRClient_NotificationReceived(object sender, NotificationReceivedEventArgs e) { //Si alguien tomo la parcela de este usuario conectado if (e.Data.M == "LandChanged") { //Logueo el Land Changed //Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.Log.ToString(), ActionPoints.Points(ActionPoints.Action.Log), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore, null, null, "Llega a signalRClient_NotificationReceived POR LandChanged")); AddPoints(Current.Instance.AddScore); if (!Current.Instance.Earthwatcher.Id.ToString().Equals(e.Data.A.Last()) && Current.Instance.Earthwatcher.Lands.Any(x => x.GeohexKey.Equals(e.Data.A.First()))) { NotificationsWindow notificationsWindow = new NotificationsWindow("ChangeLand"); notificationsWindow.LandReassigned += notificationsWindow_LandReassigned; notificationsWindow.Show(); } } else if (e.Data.M == ActionPoints.Action.LandVerified.ToString()) { if (Current.Instance.Earthwatcher.Id.ToString().Equals(e.Data.A.First())) { NotificationsWindow notificationsWindow = new NotificationsWindow(ActionPoints.Action.LandVerified.ToString()); notificationsWindow.LandVerified += notificationsWindow_LandVerified; notificationsWindow.Show(); } } else if (e.Data.M == "updateUsersOnlineCount") { this.StatsControl.UpdateOnlineUsers(e.Data.A.First()); } else if (e.Data.M == "FindTheJaguar") { int jagPosId = Convert.ToInt32(e.Data.A.First()); JaguarGameInitialize(jagPosId); } else if (e.Data.M == "JaguarFound") { JaguarGameFinalize(); if (e.Data.A.Last() != Current.Instance.Earthwatcher.Id.ToString()) { ShowFindTheJaguarFoundPopUp(e.Data.A.First()); } } else if (e.Data.M == "FindTheJaguarFinished") { JaguarGameFinalize(); } }
private void LandChanged(Land land) { selectedLand = land; bool openPoll = true; if (land == null) return; if (!Current.Instance.TutorialStarted) { //Chequeo Scoring para abrir Modals var logins = Current.Instance.RegionScores.Where(x => x.Action.Equals(ActionPoints.Action.Login.ToString())).OrderByDescending(x => x.Published); Score lastLogin = null; if (logins.Count() > 1) { lastLogin = logins.Skip(1).First(); } if (lastLogin != null) { if (Current.Instance.RegionScores.Any(x => x.Action.Equals("DemandAuthoritiesApproved") && x.Published > lastLogin.Published)) { NotificationsWindow notificationsWindow = new NotificationsWindow("DemandAuthoritiesApproved"); notificationsWindow.Show(); openPoll = false; } if (selectedLand.LastReset > lastLogin.Published) { NotificationsWindow notificationsWindow = new NotificationsWindow("NewLand"); notificationsWindow.Show(); openPoll = false; } } var last2 = Current.Instance.RegionScores.OrderByDescending(x => x.Published).Take(2); if (last2.Any(x => x.Action.Equals(ActionPoints.Action.LandVerified.ToString())) && !last2.Any(x => x.Action.Equals(ActionPoints.Action.LandVerifiedInformed.ToString()))) { NotificationsWindow notificationsWindow = new NotificationsWindow(ActionPoints.Action.LandVerifiedInformed.ToString()); notificationsWindow.Show(); openPoll = false; } // //DESCOMENTAR ESTO PARA HABILITAR LAS POLLS // //Si el ultimo login es de más de 2 horas, abrir el poll // if (openPoll && lastLogin != null && DateTime.UtcNow.AddHours(-2) >= lastLogin.Published) // { // //TODO: DB. verificar con lucas // //agrego como condicion final que el feature de poll este desbloqueado. // if (Current.Instance.Features.IsUnlocked(EwFeature.Polls)) // { // landRequest.GetVerifiedLandsGeoHexCodes(Current.Instance.Earthwatcher.Id, true); // } // } } if (!Current.Instance.TutorialStarted || Current.Instance.TutorialCurrentStep < 4) { var hexagonLayer = Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername) as HexagonLayer; if (hexagonLayer != null) hexagonLayer.AddHexagon(selectedLand); //Inicializar fincas paito var basecampLayer = Current.Instance.LayerHelper.FindLayer(Constants.BasecampsLayer) as BasecampLayer; if (basecampLayer != null) basecampLayer.LoadData(); } if (string.IsNullOrEmpty(geohexcode)) { if (!string.IsNullOrEmpty(land.GeohexKey)) { MapHelper.ZoomToHexagon(Current.Instance.MapControl, land.GeohexKey); } else { MapHelper.ZoomToHexagon(Current.Instance.MapControl, "NY8582044"); // Hack: Si viene nulo por algun motivo lo mando a la land del tutor(siempre verde, lockeada) //MessageBox.Show("TEST: MAPA CHICO, LLENDO A PARCELA DEL TUTOR"); } } else { MapHelper.ZoomToHexagon(Current.Instance.MapControl, "NY8582044"); } //Si tengo la land del tutor / No hay mas parcelas - Deshabilito el boton "Mi parcela" y "Cambiar Parcela" y muestro el msj if (!Current.Instance.TutorialStarted && Current.Instance.Earthwatcher.Lands.FirstOrDefault().IsTutorLand) { //Muestro el mensaje NotificationsWindow notificationsWindow = new NotificationsWindow(ActionPoints.Action.RegionCompleted.ToString()); notificationsWindow.Show(); this.newPlotDiv.IsHitTestVisible = false; this.newPlotDiv.Opacity = 0.2; this.myPlotDiv.IsHitTestVisible = false; this.myPlotDiv.Opacity = 0.2; } else { this.newPlotDiv.IsHitTestVisible = true; this.newPlotDiv.Opacity = 1; this.myPlotDiv.IsHitTestVisible = true; this.myPlotDiv.Opacity = 1; } }
private void reshuffleButton_click(object sender, MouseButtonEventArgs e) { NewPlotHooverOff(null, null); NotificationsWindow notificationsWindow = new NotificationsWindow(ActionPoints.Action.LandReassigned.ToString()); notificationsWindow.LandReassigned += notificationsWindow_LandReassigned; notificationsWindow.Show(); }