Exemple #1
0
 /// <summary>
 /// 事件:页面加载完毕
 /// </summary>
 private void Stage3D_OnLoaded(object sender, RoutedEventArgs e)
 {
     if (this.isInit == false)
     {
         PreviewSCamera3D.Init();
         this.isInit = true;
     }
 }
Exemple #2
0
        /// <summary>
        /// 以某个区块为焦点调整焦距
        /// </summary>
        /// <param name="r">区块的横向编号,值域[0, 4],其中2是屏幕纵向正中</param>
        /// <param name="c">区块的纵向编号,值域[0, 32],其中0是屏幕横向正中</param>
        /// <param name="ratio">缩放的倍率,值域[0.0, +∞],原始尺寸对应于1.0,原始尺寸指设置中所定义的立绘原始缩放比</param>
        /// <param name="immediate">是否立即执行完毕</param>
        public static void FocusOn(int r, int c, double ratio, bool immediate = false)
        {
            var aniTime = immediate ? 1 : PreviewSCamera3D.animationTimeMS;
            // 计算运动轨迹
            var orgPoint         = PreviewSCamera3D.GetScreenCoordination(PreviewSCamera3D.SCameraFocusRow, PreviewSCamera3D.SCameraFocusCol);
            var destPoint        = PreviewSCamera3D.GetScreenCoordination(r, c);
            var destZ            = PreviewSCamera3D.GetCameraZIndex(ratio);
            var deltaXY          = PreviewSCamera3D.GetManhattanDistance(destPoint, orgPoint);
            var actualBeginPoint = PreviewSCamera3D.ST3D_Camera.Position;
            // 动画
            Point3DAnimationUsingKeyFrames v3dAni = new Point3DAnimationUsingKeyFrames();
            EasingPoint3DKeyFrame          k1     = new EasingPoint3DKeyFrame()
            {
                Value          = new Point3D(actualBeginPoint.X, actualBeginPoint.Y, PreviewSCamera3D.SCameraScale),
                KeyTime        = TimeSpan.FromMilliseconds(0),
                EasingFunction = new CubicEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };
            EasingPoint3DKeyFrame k2 = new EasingPoint3DKeyFrame()
            {
                Value          = new Point3D(actualBeginPoint.X + deltaXY.X, actualBeginPoint.Y + deltaXY.Y, destZ),
                KeyTime        = TimeSpan.FromMilliseconds(aniTime),
                EasingFunction = new CubicEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };

            v3dAni.KeyFrames.Add(k1);
            v3dAni.KeyFrames.Add(k2);
            v3dAni.FillBehavior = FillBehavior.Stop;
            v3dAni.Completed   += delegate
            {
                lock (PreviewSCamera3D.AnimatingStorySet)
                {
                    PreviewSCamera3D.AnimatingStorySet.Remove(v3dAni);
                }
                PreviewSCamera3D.ST3D_Camera.Position = new Point3D(actualBeginPoint.X + deltaXY.X, actualBeginPoint.Y + deltaXY.Y, destZ);
            };
            PreviewSCamera3D.ST3D_Camera.BeginAnimation(ProjectionCamera.PositionProperty, v3dAni);
            // 更新后台
            PreviewSCamera3D.SCameraFocusRow = r;
            PreviewSCamera3D.SCameraFocusCol = c;
            PreviewSCamera3D.SCameraScale    = destZ;
        }
