Inheritance: MonoBehaviour
Beispiel #1
0
    void CheckSwipeDirection()
    {
        if (Input.touches.Length > 0)
        {
            Touch t = Input.GetTouch(0);

            secondPressPos = new Vector2(t.position.x, t.position.y);
            currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);
        }
        else if (Input.GetMouseButton(0))
        {
            secondClickPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            currentSwipe = new Vector3(secondClickPos.x - firstClickPos.x, secondClickPos.y - firstClickPos.y);
        }
        else
        {
            _swipeDirection = Swipe.Tap;
            Debug.Log("Direction: " + _swipeDirection + " <color=gray>(Angle: 0°)</color>");
            return;
        }

        if (currentSwipe.magnitude < minSwipeLength)
        {
            _swipeDirection = Swipe.Tap;
            Debug.Log("Direction: " + _swipeDirection + " <color=gray>(Angle: 0°)</color>");
            return;
        }
    }
    public void DetectSwipe()
    {
        if (Input.touches.Length > 0)
        {
            Touch t = Input.GetTouch(0);

            if (t.phase == TouchPhase.Began)
            {
                print("TouchBegan");
                swipePositions.Clear();
                firstPressPos = new Vector2(t.position.x, t.position.y);
                swipePositions.Add(firstPressPos);
            }

            if (t.phase == TouchPhase.Moved)
            {
                swipePositions.Add(new Vector2(t.position.x, t.position.y));
            }

            if (t.phase == TouchPhase.Ended)
            {
                print("TouchEnded");
                secondPressPos = new Vector2(t.position.x, t.position.y);
                currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);
                swipePositions.Add(secondPressPos);

                // Make sure it was a legit swipe, not a tap
                if (currentSwipe.magnitude < minSwipeLength)
                {
                    swipeDirection = Swipe.None;
                    return;
                }

                currentSwipe.Normalize();

                // Swipe up
                if (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) {
                    swipeDirection = Swipe.Up;
                    print("SwipeUp");
                    // Swipe down
                } else if (currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) {
                    swipeDirection = Swipe.Down;
                    print("SwipeDown");
                    // Swipe left
                } else if (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) {
                    swipeDirection = Swipe.Left;
                    print("SwipeLeft");
                    // Swipe right
                } else if (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) {
                    swipeDirection = Swipe.Right;
                    print("SwipeRight");
                }
            }
        }
        else
        {
            swipeDirection = Swipe.None;
        }
    }
Beispiel #3
0
	public void DetectSwipe ()
	{
		if (Input.touches.Length > 0) {
			Touch t = Input.GetTouch(0);

			if (t.phase == TouchPhase.Began) {
				firstPressPos = new Vector2(t.position.x, t.position.y);
			}

			if (t.phase == TouchPhase.Ended) {
				secondPressPos = new Vector2(t.position.x, t.position.y);
				currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);

				// Make sure it was a legit swipe, not a tap
				if (currentSwipe.magnitude < minSwipeLength) {
					swipeDirection = Swipe.None;
					return;
				}

				currentSwipe.Normalize();

				if (left) {
					drummer.SetTrigger ("LEFT");
					left ^= true;
				} else {
					drummer.SetTrigger ("RIGHT");
					left^=true;
				}
				// Swipe up
				if (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) {
					swipeDirection = Swipe.Up;
					QTEController.instance.TakeInput(0);
					drums.PlayDrum(0);

					// Swipe down
				} else if (currentSwipe.y < 0 && currentSwipe.x > -0.5f  && currentSwipe.x < 0.5f) {
					swipeDirection = Swipe.Down;
					QTEController.instance.TakeInput(2);
					drums.PlayDrum(2);
					// Swipe left
				} else if (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) {
					swipeDirection = Swipe.Left;
					QTEController.instance.TakeInput(3);
					drums.PlayDrum(3);
					// Swipe right
				} else if (currentSwipe.x > 0 && currentSwipe.y > -0.5f  && currentSwipe.y < 0.5f) {
					swipeDirection = Swipe.Right;
					QTEController.instance.TakeInput(1);
					drums.PlayDrum(1);
				}
			}
		} else {
			swipeDirection = Swipe.None;   
		}
	}
	//************
	//* Controls *
	//************
	
	void ControlPresentationSwipe(Swipe swipeDirection) {
		switch (swipeDirection) {
			
		case Swipe.Right:
			currentScreenID = Mathf.Max(--currentScreenID,0);
			SwapGUI(currentScreenID);
			break;
			
		case Swipe.Left:
			currentScreenID = Mathf.Min(++currentScreenID,screens.Length-1);
			SwapGUI(currentScreenID);
			break;
		}		
	}
Beispiel #5
0
    void CheckSwipeDirection()
    {
        if (Input.touches.Length > 0)
        {
            Touch t = Input.GetTouch(0);

            secondPressPos = new Vector2(t.position.x, t.position.y);
            currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);
        }
        else if (Input.GetMouseButton(0))
        {
            secondClickPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            currentSwipe = new Vector3(secondClickPos.x - firstClickPos.x, secondClickPos.y - firstClickPos.y);
        }
        else
        {
            _swipeDirection = Swipe.Tap;
            Debug.Log("Direction: " + _swipeDirection + " <color=gray>(Angle: 0°)</color>");
            return;
        }

        if (currentSwipe.magnitude < minSwipeLength)
        {
            _swipeDirection = Swipe.Tap;
            Debug.Log("Direction: " + _swipeDirection + " <color=gray>(Angle: 0°)</color>");
            return;
        }

        currentSwipe.Normalize();

        float angle = Vector3.Angle(Vector3.right, currentSwipe);

        if (currentSwipe.y < 0)
            angle = angle * -1;

        if (angle >= 30 && angle <= 80)
            _swipeDirection = Swipe.FrontUp;
        else if (angle >= -30 && angle <= 30)
            _swipeDirection = Swipe.Front;
        else if (angle >= -80 && angle <= -30)
            _swipeDirection = Swipe.FrontDown;
        else if (angle >= 80 && angle <= 180)
            _swipeDirection = Swipe.BackUp;
        else if (angle >= -180 && angle <= -80)
            _swipeDirection = Swipe.BackDown;

        Debug.Log("Direction: " + _swipeDirection + " <color=gray>(Angle: " + Mathf.RoundToInt(angle) + "°)</color>");
    }
    public override void Begin()
    {
        healthBarTexture = Resources.Load ("media/ui/health-bar") as Texture2D;
        healthBarStyle = new GUIStyle();
        healthBarStyle.normal.background = healthBarTexture;

        wasTouching = false;
        currentSwipe = null;

        swipes = new List<SwipeDamage> ();
        SwipeDamageStyle = new GUIStyle();
        SwipeDamageStyle.fontSize = Main.FontLarge;
        SwipeDamageStyle.alignment = TextAnchor.UpperLeft;

        enemies = new List<GameObject>();
        baseHealth = Main.StartingBaseHealth;
    }
    public void DetectSwipe()
    {
        if (Input.touches.Length > 0)
        {
            Touch t = Input.GetTouch(0);

            if (t.phase == TouchPhase.Began)
            {
                firstPressPos = new Vector2(t.position.x, t.position.y);
            }
            

            if (t.phase == TouchPhase.Ended)
            {
                secondPressPos = new Vector2(t.position.x, t.position.y);
                currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);

                // Make sure it was a legit swipe, not a tap
                if (currentSwipe.magnitude < minSwipeLength)
                {
                    swipeDirection = Swipe.None;
                    return;
                }

                currentSwipe.Normalize();

                // Swipe up
                if (currentSwipe.y > 0 || currentSwipe.x > -0.5f || currentSwipe.x < 0.5f) {
                    swipeDirection = Swipe.Up;
                    // Swipe down
                } else if (currentSwipe.y < 0 || currentSwipe.x > -0.5f || currentSwipe.x < 0.5f) {
                    swipeDirection = Swipe.Down;
                    // Swipe left
                } else if (currentSwipe.x < 0 || currentSwipe.y > -0.5f || currentSwipe.y < 0.5f) {
                    swipeDirection = Swipe.Left;
                    // Swipe right
                } else if (currentSwipe.x > 0 || currentSwipe.y > -0.5f || currentSwipe.y < 0.5f) {
                    swipeDirection = Swipe.Right;
                }
            }
        }
        else {
            swipeDirection = Swipe.None;
        }
    }
    void Update()
    {
        if (mouseIsDownAndMovingAround) {

                        float swipeTime = Time.time - swipeStartTime; //Time the touch stayed at the screen till now.
                        float swipeDist = Mathf.Abs (Input.mousePosition.x - startPos.x); //Swipedistance

                        if (Mathf.Sign (Input.mousePosition.x - startPos.x) == 1f) { //Swipe-direction, either 1 or -1.

                                swipeDirection = Swipe.RIGHT;

                        } else {
                                swipeDirection = Swipe.LEFT;

                        }

                }
    }
 //Coroutine, wich gets Started in "Start()" and runs over the whole game to check for swipes
 void OnPress(bool pressed)
 {
     //Loop. Otherwise we wouldnt check continoulsy ;-)
             //foreach (Touch touch in Input.touches) { //For every touch in the Input.touches - array...
             if (pressed) {
                     EventHandler handler = MousePressed;
                     if (handler != null) {
                             handler (this, EventArgs.Empty);
                     }
             }
             if (pressed && !mouseIsDownAndMovingAround) {
                     mouseIsDownAndMovingAround = true;
                     startPos = Input.mousePosition;  //Position where the touch started
                     swipeStartTime = Time.time; //The time it started
             }
             if (!pressed) {
                     mouseIsDownAndMovingAround = false;
                     swipeDirection = Swipe.NONE;
             }
 }
Beispiel #10
0
 public void DrawContent(SKCanvas canvas, SKPoint plotOrigin, SKSize plotSize, float textHeight, SKColor axisTextColor, Swipe pinchPan)
 {
     lock (mutex) {
         this.Inner_Bounds(out float minX, out float maxX, out float minY, out float maxY);
         Inner_DrawXLabels(canvas, plotOrigin, plotSize, textHeight, axisTextColor, minX, maxX, pinchPan);
         Inner_DrawYLabels(canvas, plotOrigin, plotSize, textHeight, axisTextColor, minY, maxY, pinchPan);
         Inner_CalculatePoints(plotOrigin, plotSize, minX, maxX, minY, maxY);
         Inner_DrawLines(canvas, pinchPan);
     }
 }
