示例#1
0
        public void Update()
        {
            for (int id = 0; id < 10; id++)
            {
                Vector2 pos = input.GetInputPosition(id);

                if (input.GetInputClicked(id))
                {
                    linearPair[id] = new Pair2(pos, pos);
                    startedSlice   = false;
                }

                // Start Slice If Possible
                if (startSliceIfPossible)
                {
                    if (startedSlice == true)
                    {
                        if (Sliceable2D.PointInSlicerComponent(pos.ToVector2D()) == null)
                        {
                            startedSlice = false;
                        }
                    }
                    else if (startedSlice == false)
                    {
                        if (Sliceable2D.PointInSlicerComponent(pos.ToVector2D()) != null)
                        {
                            startedSlice = true;
                        }
                        else
                        {
                            linearPair[id].a = pos;
                        }
                    }
                }

                // End Slice If Possible
                if (input.GetInputHolding(id))
                {
                    linearPair[id].b = pos;

                    if (endSliceIfPossible)
                    {
                        if (input.GetSlicingEnabled(id))
                        {
                            if (LinearSlice(GetPair(id).ToPair2D()))
                            {
                                linearPair[id].a = pos;

                                if (startSliceIfPossible)
                                {
                                    linearPair[id] = new Pair2(pos, pos);
                                    startedSlice   = false;
                                }
                            }
                        }
                    }
                }

                if (input.GetInputReleased(id))
                {
                    if (input.GetSlicingEnabled(id))
                    {
                        LinearSlice(GetPair(id).ToPair2D());
                    }
                }
            }
        }
示例#2
0
        public void Update()
        {
            for (int id = 0; id < 10; id++)
            {
                Vector2 pos = input.GetInputPosition(id);

                if (input.GetInputClicked(id))
                {
                    pointsList[id].Clear();
                    pointsList[id].Add(pos);
                    startedSlice = false;
                }

                if (pointsList[id].Count() < 1)
                {
                    return;
                }

                if (input.GetInputHolding(id))
                {
                    Vector2 posMove   = pointsList[id].Last();
                    bool    added     = false;
                    int     loopCount = 0;

                    while ((Vector2.Distance(posMove, pos) > minVertexDistance * visuals.visualScale))
                    {
                        float direction = (float)Vector2D.Atan2(pos, posMove);
                        posMove = posMove.Push(direction, minVertexDistance * visuals.visualScale);

                        if (startSliceIfPossible == true && startedSlice == false)
                        {
                            if (Sliceable2D.PointInSlicerComponent(posMove.ToVector2D()) != null)
                            {
                                while (pointsList[id].Count() > 2)
                                {
                                    pointsList[id].RemoveAt(0);
                                }

                                startedSlice = true;
                            }
                        }

                        pointsList[id].Add(posMove);

                        added = true;

                        loopCount++;
                        if (loopCount > 150)
                        {
                            break;
                        }
                    }

                    if (endSliceIfPossible == true && added)
                    {
                        if (ComplexMerge(GetPoints(id).ToVector2DList()) == true)
                        {
                            pointsList[id].Clear();

                            if (startSliceIfPossible)
                            {
                                pointsList[id].Add(pos);
                                startedSlice = false;
                            }
                        }
                    }
                }

                if (input.GetInputReleased(id))
                {
                    startedSlice = false;
                    Sliceable2D.complexSliceType = complexSliceType;
                    ComplexMerge(GetPoints(id).ToVector2DList());
                    pointsList[id].Clear();
                }
            }
        }