Exemple #1
0
    /// <summary>
    /// 修改相机缩放
    /// </summary>
    /// <param name="bAdd"></param>
    private void ModifyCameraScale(bool bAdd)
    {
        if (bAdd)
        {
            if (CameraScaleType_ >= CameraScaleType.Max)
            {
                return;
            }
        }
        else
        {
            if (CameraScaleType_ <= CameraScaleType.Min)
            {
                return;
            }
        }
        CameraScaleType_ += (bAdd ? 1 : -1);
        float positionY = 0;
        float rotationX = 0;

        GetPositionY(CameraScaleType_, out positionY);
        GetRotationX(CameraScaleType_, out rotationX);
        for (CameraStatusType type = CameraStatusType.Free; type != CameraStatusType.All; type++)
        {
            CameraInfo cameraInfo = GetCameraInfo(type);
            cameraInfo.position.y = positionY;
            cameraInfo.angles.x   = rotationX;
        }
    }
Exemple #2
0
    /// <summary>
    /// 通过相机缩放类型得到相机与选中目标的距离
    /// </summary>
    /// <param name="scaleType"></param>
    /// <param name="distance"></param>
    /// <returns></returns>
    private bool GetDistance(CameraScaleType scaleType, out float distance)
    {
        distance = 98;

        // 只在锁定状态下该值才有效
        if (CameraStatusType_ != CameraStatusType.Lock)
        {
            return(false);
        }

        if (scaleType == CameraScaleType.Min)
        {
            distance = 98;
            return(true);
        }
        else if (scaleType == CameraScaleType.Normal)
        {
            distance = 135;
            return(true);
        }
        else if (scaleType == CameraScaleType.Max)
        {
            distance = 195;
            return(true);
        }
        return(false);
    }
Exemple #3
0
    public void InitBattleCamera()
    {
        if (MainCamera_ == null)
        {
            Debug.LogError("MainCamera is null, InitBattleCamera Failed!");
            return;
        }
        CameraStatusType_ = CameraStatusType.Normal;
        CameraScaleType_  = CameraScaleType.Max;
        CameraInfo cameraInfo = GetCameraInfo(CameraStatusType_);
        float      positionY  = 0;
        float      rotationX  = 0;

        GetPositionY(CameraScaleType_, out positionY);
        GetRotationX(CameraScaleType_, out rotationX);
        cameraInfo.position = new Vector3(OriginPositionX, positionY, OriginPositionZ);
        cameraInfo.angles   = new Vector3(rotationX, OriginRotationY, 0);
        // 初始化位置和旋转为普通模式,并确认对应坐标
        Vector3    position   = GetBattleCameraOriginPosition();
        Quaternion rotation   = Quaternion.Euler(cameraInfo.angles);
        Vector3    tempTarget = new Vector3(cameraInfo.position.x, cameraInfo.position.y, position.z - NormalCameraZDistance);

        MainCamera_.transform.rotation = rotation;
        MainCamera_.transform.position = tempTarget;
    }
Exemple #4
0
    /// <summary>
    /// 初始化布阵相机
    /// </summary>
    public bool InitDepolyCamera()
    {
        bool succeed = false;

        if (MainCamera_ == null)
        {
            Debug.LogError("MainCamera is null, InitDepolyCamera Failed!");
            return(succeed);
        }
        CameraStatusType_  = CameraStatusType.AutoMoveInDeploy;
        CameraScaleType_   = CameraScaleType.Max;
        CameraTargetTrans_ = null;
        Vector3 originPos = GetDeployCameraOriginPostion();

        MainCamera_.transform.position         = new Vector3(originPos.x, originPos.y, originPos.z);
        MainCamera_.transform.localEulerAngles = new Vector3(DeployOriginRotationX, DeployOriginRotationY, DeployOriginRotationZ);
        succeed = true;
        return(succeed);
    }
Exemple #5
0
 /// <summary>
 /// 通过相机缩放类型得到相机应该处于的X旋转
 /// </summary>
 /// <param name="scaleType"></param>
 /// <param name="rotationX"></param>
 /// <returns></returns>
 private bool GetRotationX(CameraScaleType scaleType, out float rotationX)
 {
     rotationX = 40;
     if (scaleType == CameraScaleType.Min)
     {
         rotationX = 40;
         return(true);
     }
     else if (scaleType == CameraScaleType.Normal)
     {
         rotationX = 60;
         return(true);
     }
     else if (scaleType == CameraScaleType.Max)
     {
         rotationX = 70;
         return(true);
     }
     return(false);
 }
Exemple #6
0
 /// <summary>
 /// 通过相机缩放类型得到相机应该处于的Y坐标
 /// </summary>
 /// <param name="scaleType"></param>
 /// <param name="positionY"></param>
 /// <param name="rotationX"></param>
 /// <returns></returns>
 private bool GetPositionY(CameraScaleType scaleType, out float positionY)
 {
     positionY = 58;
     if (scaleType == CameraScaleType.Min)
     {
         positionY = 58;
         return(true);
     }
     else if (scaleType == CameraScaleType.Normal)
     {
         positionY = 114.5f;
         return(true);
     }
     else if (scaleType == CameraScaleType.Max)
     {
         positionY = 176;
         return(true);
     }
     return(false);
 }