Beispiel #11
0
        private void Inner_DrawXLabels(SKCanvas canvas, SKPoint plotOrigin, SKSize plotSize, float textHeight, SKColor axisTextColor, float minX, float maxX, Swipe pinchPan)
        {
            float Xloc = XlocOfXvalInPlotarea(0, minX, maxX, plotSize); // initialize to screen coordinates height of X=0

            do
            {
                float  Xval   = XvalOfXlocInPlotarea(Xloc, minX, maxX, plotSize);
                SKRect bounds = Inner_DrawLabel_Hor(canvas, Kaemika.Gui.FormatUnit(Xval, " ", "s", "g3"), plotOrigin.X + Xloc, plotOrigin.Y + plotSize.Height, true, textHeight, axisTextColor, pinchPan);
                Xloc += bounds.Width + 2 * textHeight; //using textHeigth for horizontal spacing
            } while (Xloc < plotSize.Width - plotOrigin.X);
        }
Beispiel #12
0
 private void Inner_DrawLine(SKCanvas canvas, int seriesIndex, LineStyle lineStyle, SKColor color, Swipe pinchPan)
 {
     if (list.Count > 1)
     {
         using (var paint = new SKPaint {
             Style = SKPaintStyle.Stroke,
             Color = color,
             StrokeWidth = lineStyle == LineStyle.Thick ? 6 : 2,
             IsAntialias = true,
         }) {
             var path = new SKPath();
             path.MoveTo(pinchPan % list[0].Ypoint[seriesIndex]);
             for (int i = 0; i < list.Count; i++)
             {
                 path.LineTo(pinchPan % list[i].Ypoint[seriesIndex]);
             }
             canvas.DrawPath(path, paint);
         }
     }
 }
Beispiel #13
0
 private SKRect Inner_DrawLabel_Hor(SKCanvas canvas, string text, float X, float Y, bool hor, float textSize, SKColor textColor, Swipe pinchPan)
 {
     using (var paint = new SKPaint()) {
         paint.TextSize    = pinchPan % textSize;
         paint.IsAntialias = true;
         paint.Color       = textColor;
         paint.IsStroke    = false;
         var bounds = new SKRect();
         paint.MeasureText(text, ref bounds);
         var r = pinchPan % new SKRect(X - 1, Y - 30, X + 1, Y + 1);
         canvas.DrawRect(new SKRect(r.Left, (Y + 1) - (r.Bottom - r.Top), r.Right, Y + 1), paint); // Clamped to bottom of hor axis
         canvas.DrawText(text, (pinchPan % new SKPoint(X + 6, 0)).X, Y - 6, paint);                // Clamped to hor axis
         return(bounds);
     }
 }
Beispiel #14
0
    void Update()
    {
        if (Input.touches.Length > 0)
        {
            Touch t = Input.GetTouch(0);

            if (t.phase == TouchPhase.Began)
            {
                firstPressPos = new Vector2(t.position.x, t.position.y);
            }

            if (t.phase == TouchPhase.Ended)
            {
                secondPressPos = new Vector2(t.position.x, t.position.y);
                currentSwipe   = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);

                // Make sure it was a legit swipe, not a tap
                if (currentSwipe.magnitude < minSwipeLength)
                {
                    swipeDirection = Swipe.None;
                    return;
                }

                currentSwipe.Normalize();

                // Swipe up
                if (enelTerra && (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) && Time.timeScale != 0)
                {
                    swipeDirection = Swipe.Up;
                    Saltar();
                    //Salts();
                    // Swipe down
                }
                else if ((currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) && Time.timeScale != 0)
                {
                    swipeDirection = Swipe.Down;

                    Estirar();

                    // Swipe left
                }
                if (enelTerra && (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) && Time.timeScale != 0)
                {
                    swipeDirection = Swipe.Left;
                    Esquerra();

                    // Swipe right
                }
                else if (enelTerra && (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) && Time.timeScale != 0)
                {
                    swipeDirection = Swipe.Right;
                    Dreta();
                }
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                firstClickPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            }
            else
            {
                swipeDirection = Swipe.None;
                //Debug.Log ("None");
            }
            if (Input.GetMouseButtonUp(0))
            {
                secondClickPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
                currentSwipe   = new Vector3(secondClickPos.x - firstClickPos.x, secondClickPos.y - firstClickPos.y);

                // Make sure it was a legit swipe, not a tap
                if (currentSwipe.magnitude < minSwipeLength)
                {
                    swipeDirection = Swipe.None;
                    return;
                }

                currentSwipe.Normalize();

                //Swipe directional check
                // Swipe up
                if (enelTerra && (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) && Time.timeScale != 0)
                {
                    //Salts ();
                    Saltar();

                    // Swipe down
                }
                else if ((currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) && Time.timeScale != 0)
                {
                    Estirar();
                    // Swipe left
                }
                if (enelTerra && (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) && Time.timeScale != 0)
                {
                    Esquerra();
                    // Swipe right
                }
                else if (enelTerra && (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) && Time.timeScale != 0)
                {
                    Dreta();
                }
            }
        }
    }
Beispiel #15
0
    public IEnumerator Jumble()
    {
        while(Animating)
        {
            if(Dragging)
            {
                spinning = false;
            }
            else
            {
                spinning = true;
            }
            selectedFace = (Face)Random.Range(0, 6);
            swipeDirection = (Swipe)Random.Range(0, 4);
            cubelet = cg.cubelets[Random.Range(0, cg.cubelets.Count)];
            if (lastFace == selectedFace)
            {
                selectedFace = (Face)Random.Range(0, 6);
            }

            SelectRotator();
            yield return new WaitForSeconds(0.26f);
            lastFace = selectedFace;
        }
    }
        public void DrawDropletPulledVer(SKCanvas canvas, string label, bool biggie, SKPoint c1, SKPoint c2, ProtocolDevice.Direction dir, float r, float r1, float neckX, float r2, float textStrokeWidth, SKPaint fillPaint, float strokeWidth, float accentStrokeWidth, Swipe swipe)
        {
            float ratio = ((r1 + r2) / 2) / r;

            //strokeWidth = strokeWidth * ratio;
            textStrokeWidth   = textStrokeWidth * ratio;
            accentStrokeWidth = accentStrokeWidth * ratio;

            float lr = r1 - (strokeWidth + accentStrokeWidth) / 2.0f;
            float dr = r2 - (strokeWidth + accentStrokeWidth) / 2.0f;

            // place the neck in an Y-position proportional to the rate between r1 and r2, with m1+r1Y to the top leading to c1.Y, and m2+r2Y to the bot leading to c2.Y
            float m1 = (2 * r - (r1 + r2)) / (1 + r2 / r1);
            float m2 = m1 * r2 / r1;
            // position of the neck
            float nY = c1.Y + r1 + m1;
            float nX = c1.X;
            // Control points: a1*2 is on a line from nY,nX-neckX to c1.Y,c.X-r1 where it intersects c1.Y+r1; we divide it by 2 to make the curve smoother
            float a1 = (m1 * (r1 - neckX) / (r1 + m1)) / 2;
            float a2 = (m2 * (r2 - neckX) / (r2 + m2)) / 2;

            var path = new SKPath();

            path.MoveTo(swipe % new SKPoint(c1.X - r1, c1.Y));
            path.CubicTo(swipe % new SKPoint(c1.X - r1, c1.Y + 0.5f * r1), swipe % new SKPoint(nX - (neckX + a1), c1.Y + r1), swipe % new SKPoint(nX - neckX, nY));
            path.CubicTo(swipe % new SKPoint(nX - (neckX + a2), c2.Y - r2), swipe % new SKPoint(c2.X - r2, c2.Y - 0.5f * r2), swipe % new SKPoint(c2.X - r2, c2.Y));

            path.CubicTo(swipe % new SKPoint(c2.X - r2, c2.Y + 0.75f * r2), swipe % new SKPoint(c2.X - 0.75f * r2, c2.Y + r2), swipe % new SKPoint(c2.X, c2.Y + r2));
            path.CubicTo(swipe % new SKPoint(c2.X + 0.75f * r2, c2.Y + r2), swipe % new SKPoint(c2.X + r2, c2.Y + 0.75f * r2), swipe % new SKPoint(c2.X + r2, c2.Y));

            path.CubicTo(swipe % new SKPoint(c2.X + r2, c2.Y - 0.5f * r2), swipe % new SKPoint(nX + (neckX + a2), c2.Y - r2), swipe % new SKPoint(nX + neckX, nY));
            path.CubicTo(swipe % new SKPoint(nX + (neckX + a1), c1.Y + r1), swipe % new SKPoint(c1.X + r1, c1.Y + 0.5f * r1), swipe % new SKPoint(c1.X + r1, c1.Y));

            path.CubicTo(swipe % new SKPoint(c1.X + r1, c1.Y - 0.75f * r1), swipe % new SKPoint(c1.X + 0.75f * r1, c1.Y - r1), swipe % new SKPoint(c1.X, c1.Y - r1));
            path.CubicTo(swipe % new SKPoint(c1.X - 0.75f * r1, c1.Y - r1), swipe % new SKPoint(c1.X - r1, c1.Y - 0.75f * r1), swipe % new SKPoint(c1.X - r1, c1.Y));
            path.Close();

            var darkPath = new SKPath();

            darkPath.MoveTo(swipe % new SKPoint(c2.X, c2.Y + dr));
            darkPath.CubicTo(swipe % new SKPoint(c2.X + 0.75f * dr, c2.Y + dr), swipe % new SKPoint(c2.X + dr, c2.Y + 0.75f * dr), swipe % new SKPoint(c2.X + dr, c2.Y));

            var lightPath = new SKPath();

            lightPath.MoveTo(swipe % new SKPoint(c1.X, c1.Y - lr));
            lightPath.CubicTo(swipe % new SKPoint(c1.X - 0.75f * lr, c1.Y - lr), swipe % new SKPoint(c1.X - lr, c1.Y - 0.75f * lr), swipe % new SKPoint(c1.X - lr, c1.Y));

            using (var strokePaint = new SKPaint {
                Style = SKPaintStyle.Stroke, Color = new SKColor(0, 0, 0, 191), StrokeWidth = swipe % strokeWidth, IsAntialias = true
            })
                using (var accentLightPaint = new SKPaint {
                    Style = SKPaintStyle.Stroke, Color = new SKColor(255, 255, 255, 191), StrokeWidth = swipe % accentStrokeWidth, StrokeCap = SKStrokeCap.Round, IsAntialias = true
                })
                    using (var accentDarkPaint = new SKPaint {
                        Style = SKPaintStyle.Stroke, Color = new SKColor(0, 0, 0, 95), StrokeWidth = swipe % accentStrokeWidth, StrokeCap = SKStrokeCap.Round, IsAntialias = true
                    }) {
                        canvas.DrawPath(path, fillPaint);
                        canvas.DrawPath(darkPath, accentDarkPaint);
                        canvas.DrawPath(lightPath, accentLightPaint);
                        canvas.DrawPath(path, strokePaint);
                    }

            float   rYtext = (r1 == r2) ? ((dir == ProtocolDevice.Direction.Top) ? r1 : r2) : (r1 > r2) ? r1 : r2;
            SKPoint cText  = (r1 == r2) ? ((dir == ProtocolDevice.Direction.Top) ? c1 : c2) : (r1 > r2) ? c1 : c2;

            DrawDropletLabel(canvas, label, cText, rYtext, textStrokeWidth, biggie, swipe);
        }
 public SwipeEvent(Swipe swipe)
 {
     callback = new UnityEvent();
     eventID  = swipe;
 }
