/// <summary>
    /// 中心点射线选中的目标
    /// </summary>
    /// <returns></returns>
    private SpacecraftEntity GetTargetSelectedByCenterRay()
    {
        PlayerSkillVO       skillVO     = m_PlayerSkillProxy.GetCurrentWeaponSkill();
        SkillSystemGrow     skillGrow   = skillVO.GetSkillGrow();
        float               maxDistance = skillGrow.Range * SceneController.SPACE_ACCURACY_TO_CLIENT;
        MainCameraComponent mainCam     = CameraManager.GetInstance().GetMainCamereComponent();
        Ray        ray     = new Ray(mainCam.GetPosition(), mainCam.GetForward());
        RaycastHit hitInfo = new RaycastHit();

        if (Physics.Raycast(ray, out hitInfo, maxDistance, LayerUtil.GetLayersIntersectWithSkillProjectile(true)))
        {
            return(hitInfo.collider.attachedRigidbody?.GetComponent <SpacecraftEntity>());
        }
        else
        {
            return(null);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 根据这次射击的弹道方向, 计算命中的目标Entity和目标点
    /// </summary>
    /// <param name="camDirAffectedByRecoil"></param>
    /// <returns></returns>
    protected SkillTarget CalulateTargetDataByShootingDirection(Vector3 camDirAffectedByRecoil)
    {
        // 计算射线碰到的目标点, 并重新计算从Launcher到目标点的方向
        PlayerSkillVO   skillVO     = m_PlayerSkillProxy.GetCurrentWeaponSkill();
        SkillSystemGrow skillGrow   = skillVO.GetSkillGrow();
        float           maxDistance = skillGrow.Range * SceneController.SPACE_ACCURACY_TO_CLIENT;
        Ray             ray         = new Ray(CameraManager.GetInstance().GetMainCamereComponent().GetPosition(), camDirAffectedByRecoil);
        RaycastHit      hitInfo     = new RaycastHit();

        if (Physics.Raycast(ray, out hitInfo, maxDistance, LayerUtil.GetLayersIntersectWithSkillProjectile(true)))
        {
            return(new SkillTarget(hitInfo.collider.attachedRigidbody?.GetComponent <SpacecraftEntity>(), hitInfo.point));
        }
        else
        {
            Vector3 skillReleasingDir = (ray.GetPoint(maxDistance) - m_MainPlayer.GetRootTransform().position).normalized;
            return(new SkillTarget(null, m_MainPlayer.GetRootTransform().position + skillReleasingDir * maxDistance));
        }
    }
Esempio n. 3
0
    /// <summary>
    /// 选中一个新的目标
    /// 1. 与上一帧选中的目标不同
    /// 2. 上一帧选中的目标已经锁定完成, 进行下一轮锁定
    /// </summary>
    /// <returns>是否有新的目标</returns>
    private bool PickNewTarget(out SpacecraftEntity newTarget)
    {
        PlayerSkillVO       skillVO     = m_PlayerSkillProxy.GetCurrentWeaponSkill();
        SkillSystemGrow     skillGrow   = skillVO.GetSkillGrow();
        float               maxDistance = skillGrow.Range * SceneController.SPACE_ACCURACY_TO_CLIENT;
        MainCameraComponent mainCam     = CameraManager.GetInstance().GetMainCamereComponent();
        Ray        ray     = new Ray(mainCam.GetPosition(), mainCam.GetForward());
        RaycastHit hitInfo = new RaycastHit();

        // UNDONE
        // 第一版: 使用屏幕中心射线作为目标选取射线. NOW
        // 第二版: 使用 Physics.BoxCast
        if (Physics.Raycast(ray, out hitInfo, maxDistance, LayerUtil.GetLayersIntersectWithSkillProjectile(true)))
        {
            SpacecraftEntity pickedTarget = hitInfo.collider.attachedRigidbody?.GetComponent <SpacecraftEntity>();
            newTarget = pickedTarget;
            return(true);
        }
        else
        {
            newTarget = null;
            return(false);
        }
    }
Esempio n. 4
0
    public float GetRemainingCD(int skillID)
    {
        Debug.Assert(m_SkillIDToSkill.ContainsKey(skillID));
        if (!m_SkillIDToSkill.ContainsKey(skillID))
        {
            return(0f);
        }

        PlayerSkillVO skill             = m_SkillIDToSkill[skillID];
        float         skillCD           = skill.GetRemainingCD();
        float         remainingGlobalCD = Mathf.Clamp(m_SkillTypeToGlobalCDEndTime[(SkillType)skill.GetSkillGrow().SkillType] - Time.time, 0, 99999f);

        if (remainingGlobalCD > skillCD)
        {
            skillCD = remainingGlobalCD;
        }

        return(skillCD);
    }