示例#1
0
    public void ConsumableItemUsed(E_ItemID id)
    {
        int index = PlayerData.InventoryList.Items.FindIndex(p => p.ID == id);

        if (index < 0)
        {
            return;
        }

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

        MFDebugUtils.Assert(itemData.IsValid());

        itemData.Count--;
        PlayerData.InventoryList.Items[index] = itemData;

        if (uLink.Network.isServer)
        {
            //SEND TO CLOUD !!!!
            ItemSettings settings = ItemSettingsManager.Instance.Get(id);

            CloudServices.GetInstance()
            .ModifyItem(PrimaryKey,
                        PPIManager.ProductID,
                        settings.GUID,
                        "Count",
                        itemData.Count.ToString(),
                        CloudConfiguration.DedicatedServerPasswordHash);
        }
    }
示例#2
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
    }