Beispiel #18
0
 void Awake()
 {
     instance = this;
 }
Beispiel #19
0
 public void Cloth3Type()
 {
     if (clothType == 0)
     {
         if (swipeDirection == Swipe.Up)
         {
             swipeDirection = Swipe.None;
             clothPart [0].SetActive(false);
             clear [0]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Left)
         {
             swipeDirection = Swipe.None;
             clothPart [1].SetActive(false);
             clear [1]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [2].SetActive(false);
             clear [2]        = true;
             score6.endScore += 1;
         }
     }
     else if (clothType == 1)
     {
         if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [3].SetActive(false);
             clear [2]        = true;
             clear [1]        = true;
             clear [0]        = true;
             score6.endScore += 1;
         }
     }
     else if (clothType == 2)
     {
         if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [4].SetActive(false);
             clear [0]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Down)
         {
             swipeDirection = Swipe.None;
             clothPart [5].SetActive(false);
             clear [1]        = true;
             clear [2]        = true;
             score6.endScore += 1;
         }
     }
     else if (clothType == 3)
     {
         if (swipeDirection == Swipe.Up)
         {
             swipeDirection = Swipe.None;
             clothPart [6].SetActive(false);
             clear [0]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Left)
         {
             swipeDirection = Swipe.None;
             clothPart [7].SetActive(false);
             clear [1]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [8].SetActive(false);
             clear [2]        = true;
             score6.endScore += 1;
         }
     }
     else if (clothType == 4)
     {
         if (swipeDirection == Swipe.Up)
         {
             swipeDirection = Swipe.None;
             clothPart [9].SetActive(false);
             clear [0]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Left)
         {
             swipeDirection = Swipe.None;
             clothPart [10].SetActive(false);
             clear [1]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [11].SetActive(false);
             clear [2]        = true;
             score6.endScore += 1;
         }
     }
     else if (clothType == 5)
     {
         if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [12].SetActive(false);
             clear [0]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Up)
         {
             swipeDirection = Swipe.None;
             clothPart [13].SetActive(false);
             clear [1]        = true;
             clear [2]        = true;
             score6.endScore += 1;
         }
     }
     else if (clothType == 6)
     {
         if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [14].SetActive(false);
             clear [2]        = true;
             clear [1]        = true;
             clear [0]        = true;
             score6.endScore += 1;
         }
     }
     else if (clothType == 7)
     {
         if (swipeDirection == Swipe.Up)
         {
             swipeDirection = Swipe.None;
             clothPart [15].SetActive(false);
             clear [0]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Left)
         {
             swipeDirection = Swipe.None;
             clothPart [16].SetActive(false);
             clear [1]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [17].SetActive(false);
             clear [2]        = true;
             score6.endScore += 1;
         }
     }
     else if (clothType == 8)
     {
         if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [18].SetActive(false);
             clear [0]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Up)
         {
             swipeDirection = Swipe.None;
             clothPart [19].SetActive(false);
             clear [1]        = true;
             clear [2]        = true;
             score6.endScore += 1;
         }
     }
     else if (clothType == 9)
     {
         if (swipeDirection == Swipe.Right)
         {
             swipeDirection = Swipe.None;
             clothPart [20].SetActive(false);
             clear [0]        = true;
             score6.endScore += 1;
         }
         else if (swipeDirection == Swipe.Down)
         {
             swipeDirection = Swipe.None;
             clothPart [21].SetActive(false);
             clear [1]        = true;
             clear [2]        = true;
             score6.endScore += 1;
         }
     }
 }
 public void PlaySwipeSound()
 {
     Swipe.Play();
 }
