Exemplo n.º 1
0
 private void ResolvePresent(TweenDepot depot, IPuzzle puzzle, IOperation origin, IOperation op, float delay)
 {
     IQuad[] rowQuads = puzzle.GetRowQuads(op.row);
     if ((op.direction & QuadValue.Left) > 0)
     {
         for (int i = op.column - 1; i >= 0; i--)
         {
             // 左舷依次翻转
             IQuad quad   = rowQuads[i];
             float qdelay = (Mathf.Abs(quad.column - op.column) - 1) * Style.QuadRollDelay;
             if (quad.value == QuadValue.Block)
             {
                 DOTween.Sequence().AppendInterval(delay + qdelay)
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles + new Vector3(0, Style.QuadShakeAngle, 0), Style.QuadShakeDuration * 0.25f))
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles + new Vector3(0, -Style.QuadShakeAngle, 0), Style.QuadShakeDuration * 0.25f))
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles, Style.QuadShakeDuration * 0.5f)
                         .SetEase(Ease.OutBack));
                 break;
             }
             else if ((quad.value & (QuadValue.Left | QuadValue.Right | QuadValue.Up | QuadValue.Down)) > 0)
             {
                 VisionSpark spark = new VisionSpark(VisionSparkType.Sprinkle);
                 spark.delay = delay + qdelay;
                 quad.Spark(spark);
                 ResolvePresent(depot, puzzle, origin, new Operation(OpType.TouchClick, quad.row, quad.column, quad.value), delay + qdelay + Style.QuadRollDuration);
                 break;
             }
             else
             {
                 string    tid = Style.QuadUnifiedRotateId + "_" + quad.row + "_" + quad.column;
                 TweenInfo lt  = depot.GetFirst(tid);
                 if (lt != null && Mathf.Abs(lt.atPosition - delay - qdelay) < Style.QuadRollDuration)
                 {
                     lt.Kill();
                     Tweener t = DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, new Vector3(0, 0, Style.QuadConflictAngle), Style.QuadConflictDuration)
                                 .SetEase(Ease.OutBack)
                                 .SetRelative();
                     depot.Add(delay + qdelay, t);
                 }
                 else
                 {
                     Tweener t = DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, new Vector3(0, Style.QuadRollAngle, 0), Style.QuadRollDuration)
                                 .SetId(tid)
                                 .SetEase(Ease.OutBack)
                                 .SetRelative();
                     depot.Add(delay + qdelay, t);
                 }
             }
         }
     }
     if ((op.direction & QuadValue.Right) > 0)
     {
         for (int i = op.column + 1, len = rowQuads.Length; i < len; i++)
         {
             // 右舷依次翻转
             IQuad quad   = rowQuads[i];
             float qdelay = (Mathf.Abs(quad.column - op.column) - 1) * Style.QuadRollDelay;
             if (quad.value == QuadValue.Block)
             {
                 DOTween.Sequence().AppendInterval(delay + qdelay)
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles + new Vector3(0, -Style.QuadShakeAngle, 0), Style.QuadShakeDuration * 0.25f))
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles + new Vector3(0, Style.QuadShakeAngle, 0), Style.QuadShakeDuration * 0.25f))
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles, Style.QuadShakeDuration * 0.5f)
                         .SetEase(Ease.OutBack));
                 break;
             }
             else if ((quad.value & (QuadValue.Left | QuadValue.Right | QuadValue.Up | QuadValue.Down)) > 0)
             {
                 VisionSpark spark = new VisionSpark(VisionSparkType.Sprinkle);
                 spark.delay = delay + qdelay;
                 quad.Spark(spark);
                 ResolvePresent(depot, puzzle, origin, new Operation(OpType.TouchClick, quad.row, quad.column, quad.value), delay + qdelay + Style.QuadRollDuration);
                 break;
             }
             else
             {
                 string    tid = Style.QuadUnifiedRotateId + "_" + quad.row + "_" + quad.column;
                 TweenInfo lt  = depot.GetFirst(tid);
                 if (lt != null && Mathf.Abs(lt.atPosition - delay - qdelay) < Style.QuadRollDuration)
                 {
                     lt.Kill();
                     Tweener t = DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, new Vector3(0, 0, -Style.QuadConflictAngle), Style.QuadConflictDuration)
                                 .SetEase(Ease.OutBack)
                                 .SetRelative();
                     depot.Add(delay + qdelay, t);
                 }
                 else
                 {
                     Tweener t = DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, new Vector3(0, -Style.QuadRollAngle, 0), Style.QuadRollDuration)
                                 .SetId(tid)
                                 .SetEase(Ease.OutBack)
                                 .SetRelative();
                     depot.Add(delay + qdelay, t);
                 }
             }
         }
     }
     IQuad[] columnQuads = puzzle.GetColumnQuads(op.column);
     if ((op.direction & QuadValue.Up) > 0)
     {
         for (int i = op.row - 1; i >= 0; i--)
         {
             // 上侧依次翻转
             IQuad quad   = columnQuads[i];
             float qdelay = (Mathf.Abs(quad.row - op.row) - 1) * Style.QuadRollDelay;
             if (quad.value == QuadValue.Block)
             {
                 DOTween.Sequence().AppendInterval(delay + qdelay)
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles + new Vector3(-Style.QuadShakeAngle, 0, 0), Style.QuadShakeDuration * 0.25f))
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles + new Vector3(Style.QuadShakeAngle, 0, 0), Style.QuadShakeDuration * 0.25f))
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles, Style.QuadShakeDuration * 0.5f)
                         .SetEase(Ease.OutBack));
                 break;
             }
             else if ((quad.value & (QuadValue.Left | QuadValue.Right | QuadValue.Up | QuadValue.Down)) > 0)
             {
                 VisionSpark spark = new VisionSpark(VisionSparkType.Sprinkle);
                 spark.delay = delay + qdelay;
                 quad.Spark(spark);
                 ResolvePresent(depot, puzzle, origin, new Operation(OpType.TouchClick, quad.row, quad.column, quad.value), delay + qdelay + Style.QuadRollDuration);
                 break;
             }
             else
             {
                 string    tid = Style.QuadUnifiedRotateId + "_" + quad.row + "_" + quad.column;
                 TweenInfo lt  = depot.GetFirst(tid);
                 if (lt != null && Mathf.Abs(lt.atPosition - delay - qdelay) < Style.QuadRollDuration)
                 {
                     lt.Kill();
                     Tweener t = DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, new Vector3(0, 0, Style.QuadConflictAngle), Style.QuadConflictDuration)
                                 .SetEase(Ease.OutBack)
                                 .SetRelative();
                     depot.Add(delay + qdelay, t);
                 }
                 else
                 {
                     Tweener t = DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, new Vector3(-Style.QuadRollAngle, 0, 0), Style.QuadRollDuration)
                                 .SetId(tid)
                                 .SetEase(Ease.OutBack)
                                 .SetRelative();
                     depot.Add(delay + qdelay, t);
                 }
             }
         }
     }
     if ((op.direction & QuadValue.Down) > 0)
     {
         for (int i = op.row + 1, len = columnQuads.Length; i < len; i++)
         {
             // 下侧依次翻转
             IQuad quad   = columnQuads[i];
             float qdelay = (Mathf.Abs(quad.row - op.row) - 1) * Style.QuadRollDelay;
             if (quad.value == QuadValue.Block)
             {
                 DOTween.Sequence().AppendInterval(delay + qdelay)
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles + new Vector3(Style.QuadShakeAngle, 0, 0), Style.QuadShakeDuration * 0.25f))
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles + new Vector3(-Style.QuadShakeAngle, 0, 0), Style.QuadShakeDuration * 0.25f))
                 .Append(DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, quad.localEulerAngles, Style.QuadShakeDuration * 0.5f)
                         .SetEase(Ease.OutBack));
                 break;
             }
             else if ((quad.value & (QuadValue.Left | QuadValue.Right | QuadValue.Up | QuadValue.Down)) > 0)
             {
                 VisionSpark spark = new VisionSpark(VisionSparkType.Sprinkle);
                 spark.delay = delay + qdelay;
                 quad.Spark(spark);
                 ResolvePresent(depot, puzzle, origin, new Operation(OpType.TouchClick, quad.row, quad.column, quad.value), delay + qdelay + Style.QuadRollDuration);
                 break;
             }
             else
             {
                 string    tid = Style.QuadUnifiedRotateId + "_" + quad.row + "_" + quad.column;
                 TweenInfo lt  = depot.GetFirst(tid);
                 if (lt != null && Mathf.Abs(lt.atPosition - delay - qdelay) < Style.QuadRollDuration)
                 {
                     lt.Kill();
                     Tweener t = DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, new Vector3(0, 0, -Style.QuadConflictAngle), Style.QuadConflictDuration)
                                 .SetEase(Ease.OutBack)
                                 .SetRelative();
                     depot.Add(delay + qdelay, t);
                 }
                 else
                 {
                     Tweener t = DOTween.To(() => quad.localEulerAngles, x => quad.localEulerAngles = x, new Vector3(Style.QuadRollAngle, 0, 0), Style.QuadRollDuration)
                                 .SetId(tid)
                                 .SetEase(Ease.OutBack)
                                 .SetRelative();
                     depot.Add(delay + qdelay, t);
                 }
             }
         }
     }
 }