Beispiel #1
0
    // IGUIPAGEPLAYERSTATS INTERFACE

    void IGuiPagePlayerStats.Refresh(PlayerPersistantInfo ppi)
    {
        // collected values

        PPIPlayerStats stats = ppi.Statistics;

        PPIPlayerStats.GameData dm = stats.GetGameData(E_MPGameType.DeathMatch);
        PPIPlayerStats.GameData zc = stats.GetGameData(E_MPGameType.ZoneControl);

        // death match

        SetText("DMKills_Enum", dm.Kills.ToString());
        SetText("DMDeaths_Enum", dm.Deaths.ToString());
        SetText("DMGoldEarn_Enum", dm.Golds.ToString());
        SetText("DMMoneyEarn_Enum", dm.Money.ToString());
        SetText("DMXPEarn_Enum", dm.Experience.ToString());
        SetText("DMTotal_Enum", dm.Score.ToString());

        // zone control

        SetText("ZCKills_Enum", zc.Kills.ToString());
        SetText("ZCDeaths_Enum", zc.Deaths.ToString());
        SetText("ZCGoldEarn_Enum", zc.Golds.ToString());
        SetText("ZCMoneyEarn_Enum", zc.Money.ToString());
        SetText("ZCXPEarn_Enum", zc.Experience.ToString());
        SetText("ZCTotal_Enum", zc.Score.ToString());
    }
Beispiel #2
0
    public void MarkLastFinishedGame(bool winner)
    {
        PlayerData.Stats.Today.GamesFinished += 1;
        PlayerData.Stats.Today.GamesWon      += winner ? 1 : 0;

        int gameType = (int)Game.GetMultiplayerGameType();

        PPIPlayerStats.GameData gameData = PlayerData.Stats.Games[gameType];
        gameData.LastFinishedGameDate    = GuiBaseUtils.DateToEpoch(CloudDateTime.UtcNow);
        PlayerData.Stats.Games[gameType] = gameData;
        PlayerDataChanged = true;
    }