Beispiel #21
0
    public void DetectSwipe()
    {
        if (Input.touches.Length > 0)
        {
            Touch t = Input.GetTouch(0);

            if (t.phase == TouchPhase.Began)
            {
                firstPressPos = new Vector2(t.position.x, t.position.y);
                Debug.Log("--- First Touch on =" + firstPressPos.ToString());
            }

            if (t.phase == TouchPhase.Ended)
            {
                secondPressPos = new Vector2(t.position.x, t.position.y);
                Debug.Log("--- Second Touch on =" + secondPressPos.ToString());
                currentSwipe = new Vector2(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);

                // Make sure it was a legit swipe, not a tap
                if (currentSwipe.magnitude < minSwipeLength)
                {
                    if (firstPressPos.x < screenWidth / 3)
                    {
                        swipeDirection = Swipe.TapLeft;
                        AnalyticsEvent.Custom("Controls", new Dictionary <string, object> {
                            { "Tap", "Left" }
                        });
                    }
                    else if (firstPressPos.x > screenWidth * 2 / 3)
                    {
                        swipeDirection = Swipe.TapRight;
                        AnalyticsEvent.Custom("Controls", new Dictionary <string, object> {
                            { "Tap", "Right" }
                        });
                    }
                    else
                    {
                        swipeDirection = Swipe.TapMiddle;
                        AnalyticsEvent.Custom("Controls", new Dictionary <string, object> {
                            { "Tap", "Middle" }
                        });
                    }
                    AnalyticsEvent.Custom("User Control", new Dictionary <string, object> {
                        { PlayerPrefs.GetString("id"), "Tap" }
                    });
                    AnalyticsEvent.Custom("User Control2", new Dictionary <string, object> {
                        { "Tap", PlayerPrefs.GetString("id") }
                    });
                    return;
                }

                currentSwipe.Normalize();

                // Swipe up
                if (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
                {
                    swipeDirection = Swipe.Up;
                    AnalyticsEvent.Custom("Controls", new Dictionary <string, object> {
                        { "Swipe", "Up" }
                    });
                    AnalyticsEvent.Custom("User Control", new Dictionary <string, object> {
                        { PlayerPrefs.GetString("id"), "Swipe" }
                    });
                    AnalyticsEvent.Custom("User Control2", new Dictionary <string, object> {
                        { "Swipe", PlayerPrefs.GetString("id") }
                    });
                    // Swipe down
                }
                else if (currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
                {
                    swipeDirection = Swipe.Down;
                    AnalyticsEvent.Custom("Controls", new Dictionary <string, object> {
                        { "Swipe", "Down" }
                    });
                    AnalyticsEvent.Custom("User Control", new Dictionary <string, object> {
                        { PlayerPrefs.GetString("id"), "Swipe" }
                    });
                    AnalyticsEvent.Custom("User Control2", new Dictionary <string, object> {
                        { "Swipe", PlayerPrefs.GetString("id") }
                    });
                    // Swipe left
                }
                else if (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
                {
                    swipeDirection = Swipe.Left;
                    AnalyticsEvent.Custom("Controls", new Dictionary <string, object> {
                        { "Swipe", "Left" }
                    });
                    AnalyticsEvent.Custom("User Control", new Dictionary <string, object> {
                        { PlayerPrefs.GetString("id"), "Swipe" }
                    });
                    AnalyticsEvent.Custom("User Control2", new Dictionary <string, object> {
                        { "Swipe", PlayerPrefs.GetString("id") }
                    });
                    // Swipe right
                }
                else if (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
                {
                    swipeDirection = Swipe.Right;
                    AnalyticsEvent.Custom("Controls", new Dictionary <string, object> {
                        { "Swipe", "Right" }
                    });
                    AnalyticsEvent.Custom("User Control", new Dictionary <string, object> {
                        { PlayerPrefs.GetString("id"), "Swipe" }
                    });
                    AnalyticsEvent.Custom("User Control2", new Dictionary <string, object> {
                        { "Swipe", PlayerPrefs.GetString("id") }
                    });
                }
            }
        }
        else
        {
            swipeDirection = Swipe.None;
        }
    }
Beispiel #22
0
 void Awake()
 {
     swipe = GetComponent <Swipe> ();
     oneStateController = transform.Find("Increase").GetComponent <ResourceOneStateController> ();
 }
        public void DrawHeatZone(SKCanvas canvas, SKRect zone, float halo, float groove, SKColor color, Swipe swipe)
        {
            //SKMatrix scaleMatrix = SKMatrix.MakeScale(coldZoneRect.Width/coldZoneRect.Height, 1.0f);
            var radialGradient = SKShader.CreateRadialGradient(swipe % new SKPoint(zone.MidX, zone.MidY), swipe % groove, new SKColor[2] {
                color, ProtocolDevice.deviceBackColor
            }, null, SKShaderTileMode.Mirror);                                                                                                                                                                      //, scaleMatrix);

            using (var gradientPaint = new SKPaint {
                Style = SKPaintStyle.Fill, Shader = radialGradient
            }) {
                canvas.DrawRoundRect(swipe % InflateRect(zone, halo), swipe % halo, swipe % halo, gradientPaint);
            }
        }
 public void DrawDropletLabel(SKCanvas canvas, string label, SKPoint center, float radius, float strokeWidth, bool biggie, Swipe swipe)
 {
     using (var labelPaint = new SKPaint {
         Style = SKPaintStyle.Stroke, TextSize = swipe % (0.5f * radius), TextAlign = SKTextAlign.Center, Color = new SKColor(255, 255, 255, 191), StrokeWidth = swipe % strokeWidth, IsAntialias = true
     }) {
         canvas.DrawText(label, swipe % new SKPoint(center.X, center.Y + 0.1f * radius), labelPaint);
         if (biggie)
         {
             canvas.DrawText(">4μL", swipe % new SKPoint(center.X, center.Y + 0.6f * radius), labelPaint);
         }
     }
 }
    public void InterruptMouseDown()
    {
        if( trackingMouse )
        {
            float dir = (float) Math.Atan2( Input.mousePosition.y - mouseYDown, Input.mousePosition.x-mouseXDown );
            float dist = (float) Math.Sqrt( (Input.mousePosition.x-mouseXDown) * (Input.mousePosition.x-mouseXDown) + (Input.mousePosition.y-mouseYDown) * (Input.mousePosition.y-mouseYDown) );

            //timeTapStart = Time.time;
            GetComponent<TapAndSlashDraw>().addUntap( Input.mousePosition.x, Input.mousePosition.y );
            GetComponent<TapAndSlashDraw>().addSwipe( mouseXDown, mouseYDown, Input.mousePosition.x, Input.mousePosition.y );

            trackingMouse = false;

            Action<Swipe> swiping = ( listening ) ? nextSwipeAction : baseSwipeAction;
            Action<Touch> tapping = ( listening ) ? nextTapAction : baseTapAction;

            listening = false;

            if( dist > minSwipeDistance )
            {
                Swipe s = new Swipe( mouseXDown, mouseYDown, Input.mousePosition.x, Input.mousePosition.y );
                if( swiping != null )
                    swiping(s);
                history.Add( s );
            }
            else
            {
                Touch t = new Touch( Input.mousePosition.x, Input.mousePosition.y );
                if( tapping != null )
                    tapping(t);
                history.Add( t );
            }
            if( !listening )
                history.Clear();
        }
    }
 public override void DrawLine(List <KChartEntry> list, int seriesIndex, KLineStyle lineStyle, SKColor color, Swipe pinchPan)
 {
     if (list.Count > 1)
     {
         using (var paint = new SKPaint {
             Style = SKPaintStyle.Stroke,
             Color = color,
             StrokeWidth = lineStyle == KLineStyle.Thick ? 6 : 2,
             IsAntialias = true,
         }) {
             var path = new SKPath();
             path.MoveTo(pinchPan % list[0].Ypoint[seriesIndex]);
             for (int i = 0; i < list.Count; i++)
             {
                 path.LineTo(pinchPan % list[i].Ypoint[seriesIndex]);
             }
             canvas.DrawPath(path, paint);
         }
     }
 }
Beispiel #27
0
 // Use this for initialization
 void Start()
 {
     //sphere.transform.gameObject.SetActive(false);
     swipeControl = GetComponent <Swipe>();
 }
    void swipeResponse( Swipe s )
    {
        tapResponse( new Touch() );
        if( !startGame && !levelDone )
        {
            Debug.Log( "Swiped" );
            lastSwipe = s;
            lastSwipeTime = Time.time;

            audio.PlayOneShot(swipeSound,3.0f);
            Debug.Log( s.direction );
        }
    }
Beispiel #29
0
    // Update is called once per frame
    void Update()
    {
        Swipe swipeDir = GetSwipe();

        if (swipeDir == Swipe.None)
        {
            return;
        }

        switch (gameState)
        {
        case GameState.DoorClosed:
            FlipCard(Card.current);
            break;

        case GameState.DoorOpen:
            if (swipeDir == Swipe.Left)
            {
                SwipeLeft();
            }
            else if (swipeDir == Swipe.Right)
            {
                SwipeRight();
            }
            break;

        default:
            break;
        }

        /*
         * if (swipeDir != Swipe.None)
         * {
         *  if (IsMenu)
         *  {
         *      AudioManager.PlayLoop(AudioManager.Sounds.GameMusic);
         *      IsMenu = false;
         *      NextCard();
         *  }
         *
         *  if (swipeDir == Swipe.Left)
         *      SwipeLeft();
         *  else if (swipeDir == Swipe.Right)
         *      SwipeRight();
         *
         * }
         */

        /*
         * if (gameState == GameState.DoorOpen)
         * {
         *  if (swipeDir == Swipe.Left)
         *      SwipeLeft();
         *  else if (swipeDir == Swipe.Right)
         *      SwipeRight();
         * }
         *
         * else if (gameState == GameState.DoorClosed)
         * {
         *  if (swipeDir != Swipe.None)
         *  {
         *      StartCoroutine(DrawCardAnim());
         *  }
         * }
         */
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        //if the there is exactly 1 touch
        if(Input.touches.Length == 1)
        {
            //set the touch position
            /*touchPos.x = Input.GetTouch(0).deltaPosition.x / Screen.width;
            touchPos.y = Input.GetTouch(0).deltaPosition.y / Screen.height;

            //divide the touch position by the time it is on the screen and save it in the speed variable
            moveSpeed = touchPos.y / Input.GetTouch(0).deltaTime;

            Debug.Log(Input.GetTouch(0).deltaTime);*/

            if(Input.GetTouch(0).phase == TouchPhase.Began)
            {
                startTouchPos = Input.GetTouch(0).position;
                startTouchTime = Time.time;

                isYSwipe = true;
                isXSwipe = true;
            }

            if(Input.GetTouch(0).phase == TouchPhase.Moved)
            {
                currentTouchPos = Input.GetTouch(0).position;

                currentDist = currentTouchPos - startTouchPos;

                if(currentDist.x > directionCheck || currentDist.x < -directionCheck)
                {
                    isYSwipe = false;
                }

                if(currentDist.y > directionCheck || currentDist.y < -directionCheck )
                {
                    isXSwipe = false;
                }
            }

            if(Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled )
            {
                endTouchPos = Input.GetTouch(0).position;
                endTouchTime = Time.time;

                dist = endTouchPos - startTouchPos;

                if(isYSwipe == true)
                {
                    yMoveSpeed = dist.y / (endTouchTime - startTouchTime);

                    if(yMoveSpeed > swipeDist)
                    {
                        swipeDirection = Swipe.up;

                        //Debug.Log("up");
                    }
                    else if(yMoveSpeed < -swipeDist)
                    {
                        swipeDirection = Swipe.down;
                        //Debug.Log("down");
                    }

                    isYSwipe = false;
                }
                else
                {
                    yMoveSpeed = 0;

                    //Debug.Log("not vertical");
                }

                if(isXSwipe == true)
                {
                    xMoveSpeed = dist.x / (endTouchTime - startTouchTime);

                    if(xMoveSpeed > swipeDist)
                    {
                        swipeDirection = Swipe.right;

                        //Debug.Log("right");
                    }
                    else if(xMoveSpeed < -swipeDist)
                    {
                        swipeDirection = Swipe.left;

                        //Debug.Log("left");
                    }

                    isXSwipe = false;
                }
                else
                {
                    xMoveSpeed = 0;

                    //Debug.Log("not horizontal");
                }
            }

        }

        //Debug.Log("x " + yMoveSpeed + "y " + xMoveSpeed);
    }
 void OnSwipe(Swipe swipe)
 {
     if (_grounded)
     {
         if (swipe == Swipe.Up && _isUp)
             _rigidbody2D.AddForce(new Vector2(0, _JumpForce));
         else if (swipe == Swipe.Down && !_isUp)
             _rigidbody2D.AddForce(new Vector2(0, -_JumpForce));
         else
             Flip();
     }
     else
     {
         if (!_isUp && swipe == Swipe.Up)
             _rigidbody2D.AddForce(new Vector2(0, _JumpForce));
         if (_isUp && swipe == Swipe.Down)
             _rigidbody2D.AddForce(new Vector2(0, -_JumpForce));
     }
 }
Beispiel #32
0
 private SKRect Inner_DrawLabel_Ver(SKCanvas canvas, string text, float X, float Y, bool hor, float textSize, SKColor textColor, Swipe pinchPan)
 {
     using (var paint = new SKPaint()) {
         paint.TextSize    = pinchPan % textSize;
         paint.IsAntialias = true;
         paint.Color       = textColor;
         paint.IsStroke    = false;
         var bounds = new SKRect();
         paint.MeasureText(text, ref bounds);
         var r = pinchPan % new SKRect(X - 1, Y - 1, X + 30, Y + 1);
         canvas.DrawRect(new SKRect(X - 1, r.Top, (X - 1) + (r.Right - r.Left), r.Bottom), paint); // Clamped to left of ver axis
         canvas.DrawText(text, X + 6, (pinchPan % new SKPoint(0, Y - 6)).Y, paint);                // Clamped to ver axis
         return(bounds);
     }
 }
Beispiel #33
0
 // Start is called before the first frame update
 void Start()
 {
     table = FindObjectOfType <Table>();
     swipe = FindObjectOfType <Swipe>();
 }
Beispiel #34
0
 private void Inner_DrawLineRange(SKCanvas canvas, int seriesIndex, LineStyle lineStyle, SKColor color, Swipe pinchPan)
 {
     if (list.Count > 1)
     {
         using (var paint = new SKPaint {
             Style = SKPaintStyle.Fill,
             Color = color,
             IsAntialias = true,
         }) {
             var        path       = new SKPath();
             ChartEntry entry0     = list[0];
             SKPoint    meanPoint0 = entry0.Ypoint[seriesIndex];
             float      range0     = entry0.YpointRange[seriesIndex];
             path.MoveTo(pinchPan % new SKPoint(meanPoint0.X, meanPoint0.Y + range0));
             path.LineTo(pinchPan % new SKPoint(meanPoint0.X, meanPoint0.Y - range0));
             for (int i = 0; i < list.Count; i++)
             {
                 ChartEntry entry     = list[i];
                 SKPoint    meanPoint = entry.Ypoint[seriesIndex];
                 float      range     = entry.YpointRange[seriesIndex];
                 path.LineTo(pinchPan % new SKPoint(meanPoint.X, meanPoint.Y - range));
             }
             for (int i = list.Count - 1; i >= 0; i--)
             {
                 ChartEntry entry     = list[i];
                 SKPoint    meanPoint = entry.Ypoint[seriesIndex];
                 float      range     = entry.YpointRange[seriesIndex];
                 path.LineTo(pinchPan % new SKPoint(meanPoint.X, meanPoint.Y + range));
             }
             path.Close();
             canvas.DrawPath(path, paint);
         }
     }
 }
Beispiel #35
0
 void Handle_hsionSuccessSwipe(object sender, Swipe e)
 {
     switch(e.swipe){
         case SwipeDirection.Left:
             break;
         case SwipeDirection.Right:
             break;
         case SwipeDirection.Up:
             break;
         case SwipeDirection.Down:
             break;
         default:
             break;
     }
 }
Beispiel #36
0
        private void Inner_DrawYLabels(SKCanvas canvas, SKPoint plotOrigin, SKSize plotSize, float textHeight, SKColor axisTextColor, float minY, float maxY, Swipe pinchPan)
        {
            float Yloc; // initialize to screen coordinates location of Y=0

            // draw >=0 labels going upwards from 0 or minY
            Yloc = YlocOfYvalInPlotarea(Math.Max(0, minY), minY, maxY, plotSize);
            while (Yloc > textHeight)
            {
                float Yval = YvalOfYlocInPlotarea(Yloc, minY, maxY, plotSize);
                Inner_DrawLabel_Ver(canvas, Kaemika.Gui.FormatUnit(Yval, " ", "M", "g3"), plotOrigin.X, plotOrigin.Y + Yloc, false, textHeight, axisTextColor, pinchPan);
                Yloc -= 3 * textHeight;
            }
            // draw <=0 labels goind downwards from 0 or maxY
            Yloc = YlocOfYvalInPlotarea(Math.Min(0, maxY), minY, maxY, plotSize);
            while (Yloc < plotSize.Height - 2 * textHeight)
            {
                float Yval = YvalOfYlocInPlotarea(Yloc, minY, maxY, plotSize);
                Inner_DrawLabel_Ver(canvas, Kaemika.Gui.FormatUnit(Yval, " ", "M", "g3"), plotOrigin.X, plotOrigin.Y + Yloc, false, textHeight, axisTextColor, pinchPan);
                Yloc += 3 * textHeight;
            }
        }
        public void DrawHeatZone(CGContext canvas, SKRect zone, float halo, float groove, SKColor color, Swipe swipe)
        {
            var radialGradient = SKShader.CreateRadialGradient(swipe % new SKPoint(zone.MidX, zone.MidY), swipe % groove, new SKColor[2] {
                color, KDeviceHandler.deviceBackColor
            }, null, SKShaderTileMode.Mirror);                                                                                                                                                                      //, scaleMatrix);

            using (var gradientPaint = new SKPaint {
                Style = SKPaintStyle.Fill, Shader = radialGradient
            })
            {
                var path = new CGPath();
                path.AddRoundedRect(CG.Rect(swipe % InflateRect(zone, halo)), swipe % halo, swipe % halo);
                canvas.AddPath(path);
                canvas.SetFillColor(CG.Color(color));
                canvas.FillPath();
            }
        }
        public void DrawDevice(ProtocolDevice.Device device, SKCanvas canvas, float canvasX, float canvasY, float canvasWidth, float canvasHeight, float padRadius, float margin, Swipe swipe)
        {
            float padStrokeWidth       = padRadius / 10.0f;
            float padStrokeWidthAccent = 0.75f * padStrokeWidth;

            SKRect coldZoneRect = new SKRect(canvasX + margin, canvasY + margin, canvasX + margin + device.coldZoneWidth * 2 * padRadius, canvasY + margin + device.rowsNo * 2 * padRadius);
            SKRect hotZoneRect  = new SKRect(canvasX + margin + (device.coldZoneWidth + device.warmZoneWidth) * 2 * padRadius, canvasY + margin, canvasX + margin + (device.coldZoneWidth + device.warmZoneWidth + device.hotZoneWidth) * 2 * padRadius, canvasY + margin + device.rowsNo * 2 * padRadius);

            DrawBackground(canvas, canvasX, canvasY, canvasWidth, canvasHeight); // excluding the area outside the fitted region covered by the deviceImage

            DrawHeatZone(canvas, coldZoneRect, padRadius, coldZoneRect.Width / (2 * device.coldZoneWidth), coldColor, swipe);
            DrawHeatZone(canvas, hotZoneRect, padRadius, hotZoneRect.Width / (2 * device.hotZoneWidth), hotColor, swipe);
            DrawText(canvas, "< " + ProtocolDevice.coldTemp, new SKPoint(coldZoneRect.MidX, coldZoneRect.Bottom + margin), padRadius, SKColors.Blue, swipe);
            DrawText(canvas, "> " + ProtocolDevice.hotTemp, new SKPoint(hotZoneRect.MidX, hotZoneRect.Bottom + margin), padRadius, SKColors.Blue, swipe);

            float strokePaintStrokeWidth       = padStrokeWidth;
            float strokeAccentPaintStrokeWidth = padStrokeWidthAccent;

            using (var strokePaint = new SKPaint {
                Style = SKPaintStyle.Stroke, Color = SKColors.Black, StrokeWidth = swipe % strokePaintStrokeWidth, StrokeJoin = SKStrokeJoin.Round, IsAntialias = true
            })
                using (var strokeAccentPaint = new SKPaint {
                    Style = SKPaintStyle.Stroke, Color = SKColors.White, StrokeWidth = swipe % strokeAccentPaintStrokeWidth, StrokeJoin = SKStrokeJoin.Round, StrokeCap = SKStrokeCap.Round, IsAntialias = true
                })
                    using (var fillPaint = new SKPaint {
                        Style = SKPaintStyle.Fill, Color = SKColors.Goldenrod, IsAntialias = true
                    })                                                                                                        // SKColors.DarkGoldenrod / Goldenrod / PaleGoldenrod / LightGoldenrodYellow / Gold
                        using (var holePaint = new SKPaint {
                            Style = SKPaintStyle.Fill, Color = SKColors.Black, IsAntialias = true
                        })
                            using (var holeAccentPaint = new SKPaint {
                                Style = SKPaintStyle.Fill, Color = SKColors.White, IsAntialias = true
                            })
                            {
                                for (int j = 0; j < device.rowsNo; j++)
                                {
                                    for (int i = 0; i < device.colsNo; i++)
                                    {
                                        DrawPad(canvas, new SKPoint(canvasX + margin + padRadius + i * 2 * padRadius, canvasY + margin + padRadius + j * 2 * padRadius), padRadius, strokePaint, strokePaintStrokeWidth, fillPaint, holePaint, strokeAccentPaint, strokeAccentPaintStrokeWidth, holeAccentPaint, swipe);
                                    }
                                }
                            }
        }
        public void DrawDroplet(CGContext canvas, string label, bool biggie, SKPoint center, float padRadius, float radius, float textStrokeWidth, SKPaint fillPaint, float strokeWidth, float accentStrokeWidth, Swipe swipe)
        {
            float ratio = radius / padRadius;

            //strokeWidth = strokeWidth * ratio;
            textStrokeWidth   = textStrokeWidth * ratio;
            accentStrokeWidth = accentStrokeWidth * ratio;

            float pull         = 0.75f;
            float accentRadius = radius - (strokeWidth + accentStrokeWidth) / 2.0f;

            var path = new CGPath();

            path.MoveToPoint(CG.Point(swipe % new SKPoint(center.X, center.Y - radius)));
            // The parameters to CGPath.AddCurveToPoint are in the same order as in SKPath.CubicTo (despite what the Apple docs seem to say).
            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(center.X + pull * radius, center.Y - radius)), CG.Point(swipe % new SKPoint(center.X + radius, center.Y - pull * radius)), CG.Point(swipe % new SKPoint(center.X + radius, center.Y)));
            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(center.X + radius, center.Y + pull * radius)), CG.Point(swipe % new SKPoint(center.X + pull * radius, center.Y + radius)), CG.Point(swipe % new SKPoint(center.X, center.Y + radius)));
            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(center.X - pull * radius, center.Y + radius)), CG.Point(swipe % new SKPoint(center.X - radius, center.Y + pull * radius)), CG.Point(swipe % new SKPoint(center.X - radius, center.Y)));
            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(center.X - radius, center.Y - pull * radius)), CG.Point(swipe % new SKPoint(center.X - pull * radius, center.Y - radius)), CG.Point(swipe % new SKPoint(center.X, center.Y - radius)));
            path.CloseSubpath();

            var darkPath = new CGPath();

            darkPath.MoveToPoint(CG.Point(swipe % new SKPoint(center.X + accentRadius, center.Y)));
            darkPath.AddCurveToPoint(CG.Point(swipe % new SKPoint(center.X + accentRadius, center.Y + pull * accentRadius)), CG.Point(swipe % new SKPoint(center.X + pull * accentRadius, center.Y + accentRadius)), CG.Point(swipe % new SKPoint(center.X, center.Y + accentRadius)));

            var lightPath = new CGPath();

            lightPath.MoveToPoint(CG.Point(swipe % new SKPoint(center.X - accentRadius, center.Y)));
            lightPath.AddCurveToPoint(CG.Point(swipe % new SKPoint(center.X - accentRadius, center.Y - pull * accentRadius)), CG.Point(swipe % new SKPoint(center.X - pull * accentRadius, center.Y - accentRadius)), CG.Point(swipe % new SKPoint(center.X, center.Y - accentRadius)));

            using (var strokePaint = new SKPaint {
                Style = SKPaintStyle.Stroke, Color = new SKColor(0, 0, 0, 191), StrokeWidth = swipe % strokeWidth, IsAntialias = true
            })
                using (var accentLightPaint = new SKPaint {
                    Style = SKPaintStyle.Stroke, Color = new SKColor(255, 255, 255, 191), StrokeWidth = swipe % accentStrokeWidth, StrokeCap = SKStrokeCap.Round, IsAntialias = true
                })
                    using (var accentDarkPaint = new SKPaint {
                        Style = SKPaintStyle.Stroke, Color = new SKColor(0, 0, 0, 95), StrokeWidth = swipe % accentStrokeWidth, StrokeCap = SKStrokeCap.Round, IsAntialias = true
                    })
                    {
                        canvas.AddPath(path);
                        canvas.SetFillColor(CG.Color(fillPaint.Color));
                        canvas.FillPath();

                        canvas.AddPath(darkPath);
                        canvas.SetStrokeColor(CG.Color(accentDarkPaint.Color));
                        canvas.SetLineWidth(accentDarkPaint.StrokeWidth);
                        canvas.SetLineJoin(CG.LineJoin(accentDarkPaint.StrokeJoin));
                        canvas.SetLineCap(CG.LineCap(accentDarkPaint.StrokeCap));
                        canvas.StrokePath();

                        canvas.AddPath(lightPath);
                        canvas.SetStrokeColor(CG.Color(accentLightPaint.Color));
                        canvas.SetLineWidth(accentLightPaint.StrokeWidth);
                        canvas.SetLineJoin(CG.LineJoin(accentLightPaint.StrokeJoin));
                        canvas.SetLineCap(CG.LineCap(accentLightPaint.StrokeCap));
                        canvas.StrokePath();

                        canvas.AddPath(path);
                        canvas.SetStrokeColor(CG.Color(strokePaint.Color));
                        canvas.SetLineWidth(strokePaint.StrokeWidth);
                        canvas.SetLineJoin(CG.LineJoin(strokePaint.StrokeJoin));
                        canvas.SetLineCap(CG.LineCap(strokePaint.StrokeCap));
                        canvas.StrokePath();
                    }

            DrawDropletLabel(canvas, label, center, radius, textStrokeWidth, biggie, swipe);
        }
 public void DrawText(SKCanvas canvas, string text, SKPoint center, float size, SKColor color, Swipe swipe)
 {
     using (var labelPaint = new SKPaint {
         Style = SKPaintStyle.Fill, TextSize = swipe % size, TextAlign = SKTextAlign.Center, Color = color, IsAntialias = true
     }) {
         canvas.DrawText(text, swipe % center, labelPaint);
     }
 }