Exemple #3
0
        /// <summary>
        /// 初始化镜头系统,必须在使用场景镜头系统前调用它
        /// </summary>
        public static void Init()
        {
            // 动画属性
            PreviewSCamera3D.SCameraAnimationTimeMS = 500;
            // 尺度初始化
            PreviewSCamera3D.SCameraScale    = PreviewSCamera3D.orginalCameraZIndex;
            PreviewSCamera3D.SCameraFocusCol = 0;
            PreviewSCamera3D.SCameraFocusRow = PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT / 2;
            // 计算区块的横向中点坐标
            double blockWidth  = PreviewSCamera3D.scrWidth / (PreviewSCamera3D.GAME_SCAMERA_SCR_COLCOUNT - PreviewSCamera3D.GAME_SCAMERA_SCR_SINGLEBLOODCOLCOUNT);
            double blockOffset = blockWidth / 2.0;
            var    xArr        = new double[PreviewSCamera3D.GAME_SCAMERA_SCR_COLCOUNT + 1];

            for (int i = PreviewSCamera3D.GAME_SCAMERA_SCR_COLCOUNT; i >= 1; i--)
            {
                xArr[i] = 0 - blockOffset - blockWidth * (PreviewSCamera3D.GAME_SCAMERA_SCR_COLCOUNT / 2.0 - i);
            }
            xArr[0] = 0;
            // 计算区块的可视区间
            PreviewSCamera3D.CharacterBlockList = new List <Tuple <Point3D, Point3D, Point3D, Point3D> >();
            for (int i = 0; i <= PreviewSCamera3D.GAME_SCAMERA_SCR_COLCOUNT; i++)
            {
                var LeftBottom  = new Point3D(xArr[i] - 2.031, -4.252, 0);
                var RightBottom = new Point3D(xArr[i] + 2.031, -4.252, 0);
                var LeftUp      = new Point3D(xArr[i] - 2.031, 1.652, 0);
                var RightUp     = new Point3D(xArr[i] + 2.031, 1.652, 0);
                PreviewSCamera3D.CharacterBlockList.Add(new Tuple <Point3D, Point3D, Point3D, Point3D>(LeftBottom, RightBottom, LeftUp, RightUp));
            }
            // 计算区块中点坐标
            double blockHeight = PreviewSCamera3D.scrHeight / PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT;

            PreviewSCamera3D.screenPointMap = new Point[PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT, PreviewSCamera3D.GAME_SCAMERA_SCR_COLCOUNT + 1];
            for (int i = 0; i < PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT; i++)
            {
                // 变量j从1开始,为0预留位置,0是预留给屏幕横向的中央
                for (int j = 1; j <= PreviewSCamera3D.GAME_SCAMERA_SCR_COLCOUNT; j++)
                {
                    PreviewSCamera3D.screenPointMap[i, j] = new Point(xArr[j], (i - PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT / 2) * blockHeight);
                }
            }
            for (int i = 0; i < PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT; i++)
            {
                PreviewSCamera3D.screenPointMap[i, 0] = new Point(xArr[0], (i - PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT / 2) * blockHeight);
            }
            // 计算标准曼哈顿距离表
            PreviewSCamera3D.manhattanDistanceMap = new Dictionary <Point, Dictionary <Point, Point> >();
            for (int i = 0; i < PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT; i++)
            {
                for (int j = 0; j <= PreviewSCamera3D.GAME_SCAMERA_SCR_COLCOUNT; j++)
                {
                    var pt = PreviewSCamera3D.screenPointMap[i, j];
                    if (PreviewSCamera3D.manhattanDistanceMap.ContainsKey(pt) == false)
                    {
                        PreviewSCamera3D.manhattanDistanceMap[pt] = new Dictionary <Point, Point>();
                    }
                    for (int m = 0; m < PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT; m++)
                    {
                        for (int n = 0; n <= PreviewSCamera3D.GAME_SCAMERA_SCR_COLCOUNT; n++)
                        {
                            var rhsPt = PreviewSCamera3D.screenPointMap[m, n];
                            PreviewSCamera3D.manhattanDistanceMap[pt][rhsPt] = PreviewSCamera3D.GetManhattanDistance(pt, rhsPt);
                        }
                    }
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// 进入场景并做默认拉长焦距效果
 /// </summary>
 public static void PostEnterScene()
 {
     PreviewSCamera3D.ResumeBlackFrame();
     PreviewSCamera3D.ResetFocus(true);
 }
Exemple #5
0
 /// <summary>
 /// 布置场景结束并准备进入时调用此方法以准备动画
 /// </summary>
 public static void PreviewEnterScene()
 {
     PreviewSCamera3D.ST3D_Camera.Position = new Point3D(0, 0, PreviewSCamera3D.orginalCameraZIndex);
     PreviewSCamera3D.FocusOn(PreviewSCamera3D.GAME_SCAMERA_SCR_ROWCOUNT / 2, 0, 1.8, true);
 }
Exemple #6
0
 /// <summary>
 /// 在镜头聚焦的区块上调整焦距
 /// </summary>
 /// <param name="ratio">缩放的倍率,值域[0.0, +∞],原始尺寸对应于1.0</param>
 public static void Focus(double ratio)
 {
     PreviewSCamera3D.FocusOn(PreviewSCamera3D.SCameraFocusRow, PreviewSCamera3D.SCameraFocusCol, ratio);
 }