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 }
// Use this for initialization protected virtual void Activate() { // Debug.Log(gameObject.name + "CW activate"); PlayerPersistantInfo ppi = PPIManager.Instance.GetPPI(Owner.NetworkView.owner); //Debug.Log(ppi.EquipList.SelectedWeapon); /*if(ppi.EquipList.SelectedWeapon != E_WeaponID.None) * CurrentWeapon = ppi.EquipList.SelectedWeapon;*/ if (Owner.BlackBoard.ProxyDataForSpawn.IsValid) { CurrentWeapon = Owner.BlackBoard.ProxyDataForSpawn.CurrentWeapon; } else { //else find first weapon (it suck, because slot could be empty) for (int i = 0; i < 3 && CurrentWeapon == E_WeaponID.None; i++) { PPIWeaponData d = ppi.EquipList.Weapons.Find(ps => ps.EquipSlotIdx == i); if (d.IsValid() == false) { continue; } CurrentWeapon = d.ID; break; } } foreach (PPIWeaponData winfo in ppi.EquipList.Weapons) { if (winfo.ID == E_WeaponID.None) { continue; } //Debug.Log("add weapon " + winfo.ID); AddWeapon(winfo.ID); if (CurrentWeapon == E_WeaponID.None) { CurrentWeapon = winfo.ID; } } AddWeaponToOwnerHand(Weapons[CurrentWeapon]); Owner.WorldState.SetWSProperty(E_PropKey.WeaponLoaded, GetCurrentWeapon().ClipAmmo > 0); //change FOV if desired if (uLink.Network.isClient && Owner.NetworkView.isMine) { float newFOV = GameCamera.Instance.DefaultFOV; if (Owner.IsInCover) { newFOV *= Owner.WeaponComponent.GetCurrentWeapon().CoverFovModificator; } GameCamera.Instance.SetFov(newFOV, 60); } }