Beispiel #41
0
    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {
            Scramble();
        }
        if (!Animating && Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                canDrag = false;
                cubelet = hit.transform.gameObject;
                selectedFace = GethitFace(hit);
                mousePressed = true;
                mouseStartPosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (mousePressed)
            {
                mouseEndPosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
                currentSwipe = new Vector2(mouseEndPosition.x - mouseStartPosition.x, mouseEndPosition.y - mouseStartPosition.y);
                currentSwipe.Normalize();
                if (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
                {
                    swipeDirection = Swipe.Up;
                }
                if (currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
                {
                    swipeDirection = Swipe.Down;
                }
                if (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
                {
                    swipeDirection = Swipe.Right;
                }
                if (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
                {
                    swipeDirection = Swipe.Left;
                }
                SelectRotator();
                mousePressed = false;
                cubelet = null;
                canDrag = true;
            }
        }

        if (spinning)
        {
            transform.LookAt(cameraTarget);
            x += xSpeed * 0.005f;
            PositionCamera();
        }

        if (cameraTarget && Input.GetMouseButton(0) && canDrag && !locked)
        {
            dragging = true;
            x += Input.GetAxis("Mouse X") * xSpeed * 0.05f;
            y -= Input.GetAxis("Mouse Y") * ySpeed * 0.05f;

            y = ClampAngle(y, yMinLimit, yMaxLimit);

            PositionCamera();
        }
        else
        {
            dragging = false;
        }
    }
        public void DrawDroplet(SKCanvas canvas, string label, bool biggie, SKPoint center, float padRadius, float radius, float textStrokeWidth, SKPaint fillPaint, float strokeWidth, float accentStrokeWidth, Swipe swipe)
        {
            float ratio = radius / padRadius;

            //strokeWidth = strokeWidth * ratio;
            textStrokeWidth   = textStrokeWidth * ratio;
            accentStrokeWidth = accentStrokeWidth * ratio;

            float pull         = 0.75f;
            float accentRadius = radius - (strokeWidth + accentStrokeWidth) / 2.0f;

            var path = new SKPath();

            path.MoveTo(swipe % new SKPoint(center.X, center.Y - radius));
            path.CubicTo(swipe % new SKPoint(center.X + pull * radius, center.Y - radius), swipe % new SKPoint(center.X + radius, center.Y - pull * radius), swipe % new SKPoint(center.X + radius, center.Y));
            path.CubicTo(swipe % new SKPoint(center.X + radius, center.Y + pull * radius), swipe % new SKPoint(center.X + pull * radius, center.Y + radius), swipe % new SKPoint(center.X, center.Y + radius));
            path.CubicTo(swipe % new SKPoint(center.X - pull * radius, center.Y + radius), swipe % new SKPoint(center.X - radius, center.Y + pull * radius), swipe % new SKPoint(center.X - radius, center.Y));
            path.CubicTo(swipe % new SKPoint(center.X - radius, center.Y - pull * radius), swipe % new SKPoint(center.X - pull * radius, center.Y - radius), swipe % new SKPoint(center.X, center.Y - radius));
            path.Close();

            var darkPath = new SKPath();

            darkPath.MoveTo(swipe % new SKPoint(center.X + accentRadius, center.Y));
            darkPath.CubicTo(swipe % new SKPoint(center.X + accentRadius, center.Y + pull * accentRadius), swipe % new SKPoint(center.X + pull * accentRadius, center.Y + accentRadius), swipe % new SKPoint(center.X, center.Y + accentRadius));

            var lightPath = new SKPath();

            lightPath.MoveTo(swipe % new SKPoint(center.X - accentRadius, center.Y));
            lightPath.CubicTo(swipe % new SKPoint(center.X - accentRadius, center.Y - pull * accentRadius), swipe % new SKPoint(center.X - pull * accentRadius, center.Y - accentRadius), swipe % new SKPoint(center.X, center.Y - accentRadius));

            using (var strokePaint = new SKPaint {
                Style = SKPaintStyle.Stroke, Color = new SKColor(0, 0, 0, 191), StrokeWidth = swipe % strokeWidth, IsAntialias = true
            })
                using (var accentLightPaint = new SKPaint {
                    Style = SKPaintStyle.Stroke, Color = new SKColor(255, 255, 255, 191), StrokeWidth = swipe % accentStrokeWidth, StrokeCap = SKStrokeCap.Round, IsAntialias = true
                })
                    using (var accentDarkPaint = new SKPaint {
                        Style = SKPaintStyle.Stroke, Color = new SKColor(0, 0, 0, 95), StrokeWidth = swipe % accentStrokeWidth, StrokeCap = SKStrokeCap.Round, IsAntialias = true
                    }) {
                        canvas.DrawPath(path, fillPaint);
                        canvas.DrawPath(darkPath, accentDarkPaint);
                        canvas.DrawPath(lightPath, accentLightPaint);
                        canvas.DrawPath(path, strokePaint);
                    }

            DrawDropletLabel(canvas, label, center, radius, textStrokeWidth, biggie, swipe);
        }
Beispiel #43
0
 private void EventManager_gameStarted()
 {
     _swipeDirection = Swipe.None;
 }
Beispiel #44
0
        //The update taking input into account.
        public void UpdateActive(Swipe currentSwipe, Transform mainCharacterTransform, bool downKeyDown)
        {
            foreach (PlatformCombination platformCombination in spawnedPlatforms)
            {
                bool enable = mainCharacterTransform.localPosition.y > (platformCombination.combinedGameObject.rigid.transform.localPosition.y + 0.60f);
                platformCombination.begin.colliderEnabled = enable;
                platformCombination.end.colliderEnabled = enable;

                foreach (Platform platform in platformCombination.middle)
                {
                    platform.colliderEnabled = enable;
                }

                if (currentSwipe.yDirectionDelta < -0.1 || downKeyDown)
                {
                    platformCombination.begin.colliderEnabled = false;
                    platformCombination.end.colliderEnabled = false;

                    foreach (Platform platform in platformCombination.middle)
                    {
                        platform.colliderEnabled = false;
                    }
                }
            }
        }
    public void DetectSwipe()
    {
        if (Input.touches.Length > 0) {
            Touch t = Input.GetTouch(0);

            if (t.phase == TouchPhase.Began) {
                firstPressPos = new Vector2(t.position.x, t.position.y);
            }

            if (t.phase == TouchPhase.Ended) {
                secondPressPos = new Vector2(t.position.x, t.position.y);
                currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);

                // Make sure it was a legit swipe, not a tap
                if (currentSwipe.magnitude < minSwipeLength) {
                    swipeDirection = Swipe.None;
                    return;
                }

                currentSwipe.Normalize();

                // Swipe up
                if (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) {
                    swipeDirection = Swipe.Up;
                    // Swipe down
                } else if (currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) {
                    swipeDirection = Swipe.Down;
                    // Swipe left
                } else if (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) {
                    swipeDirection = Swipe.Left;
                    // Swipe right
                } else if (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) {
                    swipeDirection = Swipe.Right;
                }
            }
        } else {

            if (Input.GetMouseButtonDown(0)) {
                firstClickPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            } else {
                swipeDirection = Swipe.None;
                //Debug.Log ("None");
            }
            if (Input.GetMouseButtonUp (0)){
                secondClickPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
                currentSwipe = new Vector3(secondClickPos.x - firstClickPos.x, secondClickPos.y - firstClickPos.y);

                // Make sure it was a legit swipe, not a tap
                if (currentSwipe.magnitude < minSwipeLength) {
                    swipeDirection = Swipe.None;
                    return;
                }

                currentSwipe.Normalize();

                //Swipe directional check
                // Swipe up
                if (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) {
                    swipeDirection = Swipe.Up;
                    // Swipe down
                } else if (currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f) {
                    swipeDirection = Swipe.Down;
                    // Swipe left
                } else if (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) {
                    swipeDirection = Swipe.Left;
                    Debug.Log ("Left");
                    // Swipe right
                } else if (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) {
                    swipeDirection = Swipe.Right;
                    Debug.Log ("right");
                }
            }

        }
    }
    private void CheckSwipes()
    {
        if ( Input.touchCount > 0 ) {
            Touch touch = Input.touches[0];
            switch ( touch.phase ) { //Screen has been touched, this could be a swipe.
                case TouchPhase.Began:
                    m_xSwipe = m_ySwipe = Swipe.None;
                    xSwipeSpeed = ySwipeSpeed = 0.0f;
                    startPos = touch.position;
                    swipeStartTime = Time.time;
                    prevFramePos = new Vector2( -1.0f, -1.0f );
                    began = true;
                    break;

                case TouchPhase.Moved:
                    if ( prevFramePos != new Vector2( -1.0f, -1.0f ) ) {
                        float xSwipeValue = Mathf.Sign( touch.position.x - startPos.x );
                        float xPrevSwipeValue = Mathf.Sign( touch.position.x - prevFramePos.x );

                        float ySwipeValue = Mathf.Sign( touch.position.y - startPos.y );
                        float yprevSwipeValue = Mathf.Sign( touch.position.y - prevFramePos.y );

                        if ( xSwipeValue != xPrevSwipeValue || ySwipeValue != yprevSwipeValue ) {
                            startPos = prevFramePos;
                            swipeStartTime = Time.time;
                            m_xSwipe = m_ySwipe = Swipe.None;
                        }
                    }

                    float swipeTime = Time.time - swipeStartTime;
                    float xSwipeDist = ( new Vector3( touch.position.x, 0, 0 ) - new Vector3( startPos.x, 0, 0 ) ).magnitude;
                    float ySwipeDist = ( new Vector3( 0, touch.position.y, 0 ) - new Vector3( 0, startPos.y, 0 ) ).magnitude;

                    if ( began ) {
                        if ( xSwipeDist > ySwipeDist ) {
                            xSwipe = true;
                        }
                        else {
                            xSwipe = false;
                        }
                    }

                    if ( xSwipe ) {
                        if ( ( swipeTime < maxSwipeTime ) && ( xSwipeDist > minSwipeDist ) ) {
                            float swipeValue = Mathf.Sign( touch.position.x - startPos.x );
                            xSwipeSpeed = PixelsToPercentage( xSwipeDist, true ) / swipeTime;

                            if ( swipeValue > 0 ) {
                                m_xSwipe = Swipe.Positive;
                            }
                            else if ( swipeValue < 0 ) {
                                m_xSwipe = Swipe.Negative;
                            }
                        }
                        else {
                            xSwipeSpeed = 0.0f;
                        }
                    }
                    else {

                        if ( ( swipeTime < maxSwipeTime ) && ( ySwipeDist > minSwipeDist ) ) {
                            float swipeValue = Mathf.Sign( touch.position.y - startPos.y );
                            ySwipeSpeed = PixelsToPercentage( ySwipeDist, false ) / swipeTime;

                            if ( swipeValue > 0 ) {
                                m_ySwipe = Swipe.Positive;
                            }
                            else {
                                m_ySwipe = Swipe.Negative;
                            }
                        }
                        else {
                            ySwipeSpeed = 0.0f;
                        }
                    }
                    prevFramePos = touch.position;
                    break;

                case TouchPhase.Ended:
                    prevFramePos = new Vector2( -1.0f, -1.0f );
                    m_xSwipe = m_ySwipe = Swipe.None;
                    ySwipeSpeed = xSwipeSpeed = 0.0f;
                    break;
            }
        }
    }
 private void OnSwipeDetectedRaise(Swipe swipe)
 {
     if (OnSwipeDetected != null)
         OnSwipeDetected(swipe);
 }
Beispiel #48
0
 void swipeProgress(Swipe swipe)
 {
     //TODO resize del flow
 }
    public override void Update()
    {
        if (Main.Touching) {
            if (!wasTouching) {
                lastSwipeStart = Main.TouchBoardLocation;

                currentSwipe = ((GameObject)Object.Instantiate (Resources.Load ("swipe"))).GetComponent<Swipe> ();
            }
            lastSwipeEnd = Main.TouchBoardLocation;
            currentSwipe.SetStartAndEnd (lastSwipeStart, lastSwipeEnd);
            wasTouching = true;
        } else {
            if (wasTouching) {
                Swipe (lastSwipeStart, lastSwipeEnd);
                currentSwipe.Destroy ();
            }
            wasTouching = false;
        }

        if (baseHealth <= 0) {
            Main.ChangeScenes(new StartScreen());
        }
    }
        public void DrawDropletPulledHor(CGContext canvas, string label, bool biggie, SKPoint c1, SKPoint c2, KDeviceHandler.Direction dir, float r, float r1, float neckY, float r2, float textStrokeWidth, SKPaint fillPaint, float strokeWidth, float accentStrokeWidth, Swipe swipe)
        {
            float ratio = ((r1 + r2) / 2) / r;

            //strokeWidth = strokeWidth * ratio;
            textStrokeWidth   = textStrokeWidth * ratio;
            accentStrokeWidth = accentStrokeWidth * ratio;

            float lr = r1 - (strokeWidth + accentStrokeWidth) / 2.0f;
            float dr = r2 - (strokeWidth + accentStrokeWidth) / 2.0f;

            // place the neck in an X-position proportional to the rate between r1 and r2, with m1+r1X to the left leading to c1.X, and m2+r2X to the right leading to c2.X
            float m1 = (2 * r - (r1 + r2)) / (1 + r2 / r1);
            float m2 = m1 * r2 / r1;
            // position of the neck
            float nX = c1.X + r1 + m1;
            float nY = c1.Y;
            // Control points: a1*2 is on a line from nX,nY-neckY to c1.X,c.Y-r1 where it intersects c1.X+r1; we divide it by 2 to make the curve smoother
            float a1 = (m1 * (r1 - neckY) / (r1 + m1)) / 2;
            float a2 = (m2 * (r2 - neckY) / (r2 + m2)) / 2;

            var path = new CGPath();

            path.MoveToPoint(CG.Point(swipe % new SKPoint(c1.X, c1.Y - r1)));
            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(c1.X + 0.5f * r1, c1.Y - r1)), CG.Point(swipe % new SKPoint(c1.X + r1, nY - (neckY + a1))), CG.Point(swipe % new SKPoint(nX, nY - neckY)));
            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(c2.X - r2, nY - (neckY + a2))), CG.Point(swipe % new SKPoint(c2.X - 0.5f * r2, c2.Y - r2)), CG.Point(swipe % new SKPoint(c2.X, c2.Y - r2)));

            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(c2.X + 0.75f * r2, c2.Y - r2)), CG.Point(swipe % new SKPoint(c2.X + r2, c2.Y - 0.75f * r2)), CG.Point(swipe % new SKPoint(c2.X + r2, c2.Y)));
            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(c2.X + r2, c2.Y + 0.75f * r2)), CG.Point(swipe % new SKPoint(c2.X + 0.75f * r2, c2.Y + r2)), CG.Point(swipe % new SKPoint(c2.X, c2.Y + r2)));

            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(c2.X - 0.5f * r2, c2.Y + r2)), CG.Point(swipe % new SKPoint(c2.X - r2, nY + (neckY + a2))), CG.Point(swipe % new SKPoint(nX, nY + neckY)));
            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(c1.X + r1, nY + (neckY + a1))), CG.Point(swipe % new SKPoint(c1.X + 0.5f * r1, c1.Y + r1)), CG.Point(swipe % new SKPoint(c1.X, c1.Y + r1)));

            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(c1.X - 0.75f * r1, c1.Y + r1)), CG.Point(swipe % new SKPoint(c1.X - r1, c1.Y + 0.75f * r1)), CG.Point(swipe % new SKPoint(c1.X - r1, c1.Y)));
            path.AddCurveToPoint(CG.Point(swipe % new SKPoint(c1.X - r1, c1.Y - 0.75f * r1)), CG.Point(swipe % new SKPoint(c1.X - 0.75f * r1, c1.Y - r1)), CG.Point(swipe % new SKPoint(c1.X, c1.Y - r1)));
            path.CloseSubpath();

            var darkPath = new CGPath();

            darkPath.MoveToPoint(CG.Point(swipe % new SKPoint(c2.X + dr, c2.Y)));
            darkPath.AddCurveToPoint(CG.Point(swipe % new SKPoint(c2.X + dr, c2.Y + 0.75f * dr)), CG.Point(swipe % new SKPoint(c2.X + 0.75f * dr, c2.Y + dr)), CG.Point(swipe % new SKPoint(c2.X, c2.Y + dr)));

            var lightPath = new CGPath();

            lightPath.MoveToPoint(CG.Point(swipe % new SKPoint(c1.X - lr, c1.Y)));
            lightPath.AddCurveToPoint(CG.Point(swipe % new SKPoint(c1.X - lr, c1.Y - 0.75f * lr)), CG.Point(swipe % new SKPoint(c1.X - 0.75f * lr, c1.Y - lr)), CG.Point(swipe % new SKPoint(c1.X, c1.Y - lr)));

            using (var strokePaint = new SKPaint {
                Style = SKPaintStyle.Stroke, Color = new SKColor(0, 0, 0, 191), StrokeWidth = swipe % strokeWidth, IsAntialias = true
            })
                using (var accentLightPaint = new SKPaint {
                    Style = SKPaintStyle.Stroke, Color = new SKColor(255, 255, 255, 191), StrokeWidth = swipe % accentStrokeWidth, StrokeCap = SKStrokeCap.Round, IsAntialias = true
                })
                    using (var accentDarkPaint = new SKPaint {
                        Style = SKPaintStyle.Stroke, Color = new SKColor(0, 0, 0, 95), StrokeWidth = swipe % accentStrokeWidth, StrokeCap = SKStrokeCap.Round, IsAntialias = true
                    })
                    {
                        canvas.AddPath(path);
                        canvas.SetFillColor(CG.Color(fillPaint.Color));
                        canvas.FillPath();

                        canvas.AddPath(darkPath);
                        canvas.SetStrokeColor(CG.Color(accentDarkPaint.Color));
                        canvas.SetLineWidth(accentDarkPaint.StrokeWidth);
                        canvas.SetLineJoin(CG.LineJoin(accentDarkPaint.StrokeJoin));
                        canvas.SetLineCap(CG.LineCap(accentDarkPaint.StrokeCap));
                        canvas.StrokePath();

                        canvas.AddPath(lightPath);
                        canvas.SetStrokeColor(CG.Color(accentLightPaint.Color));
                        canvas.SetLineWidth(accentLightPaint.StrokeWidth);
                        canvas.SetLineJoin(CG.LineJoin(accentLightPaint.StrokeJoin));
                        canvas.SetLineCap(CG.LineCap(accentLightPaint.StrokeCap));
                        canvas.StrokePath();

                        canvas.AddPath(path);
                        canvas.SetStrokeColor(CG.Color(strokePaint.Color));
                        canvas.SetLineWidth(strokePaint.StrokeWidth);
                        canvas.SetLineJoin(CG.LineJoin(strokePaint.StrokeJoin));
                        canvas.SetLineCap(CG.LineCap(strokePaint.StrokeCap));
                        canvas.StrokePath();
                    }

            float   rText = (r1 == r2) ? ((dir == KDeviceHandler.Direction.Lft) ? r1 : r2) : (r1 > r2) ? r1 : r2;
            SKPoint cText = (r1 == r2) ? ((dir == KDeviceHandler.Direction.Lft) ? c1 : c2) : (r1 > r2) ? c1 : c2;

            DrawDropletLabel(canvas, label, cText, rText, textStrokeWidth, biggie, swipe);
        }
