}                                        //List of IAsset for each of the entities that can colide with each other



        /// <summary>
        /// Contructor
        /// </summary>
        /// <param name="quad"></param>
        /// <param name="sat"></param>
        public CollisionManager(IQuad quad)
        {
            CollidableObjects = new List <IEntity>(); //Initialise CollidableObjects List
            WillCollide       = new List <IEntity>(); //Initialise WillCollide List
            Quad = quad;
            SAT  = new SAT_CLass();                   //Initialise new SAT class
        }
Example #2
0
 public Batch(IQuadFactory factory, IQuad quad, int count, int vbStart, int vbEnd)
 {
     QuadFactory       = factory;
     Quad              = quad;
     PrimitiveCount    = count;
     VertexBufferStart = vbStart;
     VertexBufferEnd   = vbEnd;
 }
Example #3
0
 /// <summary>
 /// tests if two quads can be put into the same SubSet
 /// </summary>
 /// <param name="quad">quad tot test with</param>
 /// <returns>true if quad can be put into same subSet</returns>
 public bool IsCompatible(IQuad quad)
 {
     if (quad == null || quad.Texture.Id != this.Texture.Id)
     {
         return(false);
     }
     return(true);
 }
Example #4
0
    public void ResolveTouchData(IPuzzle puzzle, IOperation op)
    {
        IQuad quad = puzzle[op.row, op.column];

        if (quad.value == QuadValue.Front || quad.value == QuadValue.Back)
        {
            ResolveData(puzzle, op, op);
        }
    }
Example #5
0
 public IQuad[] GetRowQuads(int row)
 {
     IQuad[] quads = new IQuad[columns];
     for (int i = 0, len = quads.Length; i < len; i++)
     {
         quads[i] = _values[row, i];
     }
     return(quads);
 }
Example #6
0
 public IQuad[] GetColumnQuads(int column)
 {
     IQuad[] quads = new IQuad[rows];
     for (int i = 0, len = quads.Length; i < len; i++)
     {
         quads[i] = _values[i, column];
     }
     return(quads);
 }
Example #7
0
 /// <summary>
 /// Fills the vertexUnit with a quad.
 /// </summary>
 /// <param name="quad">The quad to fill vertexUnit with.</param>
 public void FillVertexUnit(IQuad quad)
 {
     if (Filled + quad.VertexCount > Capacity)
     {
         Resize(System.Math.Max(Capacity * 2, Filled + quad.VertexCount));
     }
     quad.FillVertexUnit(VertexUnit, Filled);
     filled += quad.VertexCount;
 }
Example #8
0
        //---------------------------------------------------------------
        #endregion
        //---------------------------------------------------------------

        //---------------------------------------------------------------
        #region Methods
        //---------------------------------------------------------------
        private void ResizeQuads(int newCap)
        {
            IQuad[] newList = new IQuad[newCap];
            if (quads != null)
            {
                quads.CopyTo(newList, 0);
                Purple.Log.Spam("Quads resized: " + newCap);
            }
            quads = newList;
        }
Example #9
0
 private void TouchClickHandler(IEvent e)
 {
     if (level.puzzle.touchEnable)
     {
         IQuad      quad = (e.data as Collider).GetComponent <QuadView>().data;
         IOperation op   = new Operation(OpType.TouchClick, quad.row, quad.column);
         level.record.Push(op);
         level.resolver.ResolveTouch(level.puzzle, op);
     }
 }
Example #10
0
    private void TouchEndHandler(IEvent e)
    {
        Collider quadViewCollider = e.data as Collider;

        if (quadViewCollider != null)
        {
            IQuad quad = quadViewCollider.GetComponent <QuadView>().data;
            level.resolver.ResolveTouch(level.puzzle, new Operation(OpType.TouchEnd, quad.row, quad.column));
        }
    }
Example #11
0
 /// <summary>
 /// Enques the quad for rendering.
 /// </summary>
 /// <param name="quad">Quad to render.</param>
 public void Draw(IQuad quad)
 {
     if (quad.Visible)
     {
         if (quadsFilled >= quads.Length)
         {
             ResizeQuads(quads.Length * 2);
             Purple.Log.Spam("QuadManager.Resize: " + quads.Length * 2);
         }
         quads[quadsFilled] = quad;
         quadsFilled++;
     }
 }
Example #12
0
        private void CreateBatches()
        {
            IQuad lastQuad = null;

            // For every quad
            for (int i = 0; i < quadsFilled; i++)
            {
                IQuad quad = quads[i];

                // Fill indexStream and resize if too small
                if (indexFilled + quad.IndexCount > indexStream.Size)
                {
                    indexStream.Resize(System.Math.Max(indexStream.Size * 2, indexFilled + quad.IndexCount));
                }
                int startVertexBuffer = quad.QuadFactory.Filled;
                quad.FillIndexStream(indexStream, indexFilled, startVertexBuffer);
                indexFilled += quad.IndexCount;

                // Fill vertexUnit
                quad.QuadFactory.FillVertexUnit(quad);

                // create Batch
                Batch batch;
                if (lastQuad == null || lastQuad.QuadFactory != quad.QuadFactory)
                {
                    batch = new Batch(quad.QuadFactory, quad, quad.IndexCount / 3, startVertexBuffer, quad.QuadFactory.Filled);
                }
                else if (!quad.IsCompatible(lastQuad))
                {
                    batch = new Batch(null, quad, quad.IndexCount / 3, startVertexBuffer, quad.QuadFactory.Filled);
                }
                else
                {
                    // Change PrimtiveCount of batch
                    batches[batchFilled - 1].PrimitiveCount += quad.IndexCount / 3;
                    batches[batchFilled - 1].VertexBufferEnd = quad.QuadFactory.Filled;
                    continue;
                }

                // Fill batch and resize if too small
                if (batchFilled >= batches.Length)
                {
                    ResizeBatches(batches.Length * 2);
                }
                batches[batchFilled] = batch;
                batchFilled++;

                lastQuad = quad;
            }
        }
