//protected override void MessageToTheChangeOfCrosShairSize(float delta) //{ // //空继承,防止 父类 update ,给覆盖 // //改为鼠标按下时,通知hud ,此时各个区域情况,由Hud 自己循环区域动画 //} protected override MsgPlayerWeaponCrosshair GetRelativeHeightOfReticle() { MsgPlayerWeaponCrosshair crosshair = new MsgPlayerWeaponCrosshair(); Camera cam = CameraManager.GetInstance()?.GetMainCamereComponent()?.GetCamera(); if (cam != null) { float horFOV = cam.fieldOfView * cam.aspect; float verFOV = cam.fieldOfView; for (int i = 0; i < m_AimAreaList.Count; i++) { AimArea aimArea = m_AimAreaList[i]; if (!aimArea.IsSon) { //主区域 crosshair.HorizontalRelativeHeight = aimArea.GetCoverAngle() / horFOV; crosshair.VerticalRelativeHeight = aimArea.GetCoverAngle() / verFOV; } } return(crosshair); } else { return(base.GetRelativeHeightOfReticle()); } }
/// <summary> /// 通知Hud /// </summary> private void MessageToHudCrosShairSize() { Camera cam = CameraManager.GetInstance()?.GetMainCamereComponent()?.GetCamera(); if (cam != null) { MsgPlayerWeaponCrosshair_ShotGun crosshair = new MsgPlayerWeaponCrosshair_ShotGun(); float horFOV = cam.fieldOfView * cam.aspect; float verFOV = cam.fieldOfView; crosshair.SubAimAreaRelativeHeight.Clear(); crosshair.SubAimAreaScreenPosition.Clear(); for (int i = 0; i < m_AimAreaList.Count; i++) { AimArea aimArea = m_AimAreaList[i]; if (aimArea.IsSon) { //子区域 crosshair.SubAimAreaRelativeHeight.Add(new Vector2(aimArea.GetCoverAngle() / horFOV, aimArea.GetCoverAngle() / verFOV)); crosshair.SubAimAreaScreenPosition.Add(cam.WorldToScreenPoint(cam.transform.position + aimArea.GetCentralRay())); } } crosshair.RemainingRestoreDuration = Mathf.Clamp(m_TimeOfStartFire + m_RestoreDuration - Time.time, 0, float.MaxValue); GameFacade.Instance.SendNotification(NotificationName.PlayerWeaponCrosshairScale_ShotGun, crosshair); } }