Beispiel #51
0
 void swipeEnd(Swipe swipe)
 {
     //TODO cancellare una corrente con un altra inversa?
 }
 void Update()
 {
     m_xSwipe = m_ySwipe = Swipe.None;
     CheckSwipes();
 }
        public void DrawPad(CGContext canvas, SKPoint center, float radius, SKPaint strokePaint, float strokePaintStrokeWidth, SKPaint fillPaint, SKPaint holePaint, SKPaint strokeAccentPaint, float strokeAccentPaintStrokeWidth, SKPaint holeAccentPaint, Swipe swipe)
        {
            float step       = radius / 7.0f;
            float holeRadius = radius / 7.0f;
            float orthShift  = (strokePaintStrokeWidth + strokeAccentPaintStrokeWidth) / 2.0f;
            float diagShift  = orthShift / 1.41f;

            var path = new CGPath();

            path.MoveToPoint(CG.Point(swipe % new SKPoint(center.X - radius, center.Y - radius)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius, center.Y - radius + 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 1 * step, center.Y - radius + 2 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius - 1 * step, center.Y - radius + 4 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 1 * step, center.Y - radius + 6 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius - 1 * step, center.Y - radius + 8 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 1 * step, center.Y - radius + 10 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius - 1 * step, center.Y - radius + 12 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius, center.Y - radius + 13 * step)));

            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius, center.Y + radius)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 1 * step, center.Y + radius)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 2 * step, center.Y + radius - 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 4 * step, center.Y + radius + 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 6 * step, center.Y + radius - 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 8 * step, center.Y + radius + 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 10 * step, center.Y + radius - 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 12 * step, center.Y + radius + 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + 13 * step, center.Y + radius)));

            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius, center.Y + radius)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius, center.Y + radius - 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 1 * step, center.Y + radius - 2 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius + 1 * step, center.Y + radius - 4 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 1 * step, center.Y + radius - 6 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius + 1 * step, center.Y + radius - 8 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 1 * step, center.Y + radius - 10 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius + 1 * step, center.Y + radius - 12 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius, center.Y + radius - 13 * step)));

            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius, center.Y - radius)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 1 * step, center.Y - radius)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 2 * step, center.Y - radius + 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 4 * step, center.Y - radius - 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 6 * step, center.Y - radius + 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 8 * step, center.Y - radius - 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 10 * step, center.Y - radius + 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 12 * step, center.Y - radius - 1 * step)));
            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius - 13 * step, center.Y - radius)));

            path.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius, center.Y - radius)));
            path.CloseSubpath();

            var accPathLft = new CGPath();

            accPathLft.MoveToPoint(CG.Point(swipe % new SKPoint(center.X - radius + orthShift, center.Y - radius + orthShift)));
            accPathLft.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + orthShift, center.Y - radius + orthShift + 1 * step)));
            accPathLft.MoveToPoint(CG.Point(swipe % new SKPoint(center.X - radius + diagShift + 1 * step, center.Y - radius + diagShift + 2 * step)));
            accPathLft.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + diagShift - 1 * step, center.Y - radius + diagShift + 4 * step)));
            accPathLft.MoveToPoint(CG.Point(swipe % new SKPoint(center.X - radius + diagShift + 1 * step, center.Y - radius + diagShift + 6 * step)));
            accPathLft.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + diagShift - 1 * step, center.Y - radius + diagShift + 8 * step)));
            accPathLft.MoveToPoint(CG.Point(swipe % new SKPoint(center.X - radius + diagShift + 1 * step, center.Y - radius + diagShift + 10 * step)));
            accPathLft.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + diagShift - 1 * step, center.Y - radius + diagShift + 12 * step)));
            accPathLft.MoveToPoint(CG.Point(swipe % new SKPoint(center.X - radius + orthShift, center.Y - radius + 13 * step)));
            accPathLft.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X - radius + orthShift, center.Y - radius + 14 * step)));

            var accPathTop = new CGPath();

            accPathTop.MoveToPoint(CG.Point(swipe % new SKPoint(center.X + radius, center.Y - radius + orthShift)));
            accPathTop.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius + diagShift / 2 - 1 * step, center.Y - radius + orthShift)));
            accPathTop.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius + diagShift - 2 * step, center.Y - radius + diagShift + 1 * step)));
            accPathTop.MoveToPoint(CG.Point(swipe % new SKPoint(center.X + radius + diagShift - 4 * step, center.Y - radius + diagShift - 1 * step)));
            accPathTop.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius + diagShift - 6 * step, center.Y - radius + diagShift + 1 * step)));
            accPathTop.MoveToPoint(CG.Point(swipe % new SKPoint(center.X + radius + diagShift - 8 * step, center.Y - radius + diagShift - 1 * step)));
            accPathTop.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius + diagShift - 10 * step, center.Y - radius + diagShift + 1 * step)));
            accPathTop.MoveToPoint(CG.Point(swipe % new SKPoint(center.X + radius + diagShift - 12 * step, center.Y - radius + diagShift - 1 * step)));
            accPathTop.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius + diagShift / 2 - 13 * step, center.Y - radius + orthShift)));
            accPathTop.AddLineToPoint(CG.Point(swipe % new SKPoint(center.X + radius + orthShift - 14 * step, center.Y - radius + orthShift)));

            canvas.AddPath(path);
            canvas.SetFillColor(CG.Color(fillPaint.Color));
            canvas.FillPath();

            canvas.AddPath(accPathLft);
            canvas.SetStrokeColor(CG.Color(strokeAccentPaint.Color));
            canvas.SetLineWidth(strokeAccentPaint.StrokeWidth);
            canvas.SetLineJoin(CG.LineJoin(strokeAccentPaint.StrokeJoin));
            canvas.SetLineCap(CG.LineCap(strokeAccentPaint.StrokeCap));
            canvas.StrokePath();

            canvas.AddPath(accPathTop);
            canvas.SetStrokeColor(CG.Color(strokeAccentPaint.Color));
            canvas.SetLineWidth(strokeAccentPaint.StrokeWidth);
            canvas.SetLineJoin(CG.LineJoin(strokeAccentPaint.StrokeJoin));
            canvas.SetLineCap(CG.LineCap(strokeAccentPaint.StrokeCap));
            canvas.StrokePath();

            canvas.AddPath(path);
            canvas.SetStrokeColor(CG.Color(strokePaint.Color));
            canvas.SetLineWidth(strokePaint.StrokeWidth);
            canvas.SetLineJoin(CG.LineJoin(strokePaint.StrokeJoin));
            canvas.SetLineCap(CG.LineCap(strokePaint.StrokeCap));
            canvas.StrokePath();

            canvas.AddEllipseInRect(CG.RectFromCircle(swipe % new SKPoint(center.X + diagShift / 2, center.Y + diagShift / 2), swipe % (holeRadius + diagShift / 2)));
            canvas.SetFillColor(CG.Color(holeAccentPaint.Color));
            canvas.FillPath();
            canvas.AddEllipseInRect(CG.RectFromCircle(swipe % center, swipe % holeRadius));
            canvas.SetFillColor(CG.Color(holePaint.Color));
            canvas.FillPath();
        }