Example #13
0
    private void ResolveTouchEnd(IPuzzle puzzle, IOperation op)
    {
        IQuad        quad     = puzzle[op.row, op.column];
        string       tid      = Style.QuadUnifiedScaleId + "_" + quad.row + "_" + quad.column;
        List <Tween> playings = DOTween.TweensById(tid, true);

        if (playings != null)
        {
            playings.ForEach((Tween each) => each.Kill(true));
        }
        DOTween.To(
            () => quad.localScale,
            x => quad.localScale = x,
            Vector3.one,
            Style.QuadTouchScaleDuration
            ).SetId(tid);
    }
Example #14
0
    private void ResolveTouchClick(IPuzzle puzzle, IOperation op)
    {
        IQuad quad = puzzle[op.row, op.column];

        if (quad.value == QuadValue.Front || quad.value == QuadValue.Back)
        {
            List <Tween> playings = DOTween.PlayingTweens();
            if (playings != null)
            {
                playings.ForEach((Tween each) =>
                {
                    if (each.id != null && each.id.ToString().StartsWith(Style.QuadUnifiedRotateId))
                    {
                        each.Kill(true);
                    }
                });
            }
            puzzle.touchEnable = false;
            TweenDepot depot = new TweenDepot();
            ResolvePresent(depot, puzzle, op, op, 0);
            Sequence sequence = depot.ToSequence();
            sequence.SetId(Style.QuadUnifiedRotateId);
            sequence.OnComplete(() =>
            {
                ResolveTouchData(puzzle, op);
                if (IsSolved(puzzle))
                {
                    puzzle.solved = true;
                }
                else
                {
                    puzzle.touchEnable = true;
                }
            });
        }
    }
Example #15
0
 public IQuad[] GetRowQuads(int row)
 {
     IQuad[] quads = new IQuad[columns];
     for (int i = 0, len = quads.Length; i < len; i++)
     {
         quads[i] = _values[row, i];
     }
     return quads;
 }
Example #16
0
 public IQuad[] GetColumnQuads(int column)
 {
     IQuad[] quads = new IQuad[rows];
     for (int i = 0, len = quads.Length; i < len; i++)
     {
         quads[i] = _values[i, column];
     }
     return quads;
 }
Example #17
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);
                 }
             }
         }
     }
 }
Example #18
0
    private void TouchStartHandler(IEvent e)
    {
        IQuad quad = (e.data as Collider).GetComponent <QuadView>().data;

        level.resolver.ResolveTouch(level.puzzle, new Operation(OpType.TouchStart, quad.row, quad.column));
    }
Example #19
0
 protected override M OnNew(IQuad <string, string, string, string> tvp)
 => new M(tvp.V1.Over(GoodsInfo.From),
          tvp.V2.Over(at.Int32.Of),
          tvp.V3.Over(Money.From),
          tvp.V4.Over(at.Int32.Of));
Example #20
0
 private void ResolveDataLine(IPuzzle puzzle, IOperation origin, IQuad[] quads, int from, int to, int step)
 {
     // from闭to开
     for (int i = from; i != to; i += step)
     {
         if (quads[i].value == QuadValue.Block)
         {
             break;
         }
         else if ((quads[i].value & (QuadValue.Left | QuadValue.Right | QuadValue.Up | QuadValue.Down)) > 0)
         {
             ResolveData(puzzle, origin, new Operation(OpType.TouchClick, quads[i].row, quads[i].column, quads[i].value));
             break;
         }
         else
         {
             quads[i].value = (QuadValue)(QuadValue.Back - quads[i].value);
         }
     }
 }
Example #21
0
 private bool IsLoopLine(List<IQuad> arrows, IPuzzle puzzle, IQuad[] quads, int from, int to, int step)
 {
     bool result = false;
     // from闭to开
     for (int i = from; i != to; i += step)
     {
         if (quads[i].value == QuadValue.Block)
         {
             break;
         }
         else if ((quads[i].value & (QuadValue.Left | QuadValue.Right | QuadValue.Up | QuadValue.Down)) > 0)
         {
             if (arrows.IndexOf(quads[i]) == -1)
             {
                 arrows.Add(quads[i]);
                 result = IsLoop(arrows, puzzle, new Operation(OpType.TouchClick, quads[i].row, quads[i].column, quads[i].value));
             }
             else
             {
                 result = true;
             }
             break;
         }
     }
     return result;
 }