public void AddWeaponUse(E_WeaponID id) { int index = PlayerData.InventoryList.Weapons.FindIndex(p => p.ID == id); if (index < 0) { return; } PPIRoundScore.WeaponStatistics weaponStats; try { weaponStats = Score.WeaponStats[id]; weaponStats.StatsFire++; } catch (KeyNotFoundException) { weaponStats = new PPIRoundScore.WeaponStatistics(); weaponStats.StatsFire = 1; } Score.WeaponStats[id] = weaponStats; Score.Shots++; }
public void AddWeaponHit(E_WeaponID id) { if (PlayerData.InventoryList.Weapons.FindIndex(p => p.ID == id) < 0) { return; } PPIRoundScore.WeaponStatistics weaponStats; try { weaponStats = Score.WeaponStats[id]; weaponStats.StatsHits++; } catch (KeyNotFoundException) { weaponStats = new PPIRoundScore.WeaponStatistics(); weaponStats.StatsHits = 1; } Score.WeaponStats[id] = weaponStats; Score.Hits++; // Debug.Log("Weapon hit " + PlayerData.InventoryList.Weapons[index].ToString() + " " + PlayerData.Stats.Games[gameType].ToString()); }
public void AddWeaponKill(E_WeaponID id, E_BodyPart bodyPart, int num = 1) { if (uLink.Network.isServer == false) { throw new uLink.NetworkException("AddWeaponKill: could be called only on server"); } int index = PlayerData.InventoryList.Weapons.FindIndex(p => p.ID == id); if (index < 0) { return; } PPIWeaponData weaponData = PlayerData.InventoryList.Weapons[index]; //DebugUtils.Assert( weaponData.IsValid() ); // nemusi byt validni napriklad pri pouziti itemu se spatne nastavenym ID itemu (takze se vola WeaponKill na zadanou zbran) if (weaponData.IsValid()) { PPIRoundScore.WeaponStatistics weaponStats; try { weaponStats = Score.WeaponStats[id]; weaponStats.StatsKills += num; } catch (KeyNotFoundException) { weaponStats = new PPIRoundScore.WeaponStatistics(); weaponStats.StatsKills = num; } Score.WeaponStats[id] = weaponStats; } else { Debug.LogError("AddWeaponKill() with weapon '" + id + "' : weapon not found"); } Score.HeadShots += bodyPart == E_BodyPart.Head ? 1 : 0; // Debug.Log("Weapon kill " + PlayerData.InventoryList.Weapons[index].ToString() + " " + PlayerData.Stats.Games[(int)Game.GetMultiplayerGameType()].ToString()); }
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 }