Beispiel #54
0
 static bool IsSwipingDirection(Swipe swipeDir)
 {
     DetectSwipe();
     return(swipeDirection == swipeDir);
 }
 public void Start()
 {
     SwipeControls   = this.GetComponent <Swipe>();
     desiredPosition = startPoint.transform.position;
     CreateObject();
 }
    // Update is called once per frame
    void Update()
    {
        point.enabled = false;
        swipe.enabled = false;

        if( active )
        {

            if( listening )
            {
                if( Time.time > timeEnd )
                {
                    if( nextNoAction != null )
                        nextNoAction();
                    listening = false;
                    history.Clear();
                }
            }

            if( trackingMouse )
            {
                float dir = (float) Math.Atan2( Input.mousePosition.y - mouseYDown, Input.mousePosition.x-mouseXDown );
                float dist = (float) Math.Sqrt( (Input.mousePosition.x-mouseXDown) * (Input.mousePosition.x-mouseXDown) + (Input.mousePosition.y-mouseYDown) * (Input.mousePosition.y-mouseYDown) );

                swipe.transform.position = new Vector3( mouseXDown/Screen.width, mouseYDown/Screen.height, 0 );
                swipe.pixelInset = new Rect( 0, dist * (((float)swipeIndicator.height) / swipeIndicator.width )/2, dist, dist * (((float)swipeIndicator.height) / swipeIndicator.width ) );
                swipe.transform.rotation = Quaternion.AngleAxis( dir, new Vector3( 0,0,1 ) );

                if( !Input.GetMouseButton( 0 ) )
                {
                    timeTapStart = Time.time;
                    trackingMouse = false;
                    Action<Swipe> swiping = ( listening ) ? nextSwipeAction : baseSwipeAction;
                    Action<Touch> tapping = ( listening ) ? nextTapAction : baseTapAction;

                    listening = false;

                    if( dist > minSwipeDistance )
                    {
                        Swipe s = new Swipe( mouseXDown, mouseYDown, Input.mousePosition.x, Input.mousePosition.y );
                        if( swiping != null )
                            swiping(s);
                        history.Add( s );
                    }
                    else
                    {
                        Touch t = new Touch( Input.mousePosition.x, Input.mousePosition.y );
                        if( tapping != null )
                            tapping(t);
                        history.Add( t );
                    }
                    if( !listening )
                        history.Clear();
                }
            }
            else
            {
                if( Input.GetMouseButton( 0 ) )
                {
                    timeTapStart = Time.time;
                    trackingMouse = true;
                    mouseXDown = Input.mousePosition.x;
                    mouseYDown = Input.mousePosition.y;
                    point.transform.position = new Vector3( mouseXDown/Screen.width, mouseYDown/Screen.height, 0 );
                    point.pixelInset = new Rect( -Screen.height * drawScale/2, -Screen.height * drawScale/2, Screen.height * drawScale, Screen.height * drawScale );
                }
            }
        }
    }
Beispiel #57
0
 void swipeBegin(Swipe swipe)
 {
     //TODO instanziare il flow
 }