#pragma warning disable 0414 protected override void Awake() { base.Awake(); if (!PhotonNetwork.connected) Destroy(this); //FirstUpdate = false; if (!this.isMine) { if (HeatTarget.gameObject.activeSelf == false) HeatTarget.gameObject.SetActive(true); } m_PositionControl = new PhotonTransformViewPositionControl(m_PositionModel); m_RotationControl = new PhotonTransformViewRotationControl(m_RotationModel); m_ScaleControl = new PhotonTransformViewScaleControl(m_ScaleModel); Controller = this.GetComponent<bl_PlayerMovement>(); Settings = this.GetComponent<bl_PlayerSettings>(); PDM = this.GetComponent<bl_PlayerDamageManager>(); DrawName = this.GetComponent<bl_DrawName>(); }
/// <summary> /// /// </summary> void Attack() { if (Time.time > attackTime) { bl_PlayerDamageManager pdm = Target.root.GetComponent <bl_PlayerDamageManager>(); if (pdm != null) { bl_OnDamageInfo di = new bl_OnDamageInfo(); di.mActor = null; di.mDamage = Damage; di.mDirection = this.transform.position; di.mFrom = "AI"; pdm.GetDamage(di); attackTime = Time.time + AttackRate; Debug.Log("Send Damage!"); } else { Debug.Log("Can't found pdm in: " + Target.gameObject.name); } } }
/// <summary> /// /// </summary> protected override void Awake() { if (!photonView.IsMine) { return; } base.Awake(); m_Transform = transform; m_CharacterController = GetComponent <CharacterController>(); GunManager = GetComponentInChildren <bl_GunManager>(); DamageManager = GetComponent <bl_PlayerDamageManager>(); #if MFPSM Joystick = FindObjectOfType <bl_Joystick>(); #endif defaultCameraRPosition = CameraRoot.localPosition; m_Jumping = false; m_AudioSource = gameObject.AddComponent <AudioSource>(); m_AudioSource.volume = FootStepVolume; m_MouseLook.Init(m_Transform, HeatRoot, GunManager); lastJumpTime = Time.time; RunFov = 0; }
#pragma warning disable 0414 protected override void Awake() { base.Awake(); bl_PhotonCallbacks.PlayerEnteredRoom += OnPhotonPlayerConnected; if (!PhotonNetwork.IsConnected) { Destroy(this); } if (!PhotonNetwork.InRoom) { return; } //FirstUpdate = false; if (!isMine) { if (HeatTarget.gameObject.activeSelf == false) { HeatTarget.gameObject.SetActive(true); } } m_PositionControl = new PhotonTransformViewPositionControl(m_PositionModel); m_RotationControl = new PhotonTransformViewRotationControl(m_RotationModel); Controller = GetComponent <bl_FirstPersonController>(); PDM = GetComponent <bl_PlayerDamageManager>(); DrawName = GetComponent <bl_DrawName>(); m_CController = GetComponent <CharacterController>(); FrienlyFire = (bool)PhotonNetwork.CurrentRoom.CustomProperties[PropertiesKeys.RoomFriendlyFire]; #if UMM MiniMapItem = this.GetComponent <bl_MiniMapItem>(); if (isMine && MiniMapItem != null) { MiniMapItem.enabled = false; } #endif }
/// <summary> /// /// </summary> /// <param name="m_other"></param> void OnTriggerEnter(Collider m_other) { if (m_other.transform.tag == bl_PlayerSettings.LocalTag) { bl_PlayerDamageManager pdm = m_other.transform.root.GetComponent <bl_PlayerDamageManager>(); if (pdm.health < pdm.maxHealth) { if (typekit == 1) { //Prevent sum more than one if (!Alredy) { Alredy = true; bl_EventHandler.PickUpEvent(m_amount);//Call new internal event } if (m_manager != null) { m_manager.DisableNew(m_id); } } if (typekit == 2) { //Prevent sum more than one if (!Alredy) { Alredy = true; bl_EventHandler.PickUpEvent(m_amount);//Call new internal event } if (m_manager != null) { m_manager.DestroyGO(this.transform.name); } } } } }
#pragma warning disable 0414 void Awake() { if (!PhotonNetwork.connected) { Destroy(this); } //FirstUpdate = false; if (!this.isMine) { if (HeatTarget.gameObject.activeSelf == false) { HeatTarget.gameObject.SetActive(true); } } m_PositionControl = new PhotonTransformViewPositionControl(m_PositionModel); m_RotationControl = new PhotonTransformViewRotationControl(m_RotationModel); m_ScaleControl = new PhotonTransformViewScaleControl(m_ScaleModel); Controller = this.GetComponent <bl_PlayerMovement>(); Settings = this.GetComponent <bl_PlayerSettings>(); PDM = this.GetComponent <bl_PlayerDamageManager>(); DrawName = this.GetComponent <bl_DrawName>(); }
/// <summary> /// /// </summary> void Awake() { pdm = this.GetComponent <bl_PlayerDamageManager>(); m_PlayerLadder = this.GetComponent <bl_LadderPlayer>(); }
void MainMenu() { if (GetGameMode == GameMode.TDM || GetGameMode == GameMode.CTF) { //ScoreBoards for TDM if (!isPlaying && !isFinish && !AutoTeamSelection) { if (GUI.Button(new Rect(Screen.width / 2 - 300, Screen.height / 2 - 190, 200, 40), "Join Delta")) { m_window = 1; Screen.lockCursor = true; showMenu = false; GM.SpawnPlayer(Team.Delta); bl_EventHandler.KillEvent(PhotonNetwork.player.name, "", "Joined in Delta", Team.Delta.ToString(), 777, 30); isPlaying = true; } } if (m_window == 1) { GUILayout.BeginArea(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 150, 400, 350), "", ScoreBoardStyle); GUILayout.Space(5); GUILayout.BeginHorizontal("box"); GUILayout.Label("Player", GUILayout.Width(175)); GUILayout.Label("K", GUILayout.Width(50)); GUILayout.Label("D", GUILayout.Width(50)); GUILayout.Label("S", GUILayout.Width(50)); GUILayout.Label("Ms", GUILayout.Width(50)); GUILayout.EndHorizontal(); scroll_1 = GUILayout.BeginScrollView(scroll_1, false, false); foreach (PhotonPlayer player in PhotonNetwork.playerList) { if ((string)player.customProperties[PropiertiesKeys.TeamKey] == Team.Delta.ToString()) { if (player.name == PhotonNetwork.player.name)//if this player is Mine { GUI.color = new Color(1, 0.6f, 0, 1); } else { GUI.color = Color.white; } GUILayout.BeginHorizontal(); GUILayout.Label((string)player.name, GUILayout.Width(175)); GUILayout.Label(player.customProperties[PropiertiesKeys.KillsKey].ToString(), GUILayout.Width(50)); GUILayout.Label(player.customProperties[PropiertiesKeys.DeathsKey].ToString(), GUILayout.Width(50)); GUILayout.Label(player.customProperties[PropiertiesKeys.ScoreKey].ToString(), GUILayout.Width(50)); int Ping = (int)player.customProperties["Ping"]; GUILayout.Label(Ping.ToString("000") + "<size=10>ms</size>", GUILayout.Width(50)); GUILayout.EndHorizontal(); GUI.color = Color.white; } } GUILayout.EndScrollView(); GUILayout.EndArea(); } if (isPlaying) { if (GUI.Button(new Rect(Screen.width / 2 - 75, Screen.height / 2 - 180, 150, 30), "Resume")) { m_window = 1; Screen.lockCursor = true; showMenu = false; } if (GUI.Button(new Rect(Screen.width / 2 - 225, Screen.height / 2 - 180, 150, 30), "Settings")) { m_window = 2; } if (GUI.Button(new Rect(Screen.width / 2 + 75, Screen.height / 2 - 180, 150, 30), "ScoreBoard")) { m_window = 1; } if (GUI.Button(new Rect(Screen.width / 2 - 150, Screen.height / 2 + 200, 150, 30), "Suicide") && bl_GameManager.isAlive) { PhotonView view = PhotonView.Find(bl_GameManager.m_view); if (view != null) { bl_PlayerDamageManager pdm = view.GetComponent <bl_PlayerDamageManager>(); pdm.Suicide(); m_window = 1; Screen.lockCursor = true; showMenu = false; if (view.isMine) { bl_GameManager.SuicideCount++; Debug.Log("Suicide " + bl_GameManager.SuicideCount + " times"); //if player is a joker o abuse of suicide, them kick of room if (bl_GameManager.SuicideCount >= 3)//Max number de suicides = 3, you can change { isPlaying = false; bl_GameManager.isAlive = false; if (PhotonNetwork.connected) { PhotonNetwork.LeaveRoom(); } else { Application.LoadLevel(0); } Screen.lockCursor = false; } } } else { Debug.LogError("This view " + bl_GameManager.m_view + " is not found"); } } } if (!isPlaying && !isFinish) { SelectClassMenu(); } if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2 + 200, 150, 30), "Disconnect")) { PhotonNetwork.LeaveRoom(); } if (m_window == 1) { //Scorenoard for team2 if (!isPlaying && !isFinish && !AutoTeamSelection) { if (GUI.Button(new Rect(Screen.width / 2 + 100, Screen.height / 2 - 190, 200, 40), "Joined Recon")) { m_window = 1; Screen.lockCursor = true; showMenu = false; GM.SpawnPlayer(Team.Recon); bl_EventHandler.KillEvent(PhotonNetwork.player.name, "", "Joined in Recon", Team.Recon.ToString(), 777, 30); isPlaying = true; } } GUILayout.BeginArea(new Rect(Screen.width / 2 + 5, Screen.height / 2 - 150, 400, 350), "", ScoreBoardStyle); GUILayout.Space(5); GUILayout.BeginHorizontal("box"); GUILayout.Label("Player", GUILayout.Width(175)); GUILayout.Label("K", GUILayout.Width(50)); GUILayout.Label("D", GUILayout.Width(50)); GUILayout.Label("S", GUILayout.Width(50)); GUILayout.Label("Ms", GUILayout.Width(50)); GUILayout.EndHorizontal(); scroll_2 = GUILayout.BeginScrollView(scroll_2, false, false); foreach (PhotonPlayer player in PhotonNetwork.playerList) { if ((string)player.customProperties["Team"] == Team.Recon.ToString()) { if (player.name == PhotonNetwork.player.name)//if this player is Mine { GUI.color = new Color(1, 0.6f, 0, 1); } else { GUI.color = Color.white; } GUILayout.BeginHorizontal(); GUILayout.Label((string)player.name, GUILayout.Width(175)); GUILayout.Label(player.customProperties[PropiertiesKeys.KillsKey].ToString(), GUILayout.Width(50)); GUILayout.Label(player.customProperties[PropiertiesKeys.DeathsKey].ToString(), GUILayout.Width(50)); GUILayout.Label(player.customProperties[PropiertiesKeys.ScoreKey].ToString(), GUILayout.Width(50)); int Ping = (int)player.customProperties["Ping"]; GUILayout.Label(Ping.ToString("000") + "<size=10>ms</size>", GUILayout.Width(50)); GUILayout.EndHorizontal(); GUI.color = Color.white; } } GUILayout.EndScrollView(); GUILayout.EndArea(); } } else if (GetGameMode == GameMode.FFA) { //Scorenoard for All in FFA if (!isPlaying && !isFinish) { if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 190, 200, 40), "Join")) { m_window = 1; Screen.lockCursor = true; showMenu = false; GM.SpawnPlayer(Team.All); bl_EventHandler.KillEvent(PhotonNetwork.player.name, "", "Joined in match", Team.All.ToString(), 777, 30); isPlaying = true; } } if (!isPlaying && !isFinish) { SelectClassMenu(); } if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2 + 200, 150, 30), "Disconnect")) { PhotonNetwork.LeaveRoom(); } if (isPlaying) { if (GUI.Button(new Rect(Screen.width / 2 - 75, Screen.height / 2 - 180, 150, 30), "Resumen")) { m_window = 1; Screen.lockCursor = true; showMenu = false; } if (GUI.Button(new Rect(Screen.width / 2 - 225, Screen.height / 2 - 180, 150, 30), "Setting")) { m_window = 2; } if (GUI.Button(new Rect(Screen.width / 2 + 75, Screen.height / 2 - 180, 150, 30), "ScoreBoard")) { m_window = 1; } if (GUI.Button(new Rect(Screen.width / 2 - 150, Screen.height / 2 + 200, 150, 30), "Suicide") && bl_GameManager.isAlive) { PhotonView view = FindPlayerView(bl_GameManager.m_view); if (view != null) { bl_PlayerDamageManager pdm = view.GetComponent <bl_PlayerDamageManager>(); pdm.Suicide(); m_window = 1; Screen.lockCursor = true; showMenu = false; if (view.isMine) { bl_GameManager.SuicideCount++; Debug.Log("Suicide " + bl_GameManager.SuicideCount + " times"); //if player is a joker o abuse of suicide, them kick of room if (bl_GameManager.SuicideCount >= 3)//Max number de suicides = 3, you can change { if (PhotonNetwork.connected) { PhotonNetwork.LeaveRoom(); } else { Application.LoadLevel(0); } Screen.lockCursor = false; } } } else { Debug.LogError("This view " + bl_GameManager.m_view + " is not found"); } } } if (m_window == 1) { GUILayout.BeginArea(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 150, 400, 350), "", ScoreBoardStyle); GUILayout.Space(5); GUILayout.BeginHorizontal("box"); GUILayout.Label("Player", GUILayout.Width(175)); GUILayout.Label("K", GUILayout.Width(50)); GUILayout.Label("D", GUILayout.Width(50)); GUILayout.Label("S", GUILayout.Width(50)); GUILayout.Label("Ms", GUILayout.Width(50)); GUILayout.EndHorizontal(); scroll_2 = GUILayout.BeginScrollView(scroll_2, false, false); foreach (PhotonPlayer player in PhotonNetwork.playerList) { if (player.name == PhotonNetwork.player.name)//if this player is Mine { GUI.color = new Color(1, 0.6f, 0, 1); GUILayout.BeginHorizontal("Box"); } else { GUI.color = Color.white; GUILayout.BeginHorizontal(); } GUILayout.Label((string)player.name, GUILayout.Width(173)); GUILayout.Label(player.customProperties[PropiertiesKeys.KillsKey].ToString(), GUILayout.Width(50)); GUILayout.Label(player.customProperties[PropiertiesKeys.DeathsKey].ToString(), GUILayout.Width(50)); GUILayout.Label(player.customProperties[PropiertiesKeys.ScoreKey].ToString(), GUILayout.Width(50)); int Ping = (int)player.customProperties["Ping"]; GUILayout.Label(Ping.ToString("000") + "<size=10>ms</size>", GUILayout.Width(50)); GUILayout.EndHorizontal(); GUI.color = Color.white; } GUILayout.EndScrollView(); GUILayout.EndArea(); } } if (m_window == 2) { SettingMenu(); } }
/// <summary> /// applying impact damage from the explosion to enemies /// </summary> private void DoDamage() { if (m_Type == ExplosionType.Shake || !bl_GameData.Instance.ArriveKitsCauseDamage) { return; } List <Player> playersInRange = this.GetPlayersInRange(); if (playersInRange != null && playersInRange.Count > 0) { foreach (Player player in playersInRange) { if (player != null) { GameObject p = FindPhotonPlayer(player); if (p != null) { bl_PlayerDamageManager pdm = p.transform.root.GetComponent <bl_PlayerDamageManager>(); DamageData odi = new DamageData(); odi.Damage = CalculatePlayerDamage(p.transform, player); odi.Direction = transform.position; odi.From = (isFromBot) ? BotName : PhotonNetwork.LocalPlayer.NickName; odi.isHeadShot = false; odi.Cause = (isFromBot) ? DamageCause.Bot : DamageCause.Explosion; odi.GunID = WeaponID; odi.Actor = PhotonNetwork.LocalPlayer; pdm.GetDamage(odi); } else { Debug.LogError("This Player " + player.NickName + " is not found"); } } } } Collider[] colls = Physics.OverlapSphere(transform.position, explosionRadius); List <string> Hited = new List <string>(); foreach (Collider c in colls) { if (c.CompareTag("AI")) { if (Hited.Contains(c.transform.root.name)) { continue; } int damage = CalculatePlayerDamage(c.transform.root, null); Hited.Add(c.transform.root.name); Team t = (isFromBot) ? AITeam : PhotonNetwork.LocalPlayer.GetPlayerTeam(); if (c.GetComponent <bl_AIShooterHealth>() != null && !isNetwork) { c.GetComponent <bl_AIShooterHealth>().DoDamage(damage, "[Explode]", transform.position, AIViewID, isFromBot, t, false); } else if (c.GetComponent <bl_AIHitBox>() != null && !isNetwork) { c.GetComponent <bl_AIHitBox>().DoDamage(damage, "[Explode]", transform.position, AIViewID, isFromBot, t); } } } }
void OnHit(RaycastHit hit) { GameObject go = null; Ray mRay = new Ray(transform.position, transform.forward); if (!isNetwork) { if (hit.rigidbody != null && !hit.rigidbody.isKinematic) // if we hit a rigi body... apply a force { float mAdjust = 1.0f / (Time.timeScale * (0.02f / Time.fixedDeltaTime)); hit.rigidbody.AddForceAtPosition(((mRay.direction * impactForce) / Time.timeScale) / mAdjust, hit.point); } } switch (hit.transform.tag) // decide what the bullet collided with and what to do with it { case "Projectile": // do nothing if 2 bullets collide break; case "BodyPart": //Send Damage for other players if (hit.transform.GetComponent <bl_BodyPart>() != null && !isNetwork) { hit.transform.GetComponent <bl_BodyPart>().GetDamage(damage, PhotonNetwork.NickName, DamageCause.Player, DirectionFrom, OwnGunID); } if (bl_GameData.Instance.ShowBlood) { go = bl_ObjectPooling.Instance.Instantiate("blood", hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); go.transform.parent = hit.transform; } Disable(); break; case "AI": //Send Damage for other players bool bot = !string.IsNullOrEmpty(AIFrom); Team t = (bot) ? AITeam : PhotonNetwork.LocalPlayer.GetPlayerTeam(); if (!string.IsNullOrEmpty(AIFrom) && AIFrom == hit.transform.root.name) { return; } if (hit.transform.GetComponent <bl_AIShooterHealth>() != null && !isNetwork) { hit.transform.GetComponent <bl_AIShooterHealth>().DoDamage((int)damage, GunName, DirectionFrom, AIViewID, bot, t, false); } else if (hit.transform.GetComponent <bl_AIHitBox>() != null && !isNetwork) { hit.transform.GetComponent <bl_AIHitBox>().DoDamage((int)damage, GunName, DirectionFrom, AIViewID, bot, t); } go = bl_ObjectPooling.Instance.Instantiate("blood", hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); go.transform.parent = hit.transform; Disable(); break; case "Player": bl_PlayerDamageManager pdm = hit.transform.GetComponent <bl_PlayerDamageManager>(); if (pdm != null && !isNetwork && !string.IsNullOrEmpty(AIFrom)) { if (!isOneTeamMode) { if (pdm.GetComponent <bl_PlayerSettings>().m_Team == AITeam) //if hit a team mate player { Disable(); return; } } DamageData info = new DamageData(); info.Actor = null; info.Damage = damage; info.Direction = DirectionFrom; info.From = AIFrom; info.Cause = DamageCause.Bot; info.GunID = OwnGunID; pdm.GetDamage(info); Disable(); } break; case "Wood": hitCount++; // add another hit to counter go = bl_ObjectPooling.Instance.Instantiate("decalw", hit.point, Quaternion.LookRotation(hit.normal)); go.transform.parent = hit.transform; break; case "Concrete": hitCount += 2; // add 2 hits to counter... concrete is hard go = bl_ObjectPooling.Instance.Instantiate("decalc", hit.point, Quaternion.LookRotation(hit.normal)); go.transform.parent = hit.transform; break; case "Metal": hitCount += 3; // metal slows bullets alot go = bl_ObjectPooling.Instance.Instantiate("decalm", hit.point, Quaternion.LookRotation(hit.normal)); go.transform.parent = hit.transform; break; case "Dirt": hasHit = true; // ground kills bullet go = bl_ObjectPooling.Instance.Instantiate("decals", hit.point, Quaternion.LookRotation(hit.normal)); go.transform.parent = hit.transform; break; case "Water": hasHit = true; // water kills bullet go = bl_ObjectPooling.Instance.Instantiate("decalwt", hit.point, Quaternion.LookRotation(hit.normal)); go.transform.parent = hit.transform; break; default: hitCount++; // add a hit go = bl_ObjectPooling.Instance.Instantiate("decal", hit.point, Quaternion.LookRotation(hit.normal)); go.transform.parent = hit.transform; break; } Disable(); }
void Awake() { pdm = this.GetComponent<bl_PlayerDamageManager>(); }
void Awake() { pdm = this.GetComponent <bl_PlayerDamageManager>(); }