// PRIVATE METHODS void UpdateResultLabel() { PlayerPersistantInfo ppi = PPIManager.Instance.GetLocalPlayerPPI(); if (ppi == null) { return; } Client.GameInfo gameInfo = Client.Instance.GameState; if (gameInfo == null) { return; } string text = string.Empty; bool winner = false; if (gameInfo.GameType == E_MPGameType.ZoneControl) { E_Team enemy = ppi.Team == E_Team.Good ? E_Team.Bad : E_Team.Good; int ourScore = gameInfo.ZCInfo.TeamScore[ppi.Team]; int enemyScore = gameInfo.ZCInfo.TeamScore[enemy]; winner = ourScore > enemyScore ? true : false; int[] textIds = winner ? m_YouWonTextIds : m_YouLoseTextIds; int textId = textIds[Random.Range(0, textIds.Length)]; text = TextDatabase.instance[textId]; } else { List <PlayerPersistantInfo> players = PPIManager.Instance.GetPPIList(); // sort players players.Sort((x, y) => { // descending by score int res = y.Score.Score.CompareTo(x.Score.Score); if (res == 0) { // descending by kills res = y.Score.Kills.CompareTo(x.Score.Kills); if (res == 0) { // increasing by deaths res = x.Score.Deaths.CompareTo(y.Score.Deaths); if (res == 0) { // increasing by names res = x.Name.CompareTo(y.Name); } } } return(res); }); int idx = players.FindIndex(obj => obj.PrimaryKey == ppi.PrimaryKey); winner = idx == 0 ? true : false; text = winner == true ? TextDatabase.instance[00502089] : string.Format(TextDatabase.instance[00502090], PlaceToString(idx + 1)); } m_WinDialog.Update(winner, text, CloudUser.instance.isPremiumAccountActive); m_LoseDialog.Update(!winner, text, CloudUser.instance.isPremiumAccountActive); }
protected override void OnShow() { base.OnShow(); int bonusXp = 0; int bonusMoney = 0; GUIBase_Widget widget = null; Client.GameInfo gameInfo = Client.Instance.GameState; if (gameInfo != null) { if (gameInfo.GameType == E_MPGameType.ZoneControl) { PlayerPersistantInfo ppi = PPIManager.Instance.GetLocalPPI(); if (ppi != null) { E_Team enemy = ppi.Team == E_Team.Good ? E_Team.Bad : E_Team.Good; int ourScore = gameInfo.ZCInfo.TeamScore[ppi.Team]; int enemyScore = gameInfo.ZCInfo.TeamScore[enemy]; m_ZoneControl.State = ourScore <= enemyScore ? "Lose" : "Win"; widget = m_ZoneControl.Widget; bonusXp = ourScore <= enemyScore ? GameplayRewards.ZC.Lost : GameplayRewards.ZC.Win; } } else { PlayerPersistantInfo ppi = PPIManager.Instance.GetLocalPPI(); List <PlayerPersistantInfo> list = new List <PlayerPersistantInfo>(PPIManager.Instance.GetPPIList()); list.Sort(ComparePPIsByScore); int max = Mathf.Min(list.Count, m_DeathMatch.Length); int idx = 0; for (; idx < max; ++idx) { if (list[idx].Player == ppi.Player) { widget = m_DeathMatch[idx]; break; } } switch (idx) { case 0: bonusXp = GameplayRewards.DM.First; break; case 1: bonusXp = GameplayRewards.DM.First; break; case 2: bonusXp = GameplayRewards.DM.First; break; default: break; } } } if (CloudUser.instance.isPremiumAccountActive == true) { bonusXp = Mathf.RoundToInt(bonusXp * GameplayRewards.PremiumAccountModificator); } bonusMoney = Mathf.RoundToInt(bonusXp * GameplayRewards.MoneyModificator); GuiBaseUtils.GetControl <GUIBase_Label>(Owner.Layout, "BonusXp_Label") .SetNewText(string.Format(TextDatabase.instance[0502073], bonusXp.ToString())); GuiBaseUtils.GetControl <GUIBase_Label>(Owner.Layout, "BonusMoney_Label") .SetNewText(string.Format(TextDatabase.instance[0502074], bonusMoney.ToString())); if (widget != null) { widget.ShowImmediate(true, true); } }