void RpcDoDamage(int damage, string wn, Vector3 direction, int viewID, bool fromBot, bool ishead) { if (Agent.death) { return; } Health -= damage; if (LastActorEnemy != viewID) { Agent.personal = false; } LastActorEnemy = viewID; if (PhotonNetwork.IsMasterClient) { Agent.OnGetHit(direction); } if (viewID == bl_GameManager.m_view)//if was me that make damage { bl_UCrosshair.Instance.OnHit(); } if (Health > 0) { Transform t = bl_GameManager.Instance.FindActor(viewID); if (t != null) { if (Agent.Target == null) { Agent.personal = true; Agent.Target = t; } else { if (t != Agent.Target) { float cd = bl_UtilityHelper.Distance(transform.position, Agent.Target.position); float od = bl_UtilityHelper.Distance(transform.position, t.position); if (od < cd && (cd - od) > 7) { Agent.personal = true; Agent.Target = t; } } } } AIAnim.OnGetHit(); } else { Agent.death = true; Agent.enabled = false; Agent.Agent.isStopped = true; GetComponent <bl_DrawName>().enabled = false; bl_AIShooterAgent killerBot = null; if (viewID == bl_GameManager.m_view && !fromBot)//if was me that kill AI { bl_EventHandler.KillEvent(base.LocalName, Agent.AIName, wn, PhotonNetwork.LocalPlayer.GetPlayerTeam().ToString(), 5, 20); //Add a new kill and update information PhotonNetwork.LocalPlayer.PostKill(1);//Send a new kill int score; //If heat shot will give you double experience if (ishead) { bl_GameManager.Instance.Headshots++; score = bl_GameData.Instance.ScoreReward.ScorePerKill + bl_GameData.Instance.ScoreReward.ScorePerHeadShot; #if KILL_STREAK bl_KillNotifierManager kn = bl_KillNotifierUtils.GetManager; if (kn != null) { kn.NewKill(true); } else { Debug.LogWarning("Kill streak notifier is enabled but not integrate in this scene."); } #endif } else { score = bl_GameData.Instance.ScoreReward.ScorePerKill; #if KILL_STREAK bl_KillNotifierManager kn = bl_KillNotifierUtils.GetManager; if (kn != null) { kn.NewKill(); } else { Debug.LogWarning("Kill streak notifier is enabled but not integrate in this scene."); } #endif } bl_KillFeed.LocalKillInfo localKillInfo = new bl_KillFeed.LocalKillInfo(); localKillInfo.Killed = Agent.AIName; localKillInfo.HeadShot = ishead; localKillInfo.Weapon = wn; bl_EventHandler.OnKillEvent(localKillInfo); //Send to update score to player PhotonNetwork.LocalPlayer.PostScore(score); } else if (fromBot) { if (PhotonNetwork.IsMasterClient) { PhotonView p = PhotonView.Find(viewID); string killer = "Unknown"; if (p != null) { killer = p.gameObject.name; //update bot stats AIManager.SetBotKill(killer); } bl_EventHandler.KillEvent(killer, Agent.AIName, wn, Agent.AITeam.ToString(), 5, 20); bl_AIShooterAgent bot = p.GetComponent <bl_AIShooterAgent>(); if (bot != null) { bot.KillTheTarget(transform); killerBot = bot; } else { Debug.Log("Bot can't be found"); } } } AIManager.SetBotDeath(Agent.AIName); gameObject.name += " (die)"; if (PhotonNetwork.IsMasterClient) { if (GetGameMode == GameMode.TDM) { string t = (Agent.AITeam == Team.Recon) ? PropertiesKeys.Team1Score : PropertiesKeys.Team2Score; int score = (int)PhotonNetwork.CurrentRoom.CustomProperties[t]; score++; ExitGames.Client.Photon.Hashtable table = new ExitGames.Client.Photon.Hashtable(); table.Add(t, score); PhotonNetwork.CurrentRoom.SetCustomProperties(table); if (Agent.AITeam == PhotonNetwork.LocalPlayer.GetPlayerTeam()) { GameObject di = bl_ObjectPooling.Instance.Instantiate("deathicon", transform.position, transform.rotation); di.GetComponent <bl_ClampIcon>().SetTempIcon(DeathIcon, 5, 20); } } AIManager.OnBotDeath(Agent, killerBot); } this.photonView.RPC("DestroyRpc", RpcTarget.AllBuffered, direction); } }
/// <summary> /// when we get a new kill, synchronize and add points to the player /// </summary> public void AddKill(bool m_heat, string m_weapon, int W_id) { //Send a new event kill feed string killfeedText = string.Empty; if (!m_heat) { #if LOCALIZATION killfeedText = string.Format("{0} [{1}]", bl_Localization.Instance.GetText(15), m_weapon); #else killfeedText = string.Format("{0} [{1}]", bl_GameTexts.Killed, m_weapon); #endif KillFeed.OnKillFeed(base.LocalName, this.gameObject.name, killfeedText, myTeam, W_id, 30); #if KILL_STREAK bl_KillNotifierManager kn = bl_KillNotifierUtils.GetManager; if (kn != null) { kn.NewKill(); } else { Debug.LogWarning("Kill streak notifier is enabled but not integrate in this scene."); } #endif } else { bl_GameManager.Instance.Headshots++; #if LOCALIZATION killfeedText = string.Format("{0} [{1}]", bl_Localization.Instance.GetText(16), m_weapon); #else killfeedText = string.Format("{0} [{1}]", bl_GameTexts.HeadShot, m_weapon); #endif KillFeed.OnKillFeed(base.LocalName, this.gameObject.name, killfeedText, myTeam, 6, 30); #if KILL_STREAK bl_KillNotifierManager kn = bl_KillNotifierUtils.GetManager; if (kn != null) { kn.NewKill(true); } else { Debug.LogWarning("Kill streak notifier is enabled but not integrate in this scene."); } #endif } //Add a new kill and update information PhotonNetwork.LocalPlayer.PostKill(1);//Send a new kill //Add xp for score and update int score = (m_heat) ? GameData.ScoreReward.ScorePerKill + GameData.ScoreReward.ScorePerHeadShot : GameData.ScoreReward.ScorePerKill; //show an local notification for the kill bl_KillFeed.LocalKillInfo localKillInfo = new bl_KillFeed.LocalKillInfo(); localKillInfo.Killed = gameObject.name; localKillInfo.HeadShot = m_heat; localKillInfo.Weapon = m_weapon; bl_EventHandler.OnKillEvent(localKillInfo); //Send to update score to player PhotonNetwork.LocalPlayer.PostScore(score); //TDM only if the score is updated if (GetGameMode == GameMode.TDM) { //Update ScoreBoard if (myTeam == Team.Delta.ToString()) { int CurrentScore = (int)PhotonNetwork.CurrentRoom.CustomProperties[PropertiesKeys.Team1Score]; CurrentScore++; Hashtable setTeamScore = new Hashtable(); setTeamScore.Add(PropertiesKeys.Team1Score, CurrentScore); PhotonNetwork.CurrentRoom.SetCustomProperties(setTeamScore); } else if (myTeam == Team.Recon.ToString()) { int CurrentScore = (int)PhotonNetwork.CurrentRoom.CustomProperties[PropertiesKeys.Team2Score]; CurrentScore++; Hashtable setTeamScore = new Hashtable(); setTeamScore.Add(PropertiesKeys.Team2Score, CurrentScore); PhotonNetwork.CurrentRoom.SetCustomProperties(setTeamScore); } } #if GR if (GetGameMode == GameMode.GR) { GunRace.GetNextGun(); } #endif }