private void RefreshParticipantHistogram(AgeTransform tableitem, EmpireInfo empireInfo, int index) { EmpireInfo empireInfo2 = this.EmpireInfos.FirstOrDefault((EmpireInfo iterator) => iterator.IsActiveOrLocalPlayer); int observerIndex = -1; if (empireInfo2 != null) { observerIndex = empireInfo2.EmpireIndex; } if (this.IsEmpireVisible(empireInfo, observerIndex)) { tableitem.Visible = true; AgePrimitiveHistogramLinear component = tableitem.GetComponent <AgePrimitiveHistogramLinear>(); component.TintColor = empireInfo.FactionColor; Snapshot[] snapshots = this.Snapshot.Snapshots; float[] array = new float[snapshots.Length]; for (int i = 0; i < snapshots.Length; i++) { string name = string.Format("Turn #{0}", i); Snapshot snapshot; Snapshot snapshot2; if (this.Snapshot.TryGetSnapshot(name, out snapshot) && snapshot.TryGetSnapshot(empireInfo.EmpireName, out snapshot2)) { snapshot2.TryRead(this.CurrentScoreDefinition.Name, out array[i]); } } component.Values = array; } else { tableitem.Visible = false; } }
private void OnQuitResult(object sender, MessagePanelResultEventArgs e) { if (e.Result == MessagePanelResult.Yes) { IRuntimeService service = Services.GetService <IRuntimeService>(); if (service != null) { ISessionService service2 = Services.GetService <ISessionService>(); Diagnostics.Assert(service2 != null); Diagnostics.Assert(service2.Session != null); Diagnostics.Assert(service.Runtime != null); Diagnostics.Assert(service.Runtime.FiniteStateMachine != null); if (!TutorialManager.IsActivated) { int lobbyData = service2.Session.GetLobbyData <int>("NumberOfMajorFactions", 0); EmpireInfo[] array = new EmpireInfo[lobbyData]; for (int i = 0; i < lobbyData; i++) { array[i] = EmpireInfo.Read(service2.Session, i); } service.Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_OutGame), new object[] { "GameEnded", array }); } else { service.Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_OutGame), new object[0]); } } } }
protected override IEnumerator OnShow(params object[] parameters) { yield return(base.OnShow(parameters)); ISessionService service = Services.GetService <ISessionService>(); int lobbyData = service.Session.GetLobbyData <int>("NumberOfMajorFactions", 0); this.scoreGraphsPanel.HideUnknownEmpires = true; EmpireInfo[] array = new EmpireInfo[lobbyData]; for (int i = 0; i < lobbyData; i++) { array[i] = EmpireInfo.Read(service.Session, i); if (array[i].IsActiveOrLocalPlayer && array[i].EmpireEliminated) { this.scoreGraphsPanel.HideUnknownEmpires = false; } } Services.GetService <IEndTurnService>().GameClientStateChange += this.EndTurnService_GameClientStateChange; DepartmentOfForeignAffairs agency = base.PlayerController.Empire.GetAgency <DepartmentOfForeignAffairs>(); if (agency != null) { agency.DiplomaticRelationStateChange += this.DepartmentOfForeignAffairs_DiplomaticRelationStateChange; } this.scoreGraphsPanel.Show(new object[] { array }); this.RefreshContent(); yield break; }
private void RefreshParticipantScoreLine(AgeTransform tableitem, EmpireInfo empireInfo, int index) { tableitem.SetupCustomELCPScaling(this.ParticipantsScoreTableScale); if (this.visibleEmpires.Contains(empireInfo.EmpireIndex)) { tableitem.Visible = true; ParticipantScoreLine component = tableitem.GetComponent <ParticipantScoreLine>(); component.ParticipantName.AgeTransform.SetupCustomELCPScaling(this.ParticipantsScoreTableScale); component.ParticipantScore.AgeTransform.SetupCustomELCPScaling(this.ParticipantsScoreTableScale); component.ParticipantLogoBackground.TintColor = empireInfo.FactionColor; component.ParticipantName.Text = empireInfo.LocalizedName; GuiFaction guiFaction = new GuiFaction(empireInfo.Faction); component.ParticipantLogo.Image = guiFaction.GetImageTexture(GuiPanel.IconSize.LogoLarge, true); Snapshot[] snapshots = this.Snapshot.Snapshots; string name = string.Format("Turn #{0}", snapshots.Length - 1); Snapshot snapshot; Snapshot snapshot2; if (this.Snapshot.TryGetSnapshot(name, out snapshot) && snapshot.TryGetSnapshot(empireInfo.EmpireName, out snapshot2)) { float num; snapshot2.TryRead(this.CurrentScoreDefinition.Name, out num); string str = ""; int decimals = 0; component.ParticipantScore.WordWrap = false; if (num >= 1000f) { str = "k"; if (num <= 10000f) { num = Mathf.Round(num / 100f); num /= 10f; decimals = 1; } else if (num <= 999999f) { num = Mathf.Round(num / 1000f); } else if (num <= 9999999f) { num = Mathf.Round(num / 100000f); num /= 10f; str = "M"; decimals = 1; } else if (num > 9999999f) { num = Mathf.Round(num / 1000000f); str = "M"; } } component.ParticipantScore.Text = GuiFormater.FormatGui(num, false, false, false, decimals) + str; return; } } else { tableitem.Visible = false; } }
private void CalculateELCPScaling() { this.visibleEmpires.Clear(); this.ParticipantsScoreTableScale = 1f; float num = (!AgeUtils.HighDefinition) ? 32f : (32f * AgeUtils.HighDefinitionFactor); float num2 = (!AgeUtils.HighDefinition) ? 4f : (4f * AgeUtils.HighDefinitionFactor); float num3 = (!AgeUtils.HighDefinition) ? 50f : (50f * AgeUtils.HighDefinitionFactor); EmpireInfo empireInfo = this.EmpireInfos.FirstOrDefault((EmpireInfo iterator) => iterator.IsActiveOrLocalPlayer); int observerIndex = -1; if (empireInfo != null) { observerIndex = empireInfo.EmpireIndex; } foreach (EmpireInfo empireInfo2 in this.EmpireInfos) { if (this.IsEmpireVisible(empireInfo2, observerIndex)) { this.visibleEmpires.Add(empireInfo2.EmpireIndex); } } if (this.visibleEmpires.Count > 8 && this.visibleEmpires.Count < 11) { this.ParticipantsScoreTableScale = 0.82f; } if (this.visibleEmpires.Count > 10) { this.ParticipantsScoreTableScale = 0.7f; num2 *= 0.5f; num3 *= 0.6f; } num *= this.ParticipantsScoreTableScale; this.ParticipantsScoreTable.HorizontalSpacing = num; this.ParticipantsScoreTable.VerticalSpacing = num2; this.ParticipantsScoreTable.PixelMarginLeft = num3; }
private bool IsEmpireVisible(EmpireInfo empireInfo, int observerIndex = -1) { if (!this.HideUnknownEmpires) { return(true); } bool flag = false; IGameService service = Services.GetService <IGameService>(); if (service != null && service.Game != null) { IPlayerControllerRepositoryService service2 = service.Game.Services.GetService <IPlayerControllerRepositoryService>(); if (service2 != null && service2.ActivePlayerController != null && service2.ActivePlayerController.Empire != null && service2.ActivePlayerController.Empire.Index == empireInfo.EmpireIndex) { flag = true; } } else if (!string.IsNullOrEmpty(empireInfo.Players)) { Steamworks.SteamUser steamUser = Steamworks.SteamAPI.SteamUser; if (steamUser != null) { flag = empireInfo.Players.Contains(steamUser.SteamID.ToString()); } } if (flag) { return(true); } if (observerIndex != -1) { switch (EmpireInfo.LastAccessibilityLevel) { case EmpireInfo.Accessibility.Default: { int num = empireInfo.EmpireExplorationBits & 1 << observerIndex; if (num != 0) { return(true); } int num2 = empireInfo.EmpireInfiltrationBits & 1 << observerIndex; if (num2 != 0) { return(true); } break; } case EmpireInfo.Accessibility.None: return(false); case EmpireInfo.Accessibility.Partial: { int num3 = empireInfo.EmpireInfiltrationBits & 1 << observerIndex; if (num3 != 0) { return(true); } break; } } } return(false); }