public void HandleCrateClicked(ObjectiveProgress progress, UXButton btn) { if (this.currentlyClaiming) { return; } if (progress.State == ObjectiveState.Active) { ObjectiveVO vO = progress.VO; if (vO == null) { Service.Logger.ErrorFormat("ObjectiveVO does not exist, objectivData:", new object[] { progress.ObjectiveUid }); return; } string crateRewardUid = vO.CrateRewardUid; CrateInfoModalScreen crateInfoModalScreen = CrateInfoModalScreen.CreateForObjectiveProgressInfo(crateRewardUid, progress); crateInfoModalScreen.IsAlwaysOnTop = true; Service.ScreenController.AddScreen(crateInfoModalScreen, true, false); } else if (progress.State == ObjectiveState.Complete && !progress.ClaimAttempt) { this.currentlyClaiming = true; this.objectiveManager.Claim(progress); } }
public override void Progress(BaseGoalProcessor processor, int amount, object cookie) { if (Service.PlanetRelocationController.IsRelocationInProgress()) { return; } if (!this.processorMap.ContainsKey(processor)) { return; } EventManager eventManager = Service.EventManager; ObjectiveProgress objectiveProgress = this.processorMap[processor]; objectiveProgress.Count = Math.Min(objectiveProgress.Count + amount, objectiveProgress.Target); if (objectiveProgress.Count >= objectiveProgress.Target) { objectiveProgress.State = ObjectiveState.Complete; eventManager.SendEvent(EventId.UpdateObjectiveToastData, objectiveProgress); int objectiveProgressIndex = this.GetObjectiveProgressIndex(objectiveProgress.ObjectiveUid); eventManager.SendEvent(EventId.ObjectiveCompleted, objectiveProgressIndex); this.processorMap.Remove(processor); processor.Destroy(); } eventManager.SendEvent(EventId.ObjectivesUpdated, objectiveProgress); }
protected override void FillProcessorMap() { if (this.processorMap.Count > 0) { Service.Logger.Error("Attempting to fill an already-full processorMap!"); } CurrentPlayer currentPlayer = Service.CurrentPlayer; string planetId = currentPlayer.PlanetId; if (currentPlayer.Objectives.ContainsKey(planetId)) { ObjectiveGroup objectiveGroup = currentPlayer.Objectives[planetId]; int i = 0; int count = objectiveGroup.ProgressObjects.Count; while (i < count) { ObjectiveProgress objectiveProgress = objectiveGroup.ProgressObjects[i]; if (objectiveProgress.State == ObjectiveState.Active) { BaseGoalProcessor processor = GoalFactory.GetProcessor(objectiveProgress.VO, this); this.processorMap.Add(processor, objectiveProgress); } i++; } } }
public void RefreshScreenForPlanetChange() { if (!this.CanRefresh(this.player)) { this.objectivesPanel.Visible = false; if (this.objectiveController.ShouldShowObjectives()) { this.labelOperationsLocked.Visible = true; this.labelOperationsLocked.Text = this.lang.Get("NO_OBJECTIVES_AVAILABLE", new object[0]); } return; } if (!this.player.Objectives.ContainsKey(this.screen.viewingPlanetVO.Uid) || this.player.Objectives[this.screen.viewingPlanetVO.Uid].ProgressObjects.Count == 0) { this.objectivesPanel.Visible = false; this.labelOperationsLocked.Visible = true; this.labelOperationsLocked.Text = this.lang.Get("NO_OBJECTIVES_AVAILABLE", new object[0]); this.specialObjectiveIcon.Visible = false; this.specialObjectiveFrame.Visible = false; return; } this.objectiveController.GetTimeData(this.lang, this.player.Objectives[this.screen.viewingPlanetVO.Uid], ref this.tempIsGrace, ref this.tempTimeString); this.objectivesPanel.Visible = true; ObjectiveGroup objectiveGroup = this.player.Objectives[this.screen.viewingPlanetVO.Uid]; ObjectiveSeriesVO objectiveSeriesVO = Service.StaticDataController.Get <ObjectiveSeriesVO>(objectiveGroup.GroupSeriesId); this.specialObjectiveIcon.Visible = objectiveSeriesVO.SpecialEvent; this.specialObjectiveFrame.Visible = objectiveSeriesVO.SpecialEvent; if (objectiveSeriesVO.SpecialEvent) { this.specialObjectiveIcon.LoadTexture(objectiveSeriesVO.EventIcon); this.specialObjectiveFrame.LoadTexture(objectiveSeriesVO.EventPlayArt); this.labelObjectivesTitle.Text = Service.Lang.Get(objectiveSeriesVO.ObjectiveString, new object[0]); } else { this.labelObjectivesTitle.Text = Service.Lang.Get("OBJECTIVES", new object[0]); } int i = 0; int num = 3; while (i < num) { if (i >= objectiveGroup.ProgressObjects.Count) { this.data[i].Objective = null; this.data[i].BtnSupplyCrate.Visible = false; } else { ObjectiveProgress objective = objectiveGroup.ProgressObjects[i]; this.data[i].Objective = objective; this.data[i].BtnSupplyCrate.Visible = true; this.data[i].SpecailObjectiveFx.Visible = objectiveSeriesVO.SpecialEvent; this.objectiveController.UpdateObjectiveEntry(this.data[i], this.tempIsGrace); } i++; } this.OnViewClockTime(0f); }
public int GetObjectiveProgressIndex(string objectiveUid) { int num = 0; CurrentPlayer currentPlayer = Service.CurrentPlayer; string planetId = currentPlayer.PlanetId; ObjectiveGroup objectiveGroup = null; if (objectiveUid != null && planetId != null && currentPlayer.Objectives != null && currentPlayer.Objectives.TryGetValue(planetId, out objectiveGroup)) { int i = 0; int count = objectiveGroup.ProgressObjects.Count; while (i < count) { ObjectiveProgress objectiveProgress = objectiveGroup.ProgressObjects[i]; if (objectiveProgress.ObjectiveUid != null && objectiveProgress.ObjectiveUid == objectiveUid) { num = i + 1; break; } i++; } } if (num == 0) { Service.Logger.ErrorFormat("Failed to get Objective progressIndex for uid:{0}", new object[] { objectiveUid }); } return(num); }
public ObjectiveProgress GetNextCompletedObjective() { if (this.completedObjectiveProgress != null && this.completedObjectiveProgress.Count > 0) { ObjectiveProgress result = this.completedObjectiveProgress[0]; this.completedObjectiveProgress.RemoveAt(0); return(result); } return(null); }
private void OnPreviewIconClicked(UXButton button) { ObjectiveViewData objectiveViewData = button.Tag as ObjectiveViewData; ObjectiveProgress objective = objectiveViewData.Objective; if (objective.State == ObjectiveState.Complete) { this.objectiveController.HandleCrateClicked(objective, button); return; } this.OnObjectivesDetailsClicked(button); }
public void Claim(ObjectiveProgress objective) { objective.State = ObjectiveState.Rewarded; Service.EventManager.SendEvent(EventId.ObjectivesUpdated, null); ClaimObjectiveRequest request = new ClaimObjectiveRequest(Service.CurrentPlayer.PlayerId, objective.PlanetId, objective.ObjectiveUid); ClaimObjectiveCommand claimObjectiveCommand = new ClaimObjectiveCommand(request); claimObjectiveCommand.AddSuccessCallback(new AbstractCommand <PlayerIdRequest, CrateDataResponse> .OnSuccessCallback(base.ClaimCallback)); claimObjectiveCommand.AddFailureCallback(new AbstractCommand <PlayerIdRequest, CrateDataResponse> .OnFailureCallback(this.ClaimFailed)); claimObjectiveCommand.Context = objective; Service.ServerAPI.Sync(claimObjectiveCommand); }
public void SetObjectiverProgress(ObjectiveProgress objectiveProgress) { _objectiveProgress = objectiveProgress; _currentProgress = _objectiveProgress.Progress; _currentProgressValue = _objectiveProgress.ProgressValue(); _cellContent.SetActive(true); _descriptionLabel.text = _objectiveProgress.FullDescription(); _progressLabel.text = _currentProgress + "/" + _objectiveProgress.TargetValue(); _progressBarImage.fillAmount = _currentProgressValue; }
public void OnCrateClickedFromDetail(UXButton button) { ObjectiveViewData objectiveViewData = button.Tag as ObjectiveViewData; ObjectiveProgress objective = objectiveViewData.Objective; if (objective.State == ObjectiveState.Rewarded) { return; } this.HandleCrateClicked(objective, button); if (objective.State == ObjectiveState.Active) { string bILoggingMessageForCrates = this.GetBILoggingMessageForCrates(objective, "details"); Service.EventManager.SendEvent(EventId.ObjectiveLockedCrateClicked, bILoggingMessageForCrates); } }
public IEnumerator<float> UpdateNewObjectiveValues(ObjectiveProgress objectiveProgress) { for (float timer = 0; timer < _progressAnimationDuration; timer += Time.deltaTime) { float progress = timer / _progressAnimationDuration; _progressLabel.text = ((int)Mathf.Lerp(_currentProgress, objectiveProgress.Progress, progress)).ToString() + "/" + _objectiveProgress.TargetValue(); _progressBarImage.fillAmount = Mathf.Lerp(_currentProgressValue, objectiveProgress.ProgressValue(), progress); Debug.Log("progress: " + progress); yield return 0f; } _objectiveProgress = objectiveProgress; _currentProgress = _objectiveProgress.Progress; _currentProgressValue = _objectiveProgress.ProgressValue(); _progressLabel.text = _currentProgress + "/" + _objectiveProgress.TargetValue(); _progressBarImage.fillAmount = _currentProgressValue; }
private void DisplayCombatProgress(ObjectiveProgress progress) { if (progress == null) { return; } if (this.objectiveManager.GetGoalType(progress.VO) != GoalType.Loot) { Lang lang = Service.Lang; string text = lang.Get("FRACTION", new object[] { progress.Count, progress.Target }); Service.UXController.MiscElementsManager.ShowPlayerInstructions(progress.VO.Uid, lang.Get(progress.VO.ObjString, new object[] { text }), 1.5f, 0.5f); } }
public int GetCompletedObjectivesCount() { int num = 0; CurrentPlayer currentPlayer = Service.CurrentPlayer; foreach (KeyValuePair <string, ObjectiveGroup> current in currentPlayer.Objectives) { ObjectiveGroup value = current.Value; int i = 0; int count = value.ProgressObjects.Count; while (i < count) { ObjectiveProgress objectiveProgress = value.ProgressObjects[i]; if (objectiveProgress.State == ObjectiveState.Complete) { num++; } i++; } } return(num); }
private string GetBILoggingMessageForCrates(ObjectiveProgress progress, string location) { ObjectiveVO objectiveVO = Service.StaticDataController.Get <ObjectiveVO>(progress.ObjectiveUid); string value = string.Empty; PlanetDetailsScreen highestLevelScreen = Service.ScreenController.GetHighestLevelScreen <PlanetDetailsScreen>(); string value2 = string.Empty; if (highestLevelScreen != null) { ObjectiveGroup objectiveGroup = this.player.Objectives[highestLevelScreen.viewingPlanetVO.Uid]; value = objectiveGroup.GroupId; value2 = highestLevelScreen.viewingPlanetVO.PlanetBIName; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(value).Append("|"); stringBuilder.Append(objectiveVO.Uid).Append("|"); stringBuilder.Append(objectiveVO.CrateRewardUid).Append("|"); stringBuilder.Append(location).Append("|"); stringBuilder.Append(value2); return(stringBuilder.ToString()); }
public void Progress(AbstractObjectiveProcessor processor, int amount) { if (Service.Get <PlanetRelocationController>().IsRelocationInProgress()) { return; } if (!this.processorMap.ContainsKey(processor)) { return; } EventManager eventManager = Service.Get <EventManager>(); ObjectiveProgress objectiveProgress = this.processorMap[processor]; objectiveProgress.Count = Math.Min(objectiveProgress.Count + amount, objectiveProgress.Target); if (objectiveProgress.Count >= objectiveProgress.Target) { objectiveProgress.State = ObjectiveState.Complete; eventManager.SendEvent(EventId.UpdateObjectiveToastData, objectiveProgress); eventManager.SendEvent(EventId.ObjectiveCompleted, null); this.processorMap.Remove(processor); processor.Destroy(); } eventManager.SendEvent(EventId.ObjectivesUpdated, objectiveProgress); }
public static CrateInfoModalScreen CreateForObjectiveProgressInfo(string crateUid, ObjectiveProgress progress) { return(new CrateInfoModalScreen(crateUid, progress.PlanetId, progress.HQ) { ModalReason = CrateInfoReason.Reason_Info }); }
public void UpdateObjectiveEntry(ObjectiveViewData objectiveData, bool isGrace) { ObjectiveProgress objective = objectiveData.Objective; UXSprite spriteCheckmark = objectiveData.SpriteCheckmark; UXSprite spriteSupplyCrate = objectiveData.SpriteSupplyCrate; UXSprite spriteObjectiveIcon = objectiveData.SpriteObjectiveIcon; UXSprite spritePreview = objectiveData.SpritePreview; UXLabel statusLabel = objectiveData.StatusLabel; UXLabel titleLabel = objectiveData.TitleLabel; UXSlider progressSlider = objectiveData.ProgressSlider; UXSprite radialProgress = objectiveData.RadialProgress; UXLabel expiredLabel = objectiveData.ExpiredLabel; UXSprite spriteObjectiveExpired = objectiveData.SpriteObjectiveExpired; UXElement objectiveBgComplete = objectiveData.ObjectiveBgComplete; UXElement objectiveBgCollected = objectiveData.ObjectiveBgCollected; UXElement objectiveBgExpired = objectiveData.ObjectiveBgExpired; UXElement objectiveBgActive = objectiveData.ObjectiveBgActive; UXElement objectiveContainer = objectiveData.ObjectiveContainer; UXElement objectiveContainerLEI = objectiveData.ObjectiveContainerLEI; bool flag = objective.State == ObjectiveState.Complete || (objective.State == ObjectiveState.Active && !isGrace); Lang lang = Service.Lang; ObjectiveVO vO = objectiveData.Objective.VO; string crateRewardUid = vO.CrateRewardUid; CrateVO optional = Service.StaticDataController.GetOptional <CrateVO>(crateRewardUid); if (optional == null) { Service.Logger.ErrorFormat("The objective {0} specifies an invalid crateRewardUid {1}", new object[] { vO.Uid, crateRewardUid }); return; } string value = null; if (objectiveContainerLEI != null) { FactionType faction = Service.CurrentPlayer.Faction; if (faction != FactionType.Rebel) { if (faction == FactionType.Empire) { value = optional.EmpireLEIUid; } } else { value = optional.RebelLEIUid; } } if (objectiveBgCollected == null || objectiveContainer == null || objectiveContainerLEI == null || objectiveBgComplete == null || objectiveBgExpired == null) { Service.Logger.Error("ObjectiveViewData is initialized incompletely"); } else { ObjectiveState state = objective.State; if (state != ObjectiveState.Active) { if (state != ObjectiveState.Complete) { if (state == ObjectiveState.Rewarded) { objectiveBgCollected.Visible = true; objectiveBgExpired.Visible = false; objectiveContainer.Visible = false; objectiveContainerLEI.Visible = false; objectiveBgComplete.Visible = false; objectiveBgActive.Visible = false; } } else { objectiveBgComplete.Visible = true; objectiveBgExpired.Visible = false; objectiveContainer.Visible = false; objectiveContainerLEI.Visible = false; objectiveBgCollected.Visible = false; objectiveBgActive.Visible = false; } } else if (isGrace) { objectiveBgExpired.Visible = true; objectiveBgCollected.Visible = false; objectiveContainer.Visible = false; objectiveContainerLEI.Visible = false; objectiveBgComplete.Visible = false; objectiveBgActive.Visible = false; } else { objectiveContainerLEI.Visible = !string.IsNullOrEmpty(value); objectiveContainer.Visible = string.IsNullOrEmpty(value); objectiveBgActive.Visible = true; objectiveBgExpired.Visible = false; objectiveBgCollected.Visible = false; objectiveBgComplete.Visible = false; } } if (progressSlider != null) { if (objective.State == ObjectiveState.Complete || (objective.State == ObjectiveState.Active && !isGrace)) { progressSlider.Visible = true; progressSlider.Value = (float)objective.Count / (float)objective.Target; } else { progressSlider.Visible = false; } } if (radialProgress != null) { if (objective.State == ObjectiveState.Complete || (objective.State == ObjectiveState.Active && !isGrace)) { radialProgress.Visible = true; radialProgress.FillAmount = (float)objective.Count / (float)objective.Target; } else { radialProgress.Visible = false; } } if (expiredLabel != null) { expiredLabel.Visible = (isGrace && objective.State == ObjectiveState.Active); } if (spriteObjectiveExpired != null) { spriteObjectiveExpired.Visible = (isGrace && objective.State == ObjectiveState.Active); } if (statusLabel != null) { ObjectiveState state2 = objective.State; if (state2 != ObjectiveState.Active) { if (state2 != ObjectiveState.Complete) { if (state2 == ObjectiveState.Rewarded) { statusLabel.TextColor = ((!flag) ? ObjectiveController.TEXT_GREEN_DIM_COLOR : ObjectiveController.TEXT_GREEN_COLOR); statusLabel.Text = lang.Get("OBJECTIVE_COLLECTED", new object[] { lang.ThousandsSeparated(objective.Count), lang.ThousandsSeparated(objective.Target) }); } } else { statusLabel.TextColor = ((!flag) ? ObjectiveController.TEXT_GREEN_DIM_COLOR : ObjectiveController.TEXT_GREEN_COLOR); statusLabel.Text = lang.Get("OBJECTIVE_ACTIVE_UNLOCKED", new object[] { lang.ThousandsSeparated(objective.Count), lang.ThousandsSeparated(objective.Target) }); } } else if (isGrace) { statusLabel.TextColor = ObjectiveController.TEXT_RED_DIM_COLOR; statusLabel.Text = lang.Get("OBJECTIVE_EXPIRED", new object[0]); } else { statusLabel.TextColor = ((!flag) ? ObjectiveController.TEXT_GREEN_DIM_COLOR : ObjectiveController.TEXT_GREEN_COLOR); statusLabel.Text = lang.Get("OBJECTIVE_PROGRESS", new object[] { lang.ThousandsSeparated(objective.Count), lang.ThousandsSeparated(objective.Target) }); } } if (titleLabel != null) { titleLabel.Text = lang.Get(objective.VO.ObjString, new object[] { lang.ThousandsSeparated(objective.Target) }); titleLabel.TextColor = ((!flag) ? ObjectiveController.TEXT_GREY_COLOR : ObjectiveController.TEXT_WHITE_COLOR); } UXSprite uXSprite = null; UXSprite uXSprite2 = null; if (spriteSupplyCrate != null) { spriteSupplyCrate.Tag = objectiveData; uXSprite2 = spriteSupplyCrate; ObjectiveState state3 = objective.State; if (state3 != ObjectiveState.Active) { if (state3 != ObjectiveState.Complete) { if (state3 == ObjectiveState.Rewarded) { spriteCheckmark.Visible = true; spriteCheckmark.SpriteName = "IcoCheck"; spriteSupplyCrate.Alpha = 0.6f; spriteSupplyCrate.Visible = true; } } else { spriteCheckmark.Visible = false; spriteSupplyCrate.Alpha = 1f; spriteSupplyCrate.Visible = true; } } else { spriteCheckmark.Visible = false; spriteSupplyCrate.Visible = !isGrace; } } if (spritePreview != null) { spritePreview.Tag = objectiveData; ObjectiveState state4 = objective.State; if (state4 != ObjectiveState.Active) { if (state4 != ObjectiveState.Complete) { if (state4 == ObjectiveState.Rewarded) { uXSprite2 = spritePreview; uXSprite = null; spriteCheckmark.Visible = true; spriteCheckmark.SpriteName = "IcoCheck"; } } else { uXSprite2 = spritePreview; uXSprite = null; spriteCheckmark.Visible = false; } } else { uXSprite = spritePreview; uXSprite2 = null; spriteCheckmark.Visible = isGrace; spriteCheckmark.SpriteName = "icoCancelRed"; } } if (spriteObjectiveIcon != null) { uXSprite = spriteObjectiveIcon; } if (objectiveData.GeoControlCrate != null) { objectiveData.GeoControlCrate.Destroy(); } if (objectiveData.GeoControlIcon != null) { objectiveData.GeoControlIcon.Destroy(); } if (uXSprite2 != null) { ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(optional, uXSprite2); projectorConfig.AnimState = this.GetAnimStateFromObjectiveState(objectiveData.Objective.State); projectorConfig.AnimPreference = AnimationPreference.AnimationAlways; projectorConfig.Outline = (objective.State == ObjectiveState.Complete); projectorConfig.OutlineInner = GameConstants.CRATE_OUTLINE_INNER; projectorConfig.OutlineOuter = GameConstants.CRATE_OUTLINE_OUTER; objectiveData.GeoControlCrate = ProjectorUtils.GenerateProjector(projectorConfig); uXSprite2.Alpha = ((!flag) ? 0.5f : 1f); } if (uXSprite != null) { IGeometryVO iconVOFromObjective = GameUtils.GetIconVOFromObjective(objectiveData.Objective.VO, objectiveData.Objective.HQ); ProjectorConfig projectorConfig2 = ProjectorUtils.GenerateGeometryConfig(iconVOFromObjective, uXSprite); projectorConfig2.AnimPreference = AnimationPreference.AnimationPreferred; objectiveData.GeoControlIcon = ProjectorUtils.GenerateProjector(projectorConfig2); uXSprite.Alpha = ((!flag) ? 0.5f : 1f); } }
public static CrateInfoModalScreen CreateForObjectiveProgressInfo(string crateUid, ObjectiveProgress progress) { return(new CrateInfoModalScreen(crateUid, progress.PlanetId, progress.HQ, Service.CurrentPlayer.Faction, ArmoryUtils.PlayerHasArmory()) { ModalReason = CrateInfoReason.Reason_Info }); }