Beispiel #3
0
    public void EndOfRound()
    {
#if !DEADZONE_CLIENT
        RoundFinalResult result = new RoundFinalResult();         //gather final result and send it to client

        result.GameType = Server.Instance.GameInfo.GameType;
        result.Team     = Team;
        result.Place    = PPIManager.Instance.GetPPIList().FindIndex(ps => ps.Player == Player);

        if (Server.Instance.GameInfo.GameType == E_MPGameType.ZoneControl)
        {
            E_Team winner = Server.Instance.GameInfo.GetWinnerTeam();

            if (Team == winner)
            {
                AddExperience(GameplayRewards.ZC.Win, E_AddMoneyAction.ZoneControl);

                result.MissionExp  = (short)(GameplayRewards.ZC.Win * (IsPremiumAccountActive? GameplayRewards.PremiumAccountModificator : 1));
                result.MissioMoney = (short)(GameplayRewards.ZC.Win * GameplayRewards.MoneyModificator * (IsPremiumAccountActive? GameplayRewards.PremiumAccountModificator : 1));

                result.Winner = true;
            }
            else
            {
                AddExperience(GameplayRewards.ZC.Lost, E_AddMoneyAction.ZoneControl);

                result.MissionExp  = (short)(GameplayRewards.ZC.Lost * (IsPremiumAccountActive? GameplayRewards.PremiumAccountModificator : 1));
                result.MissioMoney = (short)(GameplayRewards.ZC.Lost * GameplayRewards.MoneyModificator * (IsPremiumAccountActive? GameplayRewards.PremiumAccountModificator : 1));
            }
        }
        else
        {
            int amount = 0;
            if (result.Place == 0)
            {
                amount = GameplayRewards.DM.First;
            }
            else if (result.Place == 1)
            {
                amount = GameplayRewards.DM.Second;
            }
            else if (result.Place == 2)
            {
                amount = GameplayRewards.DM.Third;
            }

            AddExperience(amount, E_AddMoneyAction.DM);

            result.MissionExp  = (short)(amount * (IsPremiumAccountActive? GameplayRewards.PremiumAccountModificator : 1));
            result.MissioMoney = (short)(amount * GameplayRewards.MoneyModificator * (IsPremiumAccountActive? GameplayRewards.PremiumAccountModificator : 1));

            result.Winner = result.Place < 3;
        }

        if (GetPlayerRankFromExperience(PlayerData.Params.Experience) != GetPlayerRankFromExperience(PlayerData.Params.Experience + Score.Experience))
        {
            result.NewRank = true;
        }

        if (IsFirstGameToday(Server.Instance.GameInfo.GameType))
        {        // FIRST RUN FOR TODAY .. Multiply !!!!
            result.FirstRound = true;
            Score.Experience *= 2;
            Score.Money      *= 2;
        }

        //check new rank after bonus
        if (!result.NewRank && GetPlayerRankFromExperience(PlayerData.Params.Experience) != GetPlayerRankFromExperience(PlayerData.Params.Experience + Score.Experience))
        {
            result.NewRank = true;
            AddMoney(GameplayRewards.MoneyRank, E_AddMoneyAction.Rank);
            Score.Money += GameplayRewards.MoneyRank;             //add money twice, because later they ore once substracted
        }

        result.Experience = Score.Experience;
        result.Money      = Score.Money;
        result.Gold       = Score.Gold;

        int gameType = (int)Game.GetMultiplayerGameType();
        PPIPlayerStats.GameData gameData = PlayerData.Stats.Games[gameType];
        gameData.Score         += Score.Score;
        gameData.Money         += Score.Money;
        gameData.Experience    += Score.Experience;
        gameData.Golds         += Score.Gold;
        gameData.Kills         += Score.Kills;
        gameData.Deaths        += Score.Deaths;
        gameData.Hits          += Score.Hits;
        gameData.Shots         += Score.Shots;
        gameData.Headshots     += Score.HeadShots;
        gameData.PlayedTimes   += Score.PlayedTimes;
        gameData.LastPlayedDate = Score.LastPlayedDate;
        gameData.TimeSpent     += Score.TimeSpent;

        PlayerData.Stats.Games[gameType] = gameData;

        foreach (var key in Score.WeaponStats.Keys)
        {
            int index = PlayerData.InventoryList.Weapons.FindIndex(p => p.ID == key);

            if (index >= 0)
            {
                PPIWeaponData weaponData = PlayerData.InventoryList.Weapons[index];
                PPIRoundScore.WeaponStatistics weaponStats = Score.WeaponStats[key];

                MFDebugUtils.Assert(weaponData.IsValid());

                weaponData.StatsFire  += weaponStats.StatsFire;
                weaponData.StatsHits  += weaponStats.StatsHits;
                weaponData.StatsKills += weaponStats.StatsKills;

                PlayerData.InventoryList.Weapons[index] = weaponData;
            }
        }

        foreach (var key in Score.ItemStats.Keys)
        {
            int index = PlayerData.InventoryList.Items.FindIndex(p => p.ID == key);

            if (index >= 0)
            {
                PPIItemData itemData = PlayerData.InventoryList.Items[index];
                PPIRoundScore.ItemStatistics itemStats = Score.ItemStats[key];

                MFDebugUtils.Assert(itemData.IsValid());

                itemData.StatsKills    += itemStats.StatsKills;
                itemData.StatsUseCount += itemStats.StatsUseCount;

                PlayerData.InventoryList.Items[index] = itemData;
            }
        }

        PlayerData.Stats.Today.Experience += Score.Experience;

        PlayerData.Params.Money      += Score.Money;
        PlayerData.Params.Experience += Score.Experience;
        PlayerData.Params.Gold       += Score.Gold;

        MarkLastFinishedGame(result.Winner);

        PlayerDataChanged = true;

        Server.Instance.SendEndRoundToClient(Player, result);
        //Debug.Log("End Round: " + Name + " exp"  + Score.Experience  + " money " + Score.Money + " experience new " + Experience + " experience old " + oldExperience);
#endif
    }
Beispiel #4
0
    // IGUIPAGEPLAYERSTATS INTERFACE

    void IGuiPagePlayerStats.Refresh(PlayerPersistantInfo ppi)
    {
        // collected values

        int            thisRankExperience = PlayerPersistantInfo.GetPlayerMinExperienceForRank(Mathf.Clamp(ppi.Rank, 1, PlayerPersistantInfo.MAX_RANK));
        int            nextRankExperience = PlayerPersistantInfo.GetPlayerMinExperienceForRank(Mathf.Clamp(ppi.Rank + 1, 1, PlayerPersistantInfo.MAX_RANK));
        PPIPlayerStats stats          = ppi.Statistics;
        float          totalTimeSpent = stats.GetTimeSpent();
        float          totalShots     = stats.GetShots();
        float          totalKills     = stats.GetKills();

        PPIPlayerStats.GameData dm = stats.GetGameData(E_MPGameType.DeathMatch);
        PPIPlayerStats.GameData zc = stats.GetGameData(E_MPGameType.ZoneControl);

        // computed values

        float computedKillRatio = totalTimeSpent > 0 ? totalKills / totalTimeSpent : 0.0f;
        int   computedAccurancy = totalShots > 0 ? Mathf.RoundToInt((stats.GetHits() / (float)totalShots) * 100) : 0;
        int   dmSpentMinutes    = Mathf.RoundToInt((float)System.TimeSpan.FromMinutes(dm.TimeSpent).TotalMinutes);
        int   dmSpentHours      = Mathf.RoundToInt((float)System.TimeSpan.FromMinutes(dm.TimeSpent).TotalHours);
        int   zcSpentMinutes    = Mathf.RoundToInt((float)System.TimeSpan.FromMinutes(zc.TimeSpent).TotalMinutes);
        int   zcSpentHours      = Mathf.RoundToInt((float)System.TimeSpan.FromMinutes(zc.TimeSpent).TotalHours);
        int   totalSpentMinutes = dmSpentMinutes + zcSpentMinutes;
        int   totalSpentHours   = dmSpentHours + zcSpentHours;

        int dmTimeSpentUnitTextId;

        if (dmSpentHours == 1)
        {
            dmTimeSpentUnitTextId = 01160038;
        }
        else if (dmSpentHours > 0)
        {
            dmTimeSpentUnitTextId = 01160019;
        }
        else if (dmSpentMinutes == 1)
        {
            dmTimeSpentUnitTextId = 01160039;
        }
        else
        {
            dmTimeSpentUnitTextId = 01160033;
        }

        int zcTimeSpentUnitTextId;

        if (zcSpentHours == 1)
        {
            zcTimeSpentUnitTextId = 01160038;
        }
        else if (zcSpentHours > 0)
        {
            zcTimeSpentUnitTextId = 01160019;
        }
        else if (zcSpentMinutes == 1)
        {
            zcTimeSpentUnitTextId = 01160039;
        }
        else
        {
            zcTimeSpentUnitTextId = 01160033;
        }

        int timeSpentUnitTextId;

        if (totalSpentHours == 1)
        {
            timeSpentUnitTextId = 01160035;
        }
        else if (totalSpentHours > 0)
        {
            timeSpentUnitTextId = 01160014;
        }
        else if (totalSpentMinutes == 1)
        {
            timeSpentUnitTextId = 01160037;
        }
        else
        {
            timeSpentUnitTextId = 01160036;
        }

        // rank

        GUIBase_MultiSprite rank = GuiBaseUtils.GetControl <GUIBase_MultiSprite>(Layout, "PlayerRankPic");

        rank.State = string.Format("Rank_{0}", Mathf.Min(ppi.Rank, rank.Count - 1).ToString("D2"));

        SetText("Rank_Enum", ppi.Rank.ToString("D2"));

        // experience

        SetText("XPEarned_Enum", ppi.Experience.ToString());
        SetText("XPLeft_Label", string.Format(TextDatabase.instance[1160015], Mathf.Max(0, nextRankExperience - ppi.Experience)));
        SetProgress("XPBarFg", "XPBarBg", ppi.Experience - thisRankExperience, nextRankExperience - thisRankExperience);

        // kills

        SetText("Kills_Enum", stats.GetKills().ToString());
        SetText("KillRatio_Enum", computedKillRatio.ToString("0.0"));

        // deaths

        SetText("Deaths_Enum", stats.GetDeaths().ToString());

        // score

        SetText("TotalScore_Enum", stats.GetScore().ToString());
        SetText("GoldEarned_Enum", stats.GetGolds().ToString());
        SetText("MoneyEarned_Enum", stats.GetMoney().ToString());
        SetText("Accuracy_Enum", computedAccurancy.ToString());
        SetText("Shotsfired_Enum", totalShots.ToString());
        SetText("Headshots_Enum", stats.GetHeadshots().ToString());

        // time spent

        SetText("TotalTime_Enum", totalSpentHours > 0 ? totalSpentHours.ToString() : totalSpentMinutes.ToString());
        SetText("TotalTime_Units", TextDatabase.instance[timeSpentUnitTextId]);
        SetText("DMTime_Enum", string.Format(TextDatabase.instance[dmTimeSpentUnitTextId], dmSpentHours > 0 ? dmSpentHours : dmSpentMinutes));
        SetText("ZCTime_Enum", string.Format(TextDatabase.instance[zcTimeSpentUnitTextId], zcSpentHours > 0 ? zcSpentHours : zcSpentMinutes));
    }