void CurrentTPVGun(bool local = false) { if (GManager == null) { return; } //Get the current gun ID local and sync with remote for (int i = 0; i < NetworkGuns.Count; i++) { bl_NetworkGun guns = NetworkGuns[i]; if (guns == null) { continue; } int currentID = (local) ? GManager.GetCurrentWeapon().GunID : CurNetGun; if (guns.GetWeaponID == currentID) { guns.gameObject.SetActive(true); if (!local) { CurrenGun = guns.gameObject.GetComponent <bl_NetworkGun>(); CurrenGun.SetUpType(); } } else { if (guns != null) { guns.gameObject.SetActive(false); } } } }
/// <summary> /// /// </summary> void CalculateSensitivity() { if (GunManager != null && GunManager.GetCurrentWeapon() != null) { if (!GunManager.GetCurrentWeapon().isAimed) { XSensitivity = bl_RoomMenu.Instance.m_sensitive; YSensitivity = bl_RoomMenu.Instance.m_sensitive; } else { XSensitivity = bl_RoomMenu.Instance.SensitivityAim; YSensitivity = bl_RoomMenu.Instance.SensitivityAim; } } InvertHorizontal = bl_RoomMenu.Instance.SetIMH; InvertVertical = bl_RoomMenu.Instance.SetIMV; }
/// <summary> /// serialization method of photon public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { m_PositionControl.OnPhotonSerializeView(transform.localPosition, stream, info); m_RotationControl.OnPhotonSerializeView(transform.localRotation, stream, info); m_ScaleControl.OnPhotonSerializeView(transform.localScale, stream, info); if (isMine == false && m_PositionModel.DrawErrorGizmo == true) { DoDrawEstimatedPositionError(); } if (stream.isWriting) { //We own this player: send the others our data stream.SendNext(gameObject.name); stream.SendNext(HeatTarget.position); stream.SendNext(HeatTarget.rotation); stream.SendNext((int)Controller.State); stream.SendNext(Controller.isGrounded); stream.SendNext(GManager.GetCurrentWeapon().GunID); stream.SendNext(Settings.m_Team.ToString()); stream.SendNext(WeaponState); stream.SendNext(Controller.Velocity); } else { //Network player, receive data RemotePlayerName = (string)stream.ReceiveNext(); HeadPos = (Vector3)stream.ReceiveNext(); HeadRot = (Quaternion)stream.ReceiveNext(); m_state = (int)stream.ReceiveNext(); m_grounded = (bool)stream.ReceiveNext(); CurNetGun = (int)stream.ReceiveNext(); RemoteTeam = (string)stream.ReceiveNext(); UpperState = (string)stream.ReceiveNext(); velocity = (Vector3)stream.ReceiveNext(); m_ReceivedNetworkUpdate = true; } }
/// <summary> /// /// </summary> void CalculateSensitivity() { if (GunManager != null) { if (!GunManager.GetCurrentWeapon().isAmed) { XSensitivity = RoomMenu.m_sensitive; YSensitivity = RoomMenu.m_sensitive; } else { XSensitivity = RoomMenu.SensitivityAim; YSensitivity = RoomMenu.SensitivityAim; } } }
/// <summary> /// /// </summary> public override void OnUpdate() { CurrentGun = GManager.GetCurrentWeapon(); BulletLeft = CurrentGun.bulletsLeft; Clips = CurrentGun.numberOfClips; if (BulletLeft <= isLowBullet && CurrentGun.Info.Type == GunType.Machinegun || BulletLeft <= isLowBullet && CurrentGun.Info.Type == GunType.Burst || BulletLeft <= isLowBullet && CurrentGun.Info.Type == GunType.Pistol) { m_color = Color.Lerp(m_color, AmmoLow, Time.deltaTime * 8); } else if (CurrentGun.Info.Type == GunType.Shotgun && BulletLeft <= isLowBulletSniper || CurrentGun.Info.Type == GunType.Sniper && BulletLeft <= isLowBulletSniper) { m_color = Color.Lerp(m_color, AmmoLow, Time.deltaTime * 8); } else { m_color = Color.Lerp(m_color, AmmoNormal, Time.deltaTime * 8); } if (AmmoTextUI != null) { if (CurrentGun.Info.Type != GunType.Knife) { AmmoTextUI.text = BulletLeft.ToString("F0"); } else { AmmoTextUI.text = "--"; } AmmoTextUI.color = m_color; } if (ClipText != null) { if (CurrentGun.Info.Type != GunType.Knife) { ClipText.text = string.Format("/ {0}", Clips.ToString("F0")); } else { ClipText.text = "/ --"; } ClipText.color = m_color; } }