private void FixedUpdate() { if (weaponAttribute.active) { var visi = false; var posi = Vector3.zero; var aimPoint = myCamera.GetAimPoint(); if (Physics.Raycast(occlusionPoint.position, aimPoint - occlusionPoint.position, out hitInfo, OcclusionSensorDistance, occlusionLayer.layerMask)) { visi = true; posi = hitInfo.point; } if (!velocity.Daim) { visi = false; } var msg = new Dot() { visible = visi, position = posi }; uiMgr.SendEvent(msg); } }
public override void Enter() { base.Enter(); _velocity.Drun = false; _iKManager.SetAim(true); if (_velocity.isLocalPlayer) { if (_weaponAttribute.bore) { Sound.PlayOneShot(_audio, sound); _iKManager.aimIK.solver.axis = fireAxis; // 后坐力 if (_velocity.aiming) { _camera.forceX = _weaponAttribute.recoilX; _camera.forceY = Random.Range(-_weaponAttribute.recoilY, _weaponAttribute.recoilY); } else { _camera.forceX = _weaponAttribute.recoilX * 0.5f; } Transform OcclusionPoint = _weaponHandle.OcclusionPoint; if (Physics.Raycast(OcclusionPoint.position, OcclusionPoint.forward, out hitInfo, OcclusionSensorDistance, occlusionLayer.layerMask)) { startPoint = OcclusionPoint.position; targetPoint = hitInfo.point; visable = false; } else { // 激活枪口火光 muzzleFlash.SetActive(false); muzzleFlash.SetActive(true); // 弹道扩散 if (_velocity.aiming) { float range = _weaponAttribute.runingSpread * 0.5f * Battle.relativeRate; _weaponAttribute.runingSpread += this.spreadFroce; _weaponAttribute.runingSpread = Mathf.Clamp(_weaponAttribute.runingSpread, 0f, _weaponAttribute.aimSpread); Vector2 offset = new Vector2(Random.Range(-range, range), Random.Range(-range, range)); startPoint = _weaponHandle.shootPoint.position; targetPoint = _camera.GetAimPoint(offset); SendSpreadMsg(); } else { float range = _weaponAttribute.spread * (_velocity.crouch ? _weaponAttribute.crouchSpreadRate * 0.5f : 0.5f) * Battle.relativeRate; Vector2 offset = new Vector2(Random.Range(-range, range), Random.Range(-range, range)); startPoint = _weaponHandle.shootPoint.position; targetPoint = _camera.GetAimPoint(offset); SendSpreadMsg(_weaponAttribute.spread * (_velocity.crouch ? _weaponAttribute.crouchSpreadRate : 1f) + 20f); } visable = Vector3.Distance(startPoint, targetPoint) >= bulletVisibleDistence; } Effect.AddBullet( bullet, new Attack() { source = _battleMgr, demage = _weaponAttribute.damage, }, startPoint, targetPoint, _attributes.camp, visable ); _weaponAttribute.OnFire?.Invoke(); _photonView.RPC("NetworkFire", PhotonTargets.Others, _weaponAttribute.index, targetPoint); if (_weaponAttribute.runtimeMag > 0) { _weaponAttribute.runtimeMag--; _weaponAttribute.bore = true; } else { _weaponAttribute.bore = false; } } timer.Enter(_weaponAttribute.interval); // 发送ui消息 SendUiMsgs(); _battleMgr.AddFire(); _camera.mainCamera.fieldOfView += 0.25f; } else { Sound.PlayOneShot(_audio, sound); _iKManager.aimIK.solver.axis = fireAxis; Transform OcclusionPoint = _weaponHandle.OcclusionPoint; if (Physics.Raycast(OcclusionPoint.position, OcclusionPoint.forward, out hitInfo, OcclusionSensorDistance, occlusionLayer.layerMask)) { startPoint = OcclusionPoint.position; visable = false; } else { // 激活枪口火光 muzzleFlash.SetActive(false); muzzleFlash.SetActive(true); startPoint = _weaponHandle.shootPoint.position; } Effect.AddBullet( bullet, new Attack() { source = _battleMgr, demage = 0 }, startPoint, targetPoint, _attributes.camp, visable